From c8dc9447c4ed28caae955d6269b972b1c3a17ec8 Mon Sep 17 00:00:00 2001 From: Krzysztof Suszynski Date: Mon, 20 May 2019 19:51:03 +0200 Subject: [PATCH] Adding plugs packager samples and testing modules * Added a sampler library and use it to create samples * Introduce API nad DEVEL modules for plugs packager --- .travis.yml | 2 +- plug-api/pom.xml | 11 +- .../plugs/api/PlugsVersionIT.java | 12 +- plugs-core/pom.xml | 7 +- plugs-felix/pom.xml | 7 +- plugs-spring/pom.xml | 7 +- pom.xml | 30 ++- testing/pom.xml | 94 --------- .../plugs/testing/ansi/AnsiBackground.java | 59 ------ .../plugs/testing/ansi/AnsiColor.java | 59 ------ .../plugs/testing/ansi/AnsiComposite.java | 54 ------ .../plugs/testing/ansi/AnsiElement.java | 35 ---- .../plugs/testing/ansi/AnsiOutput.java | 176 ----------------- .../plugs/testing/ansi/AnsiStyle.java | 47 ----- .../log4j2/HighlightColorConverter.java | 179 ------------------ testing/src/main/resources/log4j2-test.xml | 37 ---- .../plugs/testing/ansi/AnsiOutputTest.java | 123 ------------ .../testing/log4j2/CollectorAppender.java | 94 --------- .../testing/log4j2/CollectorManager.java | 70 ------- .../log4j2/HighlightColorConverterTest.java | 149 --------------- testing/src/test/resources/log4j2-test.xml | 36 ---- tools/plugs-maven-plugin/pom.xml | 7 +- .../tools/maven/plugin/PackagePlugMojo.java | 12 +- .../tools/maven/plugin/PackagerFactories.java | 2 +- .../maven/plugin/PackagerFactoriesImpl.java | 2 +- .../filter/AbstractDependencyFilter.java | 2 +- .../maven/plugin/filter/ExcludeFilter.java | 2 +- .../maven/plugin/filter/FilterFactory.java | 2 +- .../maven/plugin/filter/IncludeFilter.java | 2 +- .../maven/plugin/filter/MavenFilter.java | 6 +- .../plugin/filter/MavenFilterFactory.java | 2 +- .../maven/plugin/filter/package-info.java | 3 + .../maven/plugin/mapper/ArtifactMapper.java | 2 +- .../plugin/mapper/ArtifactMapperImpl.java | 2 +- .../maven/plugin/mapper/MavenArtifact.java | 12 +- .../plugin/mapper/MavenBackedProject.java | 4 +- .../plugin/mapper/MavenLibrariesFactory.java | 6 +- .../mapper/MavenPackagerConfiguration.java | 6 +- .../MavenPackagerConfigurationFactory.java | 2 +- .../mapper/MavenPackagerCoordinates.java | 6 +- .../mapper/PackagerConfigurationFactory.java | 2 +- .../maven/plugin/mapper/package-info.java | 3 + .../model/AbstractFilterableDependency.java | 2 +- .../maven/plugin/model/MavenLibraries.java | 8 +- .../maven/plugin/model/package-info.java | 3 + .../src/test/resources/code-with-deps/pom.xml | 2 +- tools/plugs-packager-api/pom.xml | 71 +++++++ .../plugs/tools/packager/api}/Constants.java | 2 +- .../plugs/tools/packager/api}/Packager.java | 4 +- .../tools/packager/api}/PackagerFactory.java | 6 +- .../api}/RepackagingIsRequiredFactory.java | 8 +- .../packager/api}/digest/ProjectDigest.java | 4 +- .../packager/api/digest}/package-info.java | 10 +- .../packager/api}/jar/ArchiveWriterEvent.java | 2 +- .../api}/jar/ArchiveWriterListener.java | 2 +- .../packager/api}/jar/LibrariesCollector.java | 4 +- .../tools/packager/api/jar}/package-info.java | 10 +- .../api}/manifest/ManifestBuilder.java | 6 +- .../packager/api/manifest/package-info.java | 23 +++ .../tools/packager/api}/model/Artifact.java | 6 +- .../packager/api}/model/ArtifactType.java | 4 +- .../tools/packager/api}/model/CodeBlock.java | 2 +- .../tools/packager/api}/model/Filter.java | 2 +- .../api}/model/FilterableDependency.java | 2 +- .../packager/api}/model/IoPossibleBlock.java | 2 +- .../api}/model/IoPossibleSupplier.java | 2 +- .../tools/packager/api}/model/Libraries.java | 2 +- .../tools/packager/api}/model/Library.java | 2 +- .../packager/api}/model/LibraryCallback.java | 2 +- .../packager/api}/model/LibraryScope.java | 2 +- .../plugs/tools/packager/api}/model/Or.java | 2 +- .../api}/model/PackagerConfiguration.java | 2 +- .../api}/model/PackagerCoordinates.java | 2 +- .../tools/packager/api}/model/Project.java | 2 +- .../packager/api}/model/RepackageFailed.java | 2 +- .../api}/model/RepackagingIsRequired.java | 2 +- .../api}/model/StandardLibraries.java | 2 +- .../packager/api}/model/package-info.java | 5 +- .../tools/packager/api/package-info.java | 23 +++ .../packager/api}/spi/LibrariesFactory.java | 6 +- .../tools/packager/api}/spi/package-info.java | 5 +- .../api/jar/LibrariesCollectorTest.java | 53 ++++++ .../packager/api/model/ArtifactTypeTest.java | 52 +++++ .../api/model/RepackageFailedTest.java | 95 ++++++++++ tools/plugs-packager-core/pom.xml | 32 ++-- .../tools/packager/core/DefaultPackager.java | 31 +-- .../packager/core/DefaultPackagerFactory.java | 13 +- .../core/DefaultRepackagingIsRequired.java | 10 +- .../DefaultRepackagingIsRequiredFactory.java | 9 +- .../core/digest/ProjectDigestImpl.java | 23 ++- .../packager/core/digest/package-info.java | 23 +++ .../packager/core/jar/ArchiveWriter.java | 5 +- .../tools/packager/core/jar/JarWriter.java | 4 +- .../core/jar/LibraryHasBeenWritten.java | 3 +- .../packager/core/jar/WritableLibraries.java | 6 +- .../tools/packager/core/jar/package-info.java | 3 + .../core/manifest/ManifestBuilderImpl.java | 13 +- .../packager/core/manifest/package-info.java | 3 + .../tools/packager/core/package-info.java | 3 + .../META-INF/sisu/javax.inject.Named | 2 +- .../core/digest/ProjectDigestImplTest.java | 54 ++---- .../core/sample/SimpleProjectSample.java | 30 --- .../plugs/tools/packager/core/sample/pom.xml | 22 --- tools/plugs-packager-samples/pom.xml | 69 +++++++ .../sample/PackagerSamplerContext.java} | 19 +- .../sample/artifact/HibernateArtifact.java | 24 +++ .../sample/artifact/Jsr305Artifact.java | 23 +++ .../sample/artifact/OsgiCoreArtifact.java | 23 +++ .../artifact/SimpleProjectBuildArtifact.java | 23 +++ .../artifact/impl/HibernateArtifactImpl.java | 42 ++++ .../artifact/impl/Jsr305ArtifactImpl.java | 42 ++++ .../artifact/impl/MavenlikeArtifact.java | 84 ++++++++ .../artifact/impl/OsgiCoreArtifactImpl.java | 42 ++++ .../impl/SimpleProjectBuildArtifactImpl.java | 89 +++++++++ .../sample/artifact/impl/package-info.java | 23 +++ .../sample/artifact/package-info.java | 23 +++ .../tools/packager/sample/fs/VirtualRoot.java | 26 +++ .../packager/sample/fs/VirtualRootImpl.java} | 31 ++- .../packager/sample/fs/package-info.java | 23 +++ .../tools/packager/sample/package-info.java | 23 +++ .../sample/project/AbstractProject.java | 83 ++++++++ .../sample/project/SimpleProject.java | 23 +++ .../sample/project/SimpleProjectImpl.java | 67 +++++++ .../packager/sample/project/package-info.java | 23 +++ .../sample/PackagerSamplerContextIT.java | 81 ++++++++ tools/pom.xml | 2 + 126 files changed, 1484 insertions(+), 1536 deletions(-) delete mode 100644 testing/pom.xml delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiBackground.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiColor.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiComposite.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiElement.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutput.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiStyle.java delete mode 100644 testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverter.java delete mode 100644 testing/src/main/resources/log4j2-test.xml delete mode 100644 testing/src/test/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutputTest.java delete mode 100644 testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorAppender.java delete mode 100644 testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorManager.java delete mode 100644 testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverterTest.java delete mode 100644 testing/src/test/resources/log4j2-test.xml create mode 100644 tools/plugs-packager-api/pom.xml rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/Constants.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/Packager.java (92%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/PackagerFactory.java (85%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/RepackagingIsRequiredFactory.java (80%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/digest/ProjectDigest.java (89%) rename {testing/src/main/java/pl/wavesoftware/plugs/testing/ansi => tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest}/package-info.java (81%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/jar/ArchiveWriterEvent.java (93%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/jar/ArchiveWriterListener.java (94%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/jar/LibrariesCollector.java (90%) rename {testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2 => tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar}/package-info.java (80%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/manifest/ManifestBuilder.java (86%) create mode 100644 tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/package-info.java rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Artifact.java (90%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/ArtifactType.java (91%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/CodeBlock.java (92%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Filter.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/FilterableDependency.java (93%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/IoPossibleBlock.java (93%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/IoPossibleSupplier.java (94%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Libraries.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Library.java (97%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/LibraryCallback.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/LibraryScope.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Or.java (94%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/PackagerConfiguration.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/PackagerCoordinates.java (95%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/Project.java (96%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/RepackageFailed.java (97%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/RepackagingIsRequired.java (94%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/StandardLibraries.java (94%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/model/package-info.java (84%) create mode 100644 tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/package-info.java rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/spi/LibrariesFactory.java (86%) rename tools/{plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core => plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api}/spi/package-info.java (84%) create mode 100644 tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollectorTest.java create mode 100644 tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactTypeTest.java create mode 100644 tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailedTest.java create mode 100644 tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/package-info.java delete mode 100644 tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/SimpleProjectSample.java delete mode 100644 tools/plugs-packager-core/src/test/resources/pl/wavesoftware/plugs/tools/packager/core/sample/pom.xml create mode 100644 tools/plugs-packager-samples/pom.xml rename tools/{plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/Sample.java => plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContext.java} (59%) create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/HibernateArtifact.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/Jsr305Artifact.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/OsgiCoreArtifact.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/SimpleProjectBuildArtifact.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/HibernateArtifactImpl.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/Jsr305ArtifactImpl.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/MavenlikeArtifact.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/OsgiCoreArtifactImpl.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/SimpleProjectBuildArtifactImpl.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/package-info.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/package-info.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRoot.java rename tools/{plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/ProjectSamples.java => plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRootImpl.java} (52%) create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/package-info.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/package-info.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/AbstractProject.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProject.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProjectImpl.java create mode 100644 tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/package-info.java create mode 100644 tools/plugs-packager-samples/src/test/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContextIT.java diff --git a/.travis.yml b/.travis.yml index 873fef8..e60d1fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: java sudo: false dist: trusty -install: mvn install dependency:go-offline -DskipTests=true -Dmaven.javadoc.skip=true -B -V +install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V script: mvn clean verify --fail-at-end -U -V notifications: email: diff --git a/plug-api/pom.xml b/plug-api/pom.xml index fa0dbfa..70d0ec7 100644 --- a/plug-api/pom.xml +++ b/plug-api/pom.xml @@ -43,14 +43,15 @@ - pl.wavesoftware.plugs - testing - ${project.version} + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom test - com.github.zafarkhaja - java-semver + com.vdurmont + semver4j test diff --git a/plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionIT.java b/plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionIT.java index 6efacd1..85c7bf5 100644 --- a/plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionIT.java +++ b/plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionIT.java @@ -16,26 +16,26 @@ package pl.wavesoftware.plugs.api; -import com.github.zafarkhaja.semver.Version; +import com.vdurmont.semver4j.Semver; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; class PlugsVersionIT { - private static final Version BASE = Version.forIntegers(0, 0, 0); + private static final Semver BASE = new Semver("0.0.0"); @Test void getVersion() { - Version version = Version.valueOf(PlugsVersion.getVersion()); + Semver version = new Semver(PlugsVersion.getVersion()); - assertThat(version.greaterThanOrEqualTo(BASE)).isTrue(); + assertThat(version.isGreaterThanOrEqualTo(BASE)).isTrue(); } @Test void manually() { - Version version = Version.valueOf(PlugsVersion.manuallyRead()); + Semver version = new Semver(PlugsVersion.manuallyRead()); - assertThat(version.greaterThanOrEqualTo(BASE)).isTrue(); + assertThat(version.isGreaterThanOrEqualTo(BASE)).isTrue(); } } diff --git a/plugs-core/pom.xml b/plugs-core/pom.xml index 94246a2..08ebbd7 100644 --- a/plugs-core/pom.xml +++ b/plugs-core/pom.xml @@ -63,9 +63,10 @@ - pl.wavesoftware.plugs - testing - ${project.version} + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom test diff --git a/plugs-felix/pom.xml b/plugs-felix/pom.xml index 9efc251..173f886 100644 --- a/plugs-felix/pom.xml +++ b/plugs-felix/pom.xml @@ -47,9 +47,10 @@ - pl.wavesoftware.plugs - testing - ${project.version} + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom test diff --git a/plugs-spring/pom.xml b/plugs-spring/pom.xml index 2e33397..9eee6a3 100644 --- a/plugs-spring/pom.xml +++ b/plugs-spring/pom.xml @@ -58,9 +58,10 @@ - pl.wavesoftware.plugs - testing - ${project.version} + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom test diff --git a/pom.xml b/pom.xml index 8ba309b..2feccdc 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.springframework.boot + spring-boot-dependencies + 2.1.5.RELEASE + + pl.wavesoftware.plugs plugs-parent 0.1.0-SNAPSHOT @@ -60,14 +66,12 @@ plugs-spring boms-parent examples - testing tools scm:git:https://github.com/wavesoftware/plugs.git - scm:git:git@github.com:wavesoftware/plugs.git - + scm:git:git@github.com:wavesoftware/plugs.git https://github.com/wavesoftware/plugs @@ -113,20 +117,12 @@ ${skipTests} - 2.1.2.RELEASE - 6.0.2 + 6.0.3 3.6.0 - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - org.apiguardian apiguardian-api @@ -163,9 +159,9 @@ 2.0.0 - com.github.zafarkhaja - java-semver - 0.9.0 + com.vdurmont + semver4j + 2.2.0 org.apache.commons @@ -294,7 +290,7 @@ maven-surefire-plugin - 2.22.1 + 2.22.2 false @@ -302,7 +298,7 @@ maven-failsafe-plugin - 2.22.1 + 2.22.2 false diff --git a/testing/pom.xml b/testing/pom.xml deleted file mode 100644 index d8ebb4a..0000000 --- a/testing/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - 4.0.0 - - plugs-parent - pl.wavesoftware.plugs - 0.1.0-SNAPSHOT - - testing - Plugs :: Testing - - - ${project.basedir}/.. - false - - - - - org.springframework.boot - spring-boot - provided - - - pl.wavesoftware - eid-exceptions - - - org.apache.logging.log4j - log4j-slf4j-impl - - - org.apache.logging.log4j - log4j-core - - - com.portingle - slf4jtesting - runtime - - - org.junit.platform - junit-platform-launcher - - - org.junit.jupiter - junit-jupiter-engine - - - org.junit.vintage - junit-vintage-engine - - - org.junit.jupiter - junit-jupiter-params - - - org.assertj - assertj-core - - - org.mockito - mockito-junit-jupiter - - - org.awaitility - awaitility - runtime - - - io.vavr - vavr - - - diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiBackground.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiBackground.java deleted file mode 100644 index 8636694..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiBackground.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -/** - * {@link AnsiElement Ansi} background colors. - * - * @author Krzysztof Suszynski - * @author Phillip Webb (Spring Boot project) - * @author Geoffrey Chandler (Spring Boot project) - * @since 0.1.0 - * @see org.springframework.boot.ansi.AnsiBackground - */ -public enum AnsiBackground implements AnsiElement { - - DEFAULT("49"), - BLACK("40"), - RED("41"), - GREEN("42"), - YELLOW("43"), - BLUE("44"), - MAGENTA("45"), - CYAN("46"), - WHITE("47"), - BRIGHT_BLACK("100"), - BRIGHT_RED("101"), - BRIGHT_GREEN("102"), - BRIGHT_YELLOW("103"), - BRIGHT_BLUE("104"), - BRIGHT_MAGENTA("105"), - BRIGHT_CYAN("106"), - BRIGHT_WHITE("107"); - - private String code; - - AnsiBackground(String code) { - this.code = code; - } - - @Override - public String toString() { - return this.code; - } - -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiColor.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiColor.java deleted file mode 100644 index c91f6d3..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiColor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -/** - * {@link AnsiElement Ansi} colors. - * - * @author Krzysztof Suszynski - * @author Phillip Webb (Spring Boot project) - * @author Geoffrey Chandler (Spring Boot project) - * @since 0.1.0 - * @see org.springframework.boot.ansi.AnsiColor - */ -public enum AnsiColor implements AnsiElement { - - DEFAULT("39"), - BLACK("30"), - RED("31"), - GREEN("32"), - YELLOW("33"), - BLUE("34"), - MAGENTA("35"), - CYAN("36"), - WHITE("37"), - - BRIGHT_BLACK("90"), - BRIGHT_RED("91"), - BRIGHT_GREEN("92"), - BRIGHT_YELLOW("93"), - BRIGHT_BLUE("94"), - BRIGHT_MAGENTA("95"), - BRIGHT_CYAN("96"), - BRIGHT_WHITE("97"); - - private final String code; - - AnsiColor(String code) { - this.code = code; - } - - @Override - public String toString() { - return this.code; - } -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiComposite.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiComposite.java deleted file mode 100644 index 805524c..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiComposite.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * An ANSI composite color code, that consists of multiple {@link AnsiElement}s - * - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -public final class AnsiComposite implements AnsiElement { - private static final CharSequence ENCODE_JOIN = ";"; - - private final List elements; - - private AnsiComposite(AnsiElement... elements) { - this.elements = Arrays.asList(elements); - } - - /** - * A static builder method - * - * @param elements elements from which create this composite - * @return an instance - */ - public static AnsiComposite of(AnsiElement... elements) { - return new AnsiComposite(elements); - } - - @Override - public String toString() { - return elements.stream() - .map(AnsiElement::toString) - .collect(Collectors.joining(ENCODE_JOIN)); - } -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiElement.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiElement.java deleted file mode 100644 index bca5143..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiElement.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -/** - * An ANSI encodable element. - * - * @author Krzysztof Suszynski - * @author Phillip Webb (Spring Boot project) - * @since 0.1.0 - * @see org.springframework.boot.ansi.AnsiElement - */ -public interface AnsiElement { - - /** - * @return the ANSI escape code - */ - @Override - String toString(); - -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutput.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutput.java deleted file mode 100644 index f8e9bd2..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutput.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -import javax.annotation.Nullable; -import java.util.Locale; - -import static pl.wavesoftware.eid.utils.EidPreconditions.checkNotNull; - -/** - * Generates ANSI encoded output, automatically attempting to detect if the - * terminal supports ANSI. - * - * @author Krzysztof Suszynski - * @author Phillip Webb (Spring Boot project) - * @since 0.1.0 - * @see org.springframework.boot.ansi.AnsiOutput - */ -public final class AnsiOutput { - - private static Enabled enabled = Enabled.DETECT; - @Nullable - private static Boolean consoleAvailable = true; - @Nullable - private static Boolean ansiCapable; - private static boolean skipWindowsCheck = true; - - private static final String ENCODE_JOIN = ";"; - private static final String ENCODE_START = "\033["; - private static final String ENCODE_END = "m"; - private static final String RESET = "0;" + AnsiColor.DEFAULT; - - private static final String OPERATING_SYSTEM_NAME = System - .getProperty("os.name") - .toLowerCase(Locale.ENGLISH); - - private AnsiOutput() { - // nothing here - } - - /** - * Sets if ANSI output should be skipped on windows os - * - * @param skipWindowsCheck true, if output should be skipped on windows - */ - public static void setSkipWindowsCheck(boolean skipWindowsCheck) { - AnsiOutput.skipWindowsCheck = skipWindowsCheck; - } - - /** - * Sets if ANSI output is enabled. - * - * @param enabled if ANSI is enabled, disabled or detected - */ - public static void setEnabled(Enabled enabled) { - checkNotNull(enabled, "20181220:155934", "Enabled must not be null"); - AnsiOutput.enabled = enabled; - } - - /** - * Sets if the System.console() is known to be available. - * - * @param consoleAvailable if the console is known to be available or - * {@code null} to use standard detection logic. - */ - public static void setConsoleAvailable(@Nullable Boolean consoleAvailable) { - AnsiOutput.consoleAvailable = consoleAvailable; - } - - /** - * Create a new ANSI string from the specified elements. Any - * {@link AnsiElement}s will be encoded as required. - * - * @param elements the elements to encode - * @return a string of the encoded elements - */ - public static String encode(Object... elements) { - StringBuilder sb = new StringBuilder(); - if (isEnabled()) { - buildEnabled(sb, elements); - } else { - buildDisabled(sb, elements); - } - return sb.toString(); - } - - private static void buildEnabled(StringBuilder sb, Object[] elements) { - boolean writingAnsi = false; - boolean containsEncoding = false; - for (Object element : elements) { - if (element instanceof AnsiElement) { - containsEncoding = true; - if (!writingAnsi) { - sb.append(ENCODE_START); - writingAnsi = true; - } else { - sb.append(ENCODE_JOIN); - } - } else { - if (writingAnsi) { - sb.append(ENCODE_END); - writingAnsi = false; - } - } - sb.append(element); - } - if (containsEncoding) { - sb.append(writingAnsi ? ENCODE_JOIN : ENCODE_START); - sb.append(RESET); - sb.append(ENCODE_END); - } - } - - private static void buildDisabled(StringBuilder sb, Object[] elements) { - for (Object element : elements) { - if (!(element instanceof AnsiElement) && element != null) { - sb.append(element); - } - } - } - - private static boolean isEnabled() { - if (enabled == Enabled.DETECT) { - if (ansiCapable == null) { - ansiCapable = detectIfAnsiCapable(); - } - return ansiCapable; - } - return enabled == Enabled.ALWAYS; - } - - private static boolean detectIfAnsiCapable() { - if (Boolean.FALSE.equals(consoleAvailable) - || ((consoleAvailable == null) && (System.console() == null))) { - return false; - } - return skipWindowsCheck || !(OPERATING_SYSTEM_NAME.contains("win")); - } - - /** - * Possible values to pass to {@link AnsiOutput#setEnabled}. Determines when - * to output ANSI escape sequences for coloring application output. - */ - public enum Enabled { - - /** - * Try to detect whether ANSI coloring capabilities are available. The - * default value for {@link AnsiOutput}. - */ - DETECT, - - /** - * Enable ANSI-colored output. - */ - ALWAYS, - - /** - * Disable ANSI-colored output. - */ - NEVER - } -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiStyle.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiStyle.java deleted file mode 100644 index bf8676f..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/AnsiStyle.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -/** - * {@link AnsiElement Ansi} styles. - * - * @author Krzysztof Suszynski - * @author Phillip Webb (Spring Boot project) - * @since 0.1.0 - * @see org.springframework.boot.ansi.AnsiStyle - */ -public enum AnsiStyle implements AnsiElement { - - NORMAL("0"), - BOLD("1"), - FAINT("2"), - ITALIC("3"), - UNDERLINE("4"), - BLINK("5"); - - private final String code; - - AnsiStyle(String code) { - this.code = code; - } - - @Override - public String toString() { - return this.code; - } - -} diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverter.java b/testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverter.java deleted file mode 100644 index e4def53..0000000 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverter.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.log4j2; - -import io.vavr.collection.HashSet; -import io.vavr.collection.Set; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.config.Configuration; -import org.apache.logging.log4j.core.config.plugins.Plugin; -import org.apache.logging.log4j.core.layout.PatternLayout; -import org.apache.logging.log4j.core.pattern.ConverterKeys; -import org.apache.logging.log4j.core.pattern.LogEventPatternConverter; -import org.apache.logging.log4j.core.pattern.PatternConverter; -import org.apache.logging.log4j.core.pattern.PatternFormatter; -import org.apache.logging.log4j.core.pattern.PatternParser; -import org.apiguardian.api.API; -import org.apiguardian.api.API.Status; -import pl.wavesoftware.plugs.testing.ansi.AnsiBackground; -import pl.wavesoftware.plugs.testing.ansi.AnsiColor; -import pl.wavesoftware.plugs.testing.ansi.AnsiComposite; -import pl.wavesoftware.plugs.testing.ansi.AnsiElement; -import pl.wavesoftware.plugs.testing.ansi.AnsiOutput; -import pl.wavesoftware.plugs.testing.ansi.AnsiStyle; - -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Log4j2 {@link LogEventPatternConverter} colors output using the {@link AnsiOutput} - * class. A single option 'styling' can be provided to the converter, or if not specified - * color styling will be picked based on the logging level. - * - * @author Krzysztof Suszynski - * @author Vladimir Tsanev (Spring-Boot project) - * @since 0.1.0 - * @see org.springframework.boot.logging.log4j2.ColorConverter - */ -@Plugin(name = "hightlight-color", category = PatternConverter.CATEGORY) -@ConverterKeys("hl") -public final class HighlightColorConverter extends LogEventPatternConverter { - - private static final Map ELEMENTS; - private static final int NO_ARGS_WITHOUT_STYLE = 1; - private static final int NO_ARGS_WITH_STYLE = 2; - private static final Set VALID_NUMBER_OF_ARGS = HashSet.of( - NO_ARGS_WITHOUT_STYLE, - NO_ARGS_WITH_STYLE - ); - - static { - Map ansiElements = new HashMap<>(); - ansiElements.put("faint", AnsiComposite.of(AnsiColor.WHITE, AnsiStyle.FAINT)); - ansiElements.put("black", AnsiColor.BLACK); - ansiElements.put("red", AnsiColor.RED); - ansiElements.put("green", AnsiColor.GREEN); - ansiElements.put("yellow", AnsiColor.YELLOW); - ansiElements.put("blue", AnsiColor.BLUE); - ansiElements.put("magenta", AnsiColor.MAGENTA); - ansiElements.put("cyan", AnsiColor.CYAN); - ELEMENTS = Collections.unmodifiableMap(ansiElements); - } - - private static final Map LEVELS; - - static { - Map ansiLevels = new HashMap<>(); - ansiLevels.put(Level.FATAL.intLevel(), AnsiComposite.of( - AnsiColor.BLACK, AnsiBackground.RED - )); - ansiLevels.put(Level.ERROR.intLevel(), AnsiComposite.of( - AnsiColor.RED, AnsiStyle.BOLD - )); - ansiLevels.put(Level.WARN.intLevel(), AnsiColor.YELLOW); - ansiLevels.put(Level.INFO.intLevel(), AnsiColor.GREEN); - ansiLevels.put(Level.DEBUG.intLevel(), AnsiColor.BLUE); - ansiLevels.put(Level.TRACE.intLevel(), AnsiColor.CYAN); - LEVELS = Collections.unmodifiableMap(ansiLevels); - } - - private final List formatters; - - @Nullable - private final AnsiElement styling; - - private HighlightColorConverter( - List formatters, - @Nullable AnsiElement styling - ) { - super("style", "style"); - this.formatters = Collections.unmodifiableList(formatters); - this.styling = styling; - } - - /** - * Creates a new instance of the class. Required by Log4j. - * - * @param config the configuration - * @param options the options - * @return a new instance, or {@code null} if the options are invalid - */ - @SuppressWarnings("WeakerAccess") - @API(status = Status.MAINTAINED) - public static HighlightColorConverter newInstance( - Configuration config, - String[] options - ) { - if (!VALID_NUMBER_OF_ARGS.contains(options.length)) { - LOGGER.error("Incorrect number of options on style. " - + "Expected at least 1, received {}", options.length); - return null; - } - if (options[0] == null) { - LOGGER.error("No pattern supplied on style"); - return null; - } - PatternParser parser = PatternLayout.createPatternParser(config); - List formatters = parser.parse(options[0]); - AnsiElement element = null; - if (options.length != 1) { - element = ELEMENTS.get(options[1]); - } - return new HighlightColorConverter(formatters, element); - } - - @Override - public boolean handlesThrowable() { - for (PatternFormatter formatter : this.formatters) { - if (formatter.handlesThrowable()) { - return true; - } - } - return super.handlesThrowable(); - } - - @Override - public void format(LogEvent event, StringBuilder stringBuilder) { - StringBuilder buf = new StringBuilder(); - for (PatternFormatter formatter : this.formatters) { - formatter.format(event, buf); - } - if (buf.length() > 0) { - AnsiElement ansiElement = this.styling; - if (ansiElement == null) { - // Assume highlighting - ansiElement = LEVELS.getOrDefault( - event.getLevel().intLevel(), AnsiColor.BLUE - ); - } - appendAnsiString(stringBuilder, buf.toString(), ansiElement); - } - } - - private static void appendAnsiString( - StringBuilder toAppendTo, - String text, - AnsiElement ansiElement - ) { - toAppendTo.append(AnsiOutput.encode(ansiElement, text)); - } - -} diff --git a/testing/src/main/resources/log4j2-test.xml b/testing/src/main/resources/log4j2-test.xml deleted file mode 100644 index 8306854..0000000 --- a/testing/src/main/resources/log4j2-test.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - %hl{%d{HH:mm:ss.SSS}}{faint} - %hl{[%10.10t]}{yellow} - %hl{%-40.40c{1.}}{cyan} - %hl{:}{faint} %m%n%hl{%xEx} - %hl{%5p} ${DATE} ${THREAD} ${CLASS} ${MSG} - - - - - - - - - - - - - diff --git a/testing/src/test/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutputTest.java b/testing/src/test/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutputTest.java deleted file mode 100644 index bae3f52..0000000 --- a/testing/src/test/java/pl/wavesoftware/plugs/testing/ansi/AnsiOutputTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.ansi; - -import io.vavr.collection.List; -import io.vavr.collection.Seq; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; -import pl.wavesoftware.plugs.testing.ansi.AnsiOutput.Enabled; - -import java.lang.reflect.Field; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.params.provider.Arguments.arguments; - -/** - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -class AnsiOutputTest { - - @BeforeEach - @AfterEach - void reset() throws NoSuchFieldException, IllegalAccessException { - AnsiOutput.setEnabled(Enabled.DETECT); - AnsiOutput.setConsoleAvailable(true); - AnsiOutput.setSkipWindowsCheck(true); - Field field = AnsiOutput.class.getDeclaredField("ansiCapable"); - field.setAccessible(true); - field.set(null, null); - } - - @Test - void always() { - // given - AnsiOutput.setEnabled(Enabled.ALWAYS); - String text = "Colorful"; - - // when - String encoded = AnsiOutput.encode( - AnsiStyle.ITALIC, - AnsiColor.BLACK, - AnsiBackground.MAGENTA, - text - ); - - // then - assertThat(encoded).isEqualTo("\u001B[3;30;45mColorful\u001B[0;39m"); - } - - @ParameterizedTest - @ArgumentsSource(EncodeArgumentSource.class) - void encode(Seq styling, String expectedResult) { - // given - String text = "Colorful"; - Object[] toBeEncoded = styling.append(text).toJavaArray(); - - // when - String encoded = AnsiOutput.encode(toBeEncoded); - - // then - assertThat(encoded).isEqualTo(expectedResult); - } - - @ParameterizedTest - @ArgumentsSource(EncodeArgumentSource.class) - void encodeOnWindows(Seq styling) { - // given - AnsiOutput.setSkipWindowsCheck(false); - AnsiOutput.setConsoleAvailable(null); - String text = "Non-Color"; - Object[] toBeEncoded = styling.append(text).toJavaArray(); - - // when - String encoded = AnsiOutput.encode(toBeEncoded); - - // then - assertThat(encoded).isEqualTo(text); - } - - private static final class EncodeArgumentSource implements ArgumentsProvider { - - @Override - public Stream provideArguments(ExtensionContext context) { - return Stream.of( - arguments(List.of(AnsiColor.BLUE), "\u001B[34mColorful\u001B[0;39m"), - arguments( - List.of(AnsiColor.BRIGHT_YELLOW, AnsiStyle.BLINK), - "\u001B[93;5mColorful\u001B[0;39m" - ), - arguments( - List.of(AnsiComposite.of( - AnsiStyle.BOLD, - AnsiColor.BLACK, - AnsiBackground.BRIGHT_YELLOW - )), - "\u001B[1;30;103mColorful\u001B[0;39m" - ) - ); - } - } -} diff --git a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorAppender.java b/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorAppender.java deleted file mode 100644 index 99a799e..0000000 --- a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorAppender.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.log4j2; - -import org.apache.logging.log4j.core.Filter; -import org.apache.logging.log4j.core.Layout; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.appender.AbstractAppender; -import org.apache.logging.log4j.core.config.plugins.Plugin; -import org.apache.logging.log4j.core.config.plugins.PluginAttribute; -import org.apache.logging.log4j.core.config.plugins.PluginElement; -import org.apache.logging.log4j.core.config.plugins.PluginFactory; -import org.apache.logging.log4j.core.layout.PatternLayout; - -import javax.annotation.Nullable; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; - -/** - * A collector appender - * - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -@Plugin( - name = "Collector", - category = "Core", - elementType = "appender", - printObject = true -) -public final class CollectorAppender extends AbstractAppender { - private final CollectorManager manager; - - private CollectorAppender( - String name, - Layout layout, - @Nullable Filter filter, - CollectorManager manager, - boolean ignoreExceptions - ) { - super(name, filter, layout, ignoreExceptions); - this.manager = manager; - } - - /** - * Factory method for Log4j2 - * - * @param name a name - * @param ignoreExceptions do ignore exceptions - * @param layout a Log4j2 layout like pattern layout - * @param filter a Log4j2 filter - * @return a created instance - */ - @PluginFactory - public static CollectorAppender createAppender( - @Nullable @PluginAttribute("name") String name, - @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, - @Nullable @PluginElement("Layout") Layout layout, - @Nullable @PluginElement("Filters") Filter filter - ) { - - if (name == null) { - LOGGER.error("No name provided for CollectorAppender"); - return null; - } - - CollectorManager manager = CollectorManager.getCollectorManager(name); - if (layout == null) { - layout = PatternLayout.createDefaultLayout(); - } - return new CollectorAppender(name, layout, filter, manager, ignoreExceptions); - } - - @Override - public void append(LogEvent event) { - byte[] bytes = getLayout().toByteArray(event); - String formattedMessage = new String(bytes, StandardCharsets.UTF_8); - manager.collect(event, formattedMessage); - } -} diff --git a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorManager.java b/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorManager.java deleted file mode 100644 index 4aeb3ed..0000000 --- a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/CollectorManager.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.log4j2; - -import io.vavr.collection.Traversable; -import org.apache.logging.log4j.core.LogEvent; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Krzysztof Suszynski - * @since 2019-01-05 - */ -final class CollectorManager { - private static final Map MANAGERS = - new HashMap<>(); - - private final List events = new ArrayList<>(); - - static CollectorManager getCollectorManager(String name) { - return MANAGERS.computeIfAbsent(name, ignored -> new CollectorManager()); - } - - Traversable getCollected() { - return io.vavr.collection.List.ofAll(events); - } - - void collect(LogEvent event, String formattedMessage) { - events.add(new CollectedEvent(event, formattedMessage)); - } - - void clear() { - events.clear(); - } - - static final class CollectedEvent { - private final LogEvent event; - private final String formattedMessage; - - CollectedEvent(LogEvent event, String formattedMessage) { - this.event = event; - this.formattedMessage = formattedMessage; - } - - LogEvent getEvent() { - return event; - } - - String getFormattedMessage() { - return formattedMessage; - } - } -} diff --git a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverterTest.java b/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverterTest.java deleted file mode 100644 index 8c422d1..0000000 --- a/testing/src/test/java/pl/wavesoftware/plugs/testing/log4j2/HighlightColorConverterTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.testing.log4j2; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.config.Configuration; -import org.apache.logging.log4j.status.StatusLogger; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.ExtensionContext; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.ArgumentsProvider; -import org.junit.jupiter.params.provider.ArgumentsSource; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pl.wavesoftware.plugs.testing.log4j2.CollectorManager.CollectedEvent; - -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -@ExtendWith(MockitoExtension.class) -class HighlightColorConverterTest { - - @Nested - class ActualLoggingWithSlf4j { - private static final int EXPECTED_SIZE = 2; - private final CollectorManager manager = - CollectorManager.getCollectorManager("PseudoConsole"); - - @AfterEach - void after() { - manager.clear(); - } - - @Test - void format() { - // given - Logger logger = LoggerFactory.getLogger(HighlightColorConverterTest.class); - - // when - logger.info("info"); - logger.error("error"); - - // then - assertThat(manager.getCollected()) - .hasSize(EXPECTED_SIZE) - .extracting(this::formattedMessageOf) - .containsExactly( - "\u001B[32m INFO\u001B[0;39m \u001B[33m[ main]\u001B[0;39m " + - "\u001B[36mp.w.p.t.l.HighlightColorConverterTest " + - "\u001B[0;39m \u001B[37;2m:\u001B[0;39m info\n", - "\u001B[31;1mERROR\u001B[0;39m \u001B[33m[ main]\u001B[0;39m " + - "\u001B[36mp.w.p.t.l.HighlightColorConverterTest " + - "\u001B[0;39m \u001B[37;2m:\u001B[0;39m error\n" - ); - } - - private String formattedMessageOf(CollectedEvent event) { - return event.getFormattedMessage().replace("\r\n", "\n"); - } - } - - @ExtendWith(MockitoExtension.class) - @Nested - class NewInstance { - - @Mock - private Configuration configuration; - private Level level; - - @BeforeEach - void before() { - level = StatusLogger.getLogger().getLevel(); - StatusLogger.getLogger().setLevel(Level.OFF); - } - - @AfterEach - void after() { - StatusLogger.getLogger().setLevel(level); - Mockito.validateMockitoUsage(); - Mockito.verifyNoMoreInteractions(configuration); - } - - @ParameterizedTest - @ArgumentsSource(NewInstanceArgumentSource.class) - void newInstance(String[] options) { - // when - HighlightColorConverter instance = HighlightColorConverter.newInstance( - configuration, options - ); - - // then - assertThat(instance).isNull(); - } - } - - private static final class NewInstanceArgumentSource implements ArgumentsProvider { - - @Override - public Stream provideArguments(ExtensionContext context) { - return Stream.of( - new Options(new String[0]), - new Options(new String[] { null, "red" }), - new Options(new String[] { "color me", "black", "red"}) - ); - } - } - - private static final class Options implements Arguments { - - private final Object[] value; - - private Options(String[] value) { - this.value = new Object[] { value.clone() }; - } - - @Override - public Object[] get() { - return value.clone(); - } - } - -} diff --git a/testing/src/test/resources/log4j2-test.xml b/testing/src/test/resources/log4j2-test.xml deleted file mode 100644 index b2fbd4e..0000000 --- a/testing/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - %hl{%5p} %hl{[%10.10t]}{yellow} %hl{%-40.40c{1.}}{cyan} %hl{:}{faint} %m%n%ex - - - - - ${sys:CONSOLE_LOG_PATTERN} - - - - - - - - - - diff --git a/tools/plugs-maven-plugin/pom.xml b/tools/plugs-maven-plugin/pom.xml index 8dc3d5e..72113f9 100644 --- a/tools/plugs-maven-plugin/pom.xml +++ b/tools/plugs-maven-plugin/pom.xml @@ -125,9 +125,10 @@ - pl.wavesoftware.plugs - testing - ${project.version} + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom test diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagePlugMojo.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagePlugMojo.java index 451a1a2..006512e 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagePlugMojo.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagePlugMojo.java @@ -30,12 +30,12 @@ import org.slf4j.Logger; import pl.wavesoftware.plugs.tools.maven.plugin.model.Exclude; import pl.wavesoftware.plugs.tools.maven.plugin.model.Include; -import pl.wavesoftware.plugs.tools.packager.core.Packager; -import pl.wavesoftware.plugs.tools.packager.core.model.CodeBlock; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.Packager; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.model.CodeBlock; import javax.inject.Inject; import java.io.File; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactories.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactories.java index b551a66..d54e228 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactories.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactories.java @@ -19,7 +19,7 @@ import pl.wavesoftware.plugs.tools.maven.plugin.filter.FilterFactory; import pl.wavesoftware.plugs.tools.maven.plugin.io.LoggerFactory; import pl.wavesoftware.plugs.tools.maven.plugin.mapper.PackagerConfigurationFactory; -import pl.wavesoftware.plugs.tools.packager.core.PackagerFactory; +import pl.wavesoftware.plugs.tools.packager.api.PackagerFactory; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactoriesImpl.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactoriesImpl.java index 10036fc..a18a2c2 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactoriesImpl.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/PackagerFactoriesImpl.java @@ -19,7 +19,7 @@ import pl.wavesoftware.plugs.tools.maven.plugin.filter.FilterFactory; import pl.wavesoftware.plugs.tools.maven.plugin.io.LoggerFactory; import pl.wavesoftware.plugs.tools.maven.plugin.mapper.PackagerConfigurationFactory; -import pl.wavesoftware.plugs.tools.packager.core.PackagerFactory; +import pl.wavesoftware.plugs.tools.packager.api.PackagerFactory; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/AbstractDependencyFilter.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/AbstractDependencyFilter.java index 84c4101..8c31585 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/AbstractDependencyFilter.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/AbstractDependencyFilter.java @@ -20,7 +20,7 @@ import org.apache.maven.shared.artifact.filter.collection.AbstractArtifactsFilter; import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; -import pl.wavesoftware.plugs.tools.packager.core.model.FilterableDependency; +import pl.wavesoftware.plugs.tools.packager.api.model.FilterableDependency; import java.util.ArrayList; import java.util.Collections; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/ExcludeFilter.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/ExcludeFilter.java index ea81729..bae8fa1 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/ExcludeFilter.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/ExcludeFilter.java @@ -18,7 +18,7 @@ import org.apache.maven.artifact.Artifact; import pl.wavesoftware.plugs.tools.maven.plugin.model.Exclude; -import pl.wavesoftware.plugs.tools.packager.core.model.FilterableDependency; +import pl.wavesoftware.plugs.tools.packager.api.model.FilterableDependency; import java.util.List; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/FilterFactory.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/FilterFactory.java index 6f98294..41620ae 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/FilterFactory.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/FilterFactory.java @@ -18,7 +18,7 @@ import pl.wavesoftware.plugs.tools.maven.plugin.model.Exclude; import pl.wavesoftware.plugs.tools.maven.plugin.model.Include; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; import javax.annotation.Nullable; import java.util.List; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/IncludeFilter.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/IncludeFilter.java index 1276a0d..ffbbe0c 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/IncludeFilter.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/IncludeFilter.java @@ -19,7 +19,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter; import pl.wavesoftware.plugs.tools.maven.plugin.model.Include; -import pl.wavesoftware.plugs.tools.packager.core.model.FilterableDependency; +import pl.wavesoftware.plugs.tools.packager.api.model.FilterableDependency; import java.util.List; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilter.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilter.java index 93ed40c..b283fe3 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilter.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilter.java @@ -21,9 +21,9 @@ import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException; import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts; import pl.wavesoftware.plugs.tools.maven.plugin.mapper.ArtifactMapper; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilterFactory.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilterFactory.java index 7c40283..768add1 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilterFactory.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/MavenFilterFactory.java @@ -20,7 +20,7 @@ import pl.wavesoftware.plugs.tools.maven.plugin.mapper.ArtifactMapper; import pl.wavesoftware.plugs.tools.maven.plugin.model.Exclude; import pl.wavesoftware.plugs.tools.maven.plugin.model.Include; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; import javax.annotation.Nullable; import javax.inject.Inject; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/package-info.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/package-info.java index 14e26c7..be95508 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/package-info.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/filter/package-info.java @@ -19,6 +19,9 @@ * @since 0.1.0 */ @ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault package pl.wavesoftware.plugs.tools.maven.plugin.filter; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapper.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapper.java index 601c749..eef0880 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapper.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapper.java @@ -18,7 +18,7 @@ import io.vavr.collection.Traversable; import pl.wavesoftware.plugs.tools.maven.plugin.model.ResolvableDependency; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapperImpl.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapperImpl.java index 59c7d3d..5dfdd0a 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapperImpl.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/ArtifactMapperImpl.java @@ -25,7 +25,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.repository.RepositorySystem; import pl.wavesoftware.plugs.tools.maven.plugin.model.ResolvableDependency; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenArtifact.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenArtifact.java index 9b82496..0eef881 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenArtifact.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenArtifact.java @@ -16,9 +16,9 @@ package pl.wavesoftware.plugs.tools.maven.plugin.mapper; -import com.github.zafarkhaja.semver.Version; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.ArtifactType; +import com.vdurmont.semver4j.Semver; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.ArtifactType; import java.nio.file.Path; @@ -43,8 +43,8 @@ public String name() { } @Override - public Version version() { - return Version.valueOf(getDelegate().getVersion()); + public Semver version() { + return new Semver(getDelegate().getVersion()); } @Override @@ -54,7 +54,7 @@ public Path path() { @Override public ArtifactType type() { - return ArtifactType.fromPackging(getDelegate().getType()); + return ArtifactType.fromPackaging(getDelegate().getType()); } @Override diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenBackedProject.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenBackedProject.java index 6a9cd50..7e4b49c 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenBackedProject.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenBackedProject.java @@ -23,8 +23,8 @@ import org.apache.maven.model.Dependency; import org.apache.maven.project.MavenProject; import pl.wavesoftware.plugs.tools.maven.plugin.model.ResolvableDependency; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; import java.nio.file.Path; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenLibrariesFactory.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenLibrariesFactory.java index c21b20f..09c1cea 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenLibrariesFactory.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenLibrariesFactory.java @@ -19,9 +19,9 @@ import io.vavr.collection.Set; import org.slf4j.Logger; import pl.wavesoftware.plugs.tools.maven.plugin.model.MavenLibraries; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.Libraries; -import pl.wavesoftware.plugs.tools.packager.core.spi.LibrariesFactory; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Libraries; +import pl.wavesoftware.plugs.tools.packager.api.spi.LibrariesFactory; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfiguration.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfiguration.java index 50f131a..54338b8 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfiguration.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfiguration.java @@ -20,9 +20,9 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.slf4j.Logger; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; import java.io.File; import java.util.function.Supplier; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfigurationFactory.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfigurationFactory.java index a276375..c7c2183 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfigurationFactory.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerConfigurationFactory.java @@ -19,7 +19,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.slf4j.Logger; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerCoordinates.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerCoordinates.java index 1af4faf..c4b438e 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerCoordinates.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/MavenPackagerCoordinates.java @@ -17,9 +17,9 @@ package pl.wavesoftware.plugs.tools.maven.plugin.mapper; import io.vavr.Lazy; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; import java.nio.file.Path; import java.util.function.Supplier; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/PackagerConfigurationFactory.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/PackagerConfigurationFactory.java index 75aaab3..7f5009e 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/PackagerConfigurationFactory.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/PackagerConfigurationFactory.java @@ -19,7 +19,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.slf4j.Logger; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; import java.io.File; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/package-info.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/package-info.java index 72dfb9e..64abb26 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/package-info.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/mapper/package-info.java @@ -19,6 +19,9 @@ * @since 0.1.0 */ @ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault package pl.wavesoftware.plugs.tools.maven.plugin.mapper; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/AbstractFilterableDependency.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/AbstractFilterableDependency.java index 611ab1e..bbc525a 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/AbstractFilterableDependency.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/AbstractFilterableDependency.java @@ -19,7 +19,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apiguardian.api.API; import org.apiguardian.api.API.Status; -import pl.wavesoftware.plugs.tools.packager.core.model.FilterableDependency; +import pl.wavesoftware.plugs.tools.packager.api.model.FilterableDependency; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/MavenLibraries.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/MavenLibraries.java index bc3d97c..3b788ed 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/MavenLibraries.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/MavenLibraries.java @@ -23,10 +23,10 @@ import io.vavr.control.Option; import org.apache.maven.artifact.Artifact; import org.slf4j.Logger; -import pl.wavesoftware.plugs.tools.packager.core.model.Libraries; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; -import pl.wavesoftware.plugs.tools.packager.core.model.LibraryCallback; -import pl.wavesoftware.plugs.tools.packager.core.model.LibraryScope; +import pl.wavesoftware.plugs.tools.packager.api.model.Libraries; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.model.LibraryCallback; +import pl.wavesoftware.plugs.tools.packager.api.model.LibraryScope; import java.io.IOException; diff --git a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/package-info.java b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/package-info.java index 9a187d2..ea3c2d1 100644 --- a/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/package-info.java +++ b/tools/plugs-maven-plugin/src/main/java/pl/wavesoftware/plugs/tools/maven/plugin/model/package-info.java @@ -19,6 +19,9 @@ * @since 0.1.0 */ @ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault package pl.wavesoftware.plugs.tools.maven.plugin.model; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-maven-plugin/src/test/resources/code-with-deps/pom.xml b/tools/plugs-maven-plugin/src/test/resources/code-with-deps/pom.xml index 70dab07..19e8513 100644 --- a/tools/plugs-maven-plugin/src/test/resources/code-with-deps/pom.xml +++ b/tools/plugs-maven-plugin/src/test/resources/code-with-deps/pom.xml @@ -19,7 +19,7 @@ org.springframework.boot spring-boot-parent - 2.1.3.RELEASE + 2.1.5.RELEASE org.example diff --git a/tools/plugs-packager-api/pom.xml b/tools/plugs-packager-api/pom.xml new file mode 100644 index 0000000..21d6d71 --- /dev/null +++ b/tools/plugs-packager-api/pom.xml @@ -0,0 +1,71 @@ + + + + + 4.0.0 + + plugs-tools-parent + pl.wavesoftware.plugs.tools + 0.1.0-SNAPSHOT + + + plugs-packager-api + Plugs :: Tools :: Packager API + + + false + + + + + pl.wavesoftware.plugs + plug-api + ${project.version} + + + + pl.wavesoftware + eid-exceptions + + + org.slf4j + slf4j-api + + + io.vavr + vavr + + + com.vdurmont + semver4j + + + + + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom + test + + + + diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Constants.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Constants.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Constants.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Constants.java index 648df57..9461dc0 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Constants.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Constants.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core; +package pl.wavesoftware.plugs.tools.packager.api; /** * A packager core constants diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Packager.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Packager.java similarity index 92% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Packager.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Packager.java index bed49d8..9983b7a 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/Packager.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/Packager.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core; +package pl.wavesoftware.plugs.tools.packager.api; -import pl.wavesoftware.plugs.tools.packager.core.model.Or; +import pl.wavesoftware.plugs.tools.packager.api.model.Or; /** *

diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/PackagerFactory.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/PackagerFactory.java similarity index 85% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/PackagerFactory.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/PackagerFactory.java index b20650e..017ccd8 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/PackagerFactory.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/PackagerFactory.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core; +package pl.wavesoftware.plugs.tools.packager.api; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; /** * A packager factory to produce instances of {@link Packager}. diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/RepackagingIsRequiredFactory.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/RepackagingIsRequiredFactory.java similarity index 80% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/RepackagingIsRequiredFactory.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/RepackagingIsRequiredFactory.java index 7d86a6e..8b56017 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/RepackagingIsRequiredFactory.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/RepackagingIsRequiredFactory.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core; +package pl.wavesoftware.plugs.tools.packager.api; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackagingIsRequired; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackagingIsRequired; /** * A factory of a packaging required condition diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigest.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/ProjectDigest.java similarity index 89% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigest.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/ProjectDigest.java index d3bc65f..53d331e 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigest.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/ProjectDigest.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.digest; +package pl.wavesoftware.plugs.tools.packager.api.digest; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; import java.io.IOException; diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/package-info.java similarity index 81% rename from testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/package-info.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/package-info.java index c5c79f6..9c88444 100644 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/ansi/package-info.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/digest/package-info.java @@ -14,12 +14,10 @@ * limitations under the License. */ -/** - * This package is heavily inspired by Spring Boot implementation. - * - * @see org.springframework.boot.ansi - */ @ParametersAreNonnullByDefault -package pl.wavesoftware.plugs.testing.ansi; +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api.digest; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterEvent.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterEvent.java similarity index 93% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterEvent.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterEvent.java index 2f32a4b..f836e56 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterEvent.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterEvent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.jar; +package pl.wavesoftware.plugs.tools.packager.api.jar; /** * An event diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterListener.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterListener.java similarity index 94% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterListener.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterListener.java index fba4510..b2612b9 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriterListener.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/ArchiveWriterListener.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.jar; +package pl.wavesoftware.plugs.tools.packager.api.jar; /** * A listener for specific archive writer event diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibrariesCollector.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollector.java similarity index 90% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibrariesCollector.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollector.java index 09e9c72..3fc6775 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibrariesCollector.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollector.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.jar; +package pl.wavesoftware.plugs.tools.packager.api.jar; import io.vavr.collection.HashSet; import io.vavr.collection.Set; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; /** * A collector of a libraries diff --git a/testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/package-info.java similarity index 80% rename from testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/package-info.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/package-info.java index 827aded..0726607 100644 --- a/testing/src/main/java/pl/wavesoftware/plugs/testing/log4j2/package-info.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/jar/package-info.java @@ -14,12 +14,10 @@ * limitations under the License. */ -/** - * This package is heavily inspired by Spring Boot implementation. - * - * @see org.springframework.boot.logging.log4j2 - */ @ParametersAreNonnullByDefault -package pl.wavesoftware.plugs.testing.log4j2; +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api.jar; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilder.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/ManifestBuilder.java similarity index 86% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilder.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/ManifestBuilder.java index e174883..3e18d84 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilder.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/ManifestBuilder.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.manifest; +package pl.wavesoftware.plugs.tools.packager.api.manifest; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed; import java.util.jar.JarFile; import java.util.jar.Manifest; diff --git a/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/package-info.java new file mode 100644 index 0000000..2ce59c1 --- /dev/null +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/manifest/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ReturnTypesAreNonnullByDefault +@ParametersAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api.manifest; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Artifact.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Artifact.java similarity index 90% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Artifact.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Artifact.java index 8c8da27..e791f24 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Artifact.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Artifact.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; -import com.github.zafarkhaja.semver.Version; +import com.vdurmont.semver4j.Semver; import java.nio.file.Path; @@ -40,7 +40,7 @@ public interface Artifact { * * @return a version */ - Version version(); + Semver version(); /** * A path to a file that this artifact represents diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/ArtifactType.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactType.java similarity index 91% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/ArtifactType.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactType.java index dffa2c8..e8ec1b6 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/ArtifactType.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactType.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import pl.wavesoftware.eid.exceptions.EidIllegalArgumentException; @@ -40,7 +40,7 @@ public String extension() { return extension; } - public static ArtifactType fromPackging(String packaging) { + public static ArtifactType fromPackaging(String packaging) { for (ArtifactType value : ArtifactType.values()) { if (value.extension().equals(packaging)) { return value; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/CodeBlock.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/CodeBlock.java similarity index 92% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/CodeBlock.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/CodeBlock.java index 76ce3d2..354a35f 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/CodeBlock.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/CodeBlock.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * A block of code to be executed diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Filter.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Filter.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Filter.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Filter.java index 41309a2..33b06cf 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Filter.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Filter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import io.vavr.collection.Set; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/FilterableDependency.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/FilterableDependency.java similarity index 93% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/FilterableDependency.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/FilterableDependency.java index d7f9a5b..687fb18 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/FilterableDependency.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/FilterableDependency.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleBlock.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleBlock.java similarity index 93% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleBlock.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleBlock.java index bb0feb5..db59e98 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleBlock.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleBlock.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import java.io.IOException; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleSupplier.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleSupplier.java similarity index 94% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleSupplier.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleSupplier.java index 89e2b68..a19f542 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/IoPossibleSupplier.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/IoPossibleSupplier.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import java.io.IOException; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Libraries.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Libraries.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Libraries.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Libraries.java index 6a84af5..129fc2f 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Libraries.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Libraries.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import java.io.IOException; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Library.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Library.java similarity index 97% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Library.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Library.java index dad32f6..0cf139c 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Library.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Library.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import javax.annotation.Nullable; import java.io.File; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryCallback.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryCallback.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryCallback.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryCallback.java index bd42d67..b866982 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryCallback.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryCallback.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import java.io.File; import java.io.IOException; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryScope.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryScope.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryScope.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryScope.java index dca7e2c..a333e52 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/LibraryScope.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/LibraryScope.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * The scope of a library. The common {@link #COMPILE}, {@link #RUNTIME} and diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Or.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Or.java similarity index 94% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Or.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Or.java index 1e8666e..be0369b 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Or.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Or.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * This interface represent a block of code that should be execute as a diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerConfiguration.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerConfiguration.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerConfiguration.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerConfiguration.java index 910980e..a2a186e 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerConfiguration.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import org.slf4j.Logger; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerCoordinates.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerCoordinates.java similarity index 95% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerCoordinates.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerCoordinates.java index 84e3270..4b68976 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/PackagerCoordinates.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/PackagerCoordinates.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import java.nio.file.Path; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Project.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Project.java similarity index 96% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Project.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Project.java index 3b77ab6..dd29dd7 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/Project.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/Project.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import io.vavr.collection.Set; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackageFailed.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailed.java similarity index 97% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackageFailed.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailed.java index 65b8125..02ab155 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackageFailed.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailed.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; import org.slf4j.helpers.MessageFormatter; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackagingIsRequired.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackagingIsRequired.java similarity index 94% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackagingIsRequired.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackagingIsRequired.java index 92ab312..1a818e4 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/RepackagingIsRequired.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackagingIsRequired.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * A interface that represents an entity that can decide if packaging is needed diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/StandardLibraries.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/StandardLibraries.java similarity index 94% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/StandardLibraries.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/StandardLibraries.java index 7634fc4..d48910a 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/StandardLibraries.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/StandardLibraries.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.model; +package pl.wavesoftware.plugs.tools.packager.api.model; /** * A class that holds list of standard libraries diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/package-info.java similarity index 84% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/package-info.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/package-info.java index af7274b..1a113cb 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/model/package-info.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/model/package-info.java @@ -19,6 +19,9 @@ * @since 0.1.0 */ @ParametersAreNonnullByDefault -package pl.wavesoftware.plugs.tools.packager.core.model; +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api.model; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/package-info.java new file mode 100644 index 0000000..6013200 --- /dev/null +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/LibrariesFactory.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/LibrariesFactory.java similarity index 86% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/LibrariesFactory.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/LibrariesFactory.java index 18f990c..44fad89 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/LibrariesFactory.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/LibrariesFactory.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.spi; +package pl.wavesoftware.plugs.tools.packager.api.spi; import io.vavr.collection.Set; import org.slf4j.Logger; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.Libraries; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Libraries; /** diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/package-info.java b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/package-info.java similarity index 84% rename from tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/package-info.java rename to tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/package-info.java index 7c2ada4..6bda574 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/spi/package-info.java +++ b/tools/plugs-packager-api/src/main/java/pl/wavesoftware/plugs/tools/packager/api/spi/package-info.java @@ -19,6 +19,9 @@ * @since 0.1.0 */ @ParametersAreNonnullByDefault -package pl.wavesoftware.plugs.tools.packager.core.spi; +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.api.spi; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollectorTest.java b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollectorTest.java new file mode 100644 index 0000000..82bbf40 --- /dev/null +++ b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/jar/LibrariesCollectorTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.api.jar; + +import org.junit.jupiter.api.Test; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.model.LibraryScope; + +import java.io.File; + +import static org.assertj.core.api.Assertions.*; + +/** + * @author Krzysztof Suszynski + * @since 0.1.0 + */ +class LibrariesCollectorTest { + + @Test + void getCollected() { + // given + LibrariesCollector collector = new LibrariesCollector(); + File acmeFile = new File("acme"); + LibraryScope scope = LibraryScope.PROVIDED; + Library library = new Library(acmeFile, scope); + + // when + collector.collect(library); + + // then + assertThat(collector.getCollected()).hasSize(1); + assertThat(collector.getCollected().head()).extracting( + Library::getFile, Library::getScope, Library::getName + ).containsOnly( + acmeFile, scope, "acme" + ); + assertThat(scope.toString()).isEqualTo("provided"); + } +} diff --git a/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactTypeTest.java b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactTypeTest.java new file mode 100644 index 0000000..b0fc401 --- /dev/null +++ b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/ArtifactTypeTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.api.model; + +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; +import org.junit.jupiter.api.Test; +import pl.wavesoftware.eid.exceptions.EidIllegalArgumentException; + +import static org.assertj.core.api.Assertions.*; + +/** + * @author Krzysztof Suszynski + * @since 0.1.0 + */ +class ArtifactTypeTest { + + @Test + void extension() { + // when + String ext = ArtifactType.RAR.extension(); + + // then + assertThat(ext).isEqualTo("rar"); + } + + @Test + void fromPackaging() { + // when + ArtifactType type = ArtifactType.fromPackaging("jar"); + ThrowingCallable jsThrowingCallable = () -> ArtifactType.fromPackaging("js"); + + // then + assertThat(type).isSameAs(ArtifactType.JAR); + assertThatCode(jsThrowingCallable) + .isInstanceOf(EidIllegalArgumentException.class) + .hasMessageContaining("20190209:000032"); + } +} diff --git a/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailedTest.java b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailedTest.java new file mode 100644 index 0000000..81b7208 --- /dev/null +++ b/tools/plugs-packager-api/src/test/java/pl/wavesoftware/plugs/tools/packager/api/model/RepackageFailedTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.api.model; + +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; + +/** + * @author Krzysztof Suszynski + * @since 0.1.0 + */ +class RepackageFailedTest { + + @Nested + class Positive { + @Test + void check() { + // when + assertThatCode(() -> + RepackageFailed.check(true).or("polite err") + ).doesNotThrowAnyException(); + } + + @Test + void tring() { + // when + assertThatCode(() -> + RepackageFailed.tring(() -> assertThat(this).isNotNull()) + .or("polite {}", "err") + ).doesNotThrowAnyException(); + } + + @Test + void tringToGet() throws RepackageFailed { + // when + String result = RepackageFailed.tring(() -> "result") + .or(() -> "err"); + + // then + assertThat(result).isEqualTo("result"); + } + } + + @Nested + class Negative { + @Test + void check() { + // when + assertThatCode(() -> + RepackageFailed.check(false).or("err {}", 1) + ).hasMessage("err 1"); + } + + @Test + void tring() { + // when + assertThatCode(() -> + RepackageFailed.tring((IoPossibleBlock) () -> { + throw new IOException("io err"); + }).or(() -> "err 2") + ).hasMessage("err 2"); + } + + @Test + void tringToGet() { + // when + assertThatCode(() -> { + RepackageFailed.tring((IoPossibleSupplier) () -> { + throw new IOException("err io"); + }).or("err 3"); + failBecauseExceptionWasNotThrown(RepackageFailed.class); + }).hasMessage("err 3"); + } + } +} diff --git a/tools/plugs-packager-core/pom.xml b/tools/plugs-packager-core/pom.xml index 188dd09..548dd65 100644 --- a/tools/plugs-packager-core/pom.xml +++ b/tools/plugs-packager-core/pom.xml @@ -36,15 +36,11 @@ - pl.wavesoftware.plugs - plug-api + pl.wavesoftware.plugs.tools + plugs-packager-api ${project.version} - - pl.wavesoftware - eid-exceptions - org.slf4j slf4j-api @@ -53,14 +49,6 @@ javax.inject javax.inject - - io.vavr - vavr - - - com.github.zafarkhaja - java-semver - org.apache.commons commons-compress @@ -68,11 +56,23 @@ - pl.wavesoftware.plugs - testing + pl.wavesoftware.plugs.tools + plugs-packager-samples ${project.version} test + + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom + test + + + org.springframework + spring-test + test + diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackager.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackager.java index e7e129a..c33b87a 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackager.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackager.java @@ -19,22 +19,23 @@ import io.vavr.collection.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pl.wavesoftware.plugs.tools.packager.api.Packager; +import pl.wavesoftware.plugs.tools.packager.api.manifest.ManifestBuilder; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.ArtifactType; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.Libraries; +import pl.wavesoftware.plugs.tools.packager.api.model.Or; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackagingIsRequired; +import pl.wavesoftware.plugs.tools.packager.api.spi.LibrariesFactory; import pl.wavesoftware.plugs.tools.packager.core.jar.JarWriter; -import pl.wavesoftware.plugs.tools.packager.core.jar.LibrariesCollector; +import pl.wavesoftware.plugs.tools.packager.api.jar.LibrariesCollector; import pl.wavesoftware.plugs.tools.packager.core.jar.LibraryHasBeenWritten; import pl.wavesoftware.plugs.tools.packager.core.jar.WritableLibraries; -import pl.wavesoftware.plugs.tools.packager.core.manifest.ManifestBuilder; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.ArtifactType; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; -import pl.wavesoftware.plugs.tools.packager.core.model.Libraries; -import pl.wavesoftware.plugs.tools.packager.core.model.Or; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackagingIsRequired; -import pl.wavesoftware.plugs.tools.packager.core.spi.LibrariesFactory; import java.io.File; import java.io.IOException; @@ -43,8 +44,8 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; -import static pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed.check; -import static pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed.tring; +import static pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed.check; +import static pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed.tring; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackagerFactory.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackagerFactory.java index 488be1d..90b2879 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackagerFactory.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultPackagerFactory.java @@ -16,11 +16,14 @@ package pl.wavesoftware.plugs.tools.packager.core; -import pl.wavesoftware.plugs.tools.packager.core.manifest.ManifestBuilder; -import pl.wavesoftware.plugs.tools.packager.core.model.Filter; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerConfiguration; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackagingIsRequired; -import pl.wavesoftware.plugs.tools.packager.core.spi.LibrariesFactory; +import pl.wavesoftware.plugs.tools.packager.api.Packager; +import pl.wavesoftware.plugs.tools.packager.api.PackagerFactory; +import pl.wavesoftware.plugs.tools.packager.api.RepackagingIsRequiredFactory; +import pl.wavesoftware.plugs.tools.packager.api.manifest.ManifestBuilder; +import pl.wavesoftware.plugs.tools.packager.api.model.Filter; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerConfiguration; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackagingIsRequired; +import pl.wavesoftware.plugs.tools.packager.api.spi.LibrariesFactory; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequired.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequired.java index cd7f33a..69d8115 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequired.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequired.java @@ -16,10 +16,10 @@ package pl.wavesoftware.plugs.tools.packager.core; -import pl.wavesoftware.plugs.tools.packager.core.digest.ProjectDigest; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackagingIsRequired; +import pl.wavesoftware.plugs.tools.packager.api.digest.ProjectDigest; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackagingIsRequired; import java.io.File; import java.io.IOException; @@ -28,7 +28,7 @@ import java.util.jar.Manifest; import static pl.wavesoftware.eid.utils.EidExecutions.tryToExecute; -import static pl.wavesoftware.plugs.tools.packager.core.Constants.PLUGS_DIGEST_ATTRIBUTE; +import static pl.wavesoftware.plugs.tools.packager.api.Constants.PLUGS_DIGEST_ATTRIBUTE; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequiredFactory.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequiredFactory.java index f68c319..9237b70 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequiredFactory.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/DefaultRepackagingIsRequiredFactory.java @@ -16,10 +16,11 @@ package pl.wavesoftware.plugs.tools.packager.core; -import pl.wavesoftware.plugs.tools.packager.core.digest.ProjectDigest; -import pl.wavesoftware.plugs.tools.packager.core.model.PackagerCoordinates; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackagingIsRequired; +import pl.wavesoftware.plugs.tools.packager.api.RepackagingIsRequiredFactory; +import pl.wavesoftware.plugs.tools.packager.api.digest.ProjectDigest; +import pl.wavesoftware.plugs.tools.packager.api.model.PackagerCoordinates; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackagingIsRequired; import javax.inject.Inject; import javax.inject.Named; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImpl.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImpl.java index aa0de7b..e3d9379 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImpl.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImpl.java @@ -16,7 +16,8 @@ package pl.wavesoftware.plugs.tools.packager.core.digest; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.digest.ProjectDigest; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; import javax.inject.Named; import java.io.IOException; @@ -37,12 +38,18 @@ final class ProjectDigestImpl implements ProjectDigest { public CharSequence digest(Project project) throws IOException { Path sourcePath = project.mainArtifact().path(); Path buildFilePath = project.buildFilePath(); - checkArgument(sourcePath.toFile().isFile(), "20190131:221929"); - CRC32 digest = new CRC32(); - digest.update(sourcePath.toAbsolutePath().toString().getBytes(UTF_8)); - digest.update(Long.toHexString(Files.size(sourcePath)).getBytes(UTF_8)); - digest.update(Long.toHexString(Files.size(buildFilePath)).getBytes(UTF_8)); - digest.update(Long.toHexString(buildFilePath.toFile().lastModified()).getBytes(UTF_8)); - return Long.toHexString(Math.abs(digest.getValue())); + checkArgument(Files.isRegularFile(sourcePath), "20190131:221929"); + CRC32 digester = new CRC32(); + digester.update(sourcePath.toAbsolutePath().toString().getBytes(UTF_8)); + digester.update(Long.toHexString(Files.size(sourcePath)).getBytes(UTF_8)); + digester.update(Long.toHexString(Files.getLastModifiedTime(sourcePath).toMillis()).getBytes(UTF_8)); + digester.update(Long.toHexString(Files.size(buildFilePath)).getBytes(UTF_8)); + digester.update(Long.toHexString(Files.getLastModifiedTime(buildFilePath).toMillis()).getBytes(UTF_8)); + return encode(digester.getValue()); } + + private CharSequence encode(long digest) { + return Long.toUnsignedString(digest, 36); + } + } diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/package-info.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/package-info.java new file mode 100644 index 0000000..5849f32 --- /dev/null +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/digest/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.core.digest; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriter.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriter.java index 22c0444..4295639 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriter.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/ArchiveWriter.java @@ -16,7 +16,10 @@ package pl.wavesoftware.plugs.tools.packager.core.jar; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; + +import pl.wavesoftware.plugs.tools.packager.api.jar.ArchiveWriterEvent; +import pl.wavesoftware.plugs.tools.packager.api.jar.ArchiveWriterListener; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; import javax.annotation.WillClose; import java.io.IOException; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/JarWriter.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/JarWriter.java index bed7483..f91ab3b 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/JarWriter.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/JarWriter.java @@ -22,7 +22,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.helpers.MessageFormatter; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.jar.ArchiveWriterEvent; +import pl.wavesoftware.plugs.tools.packager.api.jar.ArchiveWriterListener; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; import javax.annotation.Nullable; import javax.annotation.WillClose; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibraryHasBeenWritten.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibraryHasBeenWritten.java index 68c24e1..4fa1105 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibraryHasBeenWritten.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/LibraryHasBeenWritten.java @@ -16,7 +16,8 @@ package pl.wavesoftware.plugs.tools.packager.core.jar; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.jar.ArchiveWriterEvent; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/WritableLibraries.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/WritableLibraries.java index 361b742..19d9cfa 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/WritableLibraries.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/WritableLibraries.java @@ -16,14 +16,14 @@ package pl.wavesoftware.plugs.tools.packager.core.jar; -import pl.wavesoftware.plugs.tools.packager.core.model.Libraries; -import pl.wavesoftware.plugs.tools.packager.core.model.Library; +import pl.wavesoftware.plugs.tools.packager.api.model.Libraries; +import pl.wavesoftware.plugs.tools.packager.api.model.Library; import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; -import static pl.wavesoftware.plugs.tools.packager.core.Constants.LIBRARY_DESTINATION; +import static pl.wavesoftware.plugs.tools.packager.api.Constants.LIBRARY_DESTINATION; import static pl.wavesoftware.plugs.tools.packager.core.jar.FileUtils.isZip; /** diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/package-info.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/package-info.java index 682c163..a6d6f07 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/package-info.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/jar/package-info.java @@ -18,7 +18,10 @@ * @author Krzysztof Suszynski * @since 0.1.0 */ +@ReturnTypesAreNonnullByDefault @ParametersAreNonnullByDefault package pl.wavesoftware.plugs.tools.packager.core.jar; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilderImpl.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilderImpl.java index 3947eaf..9138834 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilderImpl.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/ManifestBuilderImpl.java @@ -19,9 +19,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import pl.wavesoftware.plugs.api.PlugsVersion; -import pl.wavesoftware.plugs.tools.packager.core.digest.ProjectDigest; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; -import pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed; +import pl.wavesoftware.plugs.tools.packager.api.digest.ProjectDigest; +import pl.wavesoftware.plugs.tools.packager.api.manifest.ManifestBuilder; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed; import javax.inject.Inject; import javax.inject.Named; @@ -30,9 +31,9 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; -import static pl.wavesoftware.plugs.tools.packager.core.Constants.PLUGS_DIGEST_ATTRIBUTE; -import static pl.wavesoftware.plugs.tools.packager.core.Constants.PLUGS_VERSION_ATTRIBUTE; -import static pl.wavesoftware.plugs.tools.packager.core.model.RepackageFailed.tring; +import static pl.wavesoftware.plugs.tools.packager.api.model.RepackageFailed.tring; +import static pl.wavesoftware.plugs.tools.packager.api.Constants.PLUGS_DIGEST_ATTRIBUTE; +import static pl.wavesoftware.plugs.tools.packager.api.Constants.PLUGS_VERSION_ATTRIBUTE; /** * @author Krzysztof Suszynski diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/package-info.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/package-info.java index 937dfe5..70435c4 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/package-info.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/manifest/package-info.java @@ -18,7 +18,10 @@ * @author Krzysztof Suszynski * @since 0.1.0 */ +@ReturnTypesAreNonnullByDefault @ParametersAreNonnullByDefault package pl.wavesoftware.plugs.tools.packager.core.manifest; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/package-info.java b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/package-info.java index ec2999f..5cdbaf3 100644 --- a/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/package-info.java +++ b/tools/plugs-packager-core/src/main/java/pl/wavesoftware/plugs/tools/packager/core/package-info.java @@ -18,7 +18,10 @@ * @author Krzysztof Suszynski * @since 0.1.0 */ +@ReturnTypesAreNonnullByDefault @ParametersAreNonnullByDefault package pl.wavesoftware.plugs.tools.packager.core; +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-core/src/main/resources/META-INF/sisu/javax.inject.Named b/tools/plugs-packager-core/src/main/resources/META-INF/sisu/javax.inject.Named index 4fed7bf..e779a65 100644 --- a/tools/plugs-packager-core/src/main/resources/META-INF/sisu/javax.inject.Named +++ b/tools/plugs-packager-core/src/main/resources/META-INF/sisu/javax.inject.Named @@ -1,4 +1,4 @@ -pl.wavesoftware.plugs.tools.packager.core.jar.ProjectDigestImpl +pl.wavesoftware.plugs.tools.packager.core.digest.ProjectDigestImpl pl.wavesoftware.plugs.tools.packager.core.manifest.ManifestBuilderImpl pl.wavesoftware.plugs.tools.packager.core.DefaultPackagerFactory pl.wavesoftware.plugs.tools.packager.core.DefaultRepackagingIsRequiredFactory diff --git a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImplTest.java b/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImplTest.java index 170c3aa..9a03b83 100644 --- a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImplTest.java +++ b/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/digest/ProjectDigestImplTest.java @@ -16,66 +16,42 @@ package pl.wavesoftware.plugs.tools.packager.core.digest; -import com.github.zafarkhaja.semver.Version; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import pl.wavesoftware.plugs.tools.packager.core.model.Artifact; -import pl.wavesoftware.plugs.tools.packager.core.model.ArtifactType; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import pl.wavesoftware.plugs.tools.packager.api.digest.ProjectDigest; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.sample.PackagerSamplerContext; +import pl.wavesoftware.plugs.tools.packager.sample.project.SimpleProject; +import pl.wavesoftware.sampler.api.SamplerContext; import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; /** * @author Krzysztof Suszynski * @since 0.1.0 */ -@ExtendWith(MockitoExtension.class) +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = PackagerSamplerContext.class) class ProjectDigestImplTest { - @Mock - Project project; + @Autowired + private SamplerContext context; @Test - void digest() throws IOException, URISyntaxException { + void digest() throws IOException { // given ProjectDigest digester = new ProjectDigestImpl(); - Path buildFilePath = Paths.get(getClass().getResource("pom.xml").toURI()); - Artifact artifact = new Artifact() { - @Override - public String name() { - throw new UnsupportedOperationException("Not yet implemented"); - } - - @Override - public Version version() { - throw new UnsupportedOperationException("Not yet implemented"); - } - - @Override - public Path path() { - throw new UnsupportedOperationException("Not yet implemented"); - } - - @Override - public ArtifactType type() { - throw new UnsupportedOperationException("Not yet implemented"); - } - }; - when(project.buildFilePath()).thenReturn(buildFilePath); - when(project.mainArtifact()).thenReturn(artifact); + Project project = context.get(SimpleProject.class); // when CharSequence digest = digester.digest(project); // then - assertThat(digest).isEqualTo("22ssdd33"); + assertThat(digest).isEqualTo("1is34vi"); } } diff --git a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/SimpleProjectSample.java b/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/SimpleProjectSample.java deleted file mode 100644 index 3cace72..0000000 --- a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/SimpleProjectSample.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019 Wave Software - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package pl.wavesoftware.plugs.tools.packager.core.sample; - -import pl.wavesoftware.plugs.tools.packager.core.model.Project; - -/** - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -final class SimpleProjectSample implements Sample { - @Override - public Project get() { - throw new UnsupportedOperationException("Not yet implemented"); - } -} diff --git a/tools/plugs-packager-core/src/test/resources/pl/wavesoftware/plugs/tools/packager/core/sample/pom.xml b/tools/plugs-packager-core/src/test/resources/pl/wavesoftware/plugs/tools/packager/core/sample/pom.xml deleted file mode 100644 index 9246447..0000000 --- a/tools/plugs-packager-core/src/test/resources/pl/wavesoftware/plugs/tools/packager/core/sample/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - org.example - digest-test - 0.1.0 - diff --git a/tools/plugs-packager-samples/pom.xml b/tools/plugs-packager-samples/pom.xml new file mode 100644 index 0000000..72f8f5e --- /dev/null +++ b/tools/plugs-packager-samples/pom.xml @@ -0,0 +1,69 @@ + + + + + 4.0.0 + + plugs-tools-parent + pl.wavesoftware.plugs.tools + 0.1.0-SNAPSHOT + + + plugs-packager-samples + Plugs :: Tools :: Packager Samples + + + false + + + + + pl.wavesoftware.plugs.tools + plugs-packager-api + ${project.version} + + + pl.wavesoftware.sampler + sampler-spring + 1.0.0 + + + com.google.jimfs + jimfs + 1.1 + + + + + pl.wavesoftware.testing + junit5-starter + 1.0.0 + pom + test + + + org.springframework + spring-test + test + + + + diff --git a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/Sample.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContext.java similarity index 59% rename from tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/Sample.java rename to tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContext.java index 189badb..17dc0fc 100644 --- a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/Sample.java +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContext.java @@ -14,16 +14,15 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.sample; +package pl.wavesoftware.plugs.tools.packager.sample; -import java.util.function.Supplier; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import pl.wavesoftware.sampler.spring.Sample; + +@ComponentScan(includeFilters = @Filter(Sample.class)) +@EnableAutoConfiguration +public class PackagerSamplerContext { -/** - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -public interface Sample extends Supplier { - default T getSample() { - return get(); - } } diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/HibernateArtifact.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/HibernateArtifact.java new file mode 100644 index 0000000..056bec0 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/HibernateArtifact.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact; + +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.sampler.api.Sampler; + +public interface HibernateArtifact extends Sampler { + +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/Jsr305Artifact.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/Jsr305Artifact.java new file mode 100644 index 0000000..5f774d1 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/Jsr305Artifact.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact; + +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.sampler.api.Sampler; + +public interface Jsr305Artifact extends Sampler { +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/OsgiCoreArtifact.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/OsgiCoreArtifact.java new file mode 100644 index 0000000..d3be6d8 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/OsgiCoreArtifact.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact; + +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.sampler.api.Sampler; + +public interface OsgiCoreArtifact extends Sampler { +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/SimpleProjectBuildArtifact.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/SimpleProjectBuildArtifact.java new file mode 100644 index 0000000..48d2553 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/SimpleProjectBuildArtifact.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact; + +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.sampler.api.Sampler; + +public interface SimpleProjectBuildArtifact extends Sampler { +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/HibernateArtifactImpl.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/HibernateArtifactImpl.java new file mode 100644 index 0000000..574c241 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/HibernateArtifactImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import com.vdurmont.semver4j.Semver; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.HibernateArtifact; +import pl.wavesoftware.sampler.api.SamplerContext; +import pl.wavesoftware.sampler.spring.Sample; + +@Sample +final class HibernateArtifactImpl implements HibernateArtifact { + private final SamplerContext context; + + HibernateArtifactImpl(SamplerContext context) { + this.context = context; + } + + @Override + public Artifact create() { + return new MavenlikeArtifact( + context, + "hibernate-core", + "org.hibernate", + new Semver("5.4.2.Final") + ); + } +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/Jsr305ArtifactImpl.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/Jsr305ArtifactImpl.java new file mode 100644 index 0000000..b5004b9 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/Jsr305ArtifactImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import com.vdurmont.semver4j.Semver; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.Jsr305Artifact; +import pl.wavesoftware.sampler.api.SamplerContext; +import pl.wavesoftware.sampler.spring.Sample; + +@Sample +final class Jsr305ArtifactImpl implements Jsr305Artifact { + private final SamplerContext context; + + Jsr305ArtifactImpl(SamplerContext context) { + this.context = context; + } + + @Override + public Artifact create() { + return new MavenlikeArtifact( + context, + "jsr305", + "com.google.code.findbugs", + new Semver("3.0.2") + ); + } +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/MavenlikeArtifact.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/MavenlikeArtifact.java new file mode 100644 index 0000000..8730023 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/MavenlikeArtifact.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import com.vdurmont.semver4j.Semver; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.ArtifactType; +import pl.wavesoftware.plugs.tools.packager.sample.fs.VirtualRoot; +import pl.wavesoftware.sampler.api.SamplerContext; + +import java.nio.file.Path; + +final class MavenlikeArtifact implements Artifact { + + private final SamplerContext context; + private final String name; + private final String group; + private final Semver version; + + MavenlikeArtifact( + SamplerContext context, + String name, + String group, + Semver version + ) { + this.context = context; + this.name = name; + this.group = group; + this.version = version; + } + + @Override + public String name() { + return name; + } + + @Override + public Semver version() { + return version; + } + + @Override + public Path path() { + Path root = context.get(VirtualRoot.class); + return root.resolve("home") + .resolve("jenkins") + .resolve(".m2") + .resolve("repository") + .resolve(groupAsPath()) + .resolve(name()) + .resolve(version().toString()) + .resolve(finalName()); + } + + @Override + public ArtifactType type() { + return ArtifactType.JAR; + } + + private String groupAsPath() { + return group.replace('.', '/'); + } + + private String finalName() { + return String.format( + "%s-%s.%s", + name(), version(), type().extension() + ); + } +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/OsgiCoreArtifactImpl.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/OsgiCoreArtifactImpl.java new file mode 100644 index 0000000..32c383d --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/OsgiCoreArtifactImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import com.vdurmont.semver4j.Semver; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.OsgiCoreArtifact; +import pl.wavesoftware.sampler.api.SamplerContext; +import pl.wavesoftware.sampler.spring.Sample; + +@Sample +final class OsgiCoreArtifactImpl implements OsgiCoreArtifact { + private final SamplerContext context; + + OsgiCoreArtifactImpl(SamplerContext context) { + this.context = context; + } + + @Override + public Artifact create() { + return new MavenlikeArtifact( + context, + "osgi.core", + "org.osgi", + new Semver("7.0.0") + ); + } +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/SimpleProjectBuildArtifactImpl.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/SimpleProjectBuildArtifactImpl.java new file mode 100644 index 0000000..ae02f8d --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/SimpleProjectBuildArtifactImpl.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import com.vdurmont.semver4j.Semver; +import io.vavr.Lazy; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.ArtifactType; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.SimpleProjectBuildArtifact; +import pl.wavesoftware.plugs.tools.packager.sample.project.SimpleProject; +import pl.wavesoftware.sampler.api.SamplerContext; +import pl.wavesoftware.sampler.spring.Sample; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileTime; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; + +import static pl.wavesoftware.eid.utils.EidExecutions.tryToExecute; + +@Sample +final class SimpleProjectBuildArtifactImpl implements SimpleProjectBuildArtifact { + + private static final byte[] BYTES = {0x56, 0x45}; + private static final Instant FILE_MOD_TIME = LocalDateTime.of( + 2019, 5, 23, 20, 39 + ).toInstant(ZoneOffset.ofHours(2)); + + private final SamplerContext context; + + SimpleProjectBuildArtifactImpl(SamplerContext context) { + this.context = context; + } + + @Override + public Artifact create() { + return new Artifact() { + + private final Lazy artifactPath = Lazy.of(() -> { + Project project = context.get(SimpleProject.class); + Path path = project.outputPath().resolve(project.finalName()); + tryToExecute(() -> { + Files.createDirectories(path.getParent()); + Files.createFile(path); + Files.write(path, BYTES); + Files.setLastModifiedTime(path, FileTime.from(FILE_MOD_TIME)); + }, "20190523:203722"); + return path; + }); + + @Override + public String name() { + return "simple"; + } + + @Override + public Semver version() { + return new Semver("1.0.0"); + } + + @Override + public Path path() { + return artifactPath.get(); + } + + @Override + public ArtifactType type() { + return ArtifactType.JAR; + } + }; + } +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/package-info.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/package-info.java new file mode 100644 index 0000000..5f811dc --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/impl/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.sample.artifact.impl; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/package-info.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/package-info.java new file mode 100644 index 0000000..38da57e --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/artifact/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.sample.artifact; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRoot.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRoot.java new file mode 100644 index 0000000..1c0bedc --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRoot.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.fs; + +import pl.wavesoftware.sampler.api.Sampler; + +import java.nio.file.Path; + + +public interface VirtualRoot extends Sampler { + +} diff --git a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/ProjectSamples.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRootImpl.java similarity index 52% rename from tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/ProjectSamples.java rename to tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRootImpl.java index 4905d6f..2a32102 100644 --- a/tools/plugs-packager-core/src/test/java/pl/wavesoftware/plugs/tools/packager/core/sample/ProjectSamples.java +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/VirtualRootImpl.java @@ -14,28 +14,27 @@ * limitations under the License. */ -package pl.wavesoftware.plugs.tools.packager.core.sample; +package pl.wavesoftware.plugs.tools.packager.sample.fs; -import pl.wavesoftware.plugs.tools.packager.core.model.Project; +import com.google.common.jimfs.Configuration; +import com.google.common.jimfs.Jimfs; +import org.springframework.beans.factory.DisposableBean; +import pl.wavesoftware.sampler.spring.Sample; -import java.util.function.Supplier; +import java.nio.file.FileSystem; +import java.nio.file.Path; -/** - * @author Krzysztof Suszynski - * @since 0.1.0 - */ -public enum ProjectSamples implements Sample { - - SIMPLE_PROJECT(new SimpleProjectSample()); +@Sample +final class VirtualRootImpl implements VirtualRoot, DisposableBean { + private final FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); - private final Supplier project; - - ProjectSamples(Supplier project) { - this.project = project; + @Override + public Path create() { + return fs.getPath("/"); } @Override - public Project get() { - return project.get(); + public void destroy() throws Exception { + fs.close(); } } diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/package-info.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/package-info.java new file mode 100644 index 0000000..178ccb6 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/fs/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.sample.fs; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/package-info.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/package-info.java new file mode 100644 index 0000000..dee81db --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.sample; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/AbstractProject.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/AbstractProject.java new file mode 100644 index 0000000..e930606 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/AbstractProject.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.project; + +import io.vavr.Lazy; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileTime; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; + +import static pl.wavesoftware.eid.utils.EidExecutions.tryToExecute; + +abstract class AbstractProject implements Project { + private static final Instant POM_MOD_TIME = LocalDateTime.of( + 2019, 5, 23, 20, 54 + ).toInstant(ZoneOffset.ofHours(2)); + + private final Path projectRoot; + private final Lazy buildFilePath; + + AbstractProject(Path root) { + this(root, "project"); + } + + AbstractProject(Path root, String projectDir) { + projectRoot = root.resolve("opt").resolve(projectDir); + buildFilePath = Lazy.of(() -> { + Path path = projectRoot.resolve("pom.xml"); + tryToExecute(() -> { + Files.createDirectories(path.getParent()); + Files.createFile(path); + Files.write(path, "".getBytes(StandardCharsets.UTF_8)); + Files.setLastModifiedTime(path, FileTime.from(POM_MOD_TIME)); + }, "20190523:205548"); + return path; + }); + } + + @Override + public Path buildFilePath() { + return buildFilePath.get(); + } + + @Override + public Path outputPath() { + Path path = projectRoot.resolve("target"); + tryToExecute(() -> Files.createDirectories(path), "20190523:205605"); + return path; + } + + @Override + public String finalName() { + return mainArtifact().name() + + '-' + mainArtifact().version() + + '-' + classifier() + + '.' + mainArtifact().type().extension(); + } + + @Override + public String classifier() { + return "plug"; + } + +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProject.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProject.java new file mode 100644 index 0000000..4ae8e47 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProject.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.project; + +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.sampler.api.Sampler; + +public interface SimpleProject extends Sampler { +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProjectImpl.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProjectImpl.java new file mode 100644 index 0000000..5181933 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/SimpleProjectImpl.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample.project; + +import io.vavr.collection.HashSet; +import io.vavr.collection.Set; +import pl.wavesoftware.plugs.tools.packager.api.model.Artifact; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.HibernateArtifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.Jsr305Artifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.OsgiCoreArtifact; +import pl.wavesoftware.plugs.tools.packager.sample.artifact.SimpleProjectBuildArtifact; +import pl.wavesoftware.plugs.tools.packager.sample.fs.VirtualRoot; +import pl.wavesoftware.sampler.api.SamplerContext; +import pl.wavesoftware.sampler.spring.Sample; + +import java.nio.file.Path; + +@Sample +final class SimpleProjectImpl implements SimpleProject { + + private final SamplerContext context; + + SimpleProjectImpl(SamplerContext context) { + this.context = context; + } + + @Override + public Project create() { + Path root = context.get(VirtualRoot.class); + return new AbstractProject(root, "simple") { + @Override + public Artifact mainArtifact() { + return context.get(SimpleProjectBuildArtifact.class); + } + + @Override + public Set dependencies() { + return HashSet + .of(HibernateArtifact.class, Jsr305Artifact.class) + .map(context::get); + } + + @Override + public Set imports() { + return HashSet + .of(OsgiCoreArtifact.class) + .map(context::get); + } + }; + } + +} diff --git a/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/package-info.java b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/package-info.java new file mode 100644 index 0000000..d41ac66 --- /dev/null +++ b/tools/plugs-packager-samples/src/main/java/pl/wavesoftware/plugs/tools/packager/sample/project/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@ParametersAreNonnullByDefault +@ReturnTypesAreNonnullByDefault +package pl.wavesoftware.plugs.tools.packager.sample.project; + +import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tools/plugs-packager-samples/src/test/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContextIT.java b/tools/plugs-packager-samples/src/test/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContextIT.java new file mode 100644 index 0000000..8a64e15 --- /dev/null +++ b/tools/plugs-packager-samples/src/test/java/pl/wavesoftware/plugs/tools/packager/sample/PackagerSamplerContextIT.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 Wave Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package pl.wavesoftware.plugs.tools.packager.sample; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import pl.wavesoftware.plugs.tools.packager.api.model.Project; +import pl.wavesoftware.plugs.tools.packager.sample.project.SimpleProject; +import pl.wavesoftware.sampler.api.SamplerContext; + +import java.nio.file.Path; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = PackagerSamplerContext.class) +class PackagerSamplerContextIT { + + @Autowired + private SamplerContext samplerContext; + + @Test + void get() { + // when + Project project = samplerContext.get(SimpleProject.class); + Path dependency = project.dependencies() + .filter(art -> "hibernate-core".equals(art.name())) + .head() + .path(); + + // then + assertThat(project).isNotNull(); + assertThat(dependency.toString()).isEqualTo( + "/home/jenkins/.m2/repository/org/hibernate/hibernate-core/" + + "5.4.2.Final/hibernate-core-5.4.2.Final.jar" + ); + } + + @Test + void differentScopes() { + // when + Project project1 = samplerContext.get(SimpleProject.class); + Project project2 = samplerContext.get(SimpleProject.class); + UUID firstId = samplerContext.controller().actualId(); + samplerContext.controller().newId(); + Project project3 = samplerContext.get(SimpleProject.class); + Project project4 = samplerContext.get(SimpleProject.class); + UUID secondId = samplerContext.controller().actualId(); + samplerContext.controller().setId(firstId); + Project project5 = samplerContext.get(SimpleProject.class); + Project project6 = samplerContext.get(SimpleProject.class); + project6.dependencies(); + + // then + assertThat(project1).isNotNull().isSameAs(project2); + assertThat(project3).isNotNull().isSameAs(project4); + assertThat(project3).isNotSameAs(project1); + assertThat(project5).isNotNull().isSameAs(project6).isSameAs(project1); + assertThat(firstId).isNotNull().isNotEqualTo(secondId); + assertThat(secondId).isNotNull(); + } + +} diff --git a/tools/pom.xml b/tools/pom.xml index 41313e4..d28e3d4 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -37,7 +37,9 @@ + plugs-packager-api plugs-packager-core + plugs-packager-samples plugs-maven-plugin