├── .dependency-lock-0.x ├── README.md └── pom.xml ├── .dependency-lock └── pom.xml ├── .gitattributes ├── .github └── workflows │ ├── codeql-analysis.yml │ └── test-and-release.yaml ├── .gitignore ├── DEVELOPMENT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── java-sumtypes.json ├── pom.xml ├── resources.properties ├── spotbugs-suppressions.xml ├── src ├── it │ ├── configuration │ │ ├── allow-extraneous │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── allow-missing │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── configuration-order │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── exclude-dependencyset │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── filename-check │ │ │ ├── anothername.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── filename-lock │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── ignore-integrity-marked │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── ignore-integrity-on-folder │ │ │ ├── dependee │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ └── main │ │ │ │ │ └── java │ │ │ │ │ └── Foo.java │ │ │ ├── dependent │ │ │ │ ├── dependencies-lock.json │ │ │ │ └── pom.xml │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── ignore-integrity │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── ignore-version-marked │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── ignore-version │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── snapshot-version │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ └── use-project-version │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ ├── failures │ │ ├── everything │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── extraneous │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── integrity-on-folder │ │ │ ├── dependee │ │ │ │ └── pom.xml │ │ │ ├── dependent │ │ │ │ ├── dependencies-lock.json │ │ │ │ ├── pom.xml │ │ │ │ └── postbuild.groovy │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── missing │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── not-project-version │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── wrong-integrity │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── wrong-optional │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── wrong-scope │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ └── wrong-version │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ ├── json │ │ ├── check-build-with-extension │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── check-build │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── check-future-format │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── check │ │ │ ├── dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-build-with-extension │ │ │ ├── expected-dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-build │ │ │ ├── expected-dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-marked │ │ │ ├── expected-dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ └── lock │ │ │ ├── expected-dependencies-lock.json │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ ├── pom │ │ ├── check-build-with-extension │ │ │ ├── .dependency-lock │ │ │ │ └── pom.xml │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── check-build │ │ │ ├── .dependency-lock │ │ │ │ └── pom.xml │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── check │ │ │ ├── .dependency-lock │ │ │ │ └── pom.xml │ │ │ ├── invoker.properties │ │ │ └── pom.xml │ │ ├── future-format │ │ │ ├── .dependency-lock │ │ │ │ └── pom.xml │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-build-with-extension │ │ │ ├── expected-pom.xml │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-build │ │ │ ├── expected-pom.xml │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ ├── lock-marked │ │ │ ├── expected-pom.xml │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ │ └── lock │ │ │ ├── expected-pom.xml │ │ │ ├── invoker.properties │ │ │ ├── pom.xml │ │ │ └── postbuild.groovy │ ├── setup │ │ └── dependencies │ │ │ ├── a-classified-leaf-1.0-classy.jar │ │ │ ├── a-classified-leaf-1.0.pom │ │ │ ├── a-snapshot-leaf-1.5-SNAPSHOT.jar │ │ │ ├── a-snapshot-leaf-1.5-SNAPSHOT.pom │ │ │ ├── a-third-leaf-1.0.jar │ │ │ ├── a-third-leaf-1.0.pom │ │ │ ├── a-war-1.0.pom │ │ │ ├── a-war-1.0.war │ │ │ ├── another-leaf-1.0.jar │ │ │ ├── another-leaf-1.0.pom │ │ │ ├── leaf-1.0.jar │ │ │ ├── leaf-1.0.pom │ │ │ ├── pom.xml │ │ │ ├── with-dependency-1.0.jar │ │ │ └── with-dependency-1.0.pom │ └── transitivity │ │ ├── checked │ │ ├── dependencies-lock.json │ │ ├── invoker.properties │ │ ├── pom.xml │ │ └── postbuild.groovy │ │ └── locked │ │ ├── expected-dependencies-lock.json │ │ ├── invoker.properties │ │ ├── pom.xml │ │ └── postbuild.groovy ├── main │ ├── java │ │ └── se │ │ │ └── vandmo │ │ │ └── dependencylock │ │ │ └── maven │ │ │ ├── Artifact.java │ │ │ ├── ArtifactIdentifier.java │ │ │ ├── Artifacts.java │ │ │ ├── Build.java │ │ │ ├── Checksum.java │ │ │ ├── Dependencies.java │ │ │ ├── DependenciesLockFile.java │ │ │ ├── Dependency.java │ │ │ ├── DependencySetConfiguration.java │ │ │ ├── DiffHelper.java │ │ │ ├── DiffReport.java │ │ │ ├── Extension.java │ │ │ ├── Extensions.java │ │ │ ├── Filters.java │ │ │ ├── Integrity.java │ │ │ ├── LockFileAccessor.java │ │ │ ├── LockFileFormat.java │ │ │ ├── LockableEntities.java │ │ │ ├── LockableEntitiesWithArtifact.java │ │ │ ├── LockableEntity.java │ │ │ ├── LockableEntityWithArtifact.java │ │ │ ├── LockedArtifacts.java │ │ │ ├── LockedBuild.java │ │ │ ├── LockedDependencies.java │ │ │ ├── LockedEntities.java │ │ │ ├── LockedExtensions.java │ │ │ ├── LockedPlugins.java │ │ │ ├── LockedProject.java │ │ │ ├── Lockfile.java │ │ │ ├── MavenArtifact.java │ │ │ ├── Plugin.java │ │ │ ├── Plugins.java │ │ │ ├── PomMinimums.java │ │ │ ├── Project.java │ │ │ ├── VersionUtils.java │ │ │ ├── json │ │ │ ├── DependenciesLockFileJson.java │ │ │ ├── JsonUtils.java │ │ │ └── LockfileJson.java │ │ │ ├── lang │ │ │ └── Strings.java │ │ │ ├── mojos │ │ │ ├── AbstractDependencyLockMojo.java │ │ │ ├── CheckMojo.java │ │ │ ├── DependencySet.java │ │ │ ├── LockMojo.java │ │ │ └── LockProjectHelper.java │ │ │ └── pom │ │ │ ├── DependenciesLockFilePom.java │ │ │ ├── InvalidPomLockFile.java │ │ │ ├── LockFilePom.java │ │ │ └── PomLockFile.java │ └── resources │ │ └── se │ │ └── vandmo │ │ └── dependencylock │ │ └── maven │ │ └── pom │ │ ├── pom-with-plugins.ftlx │ │ └── pom.ftlx ├── site │ ├── site.xml │ └── xsd │ │ ├── dependencylock.xsd │ │ └── maven-4_0_0_ext.xsd └── test │ ├── java │ ├── ArtifactTests.java │ ├── DependencyTests.java │ └── se │ │ └── vandmo │ │ └── dependencylock │ │ └── maven │ │ ├── ChecksumTests.java │ │ ├── LockFileAccessorTests.java │ │ ├── VersionUtilsTests.java │ │ ├── json │ │ └── JsonUtilsTests.java │ │ ├── lang │ │ └── StringsTests.java │ │ ├── mojos │ │ └── LockProjectHelperTest.java │ │ └── pom │ │ ├── LockFilePomTest.java │ │ └── PomLockFileTests.java │ └── resources │ └── se │ └── vandmo │ └── dependencylock │ └── maven │ ├── mojos │ └── LockProjectHelperTest │ │ ├── loadPlugins_appropriatelyHandlesProfilePlugin.xml │ │ ├── loadPlugins_appropriatelyIncludesManagedProfilePlugins.xml │ │ ├── loadPlugins_logsAWarningIfProfilePluginVersionManagedInProfile.xml │ │ ├── loadPlugins_logsNothingIfProfilePluginAppropriatelyDeclared.xml │ │ └── loadPlugins_supportsProfileWithNoBuild.xml │ └── poms │ ├── element-when-text.xml │ ├── no-artifactId.xml │ ├── no-dependencies.xml │ ├── no-groupId.xml │ ├── no-integrity.xml │ ├── no-optional.xml │ ├── no-scope.xml │ ├── no-type.xml │ ├── no-version.xml │ ├── text-then-element.xml │ ├── valid.xml │ ├── wrong-end.xml │ ├── wrong-optional.xml │ └── wrong-top.xml ├── tasks ├── create-test-dependencies ├── format ├── full-build ├── generate-sumtypes ├── list-checksum-for-test-dependencies └── lock-dependencies └── test-resources.properties /.dependency-lock-0.x/README.md: -------------------------------------------------------------------------------- 1 | This file is here to get GitHub Dependabot Alerts for the 0.x branch. 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.bash text eol=lf 3 | *.sh text eol=lf 4 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | schedule: 9 | - cron: '38 17 * * 1' 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | 20 | strategy: 21 | fail-fast: false 22 | matrix: 23 | language: [ 'java' ] 24 | 25 | steps: 26 | - name: Checkout repository 27 | uses: actions/checkout@v2 28 | 29 | - name: Initialize CodeQL 30 | uses: github/codeql-action/init@v1 31 | with: 32 | languages: ${{ matrix.language }} 33 | 34 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 35 | # If this step fails, then you should remove it and run the build manually (see below) 36 | - name: Autobuild 37 | uses: github/codeql-action/autobuild@v1 38 | 39 | # ℹ️ Command-line programs to run using the OS shell. 40 | # 📚 https://git.io/JvXDl 41 | 42 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 43 | # and modify them (or add more) to build your code if your project 44 | # uses a compiled language 45 | 46 | #- run: | 47 | # make bootstrap 48 | # make release 49 | 50 | - name: Perform CodeQL Analysis 51 | uses: github/codeql-action/analyze@v1 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | .*.un~ 3 | .junk/ 4 | .project 5 | .settings/ 6 | target/ 7 | /.idea/ 8 | *.iml 9 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | There are a bunch of scripts in the `tasks/` folder that can be useful: 2 | * `tasks/format` formats all code 3 | * `tasks/full-build` run everything that is run in the build pipe 4 | * `tasks/generate-sumtypes` generates some code that shouldn't be edited manually 5 | * `tasks/lock-dependencies` updates the lock file -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | These versions are currently being supported with security updates. 6 | 7 | | Version | Supported | 8 | | ------- | ------------------ | 9 | | 1.x | :white_check_mark: | 10 | | 0.x | :white_check_mark: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | If you find any vulnerability, please report it privately here on GitHub. 15 | https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability 16 | -------------------------------------------------------------------------------- /java-sumtypes.json: -------------------------------------------------------------------------------- 1 | { 2 | "java-sumtypes": [ 3 | { 4 | "package-name": "se.vandmo.dependencylock.maven", 5 | "name": "Integrity", 6 | "types": { 7 | "Calculated": { "checksum": "String" }, 8 | "Folder": {}, 9 | "Ignored": {} 10 | }, 11 | "imports": "all" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /resources.properties: -------------------------------------------------------------------------------- 1 | # Defines where XSDs are to be found 2 | xsd_dest=https://vandmo.github.io/dependency-lock-maven-plugin -------------------------------------------------------------------------------- /spotbugs-suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/it/configuration/allow-extraneous/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/allow-extraneous/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/allow-extraneous/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | allow-extraneous 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | se.vandmo 23 | dependency-lock-maven-plugin 24 | @project.version@ 25 | 26 | 27 | 28 | 29 | se.vandmo.testing 30 | 31 | true 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/it/configuration/allow-missing/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/allow-missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/allow-missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | allow-missing 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | 28 | 29 | 30 | 31 | 32 | 33 | se.vandmo 34 | dependency-lock-maven-plugin 35 | @project.version@ 36 | 37 | 38 | 39 | 40 | se.vandmo.testing 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/it/configuration/configuration-order/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/configuration-order/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/configuration-order/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | configuration-order 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | another-leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | false 38 | false 39 | 40 | 41 | 42 | se.vandmo.testing 43 | 44 | true 45 | true 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/it/configuration/exclude-dependencyset/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/exclude-dependencyset/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/configuration/exclude-dependencyset/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | exclude-dependencyset 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 123.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing:leaf 36 | 37 | 38 | se.vandmo.testing 39 | 40 | ignore 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/configuration/filename-check/anothername.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/filename-check/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/filename-check/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | filename-check 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | anothername.json 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/configuration/filename-check/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | 5 | import org.apache.commons.io.FileUtils 6 | 7 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 8 | assertThat(buildLog, containsInRelativeOrder("[INFO] Actual dependencies matches locked dependencies")) 9 | -------------------------------------------------------------------------------- /src/it/configuration/filename-lock/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/configuration/filename-lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | filename-lock 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | anothername.json 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/configuration/filename-lock/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "anothername.json") 12 | 13 | assertTrue("Lock file missing", lockFile.isFile()) 14 | 15 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 16 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/configuration/filename-lock/anothername.json")))) 17 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-marked/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "ignored" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-marked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-marked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | ignore-integrity-marked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | ignore 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/dependee/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | dependee 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/dependee/src/main/java/Foo.java: -------------------------------------------------------------------------------- 1 | public class Foo {} 2 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/dependent/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.tests", 4 | "artifactId" : "dependee", 5 | "version" : "0-SNAPSHOT", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/dependent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | dependent 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | se.vandmo.tests 15 | dependee 16 | 0-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | 23 | se.vandmo 24 | dependency-lock-maven-plugin 25 | @project.version@ 26 | 27 | 28 | check 29 | validate 30 | 31 | check 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | se.vandmo.tests 40 | 41 | ignore 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = compile -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity-on-folder/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | ignore-integrity-on-folder 10 | 0-SNAPSHOT 11 | pom 12 | 13 | 14 | dependee 15 | dependent 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:ab/this/is/wrong/integrity/xeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-integrity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | ignore-integrity 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | ignore 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version-marked/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "ignored", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version-marked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version-marked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | ignore-version-marked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | ignore 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "2.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/ignore-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | ignore-version 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | ignore 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/configuration/snapshot-version/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "a-snapshot-leaf", 5 | "version" : "1.5-20221104.072032-1", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:GnW76HBRFfl8eM3CWdFYca4s4atdCXF0a5gZQT8OSU8iCreju1BQNLH8hblc6uM6SgAyXl6rk06crntJvJHTgw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/snapshot-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/snapshot-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | snapshot-version 10 | 1.0 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | a-snapshot-leaf 21 | 1.5-SNAPSHOT 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | snapshot 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/configuration/use-project-version/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "123.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/configuration/use-project-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/configuration/use-project-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | use-project-version 10 | 1.0 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | use-project-version 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/failures/everything/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | }, 11 | { 12 | "groupId" : "se.vandmo.testing", 13 | "artifactId" : "a-third-leaf", 14 | "version" : "2.0", 15 | "scope" : "test", 16 | "type" : "jar", 17 | "optional" : true, 18 | "integrity" : "sha512:this/is/incorrect/yes7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 19 | } ] 20 | } 21 | -------------------------------------------------------------------------------- /src/it/failures/everything/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/everything/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | everything 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | another-leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | a-third-leaf 26 | 1.0 27 | 28 | 29 | 30 | 31 | 32 | 33 | se.vandmo 34 | dependency-lock-maven-plugin 35 | @project.version@ 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/failures/everything/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project everything: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] Missing dependencies:", 12 | "[ERROR] se.vandmo.testing:leaf:jar", 13 | "[ERROR] Extraneous dependencies:", 14 | "[ERROR] se.vandmo.testing:another-leaf:jar:1.0:compile:optional=false", 15 | "[ERROR] The following dependencies differ:", 16 | "[ERROR] Expected se.vandmo.testing:a-third-leaf:jar:2.0:test:optional=true@sha512:this/is/incorrect/yes7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:a-third-leaf:jar:1.0:compile:optional=false@sha512:QjAlcrqmdWL88+sTA4UWoLft4SrjCkhDlYR2nk8oGkGeUvubkGQzGDrmURXmQuEzROIb5Y02dI7/a11R5k5ZmQ==, wrong optional, scope, integrity and version")) 17 | -------------------------------------------------------------------------------- /src/it/failures/extraneous/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [] 3 | } 4 | -------------------------------------------------------------------------------- /src/it/failures/extraneous/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/extraneous/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | extraneous 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/failures/extraneous/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project extraneous: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] Extraneous dependencies:", 12 | "[ERROR] se.vandmo.testing:leaf:jar:1.0:compile:optional=false")) 13 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/dependee/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | dependee 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/dependent/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.tests", 4 | "artifactId" : "dependee", 5 | "version" : "0-SNAPSHOT", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/dependent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | dependent 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | se.vandmo.tests 15 | dependee 16 | 0-SNAPSHOT 17 | 18 | 19 | 20 | 21 | 22 | 23 | se.vandmo 24 | dependency-lock-maven-plugin 25 | @project.version@ 26 | 27 | 28 | check 29 | validate 30 | 31 | check 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/dependent/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (check) on project dependent: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.tests:dependee:jar:0-SNAPSHOT:compile:optional=false@sha512:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== but found se.vandmo.tests:dependee:jar:0-SNAPSHOT:compile:optional=false@, wrong integrity")) 13 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = compile 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/integrity-on-folder/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | integrity-on-folder 10 | 0-SNAPSHOT 11 | pom 12 | 13 | 14 | dependee 15 | dependent 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/it/failures/missing/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "test", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/missing/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/missing/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | missing 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | se.vandmo 23 | dependency-lock-maven-plugin 24 | @project.version@ 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/it/failures/missing/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project missing: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] Missing dependencies:", 12 | "[ERROR] se.vandmo.testing:leaf:jar")) 13 | -------------------------------------------------------------------------------- /src/it/failures/not-project-version/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "2.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/not-project-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/not-project-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | not-project-version 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | se.vandmo.testing 36 | 37 | use-project-version 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/it/failures/not-project-version/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project not-project-version: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.testing:leaf:jar:0-SNAPSHOT:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==, wrong version (expected project version)")) 13 | -------------------------------------------------------------------------------- /src/it/failures/wrong-integrity/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:this/is/not/the/correct/integrity/h19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/wrong-integrity/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/wrong-integrity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | wrong-integrity 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/failures/wrong-integrity/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project wrong-integrity: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:this/is/not/the/correct/integrity/h19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==, wrong integrity")) 13 | -------------------------------------------------------------------------------- /src/it/failures/wrong-optional/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : true, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/wrong-optional/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/wrong-optional/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | wrong-optional 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/failures/wrong-optional/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project wrong-optional: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.testing:leaf:jar:1.0:compile:optional=true@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==, wrong optional")) 13 | -------------------------------------------------------------------------------- /src/it/failures/wrong-scope/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "test", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/wrong-scope/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/wrong-scope/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | wrong-scope 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/failures/wrong-scope/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project wrong-scope: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.testing:leaf:jar:1.0:test:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==, wrong scope")) 13 | -------------------------------------------------------------------------------- /src/it/failures/wrong-version/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "2.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | } ] 11 | } 12 | -------------------------------------------------------------------------------- /src/it/failures/wrong-version/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure 3 | -------------------------------------------------------------------------------- /src/it/failures/wrong-version/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | wrong-version 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/failures/wrong-version/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project wrong-version: Dependencies differ -> [Help 1]")) 10 | assertThat(buildLog, containsInRelativeOrder( 11 | "[ERROR] The following dependencies differ:", 12 | "[ERROR] Expected se.vandmo.testing:leaf:jar:2.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== but found se.vandmo.testing:leaf:jar:1.0:compile:optional=false@sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==, wrong version")) 13 | -------------------------------------------------------------------------------- /src/it/json/check-build-with-extension/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/json/check-build-with-extension/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-check-build-with-extension 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.extensions 53 | maven-enforcer-extension 54 | 3.5.0 55 | 56 | 57 | 58 | 59 | se.vandmo 60 | dependency-lock-maven-plugin 61 | @project.version@ 62 | 63 | true 64 | 65 | 66 | 67 | se.vandmo:dependency-lock-maven-plugin 68 | 69 | ignore 70 | ignore 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/it/json/check-build-with-extension/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | 5 | import org.apache.commons.io.FileUtils 6 | 7 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 8 | assertThat(buildLog, containsInRelativeOrder("[INFO] Actual dependencies, plugins and extensions matches locked dependencies, plugins and extensions")) 9 | -------------------------------------------------------------------------------- /src/it/json/check-build/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/json/check-build/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-check-build 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | true 57 | 58 | 59 | 60 | se.vandmo:dependency-lock-maven-plugin 61 | 62 | ignore 63 | ignore 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/it/json/check-build/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | 5 | import org.apache.commons.io.FileUtils 6 | 7 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 8 | assertThat(buildLog, containsInRelativeOrder("[INFO] Actual dependencies, plugins and extensions matches locked dependencies, plugins and extensions")) 9 | -------------------------------------------------------------------------------- /src/it/json/check-future-format/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "3" 3 | } 4 | -------------------------------------------------------------------------------- /src/it/json/check-future-format/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/json/check-future-format/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-check-future-format 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | 20 | se.vandmo 21 | dependency-lock-maven-plugin 22 | @project.version@ 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/it/json/check-future-format/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | 10 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project json-check-future-format: Unexpected lock file version \"3\". The file might have been generated by a newer version of this plugin than is used for this check. -> [Help 1]")) 11 | -------------------------------------------------------------------------------- /src/it/json/check/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "a-classified-leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:KDKGxTrNHDhrGZEGDSX2KVkn/2S0u1EBJ1B0jMfeZXZm4yeiNIvUnFdFb9W4X1w5HF7ce9ZqeQCnmHdGfTyk2w==", 10 | "classifier" : "classy" 11 | }, { 12 | "groupId" : "se.vandmo.testing", 13 | "artifactId" : "a-third-leaf", 14 | "version" : "1.0", 15 | "scope" : "test", 16 | "type" : "jar", 17 | "optional" : false, 18 | "integrity" : "sha512:QjAlcrqmdWL88+sTA4UWoLft4SrjCkhDlYR2nk8oGkGeUvubkGQzGDrmURXmQuEzROIb5Y02dI7/a11R5k5ZmQ==" 19 | }, { 20 | "groupId" : "se.vandmo.testing", 21 | "artifactId" : "a-war", 22 | "version" : "1.0", 23 | "scope" : "compile", 24 | "type" : "war", 25 | "optional" : false, 26 | "integrity" : "sha512:1Lojgkq/rfOAUIaUXKkI4n6P0nkuJGlDj2NVGUaX2fLrBJurCr135hiQNTRRiL+wMnLvPWbKZvPHB2rBI/hTKw==" 27 | }, { 28 | "groupId" : "se.vandmo.testing", 29 | "artifactId" : "another-leaf", 30 | "version" : "1.0", 31 | "scope" : "compile", 32 | "type" : "jar", 33 | "optional" : true, 34 | "integrity" : "sha512:0TTX1ABvSaYpbW9zHxntUejpMUeFxxod6u0Umg3Ib86RyemGEAbxWKeRtWYCX19BALAHiVr/ArGfy6osTumUOQ==" 35 | }, { 36 | "groupId" : "se.vandmo.testing", 37 | "artifactId" : "leaf", 38 | "version" : "1.0", 39 | "scope" : "compile", 40 | "type" : "jar", 41 | "optional" : false, 42 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 43 | } ] 44 | } 45 | -------------------------------------------------------------------------------- /src/it/json/check/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/json/check/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-check 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/json/check/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | 5 | import org.apache.commons.io.FileUtils 6 | 7 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 8 | assertThat(buildLog, containsInRelativeOrder("[INFO] Actual dependencies matches locked dependencies")) 9 | -------------------------------------------------------------------------------- /src/it/json/lock-build-with-extension/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/json/lock-build-with-extension/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "dependencies-lock.json") 12 | expectedLockFile = new File(basedir, "expected-dependencies-lock.json") 13 | 14 | assertTrue("Lock file missing", lockFile.isFile()) 15 | assertTrue("Lock file content not as expected", FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/json/lock-build-with-extension/dependencies-lock.json")))) 19 | -------------------------------------------------------------------------------- /src/it/json/lock-build/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/json/lock-build/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-lock-build 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | true 57 | true 58 | 59 | 60 | 61 | se.vandmo:dependency-lock-maven-plugin 62 | 63 | ignore 64 | ignore 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/it/json/lock-build/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "dependencies-lock.json") 12 | expectedLockFile = new File(basedir, "expected-dependencies-lock.json") 13 | 14 | assertTrue("Lock file missing", lockFile.isFile()) 15 | assertTrue("Lock file content not as expected", FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/json/lock-build/dependencies-lock.json")))) 19 | -------------------------------------------------------------------------------- /src/it/json/lock-marked/expected-dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "a-classified-leaf", 5 | "version" : "ignored", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "ignored", 10 | "classifier" : "classy" 11 | }, { 12 | "groupId" : "se.vandmo.testing", 13 | "artifactId" : "a-third-leaf", 14 | "version" : "ignored", 15 | "scope" : "test", 16 | "type" : "jar", 17 | "optional" : false, 18 | "integrity" : "ignored" 19 | }, { 20 | "groupId" : "se.vandmo.testing", 21 | "artifactId" : "a-war", 22 | "version" : "ignored", 23 | "scope" : "compile", 24 | "type" : "war", 25 | "optional" : false, 26 | "integrity" : "ignored" 27 | }, { 28 | "groupId" : "se.vandmo.testing", 29 | "artifactId" : "another-leaf", 30 | "version" : "ignored", 31 | "scope" : "compile", 32 | "type" : "jar", 33 | "optional" : true, 34 | "integrity" : "ignored" 35 | }, { 36 | "groupId" : "se.vandmo.testing", 37 | "artifactId" : "leaf", 38 | "version" : "ignored", 39 | "scope" : "compile", 40 | "type" : "jar", 41 | "optional" : false, 42 | "integrity" : "ignored" 43 | } ] 44 | } 45 | -------------------------------------------------------------------------------- /src/it/json/lock-marked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/json/lock-marked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-lock-marked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | true 57 | 58 | 59 | 60 | se.vandmo.testing 61 | 62 | ignore 63 | ignore 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/it/json/lock-marked/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "dependencies-lock.json") 12 | expectedLockFile = new File(basedir, "expected-dependencies-lock.json") 13 | 14 | assertTrue("Lock file missing", lockFile.isFile()) 15 | assertTrue("Lock file content not as expected", FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/json/lock-marked/dependencies-lock.json")))) 19 | -------------------------------------------------------------------------------- /src/it/json/lock/expected-dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "a-classified-leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:KDKGxTrNHDhrGZEGDSX2KVkn/2S0u1EBJ1B0jMfeZXZm4yeiNIvUnFdFb9W4X1w5HF7ce9ZqeQCnmHdGfTyk2w==", 10 | "classifier" : "classy" 11 | }, { 12 | "groupId" : "se.vandmo.testing", 13 | "artifactId" : "a-third-leaf", 14 | "version" : "1.0", 15 | "scope" : "test", 16 | "type" : "jar", 17 | "optional" : false, 18 | "integrity" : "sha512:QjAlcrqmdWL88+sTA4UWoLft4SrjCkhDlYR2nk8oGkGeUvubkGQzGDrmURXmQuEzROIb5Y02dI7/a11R5k5ZmQ==" 19 | }, { 20 | "groupId" : "se.vandmo.testing", 21 | "artifactId" : "a-war", 22 | "version" : "1.0", 23 | "scope" : "compile", 24 | "type" : "war", 25 | "optional" : false, 26 | "integrity" : "sha512:1Lojgkq/rfOAUIaUXKkI4n6P0nkuJGlDj2NVGUaX2fLrBJurCr135hiQNTRRiL+wMnLvPWbKZvPHB2rBI/hTKw==" 27 | }, { 28 | "groupId" : "se.vandmo.testing", 29 | "artifactId" : "another-leaf", 30 | "version" : "1.0", 31 | "scope" : "compile", 32 | "type" : "jar", 33 | "optional" : true, 34 | "integrity" : "sha512:0TTX1ABvSaYpbW9zHxntUejpMUeFxxod6u0Umg3Ib86RyemGEAbxWKeRtWYCX19BALAHiVr/ArGfy6osTumUOQ==" 35 | }, { 36 | "groupId" : "se.vandmo.testing", 37 | "artifactId" : "leaf", 38 | "version" : "1.0", 39 | "scope" : "compile", 40 | "type" : "jar", 41 | "optional" : false, 42 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 43 | } ] 44 | } 45 | -------------------------------------------------------------------------------- /src/it/json/lock/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/json/lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | json-lock 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/json/lock/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "dependencies-lock.json") 12 | expectedLockFile = new File(basedir, "expected-dependencies-lock.json") 13 | 14 | assertTrue("Lock file missing", lockFile.isFile()) 15 | assertTrue("Lock file content not as expected", FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/json/lock/dependencies-lock.json")))) 19 | -------------------------------------------------------------------------------- /src/it/pom/check-build-with-extension/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/pom/check-build-with-extension/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-check-build-with-extension 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.extensions 53 | maven-enforcer-extension 54 | 3.5.0 55 | 56 | 57 | 58 | 59 | se.vandmo 60 | dependency-lock-maven-plugin 61 | @project.version@ 62 | 63 | pom 64 | true 65 | 66 | 67 | 68 | se.vandmo:dependency-lock-maven-plugin 69 | 70 | ignore 71 | ignore 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/it/pom/check-build/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/pom/check-build/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-check-build 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | pom 57 | true 58 | 59 | 60 | 61 | se.vandmo:dependency-lock-maven-plugin 62 | 63 | ignore 64 | ignore 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/it/pom/check/.dependency-lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 4.0.0 8 | 9 | se.vandmo.tests 10 | pom-lock-dependency-lock 11 | 0-SNAPSHOT 12 | 13 | 14 | 15 | se.vandmo.testing 16 | a-classified-leaf 17 | 1.0 18 | jar 19 | compile 20 | classy 21 | false 22 | sha512:KDKGxTrNHDhrGZEGDSX2KVkn/2S0u1EBJ1B0jMfeZXZm4yeiNIvUnFdFb9W4X1w5HF7ce9ZqeQCnmHdGfTyk2w== 23 | 24 | 25 | se.vandmo.testing 26 | a-third-leaf 27 | 1.0 28 | jar 29 | test 30 | false 31 | sha512:QjAlcrqmdWL88+sTA4UWoLft4SrjCkhDlYR2nk8oGkGeUvubkGQzGDrmURXmQuEzROIb5Y02dI7/a11R5k5ZmQ== 32 | 33 | 34 | se.vandmo.testing 35 | a-war 36 | 1.0 37 | war 38 | compile 39 | false 40 | sha512:1Lojgkq/rfOAUIaUXKkI4n6P0nkuJGlDj2NVGUaX2fLrBJurCr135hiQNTRRiL+wMnLvPWbKZvPHB2rBI/hTKw== 41 | 42 | 43 | se.vandmo.testing 44 | another-leaf 45 | 1.0 46 | jar 47 | compile 48 | true 49 | sha512:0TTX1ABvSaYpbW9zHxntUejpMUeFxxod6u0Umg3Ib86RyemGEAbxWKeRtWYCX19BALAHiVr/ArGfy6osTumUOQ== 50 | 51 | 52 | se.vandmo.testing 53 | leaf 54 | 1.0 55 | jar 56 | compile 57 | false 58 | sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw== 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/it/pom/check/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/pom/check/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-check 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | pom 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/it/pom/future-format/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | invoker.buildResult = failure -------------------------------------------------------------------------------- /src/it/pom/future-format/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-future-format 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.extensions 53 | maven-enforcer-extension 54 | 3.5.0 55 | 56 | 57 | 58 | 59 | se.vandmo 60 | dependency-lock-maven-plugin 61 | @project.version@ 62 | 63 | pom 64 | true 65 | 66 | 67 | 68 | se.vandmo:dependency-lock-maven-plugin 69 | 70 | ignore 71 | ignore 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/it/pom/future-format/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | 6 | import org.apache.commons.io.FileUtils 7 | 8 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 9 | 10 | assertThat(buildLog, hasItem("[ERROR] Failed to execute goal se.vandmo:dependency-lock-maven-plugin:0-SNAPSHOT:check (default-cli) on project pom-future-format: Unexpected lock file version \"3\". The file might have been generated by a newer version of this plugin than is used for this check. -> [Help 1]")) 11 | -------------------------------------------------------------------------------- /src/it/pom/lock-build-with-extension/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/pom/lock-build-with-extension/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, ".dependency-lock/pom.xml") 12 | expectedLockFile = new File(basedir, "expected-pom.xml") 13 | 14 | assertTrue(lockFile.isFile()) 15 | assertTrue(FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/pom/lock-build-with-extension/.dependency-lock/pom.xml")))) 19 | -------------------------------------------------------------------------------- /src/it/pom/lock-build/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/pom/lock-build/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-lock-build 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | pom 57 | true 58 | true 59 | 60 | 61 | 62 | se.vandmo:dependency-lock-maven-plugin 63 | 64 | ignore 65 | ignore 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/it/pom/lock-build/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, ".dependency-lock/pom.xml") 12 | expectedLockFile = new File(basedir, "expected-pom.xml") 13 | 14 | assertTrue(lockFile.isFile()) 15 | assertTrue(FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/pom/lock-build/.dependency-lock/pom.xml")))) 19 | -------------------------------------------------------------------------------- /src/it/pom/lock-marked/expected-pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 4.0.0 10 | 11 | se.vandmo.tests 12 | pom-lock-marked-dependency-lock 13 | 0-SNAPSHOT 14 | 15 | 16 | 17 | se.vandmo.testing 18 | a-classified-leaf 19 | ignored 20 | jar 21 | compile 22 | classy 23 | false 24 | ignored 25 | 26 | 27 | se.vandmo.testing 28 | a-third-leaf 29 | ignored 30 | jar 31 | test 32 | false 33 | ignored 34 | 35 | 36 | se.vandmo.testing 37 | a-war 38 | ignored 39 | war 40 | compile 41 | false 42 | ignored 43 | 44 | 45 | se.vandmo.testing 46 | another-leaf 47 | ignored 48 | jar 49 | compile 50 | true 51 | ignored 52 | 53 | 54 | se.vandmo.testing 55 | leaf 56 | ignored 57 | jar 58 | compile 59 | false 60 | ignored 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/it/pom/lock-marked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/pom/lock-marked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-lock-marked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | pom 57 | true 58 | 59 | 60 | 61 | se.vandmo.testing 62 | 63 | ignore 64 | ignore 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/it/pom/lock-marked/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, ".dependency-lock/pom.xml") 12 | expectedLockFile = new File(basedir, "expected-pom.xml") 13 | 14 | assertTrue(lockFile.isFile()) 15 | assertTrue(FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/pom/lock-marked/.dependency-lock/pom.xml")))) 19 | -------------------------------------------------------------------------------- /src/it/pom/lock/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/pom/lock/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | pom-lock 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | leaf 21 | 1.0 22 | 23 | 24 | se.vandmo.testing 25 | another-leaf 26 | 1.0 27 | true 28 | 29 | 30 | se.vandmo.testing 31 | a-third-leaf 32 | 1.0 33 | test 34 | 35 | 36 | se.vandmo.testing 37 | a-classified-leaf 38 | 1.0 39 | classy 40 | 41 | 42 | se.vandmo.testing 43 | a-war 44 | 1.0 45 | war 46 | 47 | 48 | 49 | 50 | 51 | 52 | se.vandmo 53 | dependency-lock-maven-plugin 54 | @project.version@ 55 | 56 | pom 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/it/pom/lock/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, ".dependency-lock/pom.xml") 12 | expectedLockFile = new File(basedir, "expected-pom.xml") 13 | 14 | assertTrue(lockFile.isFile()) 15 | assertTrue(FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/pom/lock/.dependency-lock/pom.xml")))) 19 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-classified-leaf-1.0-classy.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/a-classified-leaf-1.0-classy.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-classified-leaf-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | a-classified-leaf 10 | 1.0 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-snapshot-leaf-1.5-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/a-snapshot-leaf-1.5-SNAPSHOT.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-snapshot-leaf-1.5-SNAPSHOT.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | a-snapshot-leaf 10 | 1.5-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-third-leaf-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/a-third-leaf-1.0.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-third-leaf-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | a-third-leaf 10 | 1.0 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-war-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | a-war 10 | 1.0 11 | war 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/a-war-1.0.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/a-war-1.0.war -------------------------------------------------------------------------------- /src/it/setup/dependencies/another-leaf-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/another-leaf-1.0.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/another-leaf-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | another-leaf 10 | 1.0 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/leaf-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/leaf-1.0.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/leaf-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | leaf 10 | 1.0 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/it/setup/dependencies/with-dependency-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vandmo/dependency-lock-maven-plugin/ba12c79a1e75a47adb063134e5ea73b2e9d5e108/src/it/setup/dependencies/with-dependency-1.0.jar -------------------------------------------------------------------------------- /src/it/setup/dependencies/with-dependency-1.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.testing 9 | with-dependency 10 | 1.0 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | se.vandmo.testing 19 | leaf 20 | 1.0 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/it/transitivity/checked/dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | }, { 11 | "groupId" : "se.vandmo.testing", 12 | "artifactId" : "with-dependency", 13 | "version" : "1.0", 14 | "scope" : "compile", 15 | "type" : "jar", 16 | "optional" : false, 17 | "integrity" : "sha512:yHcOLqnVzIG7EtziqwuzBqt5iP7zqqYRaux8mqTrmVuUEc1womgj6ID+C6yHzjPJaHyBFNPaO42QvL98iIVOIQ==" 18 | } ] 19 | } 20 | -------------------------------------------------------------------------------- /src/it/transitivity/checked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:check 2 | -------------------------------------------------------------------------------- /src/it/transitivity/checked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | transitive-dependencies-checked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | with-dependency 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/transitivity/checked/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.Matchers.containsInRelativeOrder 4 | 5 | import org.apache.commons.io.FileUtils 6 | 7 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 8 | assertThat(buildLog, containsInRelativeOrder("[INFO] Actual dependencies matches locked dependencies")) 9 | -------------------------------------------------------------------------------- /src/it/transitivity/locked/expected-dependencies-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ { 3 | "groupId" : "se.vandmo.testing", 4 | "artifactId" : "leaf", 5 | "version" : "1.0", 6 | "scope" : "compile", 7 | "type" : "jar", 8 | "optional" : false, 9 | "integrity" : "sha512:98gbCti9u7jp73/lFrslV7BeOCkxeXUiRQT19E58niRlyEKu69BXPXHB/xM8HQu1os08se3xTkbhWXG5xnGMFw==" 10 | }, { 11 | "groupId" : "se.vandmo.testing", 12 | "artifactId" : "with-dependency", 13 | "version" : "1.0", 14 | "scope" : "compile", 15 | "type" : "jar", 16 | "optional" : false, 17 | "integrity" : "sha512:yHcOLqnVzIG7EtziqwuzBqt5iP7zqqYRaux8mqTrmVuUEc1womgj6ID+C6yHzjPJaHyBFNPaO42QvL98iIVOIQ==" 18 | } ] 19 | } 20 | -------------------------------------------------------------------------------- /src/it/transitivity/locked/invoker.properties: -------------------------------------------------------------------------------- 1 | invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:lock 2 | -------------------------------------------------------------------------------- /src/it/transitivity/locked/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | se.vandmo.tests 9 | transitive-dependencies-locked 10 | 0-SNAPSHOT 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | se.vandmo.testing 20 | with-dependency 21 | 1.0 22 | 23 | 24 | 25 | 26 | 27 | 28 | se.vandmo 29 | dependency-lock-maven-plugin 30 | @project.version@ 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/it/transitivity/locked/postbuild.groovy: -------------------------------------------------------------------------------- 1 | import static java.nio.charset.StandardCharsets.UTF_8 2 | import static org.hamcrest.MatcherAssert.assertThat 3 | import static org.hamcrest.core.CombinableMatcher.both 4 | import static org.hamcrest.core.IsIterableContaining.hasItem 5 | import static org.hamcrest.core.StringEndsWith.endsWith 6 | import static org.hamcrest.core.StringStartsWith.startsWith 7 | import static org.junit.Assert.assertTrue 8 | 9 | import org.apache.commons.io.FileUtils 10 | 11 | lockFile = new File(basedir, "dependencies-lock.json") 12 | expectedLockFile = new File(basedir, "expected-dependencies-lock.json") 13 | 14 | assertTrue("Lock file missing", lockFile.isFile()) 15 | assertTrue("Lock file content not as expected", FileUtils.contentEquals(expectedLockFile, lockFile)) 16 | 17 | buildLog = FileUtils.readLines(new File(basedir, "build.log"), UTF_8) 18 | assertThat(buildLog, hasItem(both(startsWith("[INFO] Creating ")).and(endsWith("/dependency-lock-maven-plugin/target/its/transitivity/locked/dependencies-lock.json")))) 19 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Artifacts.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.stream.Collectors.toList; 4 | 5 | import java.util.Collection; 6 | 7 | public final class Artifacts extends LockableEntities { 8 | 9 | private Artifacts(Collection artifacts) { 10 | super(artifacts); 11 | } 12 | 13 | public static Artifacts fromMavenArtifacts( 14 | Collection artifacts) { 15 | return new Artifacts(artifacts.stream().map(a -> Artifact.from(a)).collect(toList())); 16 | } 17 | 18 | public static Artifacts fromArtifacts(Collection artifacts) { 19 | return new Artifacts(artifacts); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Build.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.stream.Stream; 6 | 7 | public final class Build { 8 | public final Plugins plugins; 9 | public final Extensions extensions; 10 | 11 | private Build(Plugins plugins, Extensions extensions) { 12 | this.plugins = requireNonNull(plugins); 13 | this.extensions = requireNonNull(extensions); 14 | } 15 | 16 | public static Build empty() { 17 | return from(Plugins.empty(), Extensions.empty()); 18 | } 19 | 20 | public static Build from(Plugins plugins, Extensions extensions) { 21 | return new Build(plugins, extensions); 22 | } 23 | 24 | public Stream artifacts() { 25 | return Stream.concat(extensions.artifacts(), plugins.artifacts()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Checksum.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.UncheckedIOException; 7 | import java.security.MessageDigest; 8 | import java.security.NoSuchAlgorithmException; 9 | import java.util.Base64; 10 | 11 | public final class Checksum { 12 | 13 | /** 14 | * The current algorithm that is being used. If this doesn't match an error will be thrown and 15 | * dependency files need to be regenerated. 16 | */ 17 | public static final String ALGORITHM_HEADER = "sha512:"; 18 | 19 | private static final ThreadLocal digest = 20 | new ThreadLocal() { 21 | @Override 22 | protected MessageDigest initialValue() { 23 | try { 24 | return MessageDigest.getInstance("SHA-512"); 25 | } catch (NoSuchAlgorithmException e) { 26 | throw new RuntimeException(e); 27 | } 28 | } 29 | }; 30 | private static final int BUFFER_SIZE = 8192; 31 | 32 | static { 33 | } 34 | 35 | public static String calculateFor(File file) { 36 | try { 37 | byte[] hashed; 38 | byte[] buffer = new byte[BUFFER_SIZE]; 39 | try (FileInputStream fis = new FileInputStream(file)) { 40 | MessageDigest messageDigest = digest.get(); 41 | int bytesRead = fis.read(buffer); 42 | while (bytesRead >= 0) { 43 | messageDigest.update(buffer, 0, bytesRead); 44 | bytesRead = fis.read(buffer); 45 | } 46 | hashed = messageDigest.digest(); 47 | } 48 | return encodeHashed(hashed); 49 | } catch (IOException e) { 50 | throw new UncheckedIOException(e); 51 | } 52 | } 53 | 54 | private static String encodeHashed(byte[] hashed) { 55 | return ALGORITHM_HEADER + Base64.getEncoder().encodeToString(hashed); 56 | } 57 | 58 | static String calculateFor(byte[] bytes) { 59 | byte[] hashed = digest.get().digest(bytes); 60 | return encodeHashed(hashed); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Dependencies.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.stream.Collectors.toList; 4 | 5 | import java.util.Collection; 6 | 7 | public final class Dependencies extends LockableEntitiesWithArtifact { 8 | 9 | private Dependencies(Collection dependencies) { 10 | super(dependencies); 11 | } 12 | 13 | public static Dependencies fromMavenArtifacts( 14 | Collection artifacts) { 15 | return new Dependencies(artifacts.stream().map(a -> Dependency.from(a)).collect(toList())); 16 | } 17 | 18 | public static Dependencies fromDependencies(Collection dependencies) { 19 | return new Dependencies(dependencies); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/DependenciesLockFile.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | public interface DependenciesLockFile { 4 | 5 | void write(Dependencies projectDependencies); 6 | 7 | LockedDependencies read(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/DependencySetConfiguration.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import org.apache.maven.artifact.Artifact; 4 | import org.apache.maven.artifact.resolver.filter.ArtifactFilter; 5 | 6 | public final class DependencySetConfiguration { 7 | private final ArtifactFilter includes; 8 | private final ArtifactFilter excludes; 9 | public final Version version; 10 | public final Integrity integrity; 11 | public final Boolean allowMissing; 12 | public final Boolean allowSuperfluous; 13 | 14 | public DependencySetConfiguration( 15 | ArtifactFilter includes, 16 | ArtifactFilter excludes, 17 | Version version, 18 | Integrity integrity, 19 | Boolean allowMissing, 20 | Boolean allowSuperfluous) { 21 | this.includes = includes; 22 | this.excludes = excludes; 23 | this.version = version; 24 | this.integrity = integrity; 25 | this.allowMissing = allowMissing; 26 | this.allowSuperfluous = allowSuperfluous; 27 | } 28 | 29 | public boolean matches(LockableEntity entity) { 30 | Artifact mavenArtifact = entity.getMavenArtifact(); 31 | return includes.include(mavenArtifact) && !excludes.include(mavenArtifact); 32 | } 33 | 34 | public enum Version { 35 | check, 36 | useProjectVersion, 37 | snapshot, 38 | ignore 39 | } 40 | 41 | public enum Integrity { 42 | check, 43 | ignore 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/DiffReport.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.util.List; 4 | import java.util.stream.Stream; 5 | 6 | public final class DiffReport { 7 | private final List missing; 8 | private final List different; 9 | private final List extraneous; 10 | 11 | DiffReport(List different, List missing, List extraneous) { 12 | super(); 13 | this.different = different; 14 | this.missing = missing; 15 | this.extraneous = extraneous; 16 | } 17 | 18 | public boolean equals() { 19 | return missing.isEmpty() && different.isEmpty() && extraneous.isEmpty(); 20 | } 21 | 22 | public Stream report(String category) { 23 | Stream result = Stream.empty(); 24 | if (!missing.isEmpty()) { 25 | result = 26 | Stream.concat( 27 | result, 28 | Stream.concat( 29 | Stream.of("Missing " + category + ":"), 30 | missing.stream().map(line -> " " + line))); 31 | } 32 | if (!extraneous.isEmpty()) { 33 | result = 34 | Stream.concat( 35 | result, 36 | Stream.concat( 37 | Stream.of("Extraneous " + category + ":"), 38 | extraneous.stream().map(line -> " " + line))); 39 | } 40 | if (!different.isEmpty()) { 41 | result = 42 | Stream.concat( 43 | result, 44 | Stream.concat( 45 | Stream.of("The following " + category + " differ:"), 46 | different.stream().map(line -> " " + line))); 47 | } 48 | return result; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Extension.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import org.apache.maven.plugin.ExtensionRealmCache; 6 | 7 | public final class Extension extends LockableEntityWithArtifact { 8 | public static ArtifactIdentifierBuilderStage builder() { 9 | return new ArtifactIdentifierBuilderStage(); 10 | } 11 | 12 | public static Extension of(Artifact dependency) { 13 | return new Extension(dependency); 14 | } 15 | 16 | public static Extension fromMavenExtensionRealm(ExtensionRealmCache.CacheRecord extensionRealm) { 17 | return new Extension(Artifact.from(extensionRealm.getArtifacts().get(0))); 18 | } 19 | 20 | public Extension withIntegrity(Integrity integrity) { 21 | return new Extension(artifact.withIntegrity(integrity)); 22 | } 23 | 24 | public static final class ArtifactIdentifierBuilderStage { 25 | private ArtifactIdentifierBuilderStage() {} 26 | 27 | public VersionBuilderStage artifactIdentifier(ArtifactIdentifier artifactIdentifier) { 28 | return new VersionBuilderStage(Artifact.builder().artifactIdentifier(artifactIdentifier)); 29 | } 30 | } 31 | 32 | public static final class VersionBuilderStage { 33 | private final Artifact.VersionBuilderStage artifactBuilder; 34 | 35 | private VersionBuilderStage(Artifact.VersionBuilderStage artifactBuilder) { 36 | this.artifactBuilder = requireNonNull(artifactBuilder); 37 | } 38 | 39 | public IntegrityBuilderStage version(String version) { 40 | return new IntegrityBuilderStage(artifactBuilder.version(version)); 41 | } 42 | } 43 | 44 | public static final class IntegrityBuilderStage { 45 | private final Artifact.IntegrityBuilderStage artifactBuilder; 46 | 47 | private IntegrityBuilderStage(Artifact.IntegrityBuilderStage artifactBuilder) { 48 | this.artifactBuilder = artifactBuilder; 49 | } 50 | 51 | public FinalBuilderStage integrity(String integrity) { 52 | return new FinalBuilderStage(artifactBuilder.integrity(integrity).build()); 53 | } 54 | } 55 | 56 | public static final class FinalBuilderStage { 57 | private final Artifact artifact; 58 | 59 | private FinalBuilderStage(Artifact artifact) { 60 | this.artifact = artifact; 61 | } 62 | 63 | public Extension build() { 64 | return new Extension(artifact); 65 | } 66 | } 67 | 68 | private Extension(Artifact artifact) { 69 | super(artifact); 70 | } 71 | 72 | public Extension withVersion(String version) { 73 | return new Extension(artifact.withVersion(version)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Extensions.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Collections.emptyList; 4 | 5 | import java.util.Collection; 6 | import java.util.stream.Collectors; 7 | import org.apache.maven.plugin.ExtensionRealmCache; 8 | 9 | public final class Extensions extends LockableEntitiesWithArtifact { 10 | 11 | private Extensions(Collection extensions) { 12 | super(extensions); 13 | } 14 | 15 | public static Extensions from(Collection extensions) { 16 | return new Extensions(extensions); 17 | } 18 | 19 | public static Extensions fromMavenExtensionRealms( 20 | Collection extensionRealms) { 21 | return new Extensions( 22 | extensionRealms.stream() 23 | .map(cacheRecord -> Extension.fromMavenExtensionRealm(cacheRecord)) 24 | .collect(Collectors.toList())); 25 | } 26 | 27 | public static Extensions empty() { 28 | return from(emptyList()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Filters.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Collections.unmodifiableList; 4 | import static java.util.Objects.requireNonNull; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | import java.util.List; 9 | import java.util.function.Function; 10 | 11 | public final class Filters { 12 | 13 | private final List dependencySetConfigurations; 14 | private final String projectVersion; 15 | 16 | public Filters(List dependencySets, String projectVersion) { 17 | List dependencySetConfigurations = new ArrayList<>(dependencySets); 18 | Collections.reverse(dependencySetConfigurations); 19 | this.dependencySetConfigurations = unmodifiableList(dependencySetConfigurations); 20 | this.projectVersion = requireNonNull(projectVersion); 21 | } 22 | 23 | private T configurationFor( 24 | LockableEntity entity, Function extractor, T defaultValue) { 25 | return dependencySetConfigurations.stream() 26 | .filter(d -> d.matches(entity)) 27 | .map(extractor) 28 | .filter(v -> v != null) 29 | .findFirst() 30 | .orElse(defaultValue); 31 | } 32 | 33 | public VersionConfiguration versionConfiguration(LockableEntity entity) { 34 | DependencySetConfiguration.Version type = 35 | configurationFor(entity, d -> d.version, DependencySetConfiguration.Version.check); 36 | return new VersionConfiguration(type, projectVersion); 37 | } 38 | 39 | public DependencySetConfiguration.Integrity integrityConfiguration(LockableEntity entity) { 40 | return configurationFor(entity, d -> d.integrity, DependencySetConfiguration.Integrity.check); 41 | } 42 | 43 | public boolean allowSuperfluous(LockableEntity entity) { 44 | return configurationFor(entity, d -> d.allowSuperfluous, Boolean.FALSE); 45 | } 46 | 47 | public boolean allowMissing(LockableEntity entity) { 48 | return configurationFor(entity, d -> d.allowMissing, Boolean.FALSE); 49 | } 50 | 51 | public static final class VersionConfiguration { 52 | public final DependencySetConfiguration.Version type; 53 | public final String projectVersion; 54 | 55 | private VersionConfiguration(DependencySetConfiguration.Version type, String projectVersion) { 56 | this.type = type; 57 | this.projectVersion = projectVersion; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockFileAccessor.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.nio.charset.StandardCharsets.UTF_8; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStreamReader; 11 | import java.io.OutputStreamWriter; 12 | import java.io.Reader; 13 | import java.io.UncheckedIOException; 14 | import java.io.Writer; 15 | 16 | public final class LockFileAccessor { 17 | 18 | public final File file; 19 | 20 | private LockFileAccessor(File file) { 21 | this.file = file; 22 | } 23 | 24 | public static LockFileAccessor fromBasedir(File basedir, String filename) { 25 | return new LockFileAccessor(new File(basedir, filename)); 26 | } 27 | 28 | public Reader reader() { 29 | try { 30 | return new InputStreamReader(new FileInputStream(file), UTF_8); 31 | } catch (FileNotFoundException e) { 32 | throw new UncheckedIOException(e); 33 | } 34 | } 35 | 36 | public Writer writer() { 37 | file.getParentFile().mkdirs(); 38 | try { 39 | return new OutputStreamWriter(new FileOutputStream(file), UTF_8); 40 | } catch (IOException e) { 41 | throw new UncheckedIOException(e); 42 | } 43 | } 44 | 45 | public boolean exists() { 46 | return file.exists(); 47 | } 48 | 49 | public String filename() { 50 | return file.getAbsolutePath(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockFileFormat.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.io.File; 4 | import org.apache.maven.plugin.logging.Log; 5 | import se.vandmo.dependencylock.maven.json.DependenciesLockFileJson; 6 | import se.vandmo.dependencylock.maven.json.LockfileJson; 7 | import se.vandmo.dependencylock.maven.pom.DependenciesLockFilePom; 8 | import se.vandmo.dependencylock.maven.pom.LockFilePom; 9 | 10 | public enum LockFileFormat { 11 | json { 12 | @Override 13 | public String defaultFilename() { 14 | return "dependencies-lock.json"; 15 | } 16 | 17 | @Override 18 | public DependenciesLockFile dependenciesLockFile_from( 19 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log) { 20 | return DependenciesLockFileJson.from(lockFileAccessor, log); 21 | } 22 | 23 | @Override 24 | public Lockfile lockFile_from( 25 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log) { 26 | return LockfileJson.from(lockFileAccessor, log); 27 | } 28 | }, 29 | 30 | pom { 31 | @Override 32 | public String defaultFilename() { 33 | return ".dependency-lock/pom.xml"; 34 | } 35 | 36 | @Override 37 | public DependenciesLockFile dependenciesLockFile_from( 38 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log) { 39 | return DependenciesLockFilePom.from(lockFileAccessor, pomMinimums, log); 40 | } 41 | 42 | @Override 43 | public Lockfile lockFile_from( 44 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log) { 45 | return LockFilePom.from(lockFileAccessor, pomMinimums, log); 46 | } 47 | }; 48 | 49 | abstract String defaultFilename(); 50 | 51 | private String getLockFilename(String filename) { 52 | if (filename != null) { 53 | return filename; 54 | } 55 | return defaultFilename(); 56 | } 57 | 58 | public LockFileAccessor dependenciesLockFileAccessor_fromBasedirAndFilename( 59 | File basedir, String filename) { 60 | return LockFileAccessor.fromBasedir(basedir, getLockFilename(filename)); 61 | } 62 | 63 | public abstract DependenciesLockFile dependenciesLockFile_from( 64 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log); 65 | 66 | public abstract Lockfile lockFile_from( 67 | LockFileAccessor lockFileAccessor, PomMinimums pomMinimums, Log log); 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockableEntities.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Collections.unmodifiableList; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.Comparator; 8 | import java.util.Iterator; 9 | import java.util.List; 10 | import java.util.Optional; 11 | import java.util.stream.Stream; 12 | 13 | /** 14 | * Instances of this class shall be used to gather a sorted list of {@link LockableEntity} 15 | * instances. 16 | * 17 | * @param the type of {@link LockableEntity} this implementation would be handling 18 | */ 19 | public class LockableEntities implements Iterable { 20 | 21 | private final List entities; 22 | 23 | LockableEntities(Collection contents) { 24 | ArrayList copy = new ArrayList<>(contents); 25 | copy.sort( 26 | new Comparator() { 27 | @Override 28 | public int compare(Type o1, Type o2) { 29 | return o1.getArtifactIdentifier().compareTo(o2.getArtifactIdentifier()); 30 | } 31 | }); 32 | this.entities = unmodifiableList(copy); 33 | } 34 | 35 | public final Optional by(ArtifactIdentifier identifier) { 36 | for (Type entity : entities) { 37 | if (identifier.equals(entity.getArtifactIdentifier())) { 38 | return Optional.of(entity); 39 | } 40 | } 41 | return Optional.empty(); 42 | } 43 | 44 | @Override 45 | public final Iterator iterator() { 46 | return entities.iterator(); 47 | } 48 | 49 | public final Stream stream() { 50 | return entities.stream(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockableEntitiesWithArtifact.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.util.Collection; 4 | import java.util.stream.Stream; 5 | 6 | public class LockableEntitiesWithArtifact 7 | extends LockableEntities { 8 | 9 | LockableEntitiesWithArtifact(Collection contents) { 10 | super(contents); 11 | } 12 | 13 | public Stream artifacts() { 14 | return stream().map(entity -> entity.artifact); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockableEntity.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | /** 4 | * Instances of this class shall represent a versioned entity which can be checked for integrity. 5 | */ 6 | public abstract class LockableEntity> { 7 | 8 | LockableEntity() { 9 | super(); 10 | } 11 | 12 | public abstract T withVersion(String version); 13 | 14 | public abstract T withIntegrity(Integrity integrity); 15 | 16 | public abstract Integrity getIntegrity(); 17 | 18 | public abstract String getVersion(); 19 | 20 | public abstract String getArtifactKey(); 21 | 22 | public abstract ArtifactIdentifier getArtifactIdentifier(); 23 | 24 | public abstract String toString_withoutIntegrity(); 25 | 26 | public abstract org.apache.maven.artifact.Artifact getMavenArtifact(); 27 | 28 | public abstract String getIntegrityForLockFile(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockableEntityWithArtifact.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | /** Instances of this class shall represent a lockable entity which is attached to an artifact. */ 6 | public abstract class LockableEntityWithArtifact> 7 | extends LockableEntity { 8 | final Artifact artifact; 9 | private org.apache.maven.artifact.Artifact mavenArtifact; 10 | 11 | LockableEntityWithArtifact(Artifact artifact) { 12 | super(); 13 | this.artifact = requireNonNull(artifact); 14 | } 15 | 16 | @Override 17 | public abstract T withIntegrity(Integrity integrity); 18 | 19 | @Override 20 | public abstract T withVersion(String version); 21 | 22 | @Override 23 | public final Integrity getIntegrity() { 24 | return artifact.integrity; 25 | } 26 | 27 | @Override 28 | public final String getVersion() { 29 | return this.artifact.version; 30 | } 31 | 32 | @Override 33 | public final String getArtifactKey() { 34 | return artifact.getArtifactKey(); 35 | } 36 | 37 | @Override 38 | public final ArtifactIdentifier getArtifactIdentifier() { 39 | return artifact.identifier; 40 | } 41 | 42 | @Override 43 | public String toString_withoutIntegrity() { 44 | return artifact.toString_withoutIntegrity(); 45 | } 46 | 47 | @Override 48 | public final org.apache.maven.artifact.Artifact getMavenArtifact() { 49 | org.apache.maven.artifact.Artifact result = mavenArtifact; 50 | if (null == result) { 51 | result = toMavenArtifact(); 52 | mavenArtifact = result; 53 | } 54 | return result; 55 | } 56 | 57 | org.apache.maven.artifact.Artifact toMavenArtifact() { 58 | return MavenArtifact.unscoped(artifact); 59 | } 60 | 61 | @Override 62 | public final String getIntegrityForLockFile() { 63 | return artifact.getIntegrityForLockFile(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockedArtifacts.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.atomic.AtomicReference; 7 | import org.apache.maven.plugin.logging.Log; 8 | 9 | public final class LockedArtifacts extends LockedEntities { 10 | 11 | private LockedArtifacts(Artifacts lockedArtifacts, Log log) { 12 | super(lockedArtifacts, log); 13 | } 14 | 15 | public static LockedArtifacts from(Artifacts artifacts, Log log) { 16 | return new LockedArtifacts(requireNonNull(artifacts), log); 17 | } 18 | 19 | public DiffReport compareWith(Artifacts artifacts, Filters filters) { 20 | return super.compareWith(artifacts, filters); 21 | } 22 | 23 | @Override 24 | List findDiffs( 25 | AtomicReference lockedArtifactRef, Artifact actualArtifact, Filters filters) { 26 | List wrongs = super.findDiffs(lockedArtifactRef, actualArtifact, filters); 27 | wrongs.addAll(diffVersion(lockedArtifactRef, actualArtifact, Artifact::withVersion, filters)); 28 | return wrongs; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockedBuild.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.stream.Stream; 6 | import org.apache.maven.plugin.logging.Log; 7 | 8 | public final class LockedBuild { 9 | public final Plugins plugins; 10 | public final Extensions extensions; 11 | private final Log log; 12 | 13 | private LockedBuild(Extensions extensions, Plugins plugins, Log log) { 14 | this.extensions = extensions; 15 | this.plugins = plugins; 16 | this.log = log; 17 | } 18 | 19 | public static LockedBuild from(Build build, Log log) { 20 | return from(build.plugins, build.extensions, log); 21 | } 22 | 23 | public static LockedBuild from(Plugins plugins, Extensions extensions, Log log) { 24 | return new LockedBuild(requireNonNull(extensions), requireNonNull(plugins), log); 25 | } 26 | 27 | public Diff compareWith(Build build, Filters filters) { 28 | DiffReport pluginsDiff = LockedPlugins.from(plugins, log).compareWith(build.plugins, filters); 29 | DiffReport extensionsDiff = 30 | LockedExtensions.from(extensions, log).compareWith(build.extensions, filters); 31 | return new Diff(pluginsDiff, extensionsDiff); 32 | } 33 | 34 | public static final class Diff { 35 | private final DiffReport pluginsDiff; 36 | private final DiffReport extensionsDiff; 37 | 38 | Diff(DiffReport pluginsDiff, DiffReport extensionsDiff) { 39 | this.pluginsDiff = pluginsDiff; 40 | this.extensionsDiff = extensionsDiff; 41 | } 42 | 43 | public boolean equals() { 44 | return pluginsDiff.equals() && extensionsDiff.equals(); 45 | } 46 | 47 | public Stream report() { 48 | return Stream.concat(pluginsDiff.report("plugins"), extensionsDiff.report("extensions")); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockedDependencies.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Arrays.asList; 4 | import static java.util.Collections.emptyList; 5 | import static java.util.Objects.requireNonNull; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.concurrent.atomic.AtomicReference; 10 | import org.apache.maven.plugin.logging.Log; 11 | 12 | public final class LockedDependencies extends LockedEntities { 13 | 14 | private LockedDependencies(Dependencies lockedDependencies, Log log) { 15 | super(lockedDependencies, log); 16 | } 17 | 18 | public static LockedDependencies from(Dependencies artifacts, Log log) { 19 | return new LockedDependencies(requireNonNull(artifacts), log); 20 | } 21 | 22 | public Diff compareWith(Dependencies dependencies, Filters filters) { 23 | return new Diff(super.compareWith(dependencies, filters)); 24 | } 25 | 26 | @Override 27 | List findDiffs( 28 | AtomicReference lockedDependencyRef, 29 | Dependency actualDependency, 30 | Filters filters) { 31 | List wrongs = new ArrayList<>(); 32 | wrongs.addAll(diffOptional(lockedDependencyRef.get(), actualDependency)); 33 | wrongs.addAll(diffScope(lockedDependencyRef.get(), actualDependency)); 34 | wrongs.addAll(diffIntegrity(lockedDependencyRef, actualDependency, filters)); 35 | wrongs.addAll( 36 | diffVersion(lockedDependencyRef, actualDependency, Dependency::withVersion, filters)); 37 | return wrongs; 38 | } 39 | 40 | private List diffOptional(Dependency lockedDependency, Dependency actualDependency) { 41 | if (lockedDependency.optional == actualDependency.optional) { 42 | return emptyList(); 43 | } else { 44 | return asList("optional"); 45 | } 46 | } 47 | 48 | private List diffScope(Dependency lockedDependency, Dependency actualDependency) { 49 | if (lockedDependency.scope.equals(actualDependency.scope)) { 50 | return emptyList(); 51 | } else { 52 | return asList("scope"); 53 | } 54 | } 55 | 56 | public static final class Diff { 57 | Diff(DiffReport diffReport) { 58 | this.diffReport = diffReport; 59 | } 60 | 61 | private final DiffReport diffReport; 62 | 63 | DiffReport getReport() { 64 | return diffReport; 65 | } 66 | 67 | public boolean equals() { 68 | return this.diffReport.equals(); 69 | } 70 | 71 | public void logTo(Log log) { 72 | this.diffReport.report("dependencies").forEach(log::error); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockedExtensions.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.atomic.AtomicReference; 7 | import org.apache.maven.plugin.logging.Log; 8 | 9 | public final class LockedExtensions extends LockedEntities { 10 | 11 | private LockedExtensions(Extensions lockedExtensions, Log log) { 12 | super(lockedExtensions, log); 13 | } 14 | 15 | public static LockedExtensions from(Extensions extensions, Log log) { 16 | return new LockedExtensions(requireNonNull(extensions), log); 17 | } 18 | 19 | public DiffReport compareWith(Extensions extensions, Filters filters) { 20 | return super.compareWith(extensions, filters); 21 | } 22 | 23 | @Override 24 | List findDiffs( 25 | AtomicReference lockedExtensionRef, Extension actualExtension, Filters filters) { 26 | List result = super.findDiffs(lockedExtensionRef, actualExtension, filters); 27 | result.addAll( 28 | diffVersion(lockedExtensionRef, actualExtension, Extension::withVersion, filters)); 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/LockedPlugins.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.atomic.AtomicReference; 7 | import org.apache.maven.plugin.logging.Log; 8 | 9 | public final class LockedPlugins extends LockedEntities { 10 | 11 | private LockedPlugins(Plugins lockedPlugins, Log log) { 12 | super(lockedPlugins, log); 13 | } 14 | 15 | public static LockedPlugins from(Plugins plugins, Log log) { 16 | return new LockedPlugins(requireNonNull(plugins), log); 17 | } 18 | 19 | public DiffReport compareWith(Plugins plugins, Filters filters) { 20 | return super.compareWith(plugins, filters); 21 | } 22 | 23 | @Override 24 | List findDiffs( 25 | AtomicReference lockedPluginRef, Plugin actualPlugin, Filters filters) { 26 | final List wrongs = super.findDiffs(lockedPluginRef, actualPlugin, filters); 27 | wrongs.addAll(diffVersion(lockedPluginRef, actualPlugin, Plugin::withVersion, filters)); 28 | LockedArtifacts lockedArtifacts = LockedArtifacts.from(lockedPluginRef.get().dependencies, log); 29 | DiffReport diff = lockedArtifacts.compareWith(actualPlugin.dependencies, filters); 30 | if (!diff.equals()) { 31 | diff.report("dependencies for " + lockedPluginRef.get().toString_withoutIntegrity()) 32 | .forEach(log::error); 33 | wrongs.add("dependencies"); 34 | } 35 | return wrongs; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Lockfile.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import org.apache.maven.plugin.MojoExecutionException; 4 | 5 | public interface Lockfile { 6 | 7 | void write(LockedProject contents); 8 | 9 | LockedProject read() throws MojoExecutionException; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Plugins.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Collections.emptyList; 4 | 5 | import java.util.Collection; 6 | import java.util.stream.Stream; 7 | 8 | public final class Plugins extends LockableEntitiesWithArtifact { 9 | 10 | private Plugins(Collection plugins) { 11 | super(plugins); 12 | } 13 | 14 | public static Plugins empty() { 15 | return from(emptyList()); 16 | } 17 | 18 | public static Plugins from(Collection plugins) { 19 | return new Plugins(plugins); 20 | } 21 | 22 | @Override 23 | public Stream artifacts() { 24 | return stream().flatMap(p -> Stream.concat(Stream.of(p.artifact), p.dependencies.stream())); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/PomMinimums.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import org.apache.maven.project.MavenProject; 6 | 7 | public final class PomMinimums { 8 | 9 | public final String groupId; 10 | public final String artifactId; 11 | public final String version; 12 | 13 | public static PomMinimums from(MavenProject mavenProject) { 14 | return new PomMinimums( 15 | mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion()); 16 | } 17 | 18 | PomMinimums(String groupId, String artifactId, String version) { 19 | this.groupId = requireNonNull(groupId); 20 | this.artifactId = requireNonNull(artifactId); 21 | this.version = requireNonNull(version); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/Project.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.util.Optional; 4 | 5 | public final class Project { 6 | public final Optional build; 7 | public final Dependencies dependencies; 8 | 9 | private Project(Optional build, Dependencies dependencies) { 10 | this.build = build; 11 | this.dependencies = dependencies; 12 | } 13 | 14 | public static Project from(Dependencies dependencies, Build build) { 15 | return new Project(Optional.of(build), dependencies); 16 | } 17 | 18 | public static Project from(Dependencies dependencies) { 19 | return new Project(Optional.empty(), dependencies); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/VersionUtils.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | final class VersionUtils { 7 | private VersionUtils() { 8 | super(); 9 | } 10 | 11 | static boolean snapshotMatch(String version, String otherVersion) { 12 | if (version.equals(otherVersion)) { 13 | return true; 14 | } 15 | return stripSnapshot(version).equals(stripSnapshot(otherVersion)); 16 | } 17 | 18 | private static final Pattern SNAPSHOT_TIMESTAMP = 19 | Pattern.compile("^((?.*)-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$"); 20 | 21 | static String stripSnapshot(String version) { 22 | if (version.endsWith("-SNAPSHOT")) { 23 | return version.substring(0, version.length() - 9); 24 | } 25 | Matcher matcher = SNAPSHOT_TIMESTAMP.matcher(version); 26 | if (matcher.matches()) { 27 | return matcher.group("base"); 28 | } else { 29 | return version; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/json/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.json; 2 | 3 | import static java.lang.String.format; 4 | import static java.util.Locale.ROOT; 5 | import static se.vandmo.dependencylock.maven.lang.Strings.isBlank; 6 | 7 | import com.fasterxml.jackson.core.JsonGenerator.Feature; 8 | import com.fasterxml.jackson.databind.JsonNode; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import java.io.IOException; 11 | import java.io.Reader; 12 | import java.io.UncheckedIOException; 13 | import java.io.Writer; 14 | import java.util.Optional; 15 | 16 | public final class JsonUtils { 17 | private JsonUtils() {} 18 | 19 | public static String getNonBlankStringValue(JsonNode json, String fieldName) { 20 | JsonNode jsonNode = json.get(fieldName); 21 | if (jsonNode == null) { 22 | throw missingValueFor(fieldName); 23 | } 24 | String value = jsonNode.textValue(); 25 | if (isBlank(value)) { 26 | throw missingValueFor(fieldName); 27 | } 28 | return value; 29 | } 30 | 31 | private static IllegalArgumentException missingValueFor(String fieldName) { 32 | return new IllegalArgumentException(format(ROOT, "Missing value for '%s'", fieldName)); 33 | } 34 | 35 | public static boolean getBooleanOrDefault(JsonNode json, String fieldName, boolean defaultValue) { 36 | if (!json.has(fieldName)) { 37 | return defaultValue; 38 | } 39 | JsonNode value = json.get(fieldName); 40 | if (!value.isBoolean()) { 41 | throw new IllegalArgumentException(format(ROOT, "'%s' is not a boolean value", fieldName)); 42 | } 43 | return value.booleanValue(); 44 | } 45 | 46 | public static Optional possiblyGetStringValue(JsonNode json, String fieldName) { 47 | if (!json.has(fieldName)) { 48 | return Optional.empty(); 49 | } 50 | return Optional.of(getNonBlankStringValue(json, fieldName)); 51 | } 52 | 53 | public static JsonNode readJson(Reader reader) { 54 | try { 55 | return new ObjectMapper().readTree(reader); 56 | } catch (IOException ex) { 57 | throw new UncheckedIOException(ex); 58 | } 59 | } 60 | 61 | public static void writeJson(Writer writer, JsonNode json) { 62 | try { 63 | new ObjectMapper() 64 | .disable(Feature.AUTO_CLOSE_TARGET) 65 | .writerWithDefaultPrettyPrinter() 66 | .writeValue(writer, json); 67 | writer.write(System.lineSeparator()); 68 | } catch (IOException ex) { 69 | throw new UncheckedIOException(ex); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/lang/Strings.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.lang; 2 | 3 | import java.util.List; 4 | 5 | public final class Strings { 6 | private Strings() {} 7 | 8 | public static String joinNouns(List nouns) { 9 | switch (nouns.size()) { 10 | case 0: 11 | return ""; 12 | case 1: 13 | return nouns.get(0); 14 | default: 15 | int lastIdx = nouns.size() - 1; 16 | return String.join( 17 | " and ", String.join(", ", nouns.subList(0, lastIdx)), nouns.get(lastIdx)); 18 | } 19 | } 20 | 21 | public static boolean isBlank(String s) { 22 | if (s == null) { 23 | return true; 24 | } 25 | return s.trim().equals(""); 26 | } 27 | 28 | public static boolean startsWith(String s, String prefix) { 29 | if (s == null || prefix == null) { 30 | return s == null && prefix == null; 31 | } 32 | return s.startsWith(prefix); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/mojos/CheckMojo.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.mojos; 2 | 3 | import static org.apache.maven.plugins.annotations.LifecyclePhase.VALIDATE; 4 | import static org.apache.maven.plugins.annotations.ResolutionScope.TEST; 5 | 6 | import org.apache.maven.plugin.MojoExecutionException; 7 | import org.apache.maven.plugins.annotations.Mojo; 8 | import org.apache.maven.plugins.annotations.Parameter; 9 | import se.vandmo.dependencylock.maven.Build; 10 | import se.vandmo.dependencylock.maven.LockFileAccessor; 11 | import se.vandmo.dependencylock.maven.LockedProject; 12 | import se.vandmo.dependencylock.maven.Project; 13 | 14 | @Mojo( 15 | name = "check", 16 | defaultPhase = VALIDATE, 17 | requiresDependencyResolution = TEST, 18 | threadSafe = true) 19 | public final class CheckMojo extends AbstractDependencyLockMojo { 20 | 21 | @Parameter(property = "dependencyLock.skipCheck") 22 | private Boolean skip = false; 23 | 24 | @Override 25 | public void execute() throws MojoExecutionException { 26 | if (skip) { 27 | getLog().info("Skipping check"); 28 | return; 29 | } 30 | 31 | LockFileAccessor lockFile = lockFile(); 32 | if (!lockFile.exists()) { 33 | throw new MojoExecutionException( 34 | "No lock file found, create one by running 'mvn" 35 | + " se.vandmo:dependency-lock-maven-plugin:lock'"); 36 | } 37 | LockedProject lockedProject = format().lockFile_from(lockFile, pomMinimums(), getLog()).read(); 38 | Project actualProject; 39 | if (lockedProject.build.isPresent()) { 40 | actualProject = 41 | Project.from(projectDependencies(), Build.from(projectPlugins(), projectExtensions())); 42 | } else { 43 | actualProject = Project.from(projectDependencies()); 44 | } 45 | LockedProject.Diff diff = lockedProject.compareWith(actualProject, filters()); 46 | if (actualProject.build.isPresent()) { 47 | if (diff.equals()) { 48 | getLog() 49 | .info( 50 | "Actual dependencies, plugins and extensions matches locked dependencies, plugins" 51 | + " and extensions"); 52 | } else { 53 | diff.logTo(getLog()); 54 | throw new MojoExecutionException("Dependencies / Build differ"); 55 | } 56 | } else { 57 | if (diff.equals()) { 58 | getLog().info("Actual dependencies matches locked dependencies"); 59 | } else { 60 | diff.logTo(getLog()); 61 | throw new MojoExecutionException("Dependencies differ"); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/mojos/DependencySet.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.mojos; 2 | 3 | public final class DependencySet { 4 | public String[] includes = new String[0]; 5 | public String[] excludes = new String[0]; 6 | public String version = "check"; 7 | public Integrity integrity; 8 | public Boolean allowMissing = null; 9 | public Boolean allowExtraneous = null; 10 | 11 | public enum Integrity { 12 | check, 13 | ignore 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/se/vandmo/dependencylock/maven/pom/InvalidPomLockFile.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.pom; 2 | 3 | import static java.lang.String.format; 4 | import static java.util.Locale.ROOT; 5 | 6 | import javax.xml.stream.Location; 7 | import javax.xml.stream.XMLStreamException; 8 | 9 | public final class InvalidPomLockFile extends RuntimeException { 10 | 11 | InvalidPomLockFile(String message) { 12 | super(message); 13 | } 14 | 15 | InvalidPomLockFile(String message, Location location) { 16 | super(format(ROOT, "%s on line %d", message, location.getLineNumber())); 17 | } 18 | 19 | InvalidPomLockFile(XMLStreamException cause) { 20 | super(cause); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/se/vandmo/dependencylock/maven/pom/pom.ftlx: -------------------------------------------------------------------------------- 1 | 2 | 9 | 4.0.0 10 | 11 | ${pom.groupId} 12 | ${pom.artifactId}-dependency-lock 13 | ${pom.version} 14 | 15 | 16 | <#list dependencies as dependency> 17 | 18 | ${dependency.artifactIdentifier.groupId} 19 | ${dependency.artifactIdentifier.artifactId} 20 | ${dependency.version} 21 | ${dependency.artifactIdentifier.type} 22 | ${dependency.scope} 23 | <#if dependency.artifactIdentifier.classifier.isPresent()> 24 | ${dependency.artifactIdentifier.classifier.get()} 25 | 26 | ${dependency.optional?c} 27 | ${dependency.getIntegrityForLockFile()} 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | lt.velykis.maven.skins 5 | blank-maven-skin 6 | 1.0.0 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/site/xsd/dependencylock.xsd: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Value being used when lockfile contains also covers build artifacts. 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/site/xsd/maven-4_0_0_ext.xsd: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/test/java/ArtifactTests.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.assertEquals; 2 | 3 | import org.junit.Test; 4 | import se.vandmo.dependencylock.maven.Artifact; 5 | import se.vandmo.dependencylock.maven.ArtifactIdentifier; 6 | 7 | public final class ArtifactTests { 8 | 9 | @Test(expected = NullPointerException.class) 10 | public void from_null() { 11 | Artifact.from(null); 12 | } 13 | 14 | @Test(expected = NullPointerException.class) 15 | public void builder_artifactIdentifier_null() { 16 | Artifact.builder().artifactIdentifier(null); 17 | } 18 | 19 | @Test(expected = NullPointerException.class) 20 | public void builder_version_null() { 21 | Artifact.builder().artifactIdentifier(anArtifactIdentifier()).version(null); 22 | } 23 | 24 | @Test(expected = NullPointerException.class) 25 | public void builder_integrity_null() { 26 | Artifact.builder().artifactIdentifier(anArtifactIdentifier()).version("1").integrity(null); 27 | } 28 | 29 | @Test 30 | public void toString_withoutIntegrity() { 31 | Artifact artifact = 32 | Artifact.builder() 33 | .artifactIdentifier( 34 | ArtifactIdentifier.builder() 35 | .groupId("the_groupId") 36 | .artifactId("the_artifactId") 37 | .classifier("the_classifier") 38 | .type("war") 39 | .build()) 40 | .version("1.2.3") 41 | .integrity("sha512:123abc") 42 | .build(); 43 | assertEquals( 44 | "the_groupId:the_artifactId:the_classifier:war:1.2.3", 45 | artifact.toString_withoutIntegrity()); 46 | } 47 | 48 | private static ArtifactIdentifier anArtifactIdentifier() { 49 | return ArtifactIdentifier.builder().groupId("the_groupId").artifactId("the_artifactId").build(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/DependencyTests.java: -------------------------------------------------------------------------------- 1 | import static org.junit.Assert.assertEquals; 2 | 3 | import org.junit.Test; 4 | import se.vandmo.dependencylock.maven.ArtifactIdentifier; 5 | import se.vandmo.dependencylock.maven.Dependency; 6 | 7 | public final class DependencyTests { 8 | 9 | @Test(expected = NullPointerException.class) 10 | public void from_null() { 11 | Dependency.from(null); 12 | } 13 | 14 | @Test(expected = NullPointerException.class) 15 | public void builder_artifactIdentifier_null() { 16 | Dependency.builder().artifactIdentifier(null); 17 | } 18 | 19 | @Test(expected = NullPointerException.class) 20 | public void builder_version_null() { 21 | Dependency.builder().artifactIdentifier(anArtifactIdentifier()).version(null); 22 | } 23 | 24 | @Test(expected = NullPointerException.class) 25 | public void builder_scope_null() { 26 | Dependency.builder() 27 | .artifactIdentifier(anArtifactIdentifier()) 28 | .version("1") 29 | .integrity("sha512:123abc") 30 | .scope(null); 31 | } 32 | 33 | @Test(expected = NullPointerException.class) 34 | public void builder_integrity_null() { 35 | Dependency.builder().artifactIdentifier(anArtifactIdentifier()).version("1").integrity(null); 36 | } 37 | 38 | @Test 39 | public void toString_withoutIntegrity() { 40 | Dependency dependency = 41 | Dependency.builder() 42 | .artifactIdentifier( 43 | ArtifactIdentifier.builder() 44 | .groupId("the_groupId") 45 | .artifactId("the_artifactId") 46 | .classifier("the_classifier") 47 | .type("war") 48 | .build()) 49 | .version("1.2.3") 50 | .integrity("sha512:123abc") 51 | .scope("compile") 52 | .build(); 53 | assertEquals( 54 | "the_groupId:the_artifactId:the_classifier:war:1.2.3:compile:optional=false", 55 | dependency.toString_withoutIntegrity()); 56 | } 57 | 58 | private static ArtifactIdentifier anArtifactIdentifier() { 59 | return ArtifactIdentifier.builder().groupId("the_groupId").artifactId("the_artifactId").build(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/se/vandmo/dependencylock/maven/ChecksumTests.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.nio.charset.StandardCharsets.UTF_8; 4 | import static org.junit.Assert.assertEquals; 5 | 6 | import java.io.File; 7 | import java.io.IOException; 8 | import java.nio.file.Files; 9 | import org.junit.Rule; 10 | import org.junit.Test; 11 | import org.junit.rules.TemporaryFolder; 12 | 13 | public final class ChecksumTests { 14 | 15 | @Rule public final TemporaryFolder folder = new TemporaryFolder(); 16 | 17 | @Test(expected = NullPointerException.class) 18 | public void calculateFor_byteArrayNull() { 19 | Checksum.calculateFor((byte[]) null); 20 | } 21 | 22 | @Test(expected = NullPointerException.class) 23 | public void calculateFor_fileNull() { 24 | Checksum.calculateFor((File) null); 25 | } 26 | 27 | @Test 28 | public void calculateFor() { 29 | assertEquals( 30 | "sha512:23I/NBoELY3hqoE+/V4C/BdFzL4llIYldRSATi7EvOuypG8eStRCFUlD+el+G8R8OuDt2rfeDAGpxR8VNCpbGQ==", 31 | Checksum.calculateFor("abcdefghijklmno".getBytes(UTF_8))); 32 | } 33 | 34 | @Test 35 | public void calculateForFile() throws IOException { 36 | final File file = folder.newFile("abcdefghijklmno.txt"); 37 | Files.write(file.toPath(), "abcdefghijklmno".getBytes(UTF_8)); 38 | assertEquals( 39 | "sha512:23I/NBoELY3hqoE+/V4C/BdFzL4llIYldRSATi7EvOuypG8eStRCFUlD+el+G8R8OuDt2rfeDAGpxR8VNCpbGQ==", 40 | Checksum.calculateFor(file)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/se/vandmo/dependencylock/maven/LockFileAccessorTests.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static java.lang.String.format; 4 | import static java.util.Locale.ROOT; 5 | import static org.junit.Assert.assertFalse; 6 | import static org.junit.Assert.assertTrue; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.util.Random; 11 | import org.junit.Rule; 12 | import org.junit.Test; 13 | import org.junit.rules.TemporaryFolder; 14 | 15 | public final class LockFileAccessorTests { 16 | 17 | private static Random random = new Random(); 18 | 19 | @Rule public TemporaryFolder folder = new TemporaryFolder(); 20 | 21 | @Test 22 | public void parentFoldersShouldBeCreated() throws IOException { 23 | File basedir = folder.newFolder(); 24 | String folderName1 = randomEnoughString(); 25 | String folderName2 = randomEnoughString(); 26 | String filename = randomEnoughString(); 27 | File lockFile = new File(new File(new File(basedir, folderName1), folderName2), filename); 28 | assertFalse(lockFile.isFile()); 29 | LockFileAccessor.fromBasedir( 30 | basedir, format(ROOT, "%s/%s/%s", folderName1, folderName2, filename)) 31 | .writer() 32 | .close(); 33 | assertTrue(lockFile.isFile()); 34 | } 35 | 36 | private static String randomEnoughString() { 37 | long l1 = random.nextInt(Integer.MAX_VALUE); 38 | long l2 = random.nextInt(Integer.MAX_VALUE); 39 | return (Long.toString(l1, 36) + Long.toString(l2, 36)).toUpperCase(ROOT); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/se/vandmo/dependencylock/maven/VersionUtilsTests.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertFalse; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import org.junit.Test; 8 | 9 | public final class VersionUtilsTests { 10 | 11 | @Test 12 | public void snapshotMatch() { 13 | assertTrue(VersionUtils.snapshotMatch("1.0", "1.0")); 14 | assertFalse(VersionUtils.snapshotMatch("1.0", "1.0.1")); 15 | assertTrue(VersionUtils.snapshotMatch("0-SNAPSHOT", "0-20221104.072032-1")); 16 | assertTrue(VersionUtils.snapshotMatch("0-20221104.072032-1", "0-SNAPSHOT")); 17 | assertFalse(VersionUtils.snapshotMatch("0-SNAPSHOT.1", "0-20221104.072032-1.1")); 18 | assertTrue(VersionUtils.snapshotMatch("1.2.3-SNAPSHOT", "1.2.3-20221104.072032-1")); 19 | } 20 | 21 | @Test 22 | public void stripSnapshot() { 23 | assertEquals("1.0", VersionUtils.stripSnapshot("1.0")); 24 | assertEquals("1.0", VersionUtils.stripSnapshot("1.0-SNAPSHOT")); 25 | assertEquals("1.2.3", VersionUtils.stripSnapshot("1.2.3-SNAPSHOT")); 26 | assertEquals("0", VersionUtils.stripSnapshot("0-20221104.072032-1")); 27 | assertEquals("1.2.3", VersionUtils.stripSnapshot("1.2.3-20221104.072032-1")); 28 | assertEquals( 29 | "1.2.3-20221104.072032-1-1", VersionUtils.stripSnapshot("1.2.3-20221104.072032-1-1")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/se/vandmo/dependencylock/maven/lang/StringsTests.java: -------------------------------------------------------------------------------- 1 | package se.vandmo.dependencylock.maven.lang; 2 | 3 | import static java.util.Arrays.asList; 4 | import static java.util.Collections.emptyList; 5 | import static org.junit.Assert.assertEquals; 6 | import static org.junit.Assert.assertFalse; 7 | import static org.junit.Assert.assertTrue; 8 | 9 | import org.junit.Test; 10 | 11 | public final class StringsTests { 12 | 13 | @Test(expected = NullPointerException.class) 14 | public void joinNouns_null() { 15 | Strings.joinNouns(null); 16 | } 17 | 18 | @Test 19 | public void joinNouns() { 20 | assertEquals("", Strings.joinNouns(emptyList())); 21 | assertEquals("a", Strings.joinNouns(asList("a"))); 22 | assertEquals("a and b", Strings.joinNouns(asList("a", "b"))); 23 | assertEquals("a, b and c", Strings.joinNouns(asList("a", "b", "c"))); 24 | assertEquals("a, b, c and d", Strings.joinNouns(asList("a", "b", "c", "d"))); 25 | } 26 | 27 | @Test 28 | public void isBlank() { 29 | assertTrue(Strings.isBlank(null)); 30 | assertTrue(Strings.isBlank("")); 31 | assertTrue(Strings.isBlank(" ")); 32 | assertTrue(Strings.isBlank(" \n\t ")); 33 | assertFalse(Strings.isBlank("a")); 34 | } 35 | 36 | @Test 37 | public void startsWith() { 38 | assertTrue(Strings.startsWith(null, null)); 39 | assertFalse(Strings.startsWith(null, "abc")); 40 | assertFalse(Strings.startsWith("abc", null)); 41 | assertTrue(Strings.startsWith("abcdef", "abc")); 42 | assertFalse(Strings.startsWith("defabc", "abc")); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/mojos/LockProjectHelperTest/loadPlugins_appropriatelyHandlesProfilePlugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | pom-with-profile-plugin-missing 9 | se.vandmo.tests 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | some-random-profile 15 | 16 | 17 | 18 | org.apache.maven.plugins 19 | maven-invoker-plugin 20 | 3.9.0 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/mojos/LockProjectHelperTest/loadPlugins_appropriatelyIncludesManagedProfilePlugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | pom-with-managed-profile-plugin 9 | se.vandmo.tests 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | 15 | 16 | org.apache.maven.plugins 17 | maven-invoker-plugin 18 | 3.9.0 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | some-random-profile 27 | 28 | 29 | 30 | org.apache.maven.plugins 31 | maven-invoker-plugin 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/mojos/LockProjectHelperTest/loadPlugins_logsAWarningIfProfilePluginVersionManagedInProfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | pom-with-plugin-only-declared-in-profile-and-managed-in-profile 9 | se.vandmo.tests 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | 15 | 16 | 17 | some-random-profile 18 | 19 | 20 | 21 | 22 | org.apache.maven.plugins 23 | maven-invoker-plugin 24 | 3.9.0 25 | 26 | 27 | 28 | 29 | 30 | org.apache.maven.plugins 31 | maven-invoker-plugin 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/mojos/LockProjectHelperTest/loadPlugins_logsNothingIfProfilePluginAppropriatelyDeclared.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | pom-with-recommended-profile-plugins-declaration 9 | se.vandmo.tests 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | 15 | 16 | org.apache.maven.plugins 17 | maven-invoker-plugin 18 | 3.9.0 19 | 20 | 21 | 22 | 23 | 24 | org.apache.maven.plugins 25 | maven-invoker-plugin 26 | 27 | 28 | 29 | 30 | 31 | 32 | some-random-profile 33 | 34 | 35 | 36 | org.apache.maven.plugins 37 | maven-invoker-plugin 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/mojos/LockProjectHelperTest/loadPlugins_supportsProfileWithNoBuild.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | 8 | pom-with-profile-with-no-build 9 | se.vandmo.tests 10 | 0-SNAPSHOT 11 | 12 | 13 | 14 | 15 | org.apache.maven.plugins 16 | maven-invoker-plugin 17 | 3.9.0 18 | 19 | 20 | 21 | 22 | 23 | 24 | some-random-profile 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/element-when-text.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hello 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-artifactId.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | 4.1.65.Final 11 | jar 12 | compile 13 | false 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-dependencies.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-groupId.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | netty-common 10 | 4.1.65.Final 11 | jar 12 | compile 13 | false 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-integrity.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | netty-common 11 | 4.1.65.Final 12 | jar 13 | compile 14 | false 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-optional.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | netty-common 11 | 4.1.65.Final 12 | jar 13 | compile 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-scope.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | netty-common 11 | 4.1.65.Final 12 | jar 13 | false 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-type.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | netty-common 11 | 4.1.65.Final 12 | compile 13 | false 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/no-version.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | io.netty 10 | netty-common 11 | jar 12 | compile 13 | false 14 | sha512:5P4zOFbDqM56LQYE7WrcXLKW7QAB0bgU84AWPjwNaV9T7g81XkAxbhUszx45qAtaxobgSCq3b5OQnZLE0B4Bpw== 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/text-then-element.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | hello 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/valid.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 4.0.0 8 | 9 | se.vandmo.tests 10 | pom-dependency-lock 11 | 0-SNAPSHOT 12 | 13 | abc 14 | 15 | 16 | 17 | abc 18 | 19 | 20 | 21 | abc 22 | 23 | io.netty 24 | 25 | abc 26 | 27 | netty-buffer 28 | 4.1.65.Final 29 | jar 30 | compile 31 | false 32 | sha512:something 33 | 34 | abc 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/wrong-end.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/wrong-optional.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | muahaha 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/se/vandmo/dependencylock/maven/poms/wrong-top.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tasks/create-test-dependencies: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from os import path 4 | from zipfile import ZIP_DEFLATED, ZipFile 5 | 6 | folder = 'src/it/setup/dependencies' 7 | 8 | 9 | def create(name, extension='jar'): 10 | target_filename = f'{folder}/{name}.{extension}' 11 | if path.isfile(target_filename): 12 | print(f'Skipping {target_filename} since it already exists') 13 | else: 14 | with ZipFile(target_filename, 'w', ZIP_DEFLATED) as zipf: 15 | zipf.writestr(name, name) 16 | 17 | 18 | create('leaf-1.0') 19 | create('another-leaf-1.0') 20 | create('a-third-leaf-1.0') 21 | create('a-classified-leaf-1.0-classy') 22 | create('a-snapshot-leaf-1.5-SNAPSHOT') 23 | create('with-dependency-1.0') 24 | create('a-war-1.0', 'war') 25 | -------------------------------------------------------------------------------- /tasks/format: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu -o pipefail 3 | 4 | docker run --rm\ 5 | -v "${PWD}":/local\ 6 | --user $(id -u):$(id -g)\ 7 | vandmo/google-java-format@sha256:7b81f690b62ba70ae9e2165cba54bf3b6d2d81d8c1f5bc015507acdfc91d31e7\ 8 | find /local/ -name '*.java' -exec google-java-format -i {} \; 9 | -------------------------------------------------------------------------------- /tasks/full-build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu -o pipefail 3 | 4 | mvn clean install post-site --activate-profiles its,analyze 5 | mvn com.github.spotbugs:spotbugs-maven-plugin:4.8.6.6:spotbugs com.github.spotbugs:spotbugs-maven-plugin:4.8.6.6:check --define spotbugs.excludeFilterFile=spotbugs-suppressions.xml 6 | -------------------------------------------------------------------------------- /tasks/generate-sumtypes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eu -o pipefail 3 | 4 | docker run --rm\ 5 | -v "${PWD}":/work\ 6 | --user $(id -u):$(id -g)\ 7 | vandmo/java-sumtype-generator@sha256:999539e85538db63514cee0b5ca440062c2f65c12fc62ccdc55570921d1763c6 8 | 9 | docker run --rm\ 10 | -v "${PWD}":/local\ 11 | --user $(id -u):$(id -g)\ 12 | vandmo/google-java-format@sha256:7b81f690b62ba70ae9e2165cba54bf3b6d2d81d8c1f5bc015507acdfc91d31e7\ 13 | google-java-format -i /local/src/main/java/se/vandmo/dependencylock/maven/Integrity.java 14 | -------------------------------------------------------------------------------- /tasks/list-checksum-for-test-dependencies: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import base64 4 | import hashlib 5 | import os 6 | 7 | folder = 'src/it/setup/dependencies' 8 | for filename in os.listdir(folder): 9 | if filename.endswith('.jar') or filename.endswith('.war'): 10 | sha512 = hashlib.sha512() 11 | fullname = os.path.join(folder, filename) 12 | with open(fullname, 'rb') as f: 13 | sha512.update(f.read()) 14 | b64 = base64.b64encode(sha512.digest()).decode('utf-8') 15 | print(f'{fullname}: sha512:{b64}') 16 | -------------------------------------------------------------------------------- /tasks/lock-dependencies: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eux -o pipefail 3 | 4 | mvn -DlockBuild=true se.vandmo:dependency-lock-maven-plugin:0.0.5734cd9bd748d0121eda3d28d4f428a246501ee0:lock 5 | -------------------------------------------------------------------------------- /test-resources.properties: -------------------------------------------------------------------------------- 1 | xsd_dest=. --------------------------------------------------------------------------------