From 9e7f2d9ccf8741355ee48ae2fe4b62a41ab933ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 23:15:30 +0000 Subject: [PATCH 001/441] Bump maven-plugin-annotations from 3.6.1 to 3.6.2 Bumps [maven-plugin-annotations](https://github.com/apache/maven-plugin-tools) from 3.6.1 to 3.6.2. - [Release notes](https://github.com/apache/maven-plugin-tools/releases) - [Commits](https://github.com/apache/maven-plugin-tools/compare/maven-plugin-tools-3.6.1...maven-plugin-tools-3.6.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugin-tools:maven-plugin-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e811c1afb2..dedadbd48d 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.1 + 3.6.2 provided From 04370e3d1d5e48b6ee632610546ed38e75df9593 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 23:15:24 +0000 Subject: [PATCH 002/441] Bump junit-bom from 5.8.1 to 5.8.2 Bumps [junit-bom](https://github.com/junit-team/junit5) from 5.8.1 to 5.8.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.1...r5.8.2) --- updated-dependencies: - dependency-name: org.junit:junit-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dedadbd48d..0e24944597 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ 1.8 ${mojo.java.target} - 5.8.1 + 5.8.2 3.0.5 3.4.3 1.10 From 04a9ecedb27f06d86f303dc48c3593745bc45db4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Nov 2021 23:15:16 +0000 Subject: [PATCH 003/441] Bump mrm-maven-plugin from 1.2.0 to 1.3.0 Bumps [mrm-maven-plugin](https://github.com/mojohaus/mrm) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/mojohaus/mrm/releases) - [Commits](https://github.com/mojohaus/mrm/compare/mrm-1.2.0...mrm-1.3.0) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mrm-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0e24944597..8bf2a43249 100644 --- a/pom.xml +++ b/pom.xml @@ -365,7 +365,7 @@ org.codehaus.mojo mrm-maven-plugin - 1.2.0 + 1.3.0 From 6f62a7a95173cadd704bd0ec01355a9bec6385ac Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Thu, 2 Dec 2021 00:05:49 +0100 Subject: [PATCH 004/441] (doc) Added testing with Java 17 --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index a5c8b637d2..01babff858 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -25,7 +25,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - java: [8, 11, 16] + java: [8, 11, 17] jdk: ['temurin'] fail-fast: false From b4f77a14bc2874d73fc5bcb539110cc268ee5004 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Tue, 10 Aug 2021 13:06:41 +0200 Subject: [PATCH 005/441] Display "Latest" Versions in Reports Summary --- .../AbstractVersionsReportRenderer.java | 58 +++++++++++-------- .../mojo/versions/PluginUpdatesRenderer.java | 31 +++++----- .../dependency-updates-report.properties | 1 + .../plugin-updates-report.properties | 1 + .../property-updates-report.properties | 1 + 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index bd5e15b7f1..aaa4c9adb6 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -165,37 +165,37 @@ protected void renderDependencySummaryTableRow( Dependency dependency, ArtifactV } sink.tableCell(); - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) { safeBold(); - sink.text( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( details.getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) { safeBold(); - sink.text( details.getOldestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( details.getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + if ( details.getNewestUpdate( UpdateScope.MINOR ) != null ) { safeBold(); - sink.text( details.getOldestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( details.getNewestUpdate( UpdateScope.MINOR ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + if ( details.getNewestUpdate( UpdateScope.MAJOR ) != null ) { safeBold(); - sink.text( details.getOldestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( details.getNewestUpdate( UpdateScope.MAJOR ).toString() ); safeBold_(); } sink.tableCell_(); @@ -291,16 +291,16 @@ protected void renderDependencySummaryTableHeader( boolean includeScope, boolean sink.tableHeaderCell_(); } sink.tableHeaderCell(); - sink.text( getText( "report.nextVersion" ) ); + sink.text( getText("report.latestSubIncremental") ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextIncremental" ) ); + sink.text( getText( "report.latestIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMinor" ) ); + sink.text( getText( "report.latestMinor" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMajor" ) ); + sink.text( getText( "report.latestMajor" ) ); sink.tableHeaderCell_(); sink.tableRow_(); } @@ -428,6 +428,7 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) sink.lineBreak(); } boolean bold = equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) + || equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) || equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) ) @@ -448,6 +449,10 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) { sink.text( getText( "report.nextVersion" ) ); } + else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + { + sink.text( getText("report.latestSubIncremental") ); + } else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) { sink.text( getText( "report.nextIncremental" ) ); @@ -535,37 +540,37 @@ protected void renderPropertySummaryTableRow( Property property, PropertyVersion sink.tableCell_(); sink.tableCell(); - if ( versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) { safeBold(); - sink.text( versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( versions.getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) { safeBold(); - sink.text( versions.getOldestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( versions.getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getOldestUpdate( UpdateScope.MINOR ) != null ) + if ( versions.getNewestUpdate( UpdateScope.MINOR ) != null ) { safeBold(); - sink.text( versions.getOldestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( versions.getNewestUpdate( UpdateScope.MINOR ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) + if ( versions.getNewestUpdate( UpdateScope.MAJOR ) != null ) { safeBold(); - sink.text( versions.getOldestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( versions.getNewestUpdate( UpdateScope.MAJOR ).toString() ); safeBold_(); } sink.tableCell_(); @@ -586,16 +591,16 @@ protected void renderPropertySummaryTableHeader() sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextVersion" ) ); + sink.text( getText( "report.latestSubIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextIncremental" ) ); + sink.text( getText( "report.latestIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMinor" ) ); + sink.text( getText( "report.latestMinor" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMajor" ) ); + sink.text( getText( "report.latestMajor" ) ); sink.tableHeaderCell_(); sink.tableRow_(); } @@ -697,6 +702,7 @@ else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) } boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); boolean bold = equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) + || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) || equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.INCREMENTAL ) ) || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.INCREMENTAL ) ) || equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.MINOR ) ) @@ -725,6 +731,10 @@ else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) { sink.text( getText( "report.nextVersion" ) ); } + else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + { + sink.text( getText("report.latestSubIncremental") ); + } else if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) { sink.text( getText( "report.nextIncremental" ) ); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index be98904f46..7e422ad05d 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -20,7 +20,6 @@ */ import java.text.MessageFormat; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -244,16 +243,16 @@ private void renderSummaryTableHeader() sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextVersion" ) ); + sink.text( getText("report.latestSubIncremental") ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextIncremental" ) ); + sink.text( getText( "report.latestIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMinor" ) ); + sink.text( getText( "report.latestMinor" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText( "report.nextMajor" ) ); + sink.text( getText( "report.latestMajor" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( getText( "report.dependencyStatus" ) ); @@ -293,37 +292,37 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ).toString() ); safeBold_(); } sink.tableCell_(); @@ -432,6 +431,7 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != } boolean bold = equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) + || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) ) @@ -453,6 +453,11 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != { sink.text( getText( "report.nextVersion" ) ); } + else if ( equals( versions[i], + details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + { + sink.text( getText("report.latestSubIncremental") ); + } else if ( equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) { diff --git a/src/main/resources/dependency-updates-report.properties b/src/main/resources/dependency-updates-report.properties index b6ad5f0ae2..1c5eb9722d 100644 --- a/src/main/resources/dependency-updates-report.properties +++ b/src/main/resources/dependency-updates-report.properties @@ -42,6 +42,7 @@ report.classifier=Classifier report.type=Type report.newerVersion=Newer Version(s) report.nextVersion=Next Version +report.latestSubIncremental=Latest Subincremental report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental report.nextMinor=Next Minor diff --git a/src/main/resources/plugin-updates-report.properties b/src/main/resources/plugin-updates-report.properties index 4e0eabce71..c3a37ddc7c 100644 --- a/src/main/resources/plugin-updates-report.properties +++ b/src/main/resources/plugin-updates-report.properties @@ -44,6 +44,7 @@ report.classifier=Classifier report.type=Type report.newerVersion=Newer Version(s) report.nextVersion=Next Version +report.latestSubIncremental=Latest Subincremental report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental report.nextMinor=Next Minor diff --git a/src/main/resources/property-updates-report.properties b/src/main/resources/property-updates-report.properties index 57466d7eba..ed59150ed7 100644 --- a/src/main/resources/property-updates-report.properties +++ b/src/main/resources/property-updates-report.properties @@ -39,6 +39,7 @@ report.property=Property report.currentVersion=Current Version report.newerVersion=Newer Version(s) report.nextVersion=Next Version +report.latestSubIncremental=Latest Subincremental report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental report.nextMinor=Next Minor From e6dcb4f4473cf1d6176541f8108fa4176743bff0 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Tue, 10 Aug 2021 13:17:11 +0200 Subject: [PATCH 006/441] Display "Latest" Versions in Reports Summary --- .../mojo/versions/AbstractVersionsReportRenderer.java | 6 +++--- .../org/codehaus/mojo/versions/PluginUpdatesRenderer.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index aaa4c9adb6..0931a46457 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -291,7 +291,7 @@ protected void renderDependencySummaryTableHeader( boolean includeScope, boolean sink.tableHeaderCell_(); } sink.tableHeaderCell(); - sink.text( getText("report.latestSubIncremental") ); + sink.text( getText( "report.latestSubIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( getText( "report.latestIncremental" ) ); @@ -451,7 +451,7 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) } else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) { - sink.text( getText("report.latestSubIncremental") ); + sink.text( getText( "report.latestSubIncremental" ) ); } else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) { @@ -733,7 +733,7 @@ else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) } else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) { - sink.text( getText("report.latestSubIncremental") ); + sink.text( getText( "report.latestSubIncremental" ) ); } else if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) { diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index 7e422ad05d..e3141771a8 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -243,7 +243,7 @@ private void renderSummaryTableHeader() sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); - sink.text( getText("report.latestSubIncremental") ); + sink.text( getText( "report.latestSubIncremental" ) ); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text( getText( "report.latestIncremental" ) ); @@ -456,7 +456,7 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != else if ( equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) { - sink.text( getText("report.latestSubIncremental") ); + sink.text( getText( "report.latestSubIncremental" ) ); } else if ( equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) From 6e5f7489df8a3564325912fcd15e522f22ec30fa Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:30:19 +0200 Subject: [PATCH 007/441] Display "Latest" Versions in Reports Summary --- src/it/it-dependency-updates-report-001/verify.bsh | 2 +- src/it/it-dependency-updates-report-003/verify.bsh | 2 +- src/it/it-dependency-updates-report-004/verify.bsh | 4 ++-- src/it/it-plugin-updates-report-001/verify.bsh | 4 ++-- src/it/it-plugin-updates-report-002/verify.bsh | 2 +- src/it/it-plugin-updates-report-003/verify.bsh | 2 +- src/it/it-property-updates-report-001/verify.bsh | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/it/it-dependency-updates-report-001/verify.bsh b/src/it/it-dependency-updates-report-001/verify.bsh index d71ea83580..cb1a4a8c77 100644 --- a/src/it/it-dependency-updates-report-001/verify.bsh +++ b/src/it/it-dependency-updates-report-001/verify.bsh @@ -11,7 +11,7 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( result.indexOf( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.1 1.2 2.0" ) < 0 ) + if ( result.indexOf( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.3 1.3 3.0" ) < 0 ) { System.out.println( "Did not generate summary correctly" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-dependency-updates-report-003/verify.bsh b/src/it/it-dependency-updates-report-003/verify.bsh index b9f302ee44..6d424fff75 100644 --- a/src/it/it-dependency-updates-report-003/verify.bsh +++ b/src/it/it-dependency-updates-report-003/verify.bsh @@ -11,7 +11,7 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( result.indexOf( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.1 1.2 2.0" ) < 0 ) + if ( result.indexOf( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.3 1.3 3.0" ) < 0 ) { System.out.println( "Did not pick up updated in dependencies section" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-dependency-updates-report-004/verify.bsh b/src/it/it-dependency-updates-report-004/verify.bsh index a5102914ce..2ba289b304 100644 --- a/src/it/it-dependency-updates-report-004/verify.bsh +++ b/src/it/it-dependency-updates-report-004/verify.bsh @@ -11,13 +11,13 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( !result.contains( "localhost dummy-api 1.1 jar 1.1.0-2 1.1.1 1.2 2.0" ) ) + if ( !result.contains( "localhost dummy-api 1.1 jar 1.1.0-2 1.1.3 1.3 3.0" ) ) { System.out.println( "Did not pick up updated in Dependency Management section" ); System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( !result.contains( "localhost dummy-impl 1.1 jar 1.2 2.0" ) ) + if ( !result.contains( "localhost dummy-impl 1.1 jar 1.4 2.2" ) ) { System.out.println( "Did not pick up updated in Dependency Management section" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-001/verify.bsh b/src/it/it-plugin-updates-report-001/verify.bsh index a680391ec7..67a272ca2f 100644 --- a/src/it/it-plugin-updates-report-001/verify.bsh +++ b/src/it/it-plugin-updates-report-001/verify.bsh @@ -19,13 +19,13 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( result.indexOf( "localhost dummy-maven-plugin 1.0 2.0" ) < 0 ) + if ( result.indexOf( "localhost dummy-maven-plugin 1.0 3.1" ) < 0 ) { System.out.println( "Did not generate dependency summary correctly" ); System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "dummy-api 1.1 jar 1.1.0-2 1.1.1 1.2 2.0" ) < 0 ) + if ( result.indexOf( "dummy-api 1.1 jar 1.1.0-2 1.1.3 1.3 3.0" ) < 0 ) { System.out.println( "Did not generate dependency summary correctly" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-002/verify.bsh b/src/it/it-plugin-updates-report-002/verify.bsh index 6643aa3a56..ee113ae500 100644 --- a/src/it/it-plugin-updates-report-002/verify.bsh +++ b/src/it/it-plugin-updates-report-002/verify.bsh @@ -19,7 +19,7 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( result.indexOf( "localhost dummy-maven-plugin 1.0 2.0" ) < 0 ) + if ( result.indexOf( "localhost dummy-maven-plugin 1.0 3.1" ) < 0 ) { System.out.println( "Did not generate summary correctly" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-003/verify.bsh b/src/it/it-plugin-updates-report-003/verify.bsh index 6643aa3a56..ee113ae500 100644 --- a/src/it/it-plugin-updates-report-003/verify.bsh +++ b/src/it/it-plugin-updates-report-003/verify.bsh @@ -19,7 +19,7 @@ try .replaceAll( "&[^;]+;", " " ) .replaceAll( "\\s+", " " ); - if ( result.indexOf( "localhost dummy-maven-plugin 1.0 2.0" ) < 0 ) + if ( result.indexOf( "localhost dummy-maven-plugin 1.0 3.1" ) < 0 ) { System.out.println( "Did not generate summary correctly" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-property-updates-report-001/verify.bsh b/src/it/it-property-updates-report-001/verify.bsh index 3536c4d9a5..66a0475185 100644 --- a/src/it/it-property-updates-report-001/verify.bsh +++ b/src/it/it-property-updates-report-001/verify.bsh @@ -28,7 +28,7 @@ try } if ( result.indexOf( "# of properties where the next version available is smaller than an incremental version update 0" ) < 0 ) { - System.out.println( "Did not generate with subincrermental totals correctly" ); + System.out.println( "Did not generate with subincremental totals correctly" ); System.out.println( "Result = \"" + result +"\"" ); return false; } @@ -50,13 +50,13 @@ try System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "${impl-version} 2.0 2.1" ) < 0 ) + if ( result.indexOf( "${impl-version} 2.0 2.2" ) < 0 ) { System.out.println( "Did not generate summary for ${impl-version} correctly" ); System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "${api-version} 1.0 1.0.1 1.1 2.0" ) < 0 ) + if ( result.indexOf( "${api-version} 1.0 1.0.1 1.3 3.0" ) < 0 ) { System.out.println( "Did not generate summary for ${api-version} correctly" ); System.out.println( "Result = \"" + result +"\"" ); From 78725336a8171fe36c4e1dc8d7214dbdc841df6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Nov 2021 13:25:51 +0000 Subject: [PATCH 008/441] Bump mockito-core from 3.12.4 to 4.1.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.4 to 4.1.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v3.12.4...v4.1.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- .../codehaus/mojo/versions/RequiredMavenVersionFinderTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8bf2a43249..247823c955 100644 --- a/pom.xml +++ b/pom.xml @@ -263,7 +263,7 @@ org.mockito mockito-core - 3.12.4 + 4.1.0 test diff --git a/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java b/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java index f852d255ad..45176ee755 100644 --- a/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java +++ b/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java @@ -10,7 +10,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import java.util.ArrayList; From 5b279ec0c77a90f523ebc8cdf7696879c9396823 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Thu, 2 Dec 2021 00:09:57 +0100 Subject: [PATCH 009/441] (doc) Use Maven 3.8.4 in Maven Wrapper --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 642d572ce9..598fb34156 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,2 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar From 83bbf922f13a365ecd54a50adb1e17b7b2516047 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Dec 2021 13:20:12 +0000 Subject: [PATCH 010/441] Bump doxiaVersion from 1.10 to 1.11.1 Bumps `doxiaVersion` from 1.10 to 1.11.1. Updates `doxia-core` from 1.10 to 1.11.1 - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-1.10...doxia-1.11.1) Updates `doxia-sink-api` from 1.10 to 1.11.1 - [Release notes](https://github.com/apache/maven-doxia/releases) - [Commits](https://github.com/apache/maven-doxia/compare/doxia-1.10...doxia-1.11.1) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-core dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.doxia:doxia-sink-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 247823c955..c6766fecaa 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ 5.8.2 3.0.5 3.4.3 - 1.10 + 1.11.1 1.10 ${project.version} 3.7 From 64d16eb78a444f9a5f943f5292232338d750951f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Fri, 10 Dec 2021 08:35:50 +0100 Subject: [PATCH 011/441] remove unused imports --- .../org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java | 1 - src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java | 1 - .../java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java | 1 - .../java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java | 1 - .../mojo/versions/utils/PropertiesVersionsFileReader.java | 1 - 5 files changed, 5 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java index 597749498f..05877cbc60 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.PrintWriter; -import java.util.ArrayList; import java.util.Collection; import java.util.Map; import java.util.Map.Entry; diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 75a2bb4ca5..49646141ef 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -30,7 +30,6 @@ import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; import javax.xml.stream.XMLStreamException; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index 0a6552b620..fa72cdabc4 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -32,7 +32,6 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index d15c453954..98aa321042 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.List; import javax.xml.stream.XMLStreamException; diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java index 299831a412..de22fd7878 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java @@ -3,7 +3,6 @@ import org.codehaus.mojo.versions.Property; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; From c6f517d2a08aa182364e99ccd63efe0467a0080e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Dec 2021 13:20:37 +0000 Subject: [PATCH 012/441] Bump mockito-core from 4.1.0 to 4.2.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.1.0 to 4.2.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.1.0...v4.2.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c6766fecaa..34e9a3fea1 100644 --- a/pom.xml +++ b/pom.xml @@ -263,7 +263,7 @@ org.mockito mockito-core - 4.1.0 + 4.2.0 test From f60e1b861c983a5a99dd20a50325f776bc3c6e7a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Dec 2021 13:21:52 +0000 Subject: [PATCH 013/441] Bump doxia-site-renderer from 1.10 to 1.11.1 Bumps [doxia-site-renderer](https://github.com/apache/maven-doxia-sitetools) from 1.10 to 1.11.1. - [Release notes](https://github.com/apache/maven-doxia-sitetools/releases) - [Commits](https://github.com/apache/maven-doxia-sitetools/compare/doxia-sitetools-1.10...doxia-sitetools-1.11.1) --- updated-dependencies: - dependency-name: org.apache.maven.doxia:doxia-site-renderer dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34e9a3fea1..2db6e346a8 100644 --- a/pom.xml +++ b/pom.xml @@ -102,7 +102,7 @@ 3.0.5 3.4.3 1.11.1 - 1.10 + 1.11.1 ${project.version} 3.7 2020-08-07T21:31:00Z From 8f9b7e9bc642be15061d5719f8c748c030b57818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 22 Dec 2021 23:39:47 +0100 Subject: [PATCH 014/441] mark Maven core provided artifacts with scope = provided https://maven.apache.org/ref/3.8.4/maven-core/core-extensions.html --- pom.xml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index 2db6e346a8..b991ca7550 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/${project.scm.tag} - versions-maven-plugin-2.8.1 + master github @@ -132,31 +132,37 @@ org.apache.maven maven-artifact ${mavenVersion} + provided org.apache.maven maven-core ${mavenVersion} + provided org.apache.maven maven-compat ${mavenVersion} + provided org.apache.maven maven-model ${mavenVersion} + provided org.apache.maven maven-plugin-api ${mavenVersion} + provided org.apache.maven maven-settings ${mavenVersion} + provided org.apache.maven.reporting @@ -177,6 +183,7 @@ org.apache.maven.wagon wagon-provider-api ${wagonVersion} + provided org.apache.maven.wagon @@ -201,16 +208,6 @@ org.apache.maven.doxia doxia-site-renderer ${doxia-sitetoolsVersion} - - - org.codehaus.plexus - plexus-container-default - - - org.codehaus.plexus - plexus-component-api - - @@ -222,17 +219,12 @@ org.codehaus.plexus plexus-container-default 2.1.0 + provided org.codehaus.plexus plexus-interactivity-api 1.1 - - - plexus-container-default - org.codehaus.plexus - - com.fasterxml.woodstox @@ -288,6 +280,7 @@ org.apache.maven.plugins maven-plugin-plugin + 3.6.2 true From 25734568f466b9c6b78540979ac5957c1aa3feec Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 4 Jan 2022 09:25:52 +0100 Subject: [PATCH 015/441] fix github actions badge in README: since 850b00a1c740e783b19ab8f2cce1fafb8d43b29c only a simple "maven" action is used for building also limit the badge and link to "master" branch --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c7f48ae15..68d7040868 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ This is the [versions-maven-plugin](http://www.mojohaus.org/versions-maven-plugi [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/mojohaus/versions-maven-plugin.svg?label=License)](http://www.apache.org/licenses/) [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/versions-maven-plugin.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.mojo%22%20AND%20a%3A%22versions-maven-plugin%22) -[![Main](https://github.com/mojohaus/versions-maven-plugin/workflows/Main/badge.svg)](https://github.com/mojohaus/versions-maven-plugin/actions?query=workflow%3AMain) -[![JDKBuilds](https://github.com/mojohaus/versions-maven-plugin/workflows/JDKBuilds/badge.svg)](https://github.com/mojohaus/versions-maven-plugin/actions?query=workflow%3AJDKBuilds) +[![Build Status](https://github.com/mojohaus/versions-maven-plugin/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/mojohaus/versions-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) ## Contributing From 357b8a0e7bd02b5f64bccc3f15e28d357b63bd06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Dec 2021 13:15:47 +0000 Subject: [PATCH 016/441] Bump plexus-container-default from 2.1.0 to 2.1.1 Bumps [plexus-container-default](https://github.com/codehaus-plexus/plexus-containers) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/codehaus-plexus/plexus-containers/releases) - [Changelog](https://github.com/codehaus-plexus/plexus-containers/blob/master/ReleaseNotes.md) - [Commits](https://github.com/codehaus-plexus/plexus-containers/compare/plexus-containers-2.1.0...plexus-containers-2.1.1) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-container-default dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b991ca7550..6a13635d25 100644 --- a/pom.xml +++ b/pom.xml @@ -218,7 +218,7 @@ org.codehaus.plexus plexus-container-default - 2.1.0 + 2.1.1 provided From b827092e1aed06747434cf00e0cbf83525c64c10 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 4 Jan 2022 13:33:26 +0100 Subject: [PATCH 017/441] enable version resolver for semantic plugin versioning based on tags make sure name-template and tag-template are always in sync provide a default release text template it's also useful to be able to start the workflow manually when tags are added/updated after the last run --- .github/release-drafter.yml | 19 ++++++++++++++++++- .github/workflows/release-drafter.yml | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 9315158689..35be94f806 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,2 +1,19 @@ _extends: .github -tag-template: versions-maven-plugin-$NEXT_MINOR_VERSION +name-template: '$RESOLVED_VERSION' +tag-template: 'versions-maven-plugin-$RESOLVED_VERSION' +version-resolver: + major: + labels: + - major + minor: + labels: + - minor + - enhancement + patch: + labels: + - patch + default: patch +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 4e2af9953d..8e9603bfe4 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -3,6 +3,7 @@ on: push: branches: - master + workflow_dispatch: jobs: update_release_draft: runs-on: ubuntu-latest From 04afc2c4b9c98cb9ff7cf4f8e0b7d5678cf58fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 27 Dec 2021 16:50:44 +0100 Subject: [PATCH 018/441] #453 update Reproducible Builds outputTimestamp when setting version --- .gitignore | 1 + .../invoker.properties | 1 + src/it/it-set-019-outputTimestamp/pom.xml | 14 +++++++ .../it-set-019-outputTimestamp/verify.groovy | 3 ++ .../org/codehaus/mojo/versions/SetMojo.java | 39 +++++++++++++++++++ 5 files changed, 58 insertions(+) create mode 100644 src/it/it-set-019-outputTimestamp/invoker.properties create mode 100644 src/it/it-set-019-outputTimestamp/pom.xml create mode 100644 src/it/it-set-019-outputTimestamp/verify.groovy diff --git a/.gitignore b/.gitignore index 6d49b95354..8f164d2f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ target .project *.iml .idea +/.factorypath diff --git a/src/it/it-set-019-outputTimestamp/invoker.properties b/src/it/it-set-019-outputTimestamp/invoker.properties new file mode 100644 index 0000000000..414e361403 --- /dev/null +++ b/src/it/it-set-019-outputTimestamp/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=2.0 diff --git a/src/it/it-set-019-outputTimestamp/pom.xml b/src/it/it-set-019-outputTimestamp/pom.xml new file mode 100644 index 0000000000..9029e8a2b1 --- /dev/null +++ b/src/it/it-set-019-outputTimestamp/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + localhost + it-set-019 + 1.0 + pom + set + + + 10 + + diff --git a/src/it/it-set-019-outputTimestamp/verify.groovy b/src/it/it-set-019-outputTimestamp/verify.groovy new file mode 100644 index 0000000000..e854a85867 --- /dev/null +++ b/src/it/it-set-019-outputTimestamp/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text; + +assert pom =~ /\d\d\d\d+<.project.build.outputTimestamp>/ diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 65ce2a01cd..3f823b428b 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -21,14 +21,18 @@ import java.io.File; import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; +import java.util.TimeZone; import java.util.TreeMap; import java.util.regex.Pattern; @@ -485,6 +489,9 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) for ( VersionChange versionChange : sourceChanges ) { changer.apply( versionChange ); + + // also update project.build.outputTimestamp + updateBuildOutputTimestamp( pom, model ); } } catch ( IOException e ) @@ -494,4 +501,36 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) log.clearContext(); } + private void updateBuildOutputTimestamp( ModifiedPomXMLEventReader pom, Model model ) + throws XMLStreamException + { + String buildOutputTimestamp = model.getProperties().getProperty( "project.build.outputTimestamp" ); + + if ( buildOutputTimestamp == null || StringUtils.isEmpty( buildOutputTimestamp ) ) + { + // no Reproducible Builds output timestamp defined + return; + } + + if ( StringUtils.isNumeric( buildOutputTimestamp ) ) + { + // int representing seconds since the epoch, like SOURCE_DATE_EPOCH + buildOutputTimestamp = String.valueOf( System.currentTimeMillis() / 1000 ); + } + else if ( buildOutputTimestamp.length() <= 1 ) + { + // value length == 1 means disable Reproducible Builds + return; + } + else + { + // ISO-8601 + DateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'" ); + df.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); + buildOutputTimestamp = df.format( new Date() ); + } + + PomHelper.setPropertyVersion( pom, null, "project.build.outputTimestamp", buildOutputTimestamp ); + } + } From ce83fdff13e2b24a3cd3deb5a6a2c9dff5226182 Mon Sep 17 00:00:00 2001 From: sseifert Date: Mon, 24 Aug 2020 17:01:32 +0200 Subject: [PATCH 019/441] Fixes #426 restore default behavior on setting versions in all modules of the local aggregation root that was present before the fix for #82 introduce a new flag processFromLocalAggregationRoot that enables the new (and probably more correct) behavior by setting it it false ensure old and new behavior are covered by integration tests --- src/it/it-set-018-issue-82/invoker.properties | 2 +- .../it-set-019-issue-426/invoker.properties | 3 + .../module-a1/module-b1/pom.xml | 12 ++ .../module-a1/module-b2/pom.xml | 13 +++ .../module-a1/module-b3/pom.xml | 13 +++ src/it/it-set-019-issue-426/module-a1/pom.xml | 13 +++ src/it/it-set-019-issue-426/module-a2/pom.xml | 17 +++ src/it/it-set-019-issue-426/pom.xml | 103 ++++++++++++++++++ src/it/it-set-019-issue-426/verify.groovy | 67 ++++++++++++ .../org/codehaus/mojo/versions/SetMojo.java | 18 ++- .../codehaus/mojo/versions/api/PomHelper.java | 49 +++++++++ 11 files changed, 308 insertions(+), 2 deletions(-) create mode 100644 src/it/it-set-019-issue-426/invoker.properties create mode 100644 src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml create mode 100644 src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml create mode 100644 src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml create mode 100644 src/it/it-set-019-issue-426/module-a1/pom.xml create mode 100644 src/it/it-set-019-issue-426/module-a2/pom.xml create mode 100644 src/it/it-set-019-issue-426/pom.xml create mode 100644 src/it/it-set-019-issue-426/verify.groovy diff --git a/src/it/it-set-018-issue-82/invoker.properties b/src/it/it-set-018-issue-82/invoker.properties index 2760b545a2..500af68ea4 100644 --- a/src/it/it-set-018-issue-82/invoker.properties +++ b/src/it/it-set-018-issue-82/invoker.properties @@ -1,3 +1,3 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -fmodule-a1 -DnewVersion=2.5.0-SNAPSHOT +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -fmodule-a1 -DnewVersion=2.5.0-SNAPSHOT -DprocessFromLocalAggregationRoot=false invoker.nonRecursive=true invoker.buildResult=success diff --git a/src/it/it-set-019-issue-426/invoker.properties b/src/it/it-set-019-issue-426/invoker.properties new file mode 100644 index 0000000000..2760b545a2 --- /dev/null +++ b/src/it/it-set-019-issue-426/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -fmodule-a1 -DnewVersion=2.5.0-SNAPSHOT +invoker.nonRecursive=true +invoker.buildResult=success diff --git a/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml b/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml new file mode 100644 index 0000000000..8cbd8af820 --- /dev/null +++ b/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + localdomain.localhost + module-a1 + 2.0.7-SNAPSHOT + + module-b1 + pom + diff --git a/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml b/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml new file mode 100644 index 0000000000..1b31645f98 --- /dev/null +++ b/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + + localdomain.localhost + module-a1 + 2.0.7-SNAPSHOT + + module-b2 + 2.0.7-SNAPSHOT + pom + diff --git a/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml b/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml new file mode 100644 index 0000000000..76501f10e5 --- /dev/null +++ b/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + + localdomain.localhost + module-a1 + 2.0.7-SNAPSHOT + + module-b3 + 2.0.7-SNAPSHOT + pom + diff --git a/src/it/it-set-019-issue-426/module-a1/pom.xml b/src/it/it-set-019-issue-426/module-a1/pom.xml new file mode 100644 index 0000000000..784519ec8d --- /dev/null +++ b/src/it/it-set-019-issue-426/module-a1/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + localdomain.localhost + module-a1 + pom + 2.0.7-SNAPSHOT + + module-b1 + module-b2 + module-b3 + + diff --git a/src/it/it-set-019-issue-426/module-a2/pom.xml b/src/it/it-set-019-issue-426/module-a2/pom.xml new file mode 100644 index 0000000000..cabca3391e --- /dev/null +++ b/src/it/it-set-019-issue-426/module-a2/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + localdomain.localhost + module-a2 + pom + 1.0.3-SNAPSHOT + + + + localdomain.localhost + module-b1 + 2.0.7-SNAPSHOT + + + + diff --git a/src/it/it-set-019-issue-426/pom.xml b/src/it/it-set-019-issue-426/pom.xml new file mode 100644 index 0000000000..c8a4012349 --- /dev/null +++ b/src/it/it-set-019-issue-426/pom.xml @@ -0,0 +1,103 @@ + + + + 4.0.0 + localdomain.localhost + project-a + pom + 1.2.0-SNAPSHOT + mversions-82 + + + invoking versions:set on child pom - make sure all child poms are affected + + + + module-a1 + module-a2 + + + + + + + maven-antrun-plugin + 1.1 + + + maven-assembly-plugin + 2.2-beta-2 + + + maven-clean-plugin + 2.2 + + + maven-compiler-plugin + 2.0.2 + + + maven-dependency-plugin + 2.0 + + + maven-deploy-plugin + 2.3 + + + maven-ear-plugin + 2.3.1 + + + maven-ejb-plugin + 2.1 + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-javadoc-plugin + 2.4 + + + maven-plugin-plugin + 2.4.1 + + + maven-rar-plugin + 2.2 + + + maven-release-plugin + 2.0-beta-7 + + + maven-resources-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-source-plugin + 2.0.4 + + + maven-surefire-plugin + 2.4.2 + + + maven-war-plugin + 2.1-alpha-1 + + + + + + diff --git a/src/it/it-set-019-issue-426/verify.groovy b/src/it/it-set-019-issue-426/verify.groovy new file mode 100644 index 0000000000..b91b89bc96 --- /dev/null +++ b/src/it/it-set-019-issue-426/verify.groovy @@ -0,0 +1,67 @@ +import org.apache.commons.lang.StringUtils + +import javax.xml.parsers.DocumentBuilderFactory +import javax.xml.xpath.XPathFactory + +class Checker +{ + def result = true; + + def basedir; + + public Checker(File basedir) { + this.basedir = basedir; + } + + def readXPath( String pom, String xPathExpression ) + { + def stream = new FileInputStream( new File( basedir, pom ) ); + try + { + return XPathFactory.newInstance() + .newXPath() + .evaluate( xPathExpression, DocumentBuilderFactory.newInstance() + .newDocumentBuilder() + .parse( stream ).documentElement ); + } + finally + { + stream.close(); + } + } + + Checker check( String message, String pom, String xpath, String expected ) + { + if ( result ) + { + try + { + def actual = readXPath( pom, xpath ) + if ( !StringUtils.equals( expected, actual ) ) + { + System.out.println( pom + " [xpath:" + xpath + "] expected '" + expected + "' found '" + actual + "' : " + message ); + result = false; + } + } + catch ( Throwable t ) + { + t.printStackTrace(); + result = false; + } + } + return this; + } +} + +return new Checker(basedir) + .check( "root pom unchanged", "pom.xml", "/project/version", "1.2.0-SNAPSHOT" ) + .check( "module-a1 changed", "module-a1/pom.xml", "/project/version", "2.5.0-SNAPSHOT" ) + .check( "module-a1/module-b1 parent changed", "module-a1/module-b1/pom.xml", "/project/parent/version", "2.5.0-SNAPSHOT" ) + .check( "module-a1/module-b1 remains unspecified", "module-a1/module-b1/pom.xml", "/project/version", "" ) + .check( "module-a1/module-b2 parent changed", "module-a1/module-b2/pom.xml", "/project/parent/version", "2.5.0-SNAPSHOT" ) + .check( "module-a1/module-b2 version changed", "module-a1/module-b2/pom.xml", "/project/version", "2.5.0-SNAPSHOT" ) + .check( "module-a1/module-b3 parent changed", "module-a1/module-b3/pom.xml", "/project/parent/version", "2.5.0-SNAPSHOT" ) + .check( "module-a1/module-b3 version changed", "module-a1/module-b3/pom.xml", "/project/version", "2.5.0-SNAPSHOT" ) + .check( "module-a2 unchanged", "module-a2/pom.xml", "/project/version", "1.0.3-SNAPSHOT" ) + .check( "module-a2 dependency changed", "module-a2/pom.xml", "/project/dependencies/dependency/version", "2.5.0-SNAPSHOT" ) + .result; diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 3f823b428b..72b52799a6 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -192,6 +192,16 @@ public class SetMojo @Parameter( property = "processAllModules", defaultValue = "false" ) private boolean processAllModules; + /** + * Whether to start processing at the local aggregation root (which might be a parent module + * of that module where Maven is executed in, and the version change may affect parent and sibling modules). + * Setting to fale makes sure only the module (and it's submodule) where Maven is executed for is affected. + * + * @since 2.9 + */ + @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) + private boolean processFromLocalAggregationRoot; + /** * The changes to module coordinates. Guarded by this. */ @@ -285,7 +295,13 @@ public void execute() try { - final MavenProject project = getProject(); + final MavenProject project; + if ( processFromLocalAggregationRoot ) { + project = PomHelper.getLocalRoot( projectBuilder, getProject(), localRepository, null, getLog() ); + } + else { + project = getProject(); + } getLog().info( "Local aggregation root: " + project.getBasedir() ); Map reactorModels = PomHelper.getReactorModels( project, getLog() ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 4c814eba53..4de12acd67 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -1355,6 +1355,55 @@ public static String getGroupId( Model model ) return targetGroupId; } + /** + * Finds the local root of the specified project. + * + * @param project The project to find the local root for. + * @param localRepository the local repo. + * @param globalProfileManager the global profile manager. + * @param logger The logger to log to. + * @return The local root (note this may be the project passed as an argument). + */ + public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project, + ArtifactRepository localRepository, ProfileManager globalProfileManager, + Log logger ) + { + logger.info( "Searching for local aggregator root..." ); + while ( true ) + { + final File parentDir = project.getBasedir().getParentFile(); + if ( parentDir != null && parentDir.isDirectory() ) + { + logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" ); + File parent = new File( parentDir, "pom.xml" ); + if ( parent.isFile() ) + { + try + { + final MavenProject parentProject = + builder.build( parent, localRepository, globalProfileManager ); + if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) ) + { + logger.debug( parentDir + " is an aggregator parent" ); + project = parentProject; + continue; + } + else + { + logger.debug( parentDir + " is not an aggregator parent" ); + } + } + catch ( ProjectBuildingException e ) + { + logger.warn( e ); + } + } + } + logger.debug( "Local aggregation root is " + project.getBasedir() ); + return project; + } + } + /** * Builds a map of raw models keyed by module path. * From 740e0b47cebcbec95674b1aae342a2f246d1265b Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 4 Jan 2022 14:10:49 +0100 Subject: [PATCH 020/441] #426 add missing imports (after merging with master) fix typos --- src/main/java/org/codehaus/mojo/versions/SetMojo.java | 2 +- src/main/java/org/codehaus/mojo/versions/api/PomHelper.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 72b52799a6..ee0f7c7c74 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -195,7 +195,7 @@ public class SetMojo /** * Whether to start processing at the local aggregation root (which might be a parent module * of that module where Maven is executed in, and the version change may affect parent and sibling modules). - * Setting to fale makes sure only the module (and it's submodule) where Maven is executed for is affected. + * Setting to false makes sure only the module (and it's submodules) where Maven is executed for is affected. * * @since 2.9 */ diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 4de12acd67..ab727488a6 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -20,6 +20,7 @@ */ import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -30,7 +31,10 @@ import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.profiles.ProfileManager; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.RegexUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; From dce93bea88a3d3d0a34d7ec283dc6235c6bee4af Mon Sep 17 00:00:00 2001 From: Konrad Windszus Date: Thu, 13 Jan 2022 10:04:19 +0100 Subject: [PATCH 021/441] Fix detection of plugin updates requiring newer Maven for building than for running (#527) Separate minimal Maven version detection for projects from requirements of plugins This closes #526 --- src/it-repo/dummy-maven-plugin-3.1.pom | 21 + .../invoker.properties | 1 + .../pom.xml | 45 ++ .../verify.bsh | 33 ++ .../versions/DisplayPluginUpdatesMojo.java | 58 +- ...va => MinimalMavenBuildVersionFinder.java} | 102 ++-- .../MinimalMavenBuildVersionFinderTest.java | 41 ++ .../RequiredMavenVersionFinderTest.java | 530 ------------------ 8 files changed, 202 insertions(+), 629 deletions(-) create mode 100644 src/it/it-display-plugin-updates-010-issue-526/invoker.properties create mode 100644 src/it/it-display-plugin-updates-010-issue-526/pom.xml create mode 100644 src/it/it-display-plugin-updates-010-issue-526/verify.bsh rename src/main/java/org/codehaus/mojo/versions/{RequiredMavenVersionFinder.java => MinimalMavenBuildVersionFinder.java} (68%) create mode 100644 src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java delete mode 100644 src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java diff --git a/src/it-repo/dummy-maven-plugin-3.1.pom b/src/it-repo/dummy-maven-plugin-3.1.pom index dc8a00526f..ba9772205d 100644 --- a/src/it-repo/dummy-maven-plugin-3.1.pom +++ b/src/it-repo/dummy-maven-plugin-3.1.pom @@ -119,6 +119,27 @@ + + + maven-enforcer-plugin + 3.0.0 + + + enforce-maven + + enforce + + + + + 3.8.4 + + + + + + + diff --git a/src/it/it-display-plugin-updates-010-issue-526/invoker.properties b/src/it/it-display-plugin-updates-010-issue-526/invoker.properties new file mode 100644 index 0000000000..3e9221daf4 --- /dev/null +++ b/src/it/it-display-plugin-updates-010-issue-526/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates diff --git a/src/it/it-display-plugin-updates-010-issue-526/pom.xml b/src/it/it-display-plugin-updates-010-issue-526/pom.xml new file mode 100644 index 0000000000..475104b789 --- /dev/null +++ b/src/it/it-display-plugin-updates-010-issue-526/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + + localhost + it-101 + 1.0 + pom + display-plugin-updates + IT for https://github.com/mojohaus/versions-maven-plugin/issues/526 + + + + + + localhost + dummy-maven-plugin + 1.0 + + + + + + maven-enforcer-plugin + 3.0.0 + + + enforce-maven + + enforce + + + + + 3.3.9 + + + + + + + + + + diff --git a/src/it/it-display-plugin-updates-010-issue-526/verify.bsh b/src/it/it-display-plugin-updates-010-issue-526/verify.bsh new file mode 100644 index 0000000000..c596e415bc --- /dev/null +++ b/src/it/it-display-plugin-updates-010-issue-526/verify.bsh @@ -0,0 +1,33 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + + Pattern p1 = Pattern.compile( "\\QNo plugins require a newer version of Maven than specified by the pom.\\E" ); + Matcher m1 = p1.matcher( buf.toString() ); + Pattern p2 = Pattern.compile( "\\Qlocalhost:dummy-maven-plugin\\E\\s*\\.*\\s*\\Q1.0 -> 3.1\\E" ); + Matcher m2 = p2.matcher( buf.toString() ); + if ( !m1.find() ) + { + System.out.println( "Did not correctly detect minimum Maven build version 3.0 of this project" ); + return false; + } + if ( !m2.find() ) + { + System.out.println( "Did not suggest updating dummy-maven-plugin to version 3.1" ); + return false; + } + System.out.println( m1.group( 0 ) ); + System.out.println( m2.group( 0 ) ); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 2bff6801bb..7ed7ca4b2f 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -38,6 +38,7 @@ import org.apache.maven.lifecycle.mapping.LifecycleMapping; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; +import org.apache.maven.model.Prerequisites; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; @@ -382,7 +383,7 @@ public void execute() List pluginUpdates = new ArrayList<>(); List pluginLockdowns = new ArrayList<>(); ArtifactVersion curMavenVersion = runtimeInformation.getApplicationVersion(); - ArtifactVersion specMavenVersion = new DefaultArtifactVersion( getRequiredMavenVersion( getProject(), "2.0" ) ); + ArtifactVersion specMavenVersion = MinimalMavenBuildVersionFinder.find( getProject(), "2.0", getLog() ); ArtifactVersion minMavenVersion = null; boolean superPomDrivingMinVersion = false; // if Maven prerequisite upgraded to a version, Map @@ -433,8 +434,7 @@ public void execute() getHelper().resolveArtifact( probe, true ); MavenProject pluginMavenProject = projectBuilder.buildFromRepository( probe, remotePluginRepositories, localRepository ); - ArtifactVersion pluginRequires = - new DefaultArtifactVersion( getRequiredMavenVersion( pluginMavenProject, "2.0" ) ); + ArtifactVersion pluginRequires = getPrerequisitesMavenVersion( pluginMavenProject ); if ( artifactVersion == null && compare( specMavenVersion, pluginRequires ) >= 0 ) { // ok, newer version compatible with current specMavenVersion @@ -492,8 +492,7 @@ public void execute() getHelper().resolveArtifact( probe, true ); MavenProject mavenProject = projectBuilder.buildFromRepository( probe, remotePluginRepositories, localRepository ); - ArtifactVersion requires = - new DefaultArtifactVersion( getRequiredMavenVersion( mavenProject, "2.0" ) ); + ArtifactVersion requires = getPrerequisitesMavenVersion( mavenProject ); if ( minMavenVersion == null || compare( minMavenVersion, requires ) < 0 ) { minMavenVersion = requires; @@ -595,30 +594,14 @@ && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifact logLine( false, "" ); // information on minimum Maven version - boolean noMavenMinVersion = getRequiredMavenVersion( getProject(), null ) == null; - boolean noExplicitMavenMinVersion = - getProject().getPrerequisites() == null || getProject().getPrerequisites().getMaven() == null; + boolean noMavenMinVersion = MinimalMavenBuildVersionFinder.find( getProject(), null, getLog() ) == null; if ( noMavenMinVersion ) { - getLog().warn( "Project does not define minimum Maven version, default is: 2.0" ); - } - else if ( noExplicitMavenMinVersion ) - { - logLine( false, "Project inherits minimum Maven version as: " + specMavenVersion ); + getLog().warn( "Project does not define minimum Maven version required for build, default is: 2.0" ); } else { - ArtifactVersion explicitMavenVersion = - new DefaultArtifactVersion( getProject().getPrerequisites().getMaven() ); - if ( compare( explicitMavenVersion, specMavenVersion ) < 0 ) - { - logLine( true, "Project's effective minimum Maven (from parent) is: " + specMavenVersion ); - logLine( true, "Project defines minimum Maven version as: " + explicitMavenVersion ); - } - else - { - logLine( false, "Project defines minimum Maven version as: " + specMavenVersion ); - } + logLine( false, "Project requires minimum Maven version for build of: " + specMavenVersion ); } logLine( false, "Plugins require minimum Maven version of: " + minMavenVersion ); if ( superPomDrivingMinVersion ) @@ -822,13 +805,6 @@ private String compactKey( String groupId, String artifactId ) return groupId + ":" + artifactId; } - private String getRequiredMavenVersion( MavenProject mavenProject, String defaultValue ) - { - ArtifactVersion requiredMavenVersion = new RequiredMavenVersionFinder( mavenProject ).find(); - - return requiredMavenVersion == null ? defaultValue : requiredMavenVersion.toString(); - } - private static final class StackState { private final String path; @@ -936,6 +912,26 @@ else if ( event.isEndElement() ) // -------------------------- OTHER METHODS -------------------------- + /** + * Get the minimum required Maven version of the given plugin + * Same logic as in https://github.com/apache/maven-plugin-tools/blob/c8ddcdcb10d342a5a5e2f38245bb569af5730c7c/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java#L711 + * @param pluginProject the plugin for which to retrieve the minimum Maven version which is required + * @return The minimally required Maven version (never {@code null}) + */ + private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject ) { + Prerequisites prerequisites = pluginProject.getPrerequisites(); + if (null == prerequisites) { + return new DefaultArtifactVersion("2.0"); + } + + String prerequisitesMavenValue = prerequisites.getMaven(); + if (null == prerequisitesMavenValue) { + return new DefaultArtifactVersion("2.0"); + } + + return new DefaultArtifactVersion(prerequisitesMavenValue); + } + /** * Gets the build plugins of a specific project. * diff --git a/src/main/java/org/codehaus/mojo/versions/RequiredMavenVersionFinder.java b/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java similarity index 68% rename from src/main/java/org/codehaus/mojo/versions/RequiredMavenVersionFinder.java rename to src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java index bf942f5daf..a8d8b211bd 100644 --- a/src/main/java/org/codehaus/mojo/versions/RequiredMavenVersionFinder.java +++ b/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java @@ -1,108 +1,94 @@ package org.codehaus.mojo.versions; +import java.util.ArrayList; +import java.util.List; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; -import org.apache.maven.model.Prerequisites; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.util.ArrayList; -import java.util.List; - /** - * Finds the minimum Maven version required by a Maven project. - * Checks for the existence of both the prerequisites.maven property and for maven-enforcer-plugin:enforce goal. - * Returns null if no minimum version is found. - * Checks project and it's parents recursively. - * - * Pros: works with Maven 3.5.0 which throws a warning if prerequisites.maven is set for a non Maven-Plugin project. - * Cons: tightly coupled with the maven-enforcer-plugin and the Xpp3Dom configuration tag. + * Finds the minimal Maven version required to build a Maven project. + * Evaluates the {@code maven-enforcer-plugin:enforce} goal and + * its {@code requireMavenVersion} rule. + * + * @see Require Maven Version Rule */ -class RequiredMavenVersionFinder { +class MinimalMavenBuildVersionFinder { - private final MavenProject mavenProject; - - RequiredMavenVersionFinder(MavenProject mavenProject) { - this.mavenProject = mavenProject; + private MinimalMavenBuildVersionFinder() { + // not supposed to be created, static methods only } - ArtifactVersion find() { - ArtifactVersion childMavenVersion = getHighestArtifactVersion(getPrerequisitesMavenVersion(), getEnforcerMavenVersion()); - - if (!mavenProject.hasParent()) { - return childMavenVersion; + static ArtifactVersion find(MavenProject mavenProject, String defaultVersion, Log log) { + ArtifactVersion version = getEnforcerMavenVersion(mavenProject, log); + if (version == null && defaultVersion != null) { + version = new DefaultArtifactVersion(defaultVersion); } - - ArtifactVersion parentMavenVersion = new RequiredMavenVersionFinder(mavenProject.getParent()).find(); - - return getHighestArtifactVersion(childMavenVersion, parentMavenVersion); + return version; } - private ArtifactVersion getPrerequisitesMavenVersion() { - Prerequisites prerequisites = mavenProject.getPrerequisites(); - if (null == prerequisites) { - return null; - } - - String prerequisitesMavenValue = prerequisites.getMaven(); - if (null == prerequisitesMavenValue) { - return null; - } - - return new DefaultArtifactVersion(prerequisitesMavenValue); - } - - private ArtifactVersion getEnforcerMavenVersion() { + private static ArtifactVersion getEnforcerMavenVersion(MavenProject mavenProject, Log log) { List buildPlugins = mavenProject.getBuildPlugins(); if (null == buildPlugins) { + log.debug("MinimalMavenBuildVersionFinder: No build plugins found"); return null; } Plugin mavenEnforcerPlugin = getMavenEnforcerPlugin(buildPlugins); if (null == mavenEnforcerPlugin) { + log.debug("MinimalMavenBuildVersionFinder: No maven-enforcer-plugin used"); return null; } List pluginExecutions = mavenEnforcerPlugin.getExecutions(); if (null == pluginExecutions) { + log.debug("MinimalMavenBuildVersionFinder: No executions of maven-enforcer-plugin found"); return null; } List pluginExecutionsWithEnforceGoal = getPluginExecutionsWithEnforceGoal(pluginExecutions); if (pluginExecutionsWithEnforceGoal.isEmpty()) { + log.debug("MinimalMavenBuildVersionFinder: No 'enforce' execution of maven-enforcer-plugin found"); return null; } Xpp3Dom requireMavenVersionTag = getRequireMavenVersionTag(pluginExecutionsWithEnforceGoal); if (null == requireMavenVersionTag) { + log.debug("MinimalMavenBuildVersionFinder: No 'requireMavenVersion' rule of maven-enforcer-plugin found"); return null; } Xpp3Dom versionTag = requireMavenVersionTag.getChild("version"); if (null == versionTag) { + log.debug("MinimalMavenBuildVersionFinder: No version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); return null; } String versionTagValue = versionTag.getValue(); if (null == versionTagValue || "".equals(versionTagValue)) { + log.debug("MinimalMavenBuildVersionFinder: Empty version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); return null; } - - return processMavenVersionRange(versionTagValue); + ArtifactVersion minimumVersion = getMinimumVersionFromRange(versionTagValue); + log.debug("Calculated minimum version " + minimumVersion + " from version parameter value '" + versionTagValue + "'"); + return minimumVersion; } - - private Plugin getMavenEnforcerPlugin(List buildPlugins) { + + private static Plugin getMavenEnforcerPlugin(List buildPlugins) { for (Plugin plugin : buildPlugins) { - if ("maven-enforcer-plugin".equals(plugin.getArtifactId())) { + if ("maven-enforcer-plugin".equals(plugin.getArtifactId()) && "org.apache.maven.plugins".equals(plugin.getGroupId())) { return plugin; } } return null; } - private List getPluginExecutionsWithEnforceGoal(List executions) { + private static List getPluginExecutionsWithEnforceGoal(List executions) { List pluginExecutions = new ArrayList<>(); for (PluginExecution pluginExecution : executions) { List goals = pluginExecution.getGoals(); @@ -113,7 +99,7 @@ private List getPluginExecutionsWithEnforceGoal(List executions) { + private static Xpp3Dom getRequireMavenVersionTag(List executions) { for (PluginExecution pluginExecution : executions) { Xpp3Dom configurationTag = (Xpp3Dom) pluginExecution.getConfiguration(); if (null == configurationTag) { @@ -135,30 +121,10 @@ private Xpp3Dom getRequireMavenVersionTag(List executions) { return null; } - private ArtifactVersion getHighestArtifactVersion(ArtifactVersion firstMavenVersion, ArtifactVersion secondMavenVersion) { - if (null == firstMavenVersion && null == secondMavenVersion) { - return null; - } - - if (null == firstMavenVersion) { - return secondMavenVersion; - } - - if (null == secondMavenVersion) { - return firstMavenVersion; - } - - if (firstMavenVersion.compareTo(secondMavenVersion) < 0) { - return secondMavenVersion; - } - - return firstMavenVersion; - } - /** * The below method implements the specification found at https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html */ - private ArtifactVersion processMavenVersionRange(String versionRange) { + static ArtifactVersion getMinimumVersionFromRange(String versionRange) { int openIndicesCount = 0; int closeIndicesCount = 0; diff --git a/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java b/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java new file mode 100644 index 0000000000..3d5fc064d3 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java @@ -0,0 +1,41 @@ +package org.codehaus.mojo.versions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.junit.Test; + +/** + * Unit tests for MinimalMavenBuildVersionFinder. + */ +public class MinimalMavenBuildVersionFinderTest { + + @Test + public void testValidVersionRanges() { + DefaultArtifactVersion expectedMinimumVersion = new DefaultArtifactVersion("1.0"); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0)")); + } + + @Test + public void testInvalidVersionRanges() { + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0]")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0],[1.2,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),(1.1,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),[1.1,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0()")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("()1.0")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0]")); + } + +} diff --git a/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java b/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java deleted file mode 100644 index 45176ee755..0000000000 --- a/src/test/java/org/codehaus/mojo/versions/RequiredMavenVersionFinderTest.java +++ /dev/null @@ -1,530 +0,0 @@ -package org.codehaus.mojo.versions; - -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.model.Prerequisites; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -import java.util.ArrayList; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.Mockito.when; - -/** - * Unit tests for RequiredMavenVersionFinder. - */ -@RunWith(MockitoJUnitRunner.class) -public class RequiredMavenVersionFinderTest { - - @Mock - private MavenProject mavenProject; - @Mock - private Prerequisites prerequisites; - @Mock - private Plugin nonEnforcerPlugin; - @Mock - private Plugin enforcerPlugin; - @Mock - private PluginExecution pluginExecution; - @Mock - private PluginExecution otherPluginExecution; - @Mock - private Xpp3Dom configurationTag; - @Mock - private Xpp3Dom otherConfigurationTag; - @Mock - private Xpp3Dom rulesTag; - @Mock - private Xpp3Dom otherRulesTag; - @Mock - private Xpp3Dom requireMavenVersionTag; - @Mock - private Xpp3Dom versionTag; - @Mock - private MavenProject parentMavenProject; - @Mock - private Prerequisites parentPrerequisites; - - @Before - public void setup() { - when(mavenProject.getPrerequisites()).thenReturn(null); - when(mavenProject.getBuildPlugins()).thenReturn(null); - when(mavenProject.hasParent()).thenReturn(false); - when(prerequisites.getMaven()).thenReturn(null); - when(nonEnforcerPlugin.getArtifactId()).thenReturn(null); - when(enforcerPlugin.getArtifactId()).thenReturn("maven-enforcer-plugin"); - when(enforcerPlugin.getExecutions()).thenReturn(null); - when(pluginExecution.getGoals()).thenReturn(null); - when(parentMavenProject.getPrerequisites()).thenReturn(null); - when(parentMavenProject.getBuildPlugins()).thenReturn(null); - when(parentMavenProject.hasParent()).thenReturn(false); - when(parentPrerequisites.getMaven()).thenReturn(null); - } - - @Test - public void findReturnsNullWhenPrerequisitesAreNullAndBuildPluginListIsNull() { - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenPrerequisitesMavenVersionIsNull() { - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNotNullWhenPrerequisitesMavenVersionIsNotNull() { - String mavenVersion = "1"; - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - when(prerequisites.getMaven()).thenReturn(mavenVersion); - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersion); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenBuildPluginsListDoesNotContainEnforcerPlugin() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(nonEnforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenEnforcerExecutionsIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenExecutionsListIsEmpty() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenExecutionGoalsListIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenPopulatedExecutionsListDoNotContainEnforcerExecution() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenEnforceGoalConfigurationIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - goals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(null); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenRulesChildIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - goals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(configurationTag.getChild("rules")).thenReturn(null); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenRequiredMavenVersionChildIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - goals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(null); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionChildIsNull() { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - goals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); - when(requireMavenVersionTag.getChild("version")).thenReturn(null); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - private void findReturnsValueWhenVersionTagValueIsSet(String mavenVersionRange) { - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - goals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); - when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); - when(versionTag.getValue()).thenReturn(mavenVersionRange); - } - - @Test - public void findReturnsNullWhenVersionTagValueIsNull() { - findReturnsValueWhenVersionTagValueIsSet(null); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueIsValidSimpleRange() { - String mavenVersionRange = "1.0"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoConfigurationTag() { - String mavenVersionRange = "1.0"; - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(otherPluginExecution); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - ArrayList otherGoals = new ArrayList<>(); - goals.add("enforce"); - otherGoals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(otherPluginExecution.getGoals()).thenReturn(otherGoals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(otherPluginExecution.getConfiguration()).thenReturn(null); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); - when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); - when(versionTag.getValue()).thenReturn(mavenVersionRange); - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoRulesTag() { - String mavenVersionRange = "1.0"; - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(otherPluginExecution); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - ArrayList otherGoals = new ArrayList<>(); - goals.add("enforce"); - otherGoals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(otherPluginExecution.getGoals()).thenReturn(otherGoals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(otherPluginExecution.getConfiguration()).thenReturn(otherConfigurationTag); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(otherConfigurationTag.getChild("rules")).thenReturn(null); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); - when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); - when(versionTag.getValue()).thenReturn(mavenVersionRange); - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenSecondEnforcerExecutionIsValidAndFirstEnforcerExecutionHasNoRequireMavenVersionTag() { - String mavenVersionRange = "1.0"; - ArrayList buildPlugins = new ArrayList<>(); - buildPlugins.add(enforcerPlugin); - when(mavenProject.getBuildPlugins()).thenReturn(buildPlugins); - ArrayList pluginExecutions = new ArrayList<>(); - pluginExecutions.add(otherPluginExecution); - pluginExecutions.add(pluginExecution); - ArrayList goals = new ArrayList<>(); - ArrayList otherGoals = new ArrayList<>(); - goals.add("enforce"); - otherGoals.add("enforce"); - when(pluginExecution.getGoals()).thenReturn(goals); - when(otherPluginExecution.getGoals()).thenReturn(otherGoals); - when(enforcerPlugin.getExecutions()).thenReturn(pluginExecutions); - when(pluginExecution.getConfiguration()).thenReturn(configurationTag); - when(otherPluginExecution.getConfiguration()).thenReturn(otherConfigurationTag); - when(configurationTag.getChild("rules")).thenReturn(rulesTag); - when(otherConfigurationTag.getChild("rules")).thenReturn(otherRulesTag); - when(rulesTag.getChild("requireMavenVersion")).thenReturn(requireMavenVersionTag); - when(otherRulesTag.getChild("requireMavenVersion")).thenReturn(null); - when(requireMavenVersionTag.getChild("version")).thenReturn(versionTag); - when(versionTag.getValue()).thenReturn(mavenVersionRange); - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsExact() { - String mavenVersionRange = "[1.0]"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsInclusiveMax() { - String mavenVersionRange = "(,1.0]"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsExclusiveMax() { - String mavenVersionRange = "(,1.0)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsInclusiveMin() { - String mavenVersionRange = "[1.0,)"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsExclusiveMin() { - String mavenVersionRange = "(1.0,)"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsExclusiveMinExclusiveMax() { - String mavenVersionRange = "(1.0,2.0)"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsInclusiveMinInclusiveMax() { - String mavenVersionRange = "[1.0,2.0]"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsInclusiveMinExclusiveMax() { - String mavenVersionRange = "[1.0,2.0)"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsValueWhenVersionTagValueSetsExclusiveMinInclusiveMax() { - String mavenVersionRange = "(1.0,2.0]"; - String minimumVersion = "1.0"; - DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(minimumVersion); - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertEquals(artifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsInclusiveLowerMaxInclusiveHigherMin() { - String mavenVersionRange = "(,1.0],[1.2,)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsExclusiveLowerMaxExclusiveHigherMin() { - String mavenVersionRange = "(,1.1),(1.1,)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsInclusiveLowerMaxExclusiveHigherMin() { - String mavenVersionRange = "(,1.1],(1.1,)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueSetsExclusiveLowerMaxInclusiveHigherMin() { - String mavenVersionRange = "(,1.1),[1.1,)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueOpenCharsCountGreaterThanCloseCharCount() { - String mavenVersionRange = "(1.0"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueOpenCharsCountLessThanCloseCharCount() { - String mavenVersionRange = "1.0)"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueDoesNotStartWithAnOpenChar() { - String mavenVersionRange = "1.0()"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueDoesNotEndWithAnCloseChar() { - String mavenVersionRange = "()1.0"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenVersionTagValueOpenAndCloseTagsNotSameWhenNoComma() { - String mavenVersionRange = "(1.0]"; - findReturnsValueWhenVersionTagValueIsSet(mavenVersionRange); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsNullWhenChildWithoutVersionAndParentWithoutVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - assertNull(new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsChildVersionWhenChildWithVersionAndParentWithoutVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - String childMavenVersion = "1"; - when(prerequisites.getMaven()).thenReturn(childMavenVersion); - DefaultArtifactVersion childArtifactVersion = new DefaultArtifactVersion(childMavenVersion); - assertEquals(childArtifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsParentVersionWhenChildWithoutVersionAndParentWithVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - when(parentMavenProject.getPrerequisites()).thenReturn(parentPrerequisites); - String parentMavenVersion = "1"; - when(parentPrerequisites.getMaven()).thenReturn(parentMavenVersion); - DefaultArtifactVersion parentArtifactVersion = new DefaultArtifactVersion(parentMavenVersion); - assertEquals(parentArtifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsChildVersionWhenChildWithMatchingVersionAndParentWithMatchingVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - String childMavenVersion = "1"; - when(prerequisites.getMaven()).thenReturn(childMavenVersion); - when(parentMavenProject.getPrerequisites()).thenReturn(parentPrerequisites); - String parentMavenVersion = "1"; - when(parentPrerequisites.getMaven()).thenReturn(parentMavenVersion); - DefaultArtifactVersion childArtifactVersion = new DefaultArtifactVersion(childMavenVersion); - assertEquals(childArtifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsChildVersionWhenChildWithHigherVersionAndParentWithLowerVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - String childMavenVersion = "2"; - DefaultArtifactVersion childArtifactVersion = new DefaultArtifactVersion(childMavenVersion); - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - when(prerequisites.getMaven()).thenReturn(childMavenVersion); - when(parentMavenProject.getPrerequisites()).thenReturn(parentPrerequisites); - String parentMavenVersion = "1"; - when(parentPrerequisites.getMaven()).thenReturn(parentMavenVersion); - assertEquals(childArtifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } - - @Test - public void findReturnsParentVersionWhenChildWithLowerVersionAndParentWithHigherVersion() { - when(mavenProject.hasParent()).thenReturn(true); - when(mavenProject.getParent()).thenReturn(parentMavenProject); - when(mavenProject.getPrerequisites()).thenReturn(prerequisites); - String childMavenVersion = "1"; - when(prerequisites.getMaven()).thenReturn(childMavenVersion); - when(parentMavenProject.getPrerequisites()).thenReturn(parentPrerequisites); - String parentMavenVersion = "2"; - when(parentPrerequisites.getMaven()).thenReturn(parentMavenVersion); - DefaultArtifactVersion parentArtifactVersion = new DefaultArtifactVersion(parentMavenVersion); - assertEquals(parentArtifactVersion, new RequiredMavenVersionFinder(mavenProject).find()); - } -} From 7b90796754a7f4a4ccf3184a4a2eb899b9fcd41d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 13:35:58 +0000 Subject: [PATCH 022/441] Bump woodstox-core from 6.2.7 to 6.2.8 Bumps [woodstox-core](https://github.com/FasterXML/woodstox) from 6.2.7 to 6.2.8. - [Release notes](https://github.com/FasterXML/woodstox/releases) - [Commits](https://github.com/FasterXML/woodstox/compare/woodstox-core-6.2.7...woodstox-core-6.2.8) --- updated-dependencies: - dependency-name: com.fasterxml.woodstox:woodstox-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6a13635d25..e4a0eda6ec 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ com.fasterxml.woodstox woodstox-core - 6.2.7 + 6.2.8 org.apache.commons From 55a39fa1e9f3ef1bfe3b540d0b2dc76a6bfbf45d Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 17 Jan 2022 14:33:55 +0100 Subject: [PATCH 023/441] use only major version (v5) of release drafter --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 8e9603bfe4..c8ac4b7e40 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -8,6 +8,6 @@ jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5.15.0 + - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d9464d63e97205f2575c2896cfc2abd52a1c7e67 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 18 Jan 2022 10:13:10 +0100 Subject: [PATCH 024/441] [maven-release-plugin] prepare release versions-maven-plugin-2.9.0 --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e4a0eda6ec..a290702454 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.9-SNAPSHOT + 2.9.0 maven-plugin Versions Maven Plugin @@ -88,7 +88,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/${project.scm.tag} - master + versions-maven-plugin-2.9.0 github @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2020-08-07T21:31:00Z + 2022-01-18T09:11:44Z @@ -373,7 +373,7 @@ src/it-repo - + From c0589f4a69afc1a53d8f2d461f621339fd0c0710 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 18 Jan 2022 10:14:02 +0100 Subject: [PATCH 025/441] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a290702454..bf325e2a7b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.9.0 + 2.9.1-SNAPSHOT maven-plugin Versions Maven Plugin @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2022-01-18T09:11:44Z + 2022-01-18T09:14:02Z From 6f6f872b6cd8daacb09aec4f08a684df112c7c9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:18:44 +0000 Subject: [PATCH 026/441] Bump maven-plugin-annotations from 3.6.2 to 3.6.4 Bumps [maven-plugin-annotations](https://github.com/apache/maven-plugin-tools) from 3.6.2 to 3.6.4. - [Release notes](https://github.com/apache/maven-plugin-tools/releases) - [Commits](https://github.com/apache/maven-plugin-tools/compare/maven-plugin-tools-3.6.2...maven-plugin-tools-3.6.4) --- updated-dependencies: - dependency-name: org.apache.maven.plugin-tools:maven-plugin-annotations dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bf325e2a7b..dffa7660c7 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.2 + 3.6.4 provided From 8bb0dc2ef17cfafdbc9dcbc93e2561fedfc996b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jan 2022 13:18:37 +0000 Subject: [PATCH 027/441] Bump maven-plugin-plugin from 3.6.2 to 3.6.4 Bumps [maven-plugin-plugin](https://github.com/apache/maven-plugin-tools) from 3.6.2 to 3.6.4. - [Release notes](https://github.com/apache/maven-plugin-tools/releases) - [Commits](https://github.com/apache/maven-plugin-tools/compare/maven-plugin-tools-3.6.2...maven-plugin-tools-3.6.4) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-plugin-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dffa7660c7..57268730fd 100644 --- a/pom.xml +++ b/pom.xml @@ -280,7 +280,7 @@ org.apache.maven.plugins maven-plugin-plugin - 3.6.2 + 3.6.4 true From 650d8823dd37c9f76fbbe5440e63333f3389c853 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:25:02 +0000 Subject: [PATCH 028/441] Bump mockito-core from 4.2.0 to 4.3.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.2.0 to 4.3.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.2.0...v4.3.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57268730fd..0190a1b401 100644 --- a/pom.xml +++ b/pom.xml @@ -255,7 +255,7 @@ org.mockito mockito-core - 4.2.0 + 4.3.0 test From c6a985c5d78b3d7f09768498f7e0fddc0f5de6cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jan 2022 13:20:28 +0000 Subject: [PATCH 029/441] Bump mockito-core from 4.3.0 to 4.3.1 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.3.0 to 4.3.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.3.0...v4.3.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0190a1b401..83bc9a9401 100644 --- a/pom.xml +++ b/pom.xml @@ -255,7 +255,7 @@ org.mockito mockito-core - 4.3.0 + 4.3.1 test From e5c2ae3e36839bcbe7999eb7e3002a3d723fb669 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 25 Jan 2022 21:27:02 +0100 Subject: [PATCH 030/441] #544 improve validation of plugin parameters: - ensure either 'properties' or 'propertiesVersionFile' is provided - fix validation of superfluous newVersion parameter --- .../java/org/codehaus/mojo/versions/SetPropertyMojo.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 49646141ef..4b6f813074 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -101,12 +101,14 @@ protected void update( ModifiedPomXMLEventReader pom ) } propertiesConfig = reader.getPropertiesConfig(); properties = reader.getProperties(); - } else { + } else if (!StringUtils.isEmpty(property)) { getLog().debug( "Reading properties and versions to update from property and newVersion " ); Property propertyConfig = new Property(property); propertyConfig.setVersion(newVersion); propertiesConfig = new Property[] { propertyConfig }; properties = property; + } else { + throw new MojoExecutionException("Please provide either 'property' or 'propertiesVersionsFile' parameter."); } update(pom, propertiesConfig, properties); } @@ -134,7 +136,7 @@ private void logWrongConfigWarning() { if (!StringUtils.isEmpty(property)) { getLog().warn("-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used"); } - if (!StringUtils.isEmpty(property)) { + if (!StringUtils.isEmpty(newVersion)) { getLog().warn("-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used"); } } From 130a4eff8b0e4a7bd1d89fa56c2a2c2263df0436 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 25 Jan 2022 23:33:24 +0100 Subject: [PATCH 031/441] #542 restore support for writing output files and add IT to cover this behavior root cause seems to be a regression in plexus-utils 3.4.0 with FileUtils.fileAppend failing to create a new file if it does not exist already^ --- pom.xml | 3 +- .../invoker.properties | 2 + .../pom.xml | 48 +++++++++++++++++++ .../verify.bsh | 40 ++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/it/it-display-dependency-updates-007-outputFile/invoker.properties create mode 100644 src/it/it-display-dependency-updates-007-outputFile/pom.xml create mode 100644 src/it/it-display-dependency-updates-007-outputFile/verify.bsh diff --git a/pom.xml b/pom.xml index 83bc9a9401..cf57562256 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,8 @@ org.codehaus.plexus plexus-utils - 3.4.1 + + 3.3.1 org.codehaus.plexus diff --git a/src/it/it-display-dependency-updates-007-outputFile/invoker.properties b/src/it/it-display-dependency-updates-007-outputFile/invoker.properties new file mode 100644 index 0000000000..d13e289a77 --- /dev/null +++ b/src/it/it-display-dependency-updates-007-outputFile/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts=-Dverbose=true -Dversions.outputFile=./dependencyUpdate.txt -DoutputEncoding=UTF-8 \ No newline at end of file diff --git a/src/it/it-display-dependency-updates-007-outputFile/pom.xml b/src/it/it-display-dependency-updates-007-outputFile/pom.xml new file mode 100644 index 0000000000..40d17f587a --- /dev/null +++ b/src/it/it-display-dependency-updates-007-outputFile/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + localhost + it-display-dependency-updates-007-outputFile + 1.0 + pom + display-dependency-updates + http://localhost/ + + + localhost + dummy-api + 1.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-007-outputFile/verify.bsh b/src/it/it-display-dependency-updates-007-outputFile/verify.bsh new file mode 100644 index 0000000000..96fc5f3e24 --- /dev/null +++ b/src/it/it-display-dependency-updates-007-outputFile/verify.bsh @@ -0,0 +1,40 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + + Pattern p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" ); + Matcher m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-api to version 3.0" ); + return false; + } + System.out.println( m.group( 0 ) ); + + // validate outputFile + File outputFile = new File( basedir, "dependencyUpdate.txt" ); + if (!outputFile.exists()) { + System.out.println( "outputFile not found: " + outputFile.getPath() ); + return false; + } + buf = FileUtils.fileRead( file ); + Matcher m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-api to version 3.0 in outputFile" ); + return false; + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; From c63ee83e0857b634d14b9c0fc4036a3a3d4c77a8 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 26 Jan 2022 22:31:53 +0100 Subject: [PATCH 032/441] #543 add back support for multiple property names separates by "," (#546) --- src/it/it-set-property-001/verify.bsh | 4 +- src/it/it-set-property-002/verify.bsh | 2 +- .../invoker.properties | 2 + .../pom.xml | 53 +++++++++++++++++++ .../verify.bsh | 26 +++++++++ .../mojo/versions/SetPropertyMojo.java | 12 +++-- 6 files changed, 93 insertions(+), 6 deletions(-) create mode 100644 src/it/it-set-property-003-multiple-properties/invoker.properties create mode 100644 src/it/it-set-property-003-multiple-properties/pom.xml create mode 100644 src/it/it-set-property-003-multiple-properties/verify.bsh diff --git a/src/it/it-set-property-001/verify.bsh b/src/it/it-set-property-001/verify.bsh index e655d3a87a..2ff1f7090e 100644 --- a/src/it/it-set-property-001/verify.bsh +++ b/src/it/it-set-property-001/verify.bsh @@ -8,12 +8,12 @@ try if ( buf.indexOf( "1.2.3-SNAPSHOT" ) < 0 ) { - System.err.println( "versionModule has been changed which should not happened." ); + System.err.println( "versionModule has been changed which should not happen." ); return false; } if ( buf.indexOf( "9.5.0-20170604.123223-2" ) < 0 ) { - System.err.println( "versionModuleTest has been changed which should not happen." ); + System.err.println( "versionModuleTest has not been changed which should not happen." ); return false; } } diff --git a/src/it/it-set-property-002/verify.bsh b/src/it/it-set-property-002/verify.bsh index 05511930cb..51f180ed6e 100644 --- a/src/it/it-set-property-002/verify.bsh +++ b/src/it/it-set-property-002/verify.bsh @@ -8,7 +8,7 @@ try if ( buf.indexOf( "9.5.0-20170604.123456-2" ) < 0 ) { - System.err.println( "versionModule has not been changed which should not happened." ); + System.err.println( "versionModule has not been changed which should not happen." ); return false; } if ( buf.indexOf( "1.2.3-SNAPSHOT" ) < 0 ) diff --git a/src/it/it-set-property-003-multiple-properties/invoker.properties b/src/it/it-set-property-003-multiple-properties/invoker.properties new file mode 100644 index 0000000000..094e5f7425 --- /dev/null +++ b/src/it/it-set-property-003-multiple-properties/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set-property +invoker.mavenOpts=-Dproperty=versionModule,versionModuleTest -DnewVersion=9.5.0-20170604.123456-2 \ No newline at end of file diff --git a/src/it/it-set-property-003-multiple-properties/pom.xml b/src/it/it-set-property-003-multiple-properties/pom.xml new file mode 100644 index 0000000000..c64c227187 --- /dev/null +++ b/src/it/it-set-property-003-multiple-properties/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + localhost + it-set-property-003-multiple-properties + 1.0 + pom + + set-property based on issue-543 + set-property goal to be able to set a multiple properties separated by "," + + 1.2.3-SNAPSHOT + 1.2.3-SNAPSHOT + + + + + test.package + module + ${versionModule} + + + test.package + moduleTest + ${versionModuleTest} + + + + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + diff --git a/src/it/it-set-property-003-multiple-properties/verify.bsh b/src/it/it-set-property-003-multiple-properties/verify.bsh new file mode 100644 index 0000000000..9454365151 --- /dev/null +++ b/src/it/it-set-property-003-multiple-properties/verify.bsh @@ -0,0 +1,26 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "pom.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "9.5.0-20170604.123456-2" ) < 0 ) + { + System.err.println( "versionModule has not been changed which should not happen." ); + return false; + } + if ( buf.indexOf( "9.5.0-20170604.123456-2" ) < 0 ) + { + System.err.println( "versionModuleTest has not been changed which should not happen." ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 4b6f813074..0ef7c64fba 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamException; import java.io.IOException; +import java.util.Arrays; import java.util.Map; /** @@ -50,6 +51,7 @@ public class SetPropertyMojo /** * A property to update. + * You can also specify multiple property names separated by "," which are all set to the same new version. */ @Parameter( property = "property" ) private String property = null; @@ -103,9 +105,13 @@ protected void update( ModifiedPomXMLEventReader pom ) properties = reader.getProperties(); } else if (!StringUtils.isEmpty(property)) { getLog().debug( "Reading properties and versions to update from property and newVersion " ); - Property propertyConfig = new Property(property); - propertyConfig.setVersion(newVersion); - propertiesConfig = new Property[] { propertyConfig }; + propertiesConfig = Arrays.stream(StringUtils.split(property, ",")) + .map(prp -> { + Property propertyConfig = new Property(prp); + propertyConfig.setVersion(newVersion); + return propertyConfig; + }) + .toArray(size -> new Property[size]); properties = property; } else { throw new MojoExecutionException("Please provide either 'property' or 'propertiesVersionsFile' parameter."); From dbdef5beb5a8a8c6e2db3e646cc6400afa1aa4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gw=C3=A9na=C3=ABl=20Ruelland?= <5782559+sultan@users.noreply.github.com> Date: Wed, 26 Jan 2022 22:43:41 +0100 Subject: [PATCH 033/441] Fixed regression in the maven site rendering (#537) Fixed #536 : Regression in the maven site rendering due to Doxia change to HTML 5 --- .../mojo/versions/AbstractVersionsReportRenderer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index 0931a46457..b7bca23459 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -97,16 +97,12 @@ public String getText( String key ) protected void renderWarningIcon() { - sink.figure(); sink.figureGraphics( "images/icon_warning_sml.gif" ); - sink.figure_(); } protected void renderSuccessIcon() { - sink.figure(); sink.figureGraphics( "images/icon_success_sml.gif" ); - sink.figure_(); } protected boolean equals( ArtifactVersion v1, ArtifactVersion v2 ) From 619d36cb77e29b64193ee62587dccd84a20a6315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Wed, 2 Feb 2022 07:58:45 +0100 Subject: [PATCH 034/441] update Maven Central badge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68d7040868..aaf2a4a62d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is the [versions-maven-plugin](http://www.mojohaus.org/versions-maven-plugin/). [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/mojohaus/versions-maven-plugin.svg?label=License)](http://www.apache.org/licenses/) -[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/versions-maven-plugin.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.mojo%22%20AND%20a%3A%22versions-maven-plugin%22) +[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/versions-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.mojo/versions-maven-plugin) [![Build Status](https://github.com/mojohaus/versions-maven-plugin/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/mojohaus/versions-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) From 82c6e1cd7627b1454b97fac5104b06d8cae1e046 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 26 Jan 2022 23:08:45 +0100 Subject: [PATCH 035/441] #538 switch to non-deprecated ModelInterpolator --- .../versions/DisplayPluginUpdatesMojo.java | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 7ed7ca4b2f..9e6f64f37d 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -36,11 +36,17 @@ import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.mapping.LifecycleMapping; +import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Prerequisites; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblem.Severity; +import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.interpolation.ModelInterpolator; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.plugin.MojoExecutionException; @@ -56,8 +62,6 @@ import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.project.interpolation.ModelInterpolationException; -import org.apache.maven.project.interpolation.ModelInterpolator; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -716,35 +720,29 @@ private Map getParentsPlugins( List parents ) StringWriter writer = new StringWriter(); boolean havePom = false; Model interpolatedModel; + + Model originalModel = parentProject.getOriginalModel(); + if ( originalModel == null ) + { + getLog().warn( "project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" + + parentProject.getArtifactId() + ":" + parentProject.getVersion() + + " is null, substituting project.getModel()" ); + originalModel = parentProject.getModel(); + } try { - Model originalModel = parentProject.getOriginalModel(); - if ( originalModel == null ) - { - getLog().warn( "project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" - + parentProject.getArtifactId() + ":" + parentProject.getVersion() - + " is null, substituting project.getModel()" ); - originalModel = parentProject.getModel(); - } - try - { - new MavenXpp3Writer().write( writer, originalModel ); - writer.close(); - havePom = true; - } - catch ( IOException e ) - { - // ignore - } - interpolatedModel = - modelInterpolator.interpolate( originalModel, null, - new DefaultProjectBuilderConfiguration().setExecutionProperties( getProject().getProperties() ), - false ); + new MavenXpp3Writer().write( writer, originalModel ); + writer.close(); + havePom = true; } - catch ( ModelInterpolationException e ) + catch ( IOException e ) { - throw new MojoExecutionException( e.getMessage(), e ); + // ignore } + ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); + modelBuildingRequest.setUserProperties(getProject().getProperties()); + interpolatedModel = modelInterpolator.interpolateModel( originalModel, null, + modelBuildingRequest, new IgnoringModelProblemCollector() ); if ( havePom ) { try @@ -1477,18 +1475,11 @@ private Set getProjectPlugins( Map superPomPluginManagem debugVersionMap( "final aggregate version map", excludePluginManagement ); - Model originalModel; - try - { - originalModel = - modelInterpolator.interpolate( getProject().getOriginalModel(), getProject().getBasedir(), - new DefaultProjectBuilderConfiguration().setExecutionProperties( getProject().getProperties() ), - true ); - } - catch ( ModelInterpolationException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } + ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); + modelBuildingRequest.setUserProperties(getProject().getProperties()); + Model originalModel = modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), + modelBuildingRequest, new IgnoringModelProblemCollector() ); + try { addProjectPlugins( plugins, originalModel.getBuild().getPluginManagement().getPlugins(), @@ -1800,4 +1791,12 @@ private static int compare( ArtifactVersion a, ArtifactVersion b ) { return a.compareTo( b ); } + + private static class IgnoringModelProblemCollector implements ModelProblemCollector { + @Override + public void add(Severity severity, String message, InputLocation location, Exception cause) { + // ignore + } + } + } From eaa25e65e135e8e6156ea224cd4d54cede6a88d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:22:01 +0000 Subject: [PATCH 036/441] Bump modello-maven-plugin from 1.11 to 2.0.0 Bumps [modello-maven-plugin](https://github.com/codehaus-plexus/modello) from 1.11 to 2.0.0. - [Release notes](https://github.com/codehaus-plexus/modello/releases) - [Commits](https://github.com/codehaus-plexus/modello/compare/modello-1.11...modello-2.0.0) --- updated-dependencies: - dependency-name: org.codehaus.modello:modello-maven-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf57562256..fbcf2c4687 100644 --- a/pom.xml +++ b/pom.xml @@ -273,7 +273,7 @@ org.codehaus.modello modello-maven-plugin - 1.11 + 2.0.0 From e5d77b88e91a83d6770155d4b406e87ede460d98 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Feb 2022 15:10:10 +0000 Subject: [PATCH 037/441] Bump maven-reporting-impl from 3.0.0 to 3.1.0 Bumps [maven-reporting-impl](https://github.com/apache/maven-reporting-impl) from 3.0.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-reporting-impl/releases) - [Commits](https://github.com/apache/maven-reporting-impl/commits/maven-reporting-impl-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-impl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fbcf2c4687..a2af678050 100644 --- a/pom.xml +++ b/pom.xml @@ -172,7 +172,7 @@ org.apache.maven.reporting maven-reporting-impl - 3.0.0 + 3.1.0 org.apache.maven.shared From 8aa57f237550992c455b8e389947ce70352b6b65 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:23:29 +0000 Subject: [PATCH 038/441] Bump maven-reporting-api from 3.0 to 3.1.0 Bumps [maven-reporting-api](https://github.com/apache/maven-reporting-api) from 3.0 to 3.1.0. - [Release notes](https://github.com/apache/maven-reporting-api/releases) - [Commits](https://github.com/apache/maven-reporting-api/compare/maven-reporting-api-3.0...maven-reporting-api-3.1.0) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a2af678050..41fe6d893d 100644 --- a/pom.xml +++ b/pom.xml @@ -167,7 +167,7 @@ org.apache.maven.reporting maven-reporting-api - 3.0 + 3.1.0 org.apache.maven.reporting From 79d94af3d7958a5f50fb845e3a8503d55126a72d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 13:26:13 +0000 Subject: [PATCH 039/441] Bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 01babff858..9ee27d6e29 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -32,7 +32,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-java@v2 with: distribution: ${{ matrix.jdk }} From c5f4a7a828e1ffe9f04db959fe54db1644b927dd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Mar 2022 13:19:09 +0000 Subject: [PATCH 040/441] Bump mockito-core from 4.3.1 to 4.4.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.3.1 to 4.4.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.3.1...v4.4.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 41fe6d893d..95ed6e29ee 100644 --- a/pom.xml +++ b/pom.xml @@ -256,7 +256,7 @@ org.mockito mockito-core - 4.3.1 + 4.4.0 test From 50e624a20ab1b18305168917eb0a3b019615e857 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Sat, 19 Feb 2022 23:46:03 +0000 Subject: [PATCH 041/441] Maven Wrapper v3.1.0 with Maven v3.8.4 --- .mvn/wrapper/MavenWrapperDownloader.java | 117 ------- .mvn/wrapper/maven-wrapper.jar | Bin 50710 -> 58727 bytes .mvn/wrapper/maven-wrapper.properties | 18 +- mvnw | 18 +- mvnw.cmd | 370 ++++++++++++----------- mvnwDebug | 35 +++ mvnwDebug.cmd | 44 +++ 7 files changed, 296 insertions(+), 306 deletions(-) delete mode 100644 .mvn/wrapper/MavenWrapperDownloader.java create mode 100755 mvnwDebug create mode 100644 mvnwDebug.cmd diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index b901097f2d..0000000000 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index 2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054..c1dd12f17644411d6e840bd5a10c6ecda0175f18 100644 GIT binary patch literal 58727 zcmb5W18`>1vNjyPv28mO+cqb*Z6_1kwr$(?#I}=(ZGUs`Jr}3`|DLbDUA3!L?dtC8 zUiH*ktDo+@6r@4HP=SCTA%WmZqm^Ro`Ls)bfPkcdfq?#g1(Fq27W^S8Cq^$TC?_c< zs-#ROD;6C)1wFuk7<3)nGuR^#!H;n&3*IjzXg+s8Z_S!!E0jUq(`}Itt=YdYa5Z_s z&e>2={87knpF*PKNzU;lsbk#P(l^WBvb$yEz)z+nYH43pKodrDkMp@h?;n{;K}hl>Fb^ zqx}C0|D7kg|Cj~3f7hn_zkAE}|6t|cZT|S5Hvb#3nc~C14u5UI{6#F<|FkJ0svs&S zA}S{=DXLT*BM1$`2rK%`D@vEw9l9%*=92X_2g?Fwfi=6Zfpr7+<~sgP#Bav+Df2ts zwtu~70zhqV?mrzM)}r7mMS`Hk_)NrI5K%CTtQtDxqw5iv5F0!ksIon{qqpPVnU?ds zN$|Vm{MHKEReUy>1kVfT-$3))Js0p2W_LFy3cjjZ7za0R zPdBH>y&pb0vr1|ckDpt2p$IQhwnPs5G*^b-y}sg4W!ALn}a`pY0JIa$H0$eV2T8WjWD= zWaENacQhlTyK4O!+aOXBurVR2k$eb8HVTCxy-bcHlZ4Xr!`juLAL#?t6|Ba!g9G4I zSwIt2Lla>C?C4wAZ8cKsZl9-Yd3kqE`%!5HlGdJJaFw0mu#--&**L-i|BcIdc3B$;0FC;FbE-dunVZ; zdIQ=tPKH4iJQQ=$5BeEMLov_Hn>gXib|9nOr}>eZt@B4W^m~>Zp#xhn1dax+?hS!AchWJ4makWZs@dQUeXQ zsI2+425_{X@t2KN zIbqec#)Jg5==VY3^YBeJ2B+%~^Y8|;F!mE8d(`UgNl2B9o>Ir5)qbBr)a?f%nrP zQyW(>FYPZjCVKDOU;Bw#PqPF1CCvp)dGdA&57a5hD&*vIc)jA)Z-!y5pS{5W6%#prH16zgD8s zexvpF#a|=*acp>L^lZ(PT)GiA8BJL-9!r8S$ZvXRKMVtiGe`+!@O%j<1!@msc177U zTDy>WOZu)W5anPrweQyjIu3IJC|ngdjZofGbdW&oj^DJlC7$;|xafB45evT|WBgGf-b|9y0J`fe0W-vw6xh}` z=(Tnq(-K0O{;VUcKe2y63{HXc+`R_#HLwnZ0rzWO*b#VeSuC4NG!H_ApCypbt1qx( z6y7Q$5(JOpQ&pTkc^0f}A0Kq*?;g9lEfzeE?5e2MBNZB)^8W1)YgdjsVyN+I9EZlh z3l}*}*)cFl=dOq|DvF=!ui$V%XhGQ%bDn3PK9 zV%{Y|VkAdt^d9~y4laGDqSwLd@pOnS&^@sI7}YTIb@El1&^_sq+{yAGf0|rq5TMp# z6d~;uAZ(fY3(eH=+rcbItl2=u6mf|P{lD4kiRCv;>GtFaHR3gim?WU9RjHmFZLm+m z+j<}_exaOQ1a}=K#voc~En+Mk_<(L!?1e#Uay~|H5q)LjD*yE6xFYQ-Wx{^iH1@pP zC0De#D6I26&W{;J40sZB!=%{c?XdO?YQvnTMA3TwfhAm@bvkX*(x?JTs*dFDv^=2X z284}AK)1nRn+8(Q2P?f)e>0~;NUI9%p%fnv1wBVpoXL+9OE`Vv1Y7=+nub$o7AN>y zB?R(^G8PYcMk4bxe7XItq@48QqWKb8fa*i9-N)=wdU-Q^=}!nFgTr_uT=Z=9pq z`{7!$U|+fnXFcsJ4GNm3JQQCN+G85k$)ZLhF{NbIy{REj84}Zt;0fe#>MARW)AoSb zrBpwF37ZVBMd>wZn_hAadI*xu8)Y#`aMbwRIA2n^-OS~M58_@j?#P1|PXJ1XBC9{4 zT^8*|xu<@(JlSOT*ILrVGr+7$nZN`Z3GxJJO@nY&mHsv^^duAh*lCu5q+S6zWA+`- z%^*y#)O7ko_RwGJl;bcEpP03FOrhlLWs`V_OUCrR-g>NJz*pN|itmN6O@Hw05Zq;Xtif%+sp4Py0{<7<^c zeoHHhRq>2EtYy9~2dZywm&OSk`u2ECWh6dJY?;fT-3-$U`!c(o$&hhPC%$~fT&bw3 zyj+8aXD;G!p*>BC6rpvx#6!|Qaic;KEv5>`Y+R(6F^1eIeYG6d1q3D3OL{7%7iw3R zwO)W7gMh27ASSB>-=OfP(YrKqBTNFv4hL@Im~~ombbSu44p~VoH$H-6+L_JW>Amkl zhDU~|r77?raaxD!-c$Ta?WAAi{w3T}YV=+S?1HQGC0+{Bny_^b+4Jum}oW4c=$ z#?D<}Ds{#d5v`L`${Pee;W84X*osNQ96xsKp^EAzuUh9#&zDX=eqdAp$UY)EGrkU% z(6m35n=46B$TNnejNSlih_!<)Iu@K!PW5S@Ya^0OK+EMWM=1w=GUKW^(r59U%i?d zzbo?|V4tDWGHHsrAQ}}ma#<`9r=M8%XF#%a=@Hn(p3wFBlkZ2L@8=*@J-^zuyF0aN zzJ7f!Jf8I+^6Tt$e+IIh zb80@?7y#Iz3w-0VEjgbHurqI>$qj<@n916)&O340!_5W9DtwR)P5mk6v2ljyK*DG5 zYjzE~m`>tq8HYXl%1JJ%e-%BqV4kRdPUZB1Cm$BQZr(fzp_@rn_W+;GwI$?L2Y4;b z)}c5D$#LT}2W8Si<`EHKIa_X+>+2PF(C*u~F=8E!jL(=IdQxY40%|( zoNg2Z&Aob@LEui-lJ#@)Ts)tE0_!*3{Uk)r{;-IZpX`N4mZX`#E|A;viQWImB6flI z?M_|xHCXV$5LOY-!U1_O1k;OWa=EchwlDCK4xHwBW2jE-6&%}og+9NILu${v10Z^Z#* zap|)B9a-AMU~>$r)3&|dQuP#MA$jnw54w*Ax~*_$iikp+j^OR8I5Fo<_UR#B-c>$? zeg)=;w^sGeAMi<3RGDRj$jA30Qq$e|zf2z;JyQ}tkU)ZI_k6tY%(`#AvL)p)iYXUy z5W9Su3NJ8mVyy)WqzFSk&vZM!;kUh8dVeA-myqcV%;xUne`PbHCPpvH?br`U2Y&dM zV!nJ!^n%`!H&!QSlpzLWnZpgi;#P0OAleH+<CfLa?&o|kyw1}W%6Pij zp$Vv5=;Z0LFN|j9i&9>zqX>*VnV3h#>n!2L?5gO6HJS3~kpy5G zYAVPMaB-FJOk3@OrxL(*-O~OB9^d{!G0K>wlzXuBm*$&%p1O#6SQ*?Q0CETLQ->XpfkW7< zj&Nep(}eAH1u$wWFvLV*lA{JOltP_%xKXC*a8DB&;{fD&2bATy>rC^kFY+$hFS7us;Y) zy_H?cv9XTHYz<4C<0b`WKC#{nJ15{F=oaq3x5}sYApT?Po+(Cmmo#dHZFO^{M#d~d znRT=TFATGVO%z_FNG-@G;9az|udZ>t@5l+A-K)BUWFn_|T#K3=d3EXRNqHyi#>;hX z*JQ`pT3#&tH>25laFlL6Rllu(seA*OboEd%rxMtz3@5v-+{qDP9&BcoS$2fgjgvp$ zc8!3=p0p@Ee1$u{Gg}Kkxg@M*qgZfYLlnD88{uwG1T?zxCbBR+x(RK$JB(eWJH#~; zZoY6L+esVRV?-*QmRCG}h`rB*Lv=uE%URF@+#l-g!Artx>Y9D;&G=jY2n2`J z{6-J%WX~Glx*QBmOOJ(RDRIzhfk&ibsm1t&&7aU{1P3U0uM%F2zJb4~50uby_ng+# zN)O9lK=dkJpxsUo7u8|e`Y~mmbxOTDn0i!i;d;ml#orN(Lc=j+n422NoSnlH6?0<0?th-qB7u}`5My%#?ES}>@RldOQz}WILz<$+cN~&ET zwUI01HCB((TyU$Ej8bxsE8oLmT-c7gA1Js?Iq`QMzIHV|)v)n2 zT_L(9x5%8*wU(C`VapaHoicWcm|0X@9TiNtbc|<4N6_H1F6&qgEEj=vjegFt;hC7- zLG7_=vedRFZ6Chbw!{#EpAlM?-sc#pc<~j#537n)M%RT)|L}y(ggi_-SLpsE3qi3V z=EEASxc>a{Su)jXcRS41Z@Mxk&0B7B<(?Izt5wpyyIBO|-M}ex8BhbIgi*X4 zDZ+Yk1<6&=PoZ=U-!9`!?sBVpYF#Y!JK<`fx}bXN651o0VVaW;t6ASVF@gq-mIDV_)?F^>rq1XX0NYy~(G=I6x%Fi5C2rMtvs z%P`g2>0{xLUy~#ye)%QAz^NkD5GUyPYl}K#;e-~UQ96`I$U0D!sMdQ>;%+c0h>k*Y z)sD1mi_@|rZnQ+zbWq~QxFlBQXj8WEY7NKaOYjUxAkGB8S#;l@b^C?;twRKl=mt0< zazifrBs`(q7_r14u1ZS`66VmsLpV>b5U!ktX>g4Nq~VPq6`%`3iCdr(>nS~uxxylU z>h(2p$XPJVh9BDpRLLzTDlNdp+oq8sOUlJ#{6boG`k)bwnsw5iy@#d{f_De-I|}vx6evw;ch97=;kLvM)-DBGwl6%fA%JItoMeyqjCR*_5Q70yd!KN zh=>ek8>f#~^6CJR0DXp0;7ifZjjSGBn}Cl{HeX!$iXMbtAU$F+;`%A<3TqbN#PCM& z&ueq$cB%pu2oMm_-@*aYzgn9`OiT@2ter*d+-$Aw42(@2Ng4mKG%M-IqX?q%3R|_( zN|&n$e1L#Ev=YMX5F53!O%))qDG3D(0rsOHblk;9ghWyqEOpg)mC$OduqpHAuIxr_>*|zy+|=EmOFn zFM+Ni%@CymLS-3vRWn=rVk?oZEz0V#y356IE6HR5#>7EigxZ05=cA|4<_tC8jyBJ| zgg!^kNwP7S^ooIj6riI9x`jFeQfRr4JCPumr<82M zto$j^Qb~MPmJ-|*2u{o7?yI8BI``zDaOCg2tG_5X;w<|uj5%oDthnLx-l4l)fmUGx z6N^jR|DC);yLi4q-ztTkf>*U$@2^w5(lhxu=OC|=WuTTp^!?2Nn27R`2FY_ zLHY-zFS}r+4|XyZw9b0D3)DmS!Gr+-LSdI}m{@-gL%^8CFSIYL?UZaCVd)2VI3|ay zwue39zshVrB+s2lp*};!gm<79@0HkjhgF^>`UhoR9Mi`aI#V#fI@x&1K3f&^8kaq% zkHVg$CTBoaGqEjrL)k*Y!rtiD2iQLYZ%|B}oBl8GHvR%n>HiIQN*+$mCN>I=c7H2N z&K4$4e@E^ff-cVHCbrHNMh4Dy|2Q;M{{xu|DYjeaRh2FK5QK!bG_K`kbBk$l$S4UF zq?F-%7UrX_Q?9M)a#WvcZ^R-fzJB5IFP>3uEoeCAAhN5W-ELRB&zsCnWY6#E?!)E56Pe+bxHjGF6;R9Hps)+t092-bf4 z_Wieg+0u5JL++k)#i0r?l`9*k)3ZlHOeMJ1DTdx9E1J2@BtdD3qX;&S_wMExOGv$T zl^T%oxb+)vq6vJvR`8{+YOsc@8}wSXpoK%v0k@8X*04Se3<8f)rE|fRXAoT!$6MdrKSuzeK@L*yug?MQs8oTbofqW)Df# zC2J3irHAaX_e~SGlBoRhEW`W6Z}&YX|5IMfzskAt{B*m z*w=3i!;x5Gfgc~>y9fPXFAPMhO@Si}SQESjh`P|dlV5HPRo7j(hV=$o8UMIT7~7+k z*@Sd>f%#{ARweJYhQs~ECpHie!~YXL|FJA;KS4m|CKFnT{fN`Ws>N?CcV@(>7WMPYN} z1}Wg+XU2(Yjpq7PJ|aSn;THEZ{4s8*@N!dz&bjys_Zk7%HiD+56;cF26`-a zEIo!B(T|L*uMXUvqJs&54`^@sUMtH-i~rOM9%$xGXTpmow$DxI>E5!csP zAHe|);0w%`I<==_Zw9t$e}?R+lIu%|`coRum(1p~*+20mBc?Z=$+z<0n&qS0-}|L4 zrgq|(U*eB%l3nfC=U1Y?(Tf@0x8bhdtsU2w&Y-WvyzkiyJ>GZqUP6c+<_p0`ZOnIK z#a~ynuzRWxO6c;S@*}B1pTjLJQHi(+EuE2;gG*p^Fq%6UoE1x95(^BY$H$$soSf=vpJ)_3E zp&$l=SiNaeoNLAK8x%XaHp3-So@F7 z3NMRRa@%k+Z$a%yb25ud&>Cdcb<+}n>=jZ`91)a z{wcA(j$%z#RoyB|&Z+B4%7Pe*No`pAX0Y;Ju4$wvJE{VF*Qej8C}uVF=xFpG^rY6Y+9mcz$T9^x(VP3uY>G3Zt&eU{pF*Bu<4j9MPbi4NMC=Z$kS6DMW9yN#vhM&1gd1t}8m(*YY9 zh2@s)$1p4yYT`~lYmU>>wKu+DhlnI1#Xn4(Rnv_qidPQHW=w3ZU!w3(@jO*f;4;h? zMH0!08(4=lT}#QA=eR(ZtW1=~llQij7)L6n#?5iY_p>|_mLalXYRH!x#Y?KHyzPB^ z6P3YRD}{ou%9T%|nOpP_??P;Rmra7$Q*Jz-f?42PF_y>d)+0Q^)o5h8@7S=je}xG# z2_?AdFP^t{IZHWK)9+EE_aPtTBahhUcWIQ7Awz?NK)ck2n-a$gplnd4OKbJ;;tvIu zH4vAexlK2f22gTALq5PZ&vfFqqERVT{G_d`X)eGI%+?5k6lRiHoo*Vc?ie6dx75_t z6hmd#0?OB9*OKD7A~P$e-TTv3^aCdZys6@`vq%Vi_D8>=`t&q9`Jn1=M#ktSC>SO3 z1V?vuIlQs6+{aHDHL?BB&3baSv;y#07}(xll9vs9K_vs2f9gC9Biy+9DxS77=)c z6dMbuokO-L*Te5JUSO$MmhIuFJRGR&9cDf)@y5OQu&Q$h@SW-yU&XQd9;_x;l z<`{S&Hnl!5U@%I~5p)BZspK894y7kVQE7&?t7Z|OOlnrCkvEf7$J5dR?0;Jt6oANc zMnb_Xjky|2ID#fhIB2hs-48Er>*M?56YFnjC)ixiCes%fgT?C|1tQupZ0Jon>yr|j z6M66rC(=;vw^orAMk!I1z|k}1Ox9qOILGJFxU*ZrMSfCe?)wByP=U73z+@Pfbcndc=VzYvSUnUy z+-B+_n`=f>kS8QBPwk+aD()=#IqkdxHPQMJ93{JGhP=48oRkmJyQ@i$pk(L&(p6<0 zC9ZEdO*i+t`;%(Ctae(SjV<@i%r5aune9)T4{hdzv33Uo9*K=V18S$6VVm^wgEteF za0zCLO(9~!U9_z@Qrh&rS|L0xG}RWoE1jXiEsrTgIF4qf#{0rl zE}|NGrvYLMtoORV&FWaFadDNCjMt|U8ba8|z&3tvd)s7KQ!Od*Kqe(48&C7=V;?`SQV)Qc?6L^k_vNUPbJ>>!5J?sDYm5kR&h_RZk)MfZ1 znOpQ|T;Me(%mdBJR$sbEmp3!HKDDSmMDnVpeo{S13l#9e6OImR$UPzjd-eCwmMwyT zm5~g6DIbY<_!8;xEUHdT(r_OQ<6QCE9Jy|QLoS>d(B zW6GRzX)~&Mx}})ITysFzl5_6JM*~ciBfVP(WF_r zY>z4gw&AxB%UV3Y{Y6z*t*o!p@~#u3X_t{Q9Us8ar8_9?N% zN&M~6y%2R(mAZ~@Tg1Oapt?vDr&fHuJ=V$wXstq|)eIG_4lB#@eU>fniJh zwJY<8yH5(+SSQ=$Y=-$2f$@^Ak#~kaR^NYFsi{XGlFCvK(eu{S$J(owIv17|p-%0O zL-@NyUg!rx0$Uh~JIeMX6JJE>*t<7vS9ev#^{AGyc;uio_-Je1?u#mA8+JVczhA2( zhD!koe;9$`Qgaxlcly4rdQ1VlmEHUhHe9TwduB+hm3wH2o27edh?|vrY{=;1Doy4& zIhP)IDd91@{`QQqVya(ASth4}6OY z-9BQj2d-%+-N7jO8!$QPq%o$9Fy8ja{4WT$gRP+b=Q1I48g-g|iLNjbhYtoNiR*d- z{sB}~8j*6*C3eM8JQj5Jn?mD#Gd*CrVEIDicLJ-4gBqUwLA-bp58UXko;M|ql+i5` zym-&U5BIS9@iPg#fFbuXCHrprSQKRU0#@yd%qrX1hhs*85R}~hahfFDq=e@bX))mf zWH%mXxMx|h5YhrTy;P_Xi_IDH*m6TYv>|hPX*_-XTW0G9iu!PqonQneKKaCVvvF^% zgBMDpN7!N?|G5t`v{neLaCFB{OyIl>qJQ_^0MJXQ zY2%-si~ej?F^%ytIIHU(pqT+3d+|IQ{ss#!c91R{2l*00e3ry!ha|XIsR%!q=E^Fal`6Oxu`K0fmPM?P6ZgzH7|TVQhl;l2 z)2w0L9CsN-(adU5YsuUw19OY_X69-!=7MIJ^(rUNr@#9l6aB8isAL^M{n2oD0FAHk97;X* z-INjZ5li`a|NYNt9gL2WbKT!`?%?lB^)J)9|025nBcBtEmWBRXQwi21EGg8>!tU>6Wf}S3p!>7vHNFSQR zgC>pb^&OHhRQD~7Q|gh5lV)F6i++k4Hp_F2L2WrcxH&@wK}QgVDg+y~o0gZ=$j&^W zz1aP8*cvnEJ#ffCK!Kz{K>yYW`@fc8ByF9X4XmyIv+h!?4&$YKl*~`ToalM{=Z_#^ zUs<1Do+PA*XaH;&0GW^tDjrctWKPmCF-qo7jGL)MK=XP*vt@O4wN1Y!8o`{DN|Rh) znK?nvyU&`ATc@U*l}=@+D*@l^gYOj&6SE|$n{UvyPwaiRQ_ua2?{Vfa|E~uqV$BhH z^QNqA*9F@*1dA`FLbnq;=+9KC@9Mel*>6i_@oVab95LHpTE)*t@BS>}tZ#9A^X7nP z3mIo+6TpvS$peMe@&=g5EQF9Mi9*W@Q`sYs=% z`J{3llzn$q;2G1{N!-#oTfQDY`8>C|n=Fu=iTk443Ld>>^fIr4-!R3U5_^ftd>VU> zij_ix{`V$I#k6!Oy2-z#QFSZkEPrXWsYyFURAo`Kl$LkN>@A?_);LE0rZIkmjb6T$ zvhc#L-Cv^4Ex*AIo=KQn!)A4;7K`pu-E+atrm@Cpmpl3e>)t(yo4gGOX18pL#xceU zbVB`#5_@(k{4LAygT1m#@(7*7f5zqB)HWH#TCrVLd9}j6Q>?p7HX{avFSb?Msb>Jg z9Q9DChze~0Psl!h0E6mcWh?ky! z$p#@LxUe(TR5sW2tMb#pS1ng@>w3o|r~-o4m&00p$wiWQ5Sh-vx2cv5nemM~Fl1Pn z@3ALEM#_3h4-XQ&z$#6X&r~U-&ge+HK6$)-`hqPj0tb|+kaKy*LS5@a9aSk!=WAEB z7cI`gaUSauMkEbg?nl0$44TYIwTngwzvUu0v0_OhpV;%$5Qgg&)WZm^FN=PNstTzW z5<}$*L;zrw>a$bG5r`q?DRc%V$RwwnGIe?m&(9mClc}9i#aHUKPLdt96(pMxt5u`F zsVoku+IC|TC;_C5rEU!}Gu*`2zKnDQ`WtOc3i#v}_9p>fW{L4(`pY;?uq z$`&LvOMMbLsPDYP*x|AVrmCRaI$UB?QoO(7mlBcHC};gA=!meK)IsI~PL0y1&{Dfm6! zxIajDc1$a0s>QG%WID%>A#`iA+J8HaAGsH z+1JH=+eX5F(AjmZGk|`7}Gpl#jvD6_Z!&{*kn@WkECV-~Ja@tmSR|e_L@9?N9 z3hyyry*D0!XyQh_V=8-SnJco#P{XBd1+7<5S3FA)2dFlkJY!1OO&M7z9uO?$#hp8K z><}uQS-^-B;u7Z^QD!7#V;QFmx0m%{^xtl3ZvPyZdi;^O&c;sNC4CHxzvvOB8&uHl zBN;-lu+P=jNn`2k$=vE0JzL{v67psMe_cb$LsmVfxA?yG z^q7lR00E@Ud3)mBPnT0KM~pwzZiBREupva^PE3~e zBgQ9oh@kcTk2)px3Hv^VzTtMzCG?*X(TDZ1MJ6zx{v- z;$oo46L#QNjk*1przHSQn~Ba#>3BG8`L)xla=P{Ql8aZ!A^Z6rPv%&@SnTI7FhdzT z-x7FR0{9HZg8Bd(puRlmXB(tB?&pxM&<=cA-;RT5}8rI%~CSUsR^{Dr%I2WAQghoqE5 zeQ874(T`vBC+r2Mi(w`h|d zA4x%EfH35I?h933@ic#u`b+%b+T?h=<}m@x_~!>o35p|cvIkkw07W=Ny7YcgssA_^ z|KJQrnu||Nu9@b|xC#C5?8Pin=q|UB?`CTw&AW0b)lKxZVYrBw+whPwZJCl}G&w9r zr7qsqm>f2u_6F@FhZU0%1Ioc3X7bMP%by_Z?hds`Q+&3P9-_AX+3CZ=@n!y7udAV2 zp{GT6;VL4-#t0l_h~?J^;trk1kxNAn8jdoaqgM2+mL&?tVy{I)e`HT9#Tr}HKnAfO zAJZ82j0+49)E0+=x%#1_D;sKu#W>~5HZV6AnZfC`v#unnm=hLTtGWz+21|p)uV+0= zDOyrLYI2^g8m3wtm-=pf^6N4ebLJbV%x`J8yd1!3Avqgg6|ar z=EM0KdG6a2L4YK~_kgr6w5OA;dvw0WPFhMF7`I5vD}#giMbMzRotEs&-q z^ji&t1A?l%UJezWv?>ijh|$1^UCJYXJwLX#IH}_1K@sAR!*q@j(({4#DfT|nj}p7M zFBU=FwOSI=xng>2lYo5*J9K3yZPwv(=7kbl8Xv0biOba>vik>6!sfwnH(pglq1mD-GrQi8H*AmfY*J7&;hny2F zupR}4@kzq+K*BE%5$iX5nQzayWTCLJ^xTam-EEIH-L2;huPSy;32KLb>>4 z#l$W^Sx7Q5j+Sy*E;1eSQQuHHWOT;1#LjoYpL!-{7W3SP4*MXf z<~>V7^&sY|9XSw`B<^9fTGQLPEtj=;<#x^=;O9f2{oR+{Ef^oZ z@N>P$>mypv%_#=lBSIr_5sn zBF-F_WgYS81vyW6$M;D_PoE&%OkNV1&-q+qgg~`A7s}>S`}cn#E$2m z%aeUXwNA(^3tP=;y5%pk#5Yz&H#AD`Jph-xjvZm_3KZ|J>_NR@croB^RUT~K;Exu5%wC}1D4nov3+@b8 zKyU5jYuQ*ZpTK23xXzpN51kB+r*ktnQJ7kee-gP+Ij0J_#rFTS4Gux;pkVB;n(c=6 zMks#)ZuXUcnN>UKDJ-IP-u2de1-AKdHxRZDUGkp)0Q#U$EPKlSLQSlnq)OsCour)+ zIXh@3d!ImInH7VrmR>p8p4%n;Tf6l2jx1qjJu>e3kf5aTzU)&910nXa-g0xn$tFa& z2qZ7UAl*@5o=PAh`6L${6S-0?pe3thPB4pahffb$#nL8ncN(Nyos`}r{%{g64Ji^= zK8BIywT0-g4VrhTt}n~Y;3?FGL74h?EG*QfQy0A8u>BtXuI{C-BYu*$o^}U1)z;8d zVN(ssw?oCbebREPD~I$-t7}`_5{{<0d10So7Pc2%EREdpMWIJI&$|rq<0!LL+BQM4 zn7)cq=qy|8YzdO(?NOsVRk{rW)@e7g^S~r^SCawzq3kj#u(5@C!PKCK0cCy zT@Tey2IeDYafA2~1{gyvaIT^a-Yo9kx!W#P-k6DfasKEgFji`hkzrmJ#JU^Yb%Nc~ zc)+cIfTBA#N0moyxZ~K!`^<>*Nzv-cjOKR(kUa4AkAG#vtWpaD=!Ku&;(D#(>$&~B zI?V}e8@p%s(G|8L+B)&xE<({g^M`#TwqdB=+oP|5pF3Z8u>VA!=w6k)zc6w2=?Q2` zYCjX|)fRKI1gNj{-8ymwDOI5Mx8oNp2JJHG3dGJGg!vK>$ji?n>5qG)`6lEfc&0uV z)te%G&Q1rN;+7EPr-n8LpNz6C6N0*v{_iIbta7OTukSY zt5r@sO!)rjh0aAmShx zd3=DJ3c(pJXGXzIh?#RR_*krI1q)H$FJ#dwIvz);mn;w6Rlw+>LEq4CN6pP4AI;!Y zk-sQ?O=i1Mp5lZX3yka>p+XCraM+a!1)`F`h^cG>0)f0OApGe(^cz-WoOno-Y(EeB zVBy3=Yj}ak7OBj~V259{&B`~tbJCxeVy@OEE|ke4O2=TwIvf-=;Xt_l)y`wuQ-9#D z(xD-!k+2KQzr`l$7dLvWf*$c8=#(`40h6d$m6%!SB1JzK+tYQihGQEwR*-!cM>#LD>x_J*w(LZbcvHW@LTjM?RSN z0@Z*4$Bw~Ki3W|JRI-r3aMSepJNv;mo|5yDfqNLHQ55&A>H5>_V9<_R!Ip`7^ylX=D<5 zr40z>BKiC@4{wSUswebDlvprK4SK2!)w4KkfX~jY9!W|xUKGTVn}g@0fG94sSJGV- z9@a~d2gf5s>8XT@`If?Oway5SNZS!L5=jpB8mceuf2Nd%aK2Zt|2FVcg8~7O{VPgI z#?H*_Kl!9!B}MrK1=O!Aw&faUBluA0v#gWVlAmZt;QN7KC<$;;%p`lmn@d(yu9scs zVjomrund9+p!|LWCOoZ`ur5QXPFJtfr_b5%&Ajig2dI6}s&Fy~t^j}()~4WEpAPL= zTj^d;OoZTUf?weuf2m?|R-7 z*C4M6ZhWF(F@2}nsp85rOqt+!+uZz3$ReX#{MP5-r6b`ztXDWl$_mcjFn*{sEx7f*O(ck+ou8_?~a_2Ztsq6qB|SPw26k!tLk{Q~Rz z$(8F1B;zK-#>AmmDC7;;_!;g&CU7a?qiIT=6Ts0cbUNMT6yPRH9~g zS%x{(kxYd=D&GKCkx;N21sU;OI8@4vLg2}L>Lb{Qv`B*O0*j>yJd#`R5ypf^lp<7V zCc|+>fYgvG`ROo>HK+FAqlDm81MS>&?n2E-(;N7}oF>3T9}4^PhY=Gm`9i(DPpuS- zq)>2qz!TmZ6q8;&M?@B;p1uG6RM_Y8zyId{-~XQD_}bXL{Jp7w`)~IR{l5a2?7!Vg zp!OfP4E$Ty_-K3VY!wdGj%2RL%QPHTL)uKfO5Am5<$`5 zHCBtvI~7q-ochU`=NJF*pPx@^IhAk&ZEA>w$%oPGc-}6~ywV~3-0{>*sb=|ruD{y$ ze%@-m`u28vKDaf*_rmN`tzQT>&2ltg-lofR8~c;p;E@`zK!1lkgi?JR0 z+<61+rEupp7F=mB=Ch?HwEjuQm}1KOh=o@ zMbI}0J>5}!koi&v9?!B?4FJR88jvyXR_v{YDm}C)lp@2G2{a{~6V5CwSrp6vHQsfb-U<{SSrQ zhjRbS;qlDTA&TQ2#?M(4xsRXFZ^;3A+_yLw>o-9GJ5sgsauB`LnB-hGo9sJ~tJ`Q>=X7sVmg<=Fcv=JDe*DjP-SK-0mJ7)>I zaLDLOU*I}4@cro&?@C`hH3tiXmN`!(&>@S2bFyAvI&axlSgd=!4IOi#+W;sS>lQ28 zd}q&dew9=x;5l0kK@1y9JgKWMv9!I`*C;((P>8C@JJRGwP5EL;JAPHi5fI|4MqlLU z^4D!~w+OIklt7dx3^!m6Be{Lp55j{5gSGgJz=hlNd@tt_I>UG(GP5s^O{jFU;m~l0 zfd`QdE~0Ym=6+XN*P`i0ogbgAJVjD9#%eBYJGIbDZ4s(f-KRE_>8D1Dv*kgO1~NSn zigx8f+VcA_xS)V-O^qrs&N9(}L!_3HAcegFfzVAntKxmhgOtsb4k6qHOpGWq6Q0RS zZO=EomYL%;nKgmFqxD<68tSGFOEM^u0M(;;2m1#4GvSsz2$jawEJDNWrrCrbO<}g~ zkM6516erswSi_yWuyR}}+h!VY?-F!&Y5Z!Z`tkJz&`8AyQ=-mEXxkQ%abc`V1s>DE zLXd7!Q6C)`7#dmZ4Lm?>CTlyTOslb(wZbi|6|Pl5fFq3y^VIzE4DALm=q$pK>-WM> z@ETsJj5=7=*4 z#Q8(b#+V=~6Gxl?$xq|?@_yQJ2+hAYmuTj0F76c(B8K%;DPhGGWr)cY>SQS>s7%O- zr6Ml8h`}klA=1&wvbFMqk}6fml`4A%G=o@K@8LHifs$)}wD?ix~Id@9-`;?+I7 zOhQN(D)j=^%EHN16(Z3@mMRM5=V)_z(6y^1b?@Bn6m>LUW7}?nupv*6MUVPSjf!Ym zMPo5YoD~t(`-c9w)tV%RX*mYjAn;5MIsD?0L&NQ#IY`9k5}Fr#5{CeTr)O|C2fRhY z4zq(ltHY2X)P*f?yM#RY75m8c<%{Y?5feq6xvdMWrNuqnR%(o(uo8i|36NaN<#FnT ze-_O*q0DXqR>^*1sAnsz$Ueqe5*AD@Htx?pWR*RP=0#!NjnaE-Gq3oUM~Kc9MO+o6 z7qc6wsBxp7GXx+hwEunnebz!|CX&`z{>loyCFSF-zg za}zec;B1H7rhGMDfn+t9n*wt|C_0-MM~XO*wx7-`@9~-%t?IegrHM(6oVSG^u?q`T zO<+YuVbO2fonR-MCa6@aND4dBy^~awRZcp!&=v+#kH@4jYvxt=)zsHV0;47XjlvDC8M1hSV zm!GB(KGLwSd{F-?dmMAe%W0oxkgDv8ivbs__S{*1U}yQ=tsqHJYI9)jduSKr<63$> zp;a-B^6Hg3OLUPi1UwHnptVSH=_Km$SXrCM2w8P z%F#Boi&CcZ5vAGjR1axw&YNh~Q%)VDYUDZ6f^0;>W7_sZr&QvRWc2v~p^PqkA%m=S zCwFUg2bNM(DaY>=TLmOLaDW&uH;Za?8BAwQo4+Xy4KXX;Z}@D5+}m)U#o?3UF}+(@jr$M4ja*`Y9gy~Y`0 z6Aex1*3ng@2er)@{%E9a3A;cts9cAor=RWt7ege)z=$O3$d5CX&hORZ3htL>jj5qT zW#KGQ;AZ|YbS0fvG~Y)CvVwXnBLJkSps7d~v;cj$D3w=rB9Tx>a&4>(x00yz!o*SOd*M!yIwx;NgqW?(ysFv8XLxs6Lrh8-F`3FO$}V{Avztc4qmZ zoz&YQR`*wWy_^&k-ifJ&N8Qh=E-fH6e}-}0C{h~hYS6L^lP>=pLOmjN-z4eQL27!6 zIe2E}knE;dxIJ_!>Mt|vXj%uGY=I^8(q<4zJy~Q@_^p@JUNiGPr!oUHfL~dw9t7C4I9$7RnG5p9wBpdw^)PtGwLmaQM=KYe z;Dfw@%nquH^nOI6gjP+K@B~0g1+WROmv1sk1tV@SUr>YvK7mxV3$HR4WeQ2&Y-{q~ z4PAR&mPOEsTbo~mRwg&EJE2Dj?TOZPO_@Z|HZX9-6NA!%Pb3h;G3F5J+30BoT8-PU z_kbx`I>&nWEMtfv(-m>LzC}s6q%VdBUVI_GUv3@^6SMkEBeVjWplD5y58LyJhikp4VLHhyf?n%gk0PBr(PZ3 z+V`qF971_d@rCO8p#7*#L0^v$DH>-qB!gy@ut`3 zy3cQ8*t@@{V7F*ti(u{G4i55*xY9Erw3{JZ8T4QPjo5b{n=&z4P^}wxA;x85^fwmD z6mEq9o;kx<5VneT_c-VUqa|zLe+BFgskp_;A)b>&EDmmP7Gx#nU-T@;O+(&&n7ljK zqK7&yV!`FIJAI+SaA6y=-H=tT`zWvBlaed!3X^_Lucc%Q=kuiG%65@@6IeG}e@`ieesOL} zKHBJBso6u&7gzlrpB%_yy<>TFwDI>}Ec|Gieb4=0fGwY|3YGW2Dq46=a1 zVo`Vi%yz+L9)9hbb%FLTC@-G(lODgJ(f&WmSCK9zV3-IV7XI<{2j}ms_Vmb!os)06 zhVIZPZF)hW--kWTCyDVRd2T&t|P&aDrtO5kzXy<*A+5$k7$>4+y%;% znYN-t#1^#}Z6d+ahj*Gzor+@kBD7@f|IGNR$4U=Y0J2#D2)YSxUCtiC1weJg zLp0Q&JFrt|In8!~1?fY0?=fPyaqPy$iQXJDhHP>N%B42Yck`Qz-OM_~GMuWow)>=Q z0pCCC7d0Z^Ipx29`}P3;?b{dO?7z0e{L|O*Z}nxi>X|RL8XAw$1eOLKd5j@f{RQ~Y zG?7$`hy@s7IoRF2@KA%2ZM6{ru9T5Gj)iDCz};VvlG$WuT+>_wCTS~J6`I9D{nsrU z2;X#OyopBgo778Q>D%_E>rMN~Po~d5H<`8|Zcv}F`xL5~NCVLX4Wkg007HhMgj9Pa z94$km3A+F&LzOJlpeFR*j+Y%M!Qm42ziH~cKM&3b;15s)ycD@3_tL-dk{+xP@J7#o z-)bYa-gd2esfy<&-nrj>1{1^_L>j&(MA1#WNPg3UD?reL*}V{ag{b!uT755x>mfbZ z0PzwF+kx91`qqOn`1>xw@801XAJlH>{`~|pyi6J;3s=cTOfelA&K5HX#gBp6s<|r5 zjSSj+CU*-TulqlnlP`}?)JkJ_7fg){;bRlXf+&^e8CWwFqGY@SZ=%NmLCXpYb+}7* z$4k}%iFUi^kBdeJg^kHt)f~<;Ovlz!9frq20cIj>2eIcG(dh57ry;^E^2T)E_8#;_9iJT>4sdCB_db|zO?Z^*lBN zNCs~f+Jkx%EUgkN2-xFF?B%TMr4#)%wq?-~+Nh;g9=n3tM>i5ZcH&nkVcPXgYRjG@ zf(Y7WN@hGV7o0bjx_2@bthJ`hjXXpfaes_(lWIw!(QK_nkyqj?{j#uFKpNVpV@h?7_WC3~&%)xHR1kKo`Cypj15#%0m z-o0GXem63g^|IltM?eZV=b+Z2e8&Z1%{0;*zmFc62mNqLTy$Y_c|9HiH0l>K z+mAx7DVYoHhXfdCE8Bs@j=t0f*uM++Idd25BgIm`Ad;I_{$mO?W%=JF82blr8rl>yMk6?pM z^tMluJ-ckG_}OkxP91t2o>CQ_O8^VZn$s$M_APWIXBGBq0Lt^YrTD5(Vwe2ta4y#DEYa(W~=eLOy7rD^%Vd$kL27M)MSpwgoP3P{ z!yS$zc|uP{yzaIqCwE!AfYNS;KW|OdP1Q%!LZviA0e^WDsIS5#= z!B{TW)VB)VHg{LoS#W7i6W>*sFz!qr^YS0t2kh90y=Je5{p>8)~D@dLS@QM(F# zIp{6M*#(@?tsu1Rq-Mdq+eV}ibRSpv#976C_5xlI`$#1tN`sK1?)5M+sj=OXG6dNu zV1K{y>!i0&9w8O{a>`IA#mo(3a zf*+Q=&HW7&(nX8~C1tiHZj%>;asBEp$p_Q!@Y0T8R~OuPEy3Lq@^t$8=~(FhPVmJJ z#VF8`(fNzK-b%Iin7|cxWP0xr*M&zoz|fCx@=Y!-0j_~cuxsDHHpmSo)qOalZ$bRl z2F$j0k3llJ$>28HH3l_W(KjF^!@LwtLej_b9;i;{ku2x+&WA@jKTO0ad71@_Yta!{ z2oqhO4zaU433LK371>E{bZ?+3kLZ9WQ2+3PTZAP90%P13Yy3lr3mhmy|>eN6(SHs1C%Q39p)YsUr7(kuaoIJGJhXV-PyG zjnxhcAC;fqY@6;MWWBnRK6ocG`%T&0&*k95#yK7DFtZV?;cy;!RD_*YJjsb6Q`$;K zy)&X{P`*5xEgjTQ9r=oh0|>Z_yeFm?ev!p z7q;JA4mtu@qa39v%6i)Z4%qwdxcHuOMO;a1wFMP_290FqH1OsmCG{ zq^afYrz2BQyQ0*JGE}1h!W9fKgk$b!)|!%q(1x?5=}PpmZQ$e;2EB*k4%+&+u;(E* z2n@=9HsqMv;4>Nn^2v&@4T-YTkd`TdWU^U*;sA5|r7TjZGnLY*xC=_K-GmDfkWEGC z;oN&!c1xB-<4J7=9 zJ(BedZwZhG4|64<=wvCn4)}w%Zx_TEs6ehmjVG&p5pi46r zg=3-3Q~;v55KR&8CfG;`Lv6NsXB}RqPVyNeKAfj9=Ol>fQlEUl2cH7=mPV!68+;jgtKvo5F#8&9m? z``w+#S5UR=QHFGM~noocC zVFa#v2%oo{%;wi~_~R2ci}`=B|0@ zinDfNxV3%iHIS(7{h_WEXqu!v~`CMH+7^SkvLe_3i}=pyDRah zN#L)F-`JLj6BiG}sj*WBmrdZuVVEo86Z<6VB}s)T$ZcWvG?i0cqI}WhUq2Y#{f~x# zi1LjxSZCwiKX}*ETGVzZ157=jydo*xC^}mJ<+)!DDCd4sx?VM%Y;&CTpw5;M*ihZ| zJ!FBJj0&j&-oJs?9a_I$;jzd%7|pdsQ3m`bPBe$nLoV1!YV8?Pw~0D zmSD-5Ue60>L$Rw;yk{_2d~v@CnvZa%!7{{7lb$kxWx!pzyh;6G~RbN5+|mFTbxcxf!XyfbLI^zMQSb6P~xzESXmV{9 zCMp)baZSz%)j&JWkc|Gq;_*$K@zQ%tH^91X2|Byv>=SmWR$7-shf|_^>Ll;*9+c(e z{N%43;&e8}_QGW+zE0m0myb-@QU%=Qo>``5UzB(lH0sK=E``{ZBl2Ni^-QtDp0ME1 zK88E-db_XBZQaU}cuvkCgH7crju~9eE-Y`os~0P-J=s;aS#wil$HGdK;Ut?dSO71ssyrdm{QRpMAV2nXslvlIE#+Oh>l7y_~?;}F!;ENCR zO+IG#NWIRI`FLntsz^FldCkky2f!d-%Pij9iLKr>IfCK);=}}?(NL%#4PfE(4kPQN zSC%BpZJ*P+PO5mHw0Wd%!zJsn&4g<$n#_?(=)JnoR2DK(mCPHp6e6VdV>?E5KCUF@ zf7W9wm%G#Wfm*NxTWIcJX-qtR=~NFxz4PSmDVAU8(B2wIm#IdHae-F{3jKQFiX?8NlKEhXR2Z|JCUd@HMnNVwqF~V9YJtD+T zQlOroDX-mg2% zBKV^Q5m5ECK{nWjJ7FHOSUi*a-C_?S_yo~G5HuRZH6R``^dS3Bh6u!nD`kFbxYThD zw~2%zL4tHA26rcdln4^=A(C+f9hLlcuMCv{8`u;?uoEVbU=YVNkBP#s3KnM@Oi)fQ zt_F3VjY)zASub%Q{Y?XgzlD3M5#gUBUuhW;$>uBSJH9UBfBtug*S|-;h?|L#^Z&uE zB&)spqM89dWg9ZrXi#F{KtL@r9g^xeR8J+$EhL~2u@cf`dS{8GUC76JP0hHtCKRg0 zt*rVyl&jaJAez;!fb!yX^+So4-8XMNpP@d3H*eF%t_?I|zN^1Iu5aGBXSm+}eCqn3 z^+vzcM*J>wV-FJRrx@^5;l>h0{OYT)lg{dr8!{s7(i{5T|3bivDoTonV1yo1@nVPR zXxEgGg^x5KHgp?=$xBwm_cKHeDurCgO>$B$GSO`Cd<~J8@>ni>Z-Ef!3+ck(MHVy@ z@#<*kCOb5S$V+Fvc@{Qv$oLfnOAG&YO5z_E2j6E z7a+c(>-`H)>g+6DeY1Y*ag-B6>Cl@@VhkZY@Uihe!{LlRpuTsmIsN4;+UDsHd954n9WZV6qq*{qZ5j<W)`UorOmXtVnLo3T{t#h3q^fooqQ~A+EY<$TDG4RKP*cK0liX95STt= zToC<2M2*(H1tZ)0s|v~iSAa^F-9jMwCy4cK0HM*3$@1Q`Pz}FFYm`PGP0wuamWrt*ehz3(|Fn%;0;K4}!Q~cx{0U0L=cs6lcrY^Y%Vf_rXpQIw~DfxB-72tZU6gdK8C~ea6(2P@kGH}!2N?>r(Ca{ zsI!6B!alPl%j1CHq97PTVRng$!~?s2{+6ffC#;X2z(Xb#9GsSYYe@9zY~7Dc7Hfgh z5Tq!})o30pA3ywg<9W3NpvUs;E%Cehz=s?EfLzcV0H?b{=q?vJCih2y%dhls6w3j$ zk9LB0L&(15mtul3T^QSK7KIZVTod#Sc)?1gzY~M=?ay87V}6G?F>~AIv()-N zD3rHX`;r;L{9N|Z8REN}OZB&SZ|5a80B%dQd-CNESP7HnuNn43T~Agcl1YOF@#W03 z1b*t!>t5G@XwVygHYczDIC|RdMB+ z$s5_5_W-EXN-u_5Pb{((!+8xa+?@_#dwtYHeJ_49Dql%3Fv0yXeV?!cC&Iqx@s~P%$X6%1 zYzS9pqaUv&aBQqO zBQs7d63FZIL1B&<8^oni%CZOdf6&;^oNqQ-9j-NBuQ^|9baQuZ^Jtyt&?cHq$Q9JE z5D>QY1?MU7%VVbvjysl~-a&ImiE(uFwHo{!kp;Jd`OLE!^4k8ID{`e-&>2uB7XB~= z+nIQGZ8-Sbfa}OrVPL}!mdieCrs3Nq8Ic_lpTKMIJ{h>XS$C3`h~ z?p2AbK~%t$t(NcOq5ZB3V|`a0io8A))v_PMt)Hg3x+07RL>i zGUq@t&+VV`kj55_snp?)Y@0rKZr`riC`9Q(B1P^nxffV9AvBLPrE<8D>ZP{HCDY@JIvYcYNRz8 z0Rf+Q0riSU@KaVpK)0M{2}Wuh!o~t*6>)EZSCQD{=}N4Oxjo1KO-MNpPYuPABh}E|rM!=TSl^F%NV^dg+>WNGi@Q5C z%JGsP#em`4LxDdIzA@VF&`2bLDv%J)(7vedDiXDqx{y6$Y0o~j*nVY73pINPCY?9y z$Rd&^64MN)Pkxr-CuZ+WqAJx6vuIAwmjkN{aPkrJ0I4F5-Bl}$hRzhRhZ^xN&Oe5$ za4Wrh6PyFfDG+Nzd8NTp2})j>pGtyejb&;NkU3C5-_H;{?>xK1QQ9S`xaHoMgee=2 zEbEh+*I!ggW@{T{qENlruZT)ODp~ZXHBc_Ngqu{jyC#qjyYGAQsO8VT^lts$z0HP+ z2xs^QjUwWuiEh863(PqO4BAosmhaK`pEI{-geBD9UuIn8ugOt-|6S(xkBLeGhW~)< z8aWBs0)bzOnY4wC$yW{M@&(iTe{8zhDnKP<1yr9J8akUK)1svAuxC)}x-<>S!9(?F zcA?{_C?@ZV2Aei`n#l(9zu`WS-hJsAXWt(SGp4(xg7~3*c5@odW;kXXbGuLOFMj{d z{gx81mQREmRAUHhfp#zoWh>z}GuS|raw1R#en%9R3hSR`qGglQhaq>#K!M%tooG;? zzjo}>sL7a3M5jW*s8R;#Y8b(l;%*I$@YH9)YzWR!T6WLI{$8ScBvw+5&()>NhPzd! z{>P(yk8{(G&2ovV^|#1HbcVMvXU&;0pk&6CxBTvBAB>#tK~qALsH`Ad1P0tAKWHv+BR8Fv4!`+>Obu1UX^Ov zmOpuS@Ui|NK4k-)TbG?+9T$)rkvq+?=0RDa=xdmY#JHLastjqPXdDbShqW>7NrHZ7 z7(9(HjM1-Ef(^`%3TlhySDJ27vQ?H`xr9VOM%0ANsA|A3-jj|r`KAo%oTajX3>^E` zq{Nq+*dAH{EQyjZw_d4E!54gka%phEHEm}XI5o%$)&Z+*4qj<_EChj#X+kA1t|O3V@_RzoBA(&rgxwAF+zhjMY6+Xi>tw<6k+vgz=?DPJS^! zei4z1%+2HDqt}Ow+|2v^3IZQkTR<&IRxc0IZ_-Di>CErQ+oFQ~G{;lJSzvh9rKkAiSGHlAB$1}ZRdR^v zs2OS)Pca>Ap(RaSs7lM2GfJ#%F`}$!)K4#RaGJ_tY}6PMzY{5uHi}HjU>Qb~wlXQ) zdd(`#gdDgN_cat+Q#1q&iH{`26k}U3UR5(?FXM>Jm{W%IKpM4Jo{`3aEHN)XI&Bwx zs}a_P|M)fwG1Tybl)Rkw#D__n_uM+eDn*}}uN4z)3dq)U)n>pIk&pbWpPt@TXlB?b z8AAgq!2_g-!QL>xdU4~4f6CB06j6@M?60$f;#gpb)X1N0YO*%fw2W`m=M@%ZGWPx; z)r*>C$WLCDX)-_~S%jEx%dBpzU6HNHNQ%gLO~*egm7li)zfi|oMBt1pwzMA$x@ zu{Ht#H}ZBZwaf0Ylus3KCZ*qfyfbTUYGuOQI9>??gLrBPf-0XB84}sCqt5Q(O$M& zoJ+1hx4Wp#z?uex+Q1crm2ai?kci;AE!yriBr}c@tQdCnhs$P-CE8jdP&uriF`WFt>D9wO9fCS0WzaqUKjV_uRWg>^hIC!n-~q=1K87NAECZb^W?R zjbI&9pJ)4SSxiq06Zasv*@ATm7ghLgGw3coL-dn6@_D-UhvwPXC3tLC)q3xA2`^D{ z&=G&aeSCN)6{2W6l@cg&2`cCja~D2N{_>ZQ)(5oSf!ns1i9szOif~I8@;2b)f2yQ5 zCqr{lGy5(^+d!<0g??wFzH^wuv=~0)g55&^7m8Ptk3y$OU|eI7 zIovLvNCoY%N(aW#=_C%GDqEO|hH3O9&iCp+LU=&CJ(=JYDGI;&ag&NKq}d;B`TonC zK+-t8V5KjcmDyMR@jvDs|7lkga4>TQej$5B+>A`@{zE&?j-QbQWk4J*eP2@%RzQ{J z?h`1~zwArwi^D7k9~%xtyf(2&$=GsP*n-fTKneej-y6y(3nNfC7|0{drDx{zz~cSs z<_+d2#ZDst@+`w{mwzmn?dM2aB;E;bS-Opq$%w@WnDwa$hUGL90u9c=as)+_6aO10 zLR|CR8nr<2DQTvkaH0QDsyn@TYCs7Nk3lN}Ix$)JM0*zf=0Ad$w9j723W#%{r8V&`{wx-8kSv#)mZ{FU%UZDIi zvbgLHyJ>z0BZe`GNM$Q;D6D48#zc9s(4^SGr>u-arE}okN62N{zuwX)@FL5>$ib=b z5Wtm~!ojD3X|g59lw%^hE?dL;c^bgVtBOkJxQR{Eb*nR1wVM&fJQ{<))bn9e3bSlu z3E-qpLbAE(S^I4mVn`?lycoV!yO!Qj_4qYgsg7tXR)Gu2%1)5FZu&lY7x>bU`eE}x zSZ5c`z~^&$9V?eEH!^Rp-Fz3WiCvEgf`Tq}CnWRZY+@jZ{2NewmyGUM6|xa3Sh7)v zj6d&NWUVqu9f-&W)tQ>Y%Ea!e76@y!Vm*aQp|wU5u<%knNvHZ!U}`fp*_)mIWba=j z*w9~{f5pD;zCmEWePjM#ERNiNjv!SnM-&rGpB9Nmiv}J+hwB&0f_+x?%*lgJFRHsqfFDPwyvh8<*xLT0u_BeEHw{q+UGj=$4udEx)Vq#sV zKB3+_C!RUKy?ac3-`+}dL2!D_2(5=8&@hBf`-AbU`-<_3>Ilqkg6qSI>9G(@Kx?g<0h0K&31$AR>R%d}{%DyXPss$&c^ja7NR z$0AN7Fl$>VpGxqHW15CjxAa6DUVmCpQNbOwBv8D^Y{bXg28> zEQE9xl?CWh0gS6%Y=G4Cy($Vb>jBb2f_dm#0_B<_Ce`|~Obt_Xp^nkR zK%o_`{h1XkWn}i|5Dp#q8D(;k;2|+{DAG{2gJgPNQ=KZ=FKY@d>QEu6W;oLsE(1}< zpnwSEj(K{Bu^#CXdi7L_$!X`QOx^tA1c{&-XTHo3G?3(H*&VM~*Aud?8%FU=dE&kV zJ$SqZoj^g@(q9x;7B30J$(-qUml{?3e+I^Cf?X0PpLr}m zS}W9`QaCwINRU&D5>j9O*j6S}R1`7{5+{d-xUlI~)U!^4+*b5tkuon-Msz03Z{{Kp zH!GAXoyr#1K;t5o#h#a%Lzj3XQGqM0TRnfu$(fsQe^wb_?W!m!+7r55q>svWN`k~T zS(gk9bi|@+8wg;dR<&0f;MpwQbY27$N{{laPQk3@3uCz$w1&jq)`uW*yn!Pe-V^%Q zR9)cW;UB~ODlwolWFAX?ik#_|v)AtHNwoq72E9Jg#v2e5SErf+7nTleI8&}%tn6hf zuz#5YtRs94Ui&E_1PakHfo+^t-{#ewhO*j5ls-zhm^C{kCARNEB1aORsxE!1SXBRz z6Oc-^#|0W6=7AJ;I|}pH#qby@i^C+Vsu9?zdtkE{0`oO_Hw|N=Lz9Is8j}R zI+8thGK?(KSZ5ZW4nQG1`v(=0Jd*0gIlavVihzo#fPaa=}(Rqdxl3^6O8K+{MqU`;1iTJ$<^k)Nms(A$j?A-wHJKvh9 zUHW3}JkE;x?FETPV8DFTxFLY8eSAd%C8vp?P_EuaMakmyFN_e?Hf|LBctnncUb}zF zIGP4WqtKCydoov~Bi<_I%y%$l+})!;SQVcP?>)9wM3q-GE6t9*LfoePBlo{gx~~e{g_XM5PQ8Y5dsuG%3Xq}I&qcY6 zTCo?<6E%)O$A2torq3-g8j3?GGd){+VHg@gM6Kw|E($M9}3HVIyL1D9321C zu#6~~h<<*=V7*ria%j^d5A;S^E;n!mOnFppfi+4)!BQ@#O2<|WH$RS~)&2Qol|@ff zFR#zmU(|jaqCXPA@q?UhrgbMO7zNXQYA@8$E+;4Bz7g=&zV-)=&08J_noLAz#ngz$ zA)8L8MrbXIDZuFsR_M(DsdX)s$}yH!*bLr{s$YWl5J?alLci=I#p`&MbL4`5bC}=2 z^8-(u4v2hs9*us}hjB!uiiY6vvv&QWJcVLTJ=SFG=lpR+S4Cd91l}oZ+B-*ehY2Ic_85)SRSa% zMEL~a3xrvH8ZnMIC!{9@pfOT7lrhxMf^8N20{CJXg}M35=`50S;6g-JYwjwj!K{^) z5Bohf6_G6z=+0V8&>F8xLbJ4mkCVu^g66#h&?tL z9odv&iW21IAh~y9D-DupKP-NcernF2(*RsFkAsM<$<>@-Cl1?&XAi4+Mh2Zm@2x#u zWH&J^1=8G|`|H2%94bnjUZyI>QACu9FS}^$lbtzzCz4AMspqGYEwFFM<%G!Oc$+;7 z3r_L!H~PR}5n8+3-&4v*fFr$uK{y_VamM0*TKn^))nQsn5U?7Iv?`4|Oy&m6himAG z%=a;2ji3f_RtDPqkwR>ISxhnS0f)E`ITo}TR!zIxPwECZy#jzo%q{BNYtd!<IP_S+=*yDOk1GgwLqe!d9esV@3$iVAm1!8RoE| zqnTz;5a)B(~~KcP)c>?+ysFAlAGF4EBor6)K{K*Kn>B(&QtMAkR^ynG%k%UbJpKM zI$}qQXXP3PISHe_vTFssbcL`irhG2zN7J((3ZFmh*bnPuiK~=#YG=820hXqOON#HI<0bvIT{z&SaqRvqaMG-d5<06zdP?-kIH{%UMR$Xn@S}Hx3 zFjg}6no}vN_512D+RIn-mo9^_Li-)WI5%VigYt{Jd!RyI%d|-LqJU$y3aJ*a$y6$1 zjyTuIF2&t>1rPlw&k5OVLhrYBvk5Vl8T(*Gd?Alqi}> z<@-`X_o@9EOB8Ik&?|;lvKHFU@#O+?T!kEf&oJUaLzN;>!}!!e1WIs(T}V#Irf$AK z42`x`z-9ogxd@%CS;D5S z2M^b;Pu)q)c&_KBO!va-4xnI57L7V@*_I_r4vU)z>xk5z6PDVqg92R7_iZH|VlO_B z#8R`5HZVn?ou>czd>gZ~s;w4ZkzVXJNP8FiezlB5JXe6Z-OLsDw%N7!(135!Vl2Lb zLYI79?U{h#W-_#W6hf`<$BQHJCu5ehv?IF+-uxUqt~j!ZW1cxfiEJal^q7~RMWQ0a z2CEaPa1_p|P6qRmmeKgas*N}@(2tH%U37-<5i(DSnVOFFxg-Sv%7&{hPeRh{U`&ufGz=V|JdYQ2sG5 zk%3JimSwQFP=Yr?u_beSG^B$nnh$4hrxb4lpTTiUFRQEZ3ulr+L3m;>;Io?D;jG6Wjj!b)nsZds<6 zX@cD%+aVr!ra~F7HYr`TB!|y-t)HSb^FQt zbo+_XP44IWJGGxg73JyhBjKMSv`77ngDOw}6Eve6ZIol$Q5s65d(1-sP{BU{1_y)7 zF8sh5A~jxRHk=wq3c5i3*e&otCd9>cstT?IQ&D4slC-&^q!ut1;WAQ}fE}Y+jU}r{ zmpSI%sW?})RAm8}$WUU+V$PmQOF5gSKOGQ2;LF-E(gd<67rYu2K| zom8mOppa%XJ6C(@I7-*opqLn73e9BMFStaBER?suJ{jte1$vA%z?$_`Em=a=(?T-q z*A=VZOQ`P{co!*UUKyV@Rd-c#*wmb7v<%rN=TGFmWmqhbj#&+?X|3bZYAjbNGTv~O zs7SIYi3VgW6@?=PGnbNNZIWaY^*+ChW&a)A$uqH8xxehwx2`<1w6mag?zuHbsVJiO$a)tQ zuBBoR>rLfhpA@)Qf`8BwRMx886%9HP5rOR%YCy9pQ|^Xw!=Mcnwx8j=(ZE)P-tJ&s zON&Nsr%14jS@K+IvrJj720NkCR*C(j&aI$EFCV)w$9M<#LdihyRKdzTjJPI|t9_S} z--#oF#;F?Y1KN%_yE);Bxv}9PWZphz_g5mReOKR`y%9UZ=n}GXWw?E$T1%NAfK1Ad z|0$Lp^;sntA>}=ybW)mkxNv1?hkZ`<8hCemcT5 zYl6$I^bhXDzPlz<>6zOy3Fu*3?>#q$;1fJ>nuxyx#&<&x6Y}j zCU&VmtCJ`;aYN+qP}nwr%s2ZQC|Z**axS^?iGu+x^{{>FIv!k0#HaXtEG=*C7kPe!mMnknbn}TKpp6Xv9 zVvq&%A3nmY^N*XTg&+=wO>(|{uTwm;ZP9@+M)6%T zwXPh-&{+aAfv^ZCzOEb;yj>A=f5Pbu)7T{9PT3u>#w*%?K8jqEF%I>A?q;E%CXn)f z|0ohNa5DMv@HVk^vT(L=HBtH*Vzo81L?)M=g7)>@j*vUx?S zxqZo23n3vn@K-Q@bx3lLT+5=fB_oz8+p?P;@*UU<-u)jb5WFEXzoc+8*EC5P6(HWr zY$mfFr=L&G>(jvl8US2fLQqTzHtAGizfR*;W4-kN2^I>L3KkXgx=e*}+i*N($}{?c zi=Q67G)oEMW{|Gdsm{)|V)5Evo}KLj%}gIe>98FFoNTLrJX z-ACRdewnT1w#Egct%wpGg~q%?!$}>$_UJPC4SP0^)G_$d4jN0jBEx}+rcd*^aDtnx zewG{`m!oSbQ?A~FZ6L{&V0hUE+b$DxjO_;oskFha>@gzy(jDnzGO>z3Tzz|i&Dakg zFid5$;SFxINis^4JzK5XIVabKoP`=ZWp|p|t{hTi8n|#XE=-rINwJ*blo?=%Se(qw zkW7x5Qs(LV5RVGxu2e&4);c73lY#0(iZo1x=MY;7mW`uUQIY+$_PqH`4a`6O#urwU zE6(FrvyExmB{c5z*YAj_P&t??F1t6TN2N!$N#~02u(t(PDVyD)$mL3hqKQ4E91N#GOIngPr&pUb-f_Z4*XV8`p1pq+mzrUlUY=4~i|3RDo;Lo36U}uwm zaOah}mO8c@%J*~~{Up7_7->8|3x<}WemgaMA}h>xD17Fey@V9;LgjQFSBS(A<+2kCP9( zlkD%;oXzWtZ_hgu0IxeTjH`6=vi|t_04Btl32=g8swD1oZguWr4|lx0RuXoDHbh27 z+ks?gkVWYnr~_{h+PzQjQ(#8kaJai4We{F!JuqCzU0t*+H{n6i3;K<>_6XUn1n)}) zJ?}JCUPYhT9S1Hi-M+$(Z**%fz7Z%IiMN6%kD>wh%r4#C?Ge4{>w9o??Vbehy9!3@ zffZs8?LGxyWQr@yB(|%~Aa>fVj3$O=i{K*f;?h-a@-ce{(cY8qByOCA1r0;NC}}gr zcC^fCa$Ot`42n>`ehclOAqBo7L&D6Mi=;M5!pd@jj$H z?U7LQWX_u7bHpBzF7L-s4*`C)`dUrbEIgKy5=QHsi7%#&WYozvQOXrNcG{~HIIM%x zV^eEHrB=(%$-FXVCvH@A@|nvmh`|agsu9s1UhmdPdKflZa7m&1G`3*tdUI5$9Z>*F zYy|l8`o!QqR9?pP4D7|Lqz&~*Rl-kIL8%z?mi`BQh9Pk9a$Z}_#nRe4NIwqEYR(W0 z1lAKVtT#ZTXK2pwfcCP%Apfo#EVU|strP=o4bbt3j zP?k0Bn$A&Xv$GTun3!izxU#IXsK1GQt;F0k`Tglr{z>v2>gCINX!vfs`aqag!S*AG5Z`y-# zUv_u&J4r;|EA`r!-gsoYGn<^nSZLH-nj1SRGc0MRG%LWVL)PckFn9z!ebIJ}eg+ix zIJo7GN;j1s$D6!({bYW)auypcB~eAWN;vhF%(l=|RR})$TOn;ldq^@8ZPi<%Xz~{Z zQQ|KAJ@JHaX!Ka2nhP%Cb^I}V6_C|e1SjOQpcPMMwfNz#U@Az|+rmH*Zn=cYJu-KR z{>f++Z~P=jm)4-7^yc#52U4qeNcBRYb!hhT3Q7Ngu5t@CvY*ygxu^Eh?2l6= zhdqN{QEaP(!p>1p1*toD!TllHH6EH~S%l9`mG62dyAd+?}1(vf@N*x^6vhEFU<-RqS7#12*q-xtU z5d|F^n%WSAQHnm-vL)4L-VvoUVvO0kvhpIg57Wf@9p;lYS5YfrG9jtrr?E<_JL{q% z7uPQ52{)aP{7<_v^&=J)?_|}Ep*`{dH-=cDt*65^%LodzPSH@+Z~;7sAL}ZECxQv+;z*f;(?k)>-Lp@jBh9%J`XotGJO(HcJc!21iZ98g zS-O!L9vpE(xMx1mf9DIcy8J5)hGpT!o|C8H4)o-_$BR!bDb^zNiWIT6UA{5}dYySM zHQT8>e*04zk1)?F99$dp5F^2Htt*jJ=( zH(#XwfEZ`EErdI~k(THhgbwNK9a(()+Ha1EBDWVRLSB?0Q;=5Y(M0?PRJ>2M#uzuD zmf5hDxfxr%P1;dy0k|ogO(?oahcJqGgVJmb=m16RKxNU3!xpt19>sEsWYvwP{J!u& zhdu+RFZ4v8PVYnwc{fM7MuBs+CsdV}`PdHl)2nn0;J!OA&)^P23|uK)87pmdZ@8~F$W)lLA}u#meb zcl7EI?ng$CAA;AN+8y~9?aon#I*BgYxWleUO+W3YsQxAUF@2;Lu-m#U?F(tFRNIYA zvXuKXpMuxLjHEn&4;#P|=^k+?^~TbcB2pzqPMEz1N%;UDcf{z2lSiwvJs(KhoK+3^2 zfrmK%Z-ShDHo^OUl@cfy#(cE=fZvfHxbQ!Chs#(vIsL%hf55_zyx>0|h2JT=|7JWo z+Uth3y@G;48O|plybV_jER4KV{y{$yL5wc#-5H&w(6~)&1NfQe9WP99*Kc+Z^!6u7 zj`vK@fV-8(sZW=(Si)_WUKp0uKT$p8mKTgi$@k}(Ng z#xPo-5i8eZl6VB8Bk%2=&`o=v+G7g|dW47~gh}b3hDtjW%w)47v#X!VYM}Z7hG1GI zj16;ufr@1^yZ*w3R&6pB8PMbuz%kQ%r=|F4+a!Gw2RBX6RD5c!3fU@+QCq#X7W@Q5 zuVQ}Uu0dzN+2mSX5)KV%CsU;2FL%B6YT`10$8JR^#;jOO1x?t()Q_gI zxpQr2HI0_^@ge0hNt&MQAI`yJ1Zhd-fpR{rdNmRkEEDu7SpB)QOP4ajV;UBZZZK<6 zWds;!f+|}iP-kqWAH#1@QisJpjcg`+s80!LhAG@(eMad|zcln~oE8}9l5!K{^zf~( zd=HArZ5+Mryc$uNa`@|GSdOX=y}8GZc-%p8W@OM)uk2DfmhQXCU1E#y3XJ>|+XdW2 z)FQLeK38}u_D(5E{GV|YT^rI4qds2{-r<@@@@SG@u&4LbC z5o|KKqVM{?wk$5>2?t*I?IHdh~gljn_2m2zqZNJEEz4Mb$o&I3_UAg#$B{0u$uF4-q}{ zzs5+k@qOe08!CGLGmy3eRrcuqsgB*B>i8c3>3=T^Hv>nL{{u)jtNc6tLbL7KxfUr; z=Pp14Nz+ggjuwd~*oRJ)xWwGwdge+~b!E%c3Gzw6`vT>CCxE0t6v5Z`tw1oKCcm68A~Dbc zgbhP6bkWwSQ=#5EsX*O9Sm^}EwmQQzt2V2phrqqe2y)w8;|&t6W?lUSOTjeU%PKXC z3Kw$|>1YrfgUf6^)h(|d9SRFO_0&Cvpk<+i83DLS_}jgt~^YFwg0XWQSKW?cnBUVU}$R9F3Uo;N#%+js-gOY@`B4+9DH zYuN|s&@2{9&>eH?p1WVQcdDx&V(%-kz&oSSnvqzcXC3VsggWet1#~bRj5lBJDo#zF zSz))FHQd8>3iSw{63m`Pgy_jkkj9LTmJ&!J(V0E~&}HJ4@nXp<(miz$sb;(I<8s!7 zZyezu!-+X81r03486gAlx@n#aKx_93DREBtNcYln*8oliQ zbh0~SkAgHXX%C6}HwN(TRwaK2k_$Y}PxKId;jYt=S1Bf<8s@(IL?k3u1(f^V%TYO1 zA_jPf*V)SLEZFWS#y>M&p$LoSk+%ubs`)H%WEZf=F)RKh&x;i)uLIGJ94~A4m$(;S z;1rQC{m>--`WHFcaFA&5#7~vz|5S;{fB(7pPnG;@$D~C0pZYNEG?B8X*GB2e4{Qk; za1oop8OvHqs1Lk6B`AuYOv4`y`IgM315iTr{VUVc9WeOG;xE z%eDQgE4rb_B%vuT>N?^K zRvPnQwG%7RjO26+DY!OXWjgBu4^!)W-+ob_G&nX++))pD->QdRCo0spZN?Y*J#@-q z)fk-fJvZYz8)GSxYc^oXYIM;Pw}ftHW+a3dis#dXx^OS^m-~FlwcVr6MXv78fNI!i z51K-2t&!&IZ4(GF=mT@;qIp!&R(I@UiWPPz)%Us&(FdAAGxZ-+6^UZ7em`J-F#_3r zLkHym@VAnZFM$J~?0b@&O`l4YXyvOQ+OqalbZ0{g{qD{neY_xno1ZpXlSJWM=Mv(~ zvK{?O>AcXpbd}+hn{~*>weZwDTURX*M^9RkOO#DUfRW1;comKg1bn+mlsrNY8XDyW zgWg9~AWb_1^D8zsD4bL(1J4oinVy0Fimrh&AC}Itl;IH*p4eU_I;SWkOI!9tAbi3B zO@0=q#LHAc>z?ve8Q&hsF(sR9lgf_99_5Kvuug<^&0}Y&m)YjI?bITGIuh}AJO|>z zc*`Mly$>TA={AIT#d%JuMpXHDt($qkc*3UTf-wS$8^awqDD^|EAeA{FoeyJfWM@QX zk>vJ4L|8DU7jg_fB^3Qvz*V$QmDl*AXdw6@KSckh#qxjLCM8Nba!dTkJgr(S@~Z0a zt8%|W!a~3zG4Y&X6xbLtt^JK5;JT($B`_9bv(BjRTfG_Y`tg3k-}%sQoY@F|=}}${ zwmW%Ub6jPd)$;NA0=b7w!^2dE-qvI4)AVr`yvkabJcGwvuQ2rAoRlTjvCC^-$2BG} ziy0<6nt8;J67rymwm&wVZ8E7Krouv2Ir@-GQ%ui6PR42KHKms3MK&Z$zp{_XAVvrd znK4cbg)Ggh5k(4SlFOM9yyRUlVH1oo%|6Lu9%ZxZW28!c9Z%H5#E?B?7H7ulcUtirB<{s@jnS(-R@we z^R#{Mn$#JXd~5sw9rU&~e3fYTx!T&hY{S<~7hviG-T$<4OPcG6eA0KOHJbTz^(`i~ z_WON4ILDLdi}Ra@cWXKLqyd0nPi06vnrU-)-{)Xp&|2gV>E{Uc>Td`@f@=WYJYZ^- zw&+fjnmyeRoK-unBVvX>g>wO3!ey<+X#z@8GNc9MD}khMO>TV{4`z zx4%!9|H6k|Ue;`M{G6d!p#LL+_@6WMpWgF7jk*%$D_JB3c%D`~YmHRJD1UNDLh;Tf zYbbKcv9R(81c4yK+g+1Ril{5w#?E}+NVz>d@n48C-T-(L?9a9W`JV*{dan-sH*P3_Hnt~iRv)}ye;7$b}^4l%ixphDK`G#b!4R4qoouT@*A zZ)kQa)e94??k7N>tqoRl>h(9DFq&92=z|F!LJrh-97EoFL|Wt2v}>(zG1*#aiYA_^ zM_&%_G^g*O8x650e>m!#MDmwRub!irY>^^|L=!4^%lBr;?}mvgP3y~^mSdKSm^R~WAt7T0_ck0mA`GS)J^SYTo6^vQ|vuM7!92&@$BhtcQ^Z4h2)aN zh~EQthyjn1(eI~$FtuHH!|x(iHU{9k40k5nPBwB)X@8Lo$P6u81EeoNOGRct%a-LM_4y3Ts z7ki0PWAO^Es6c%M*SSRn)2|NAoUsKyL%))uVx7?5lkrk`njxs4q@M~x+8%jr7xV;- z|KC=g3aTZO|y|g~oHXB6b42(|J_&fP2Y`*;L07H2d>{~JP zFNGl$MYUG(Qy3dR?9Bfdg8#peGRiVP8VYn@)6T1bj*v)s6q*7<6P(ZVm4ZnTA;rOHSd>P`_5uT0+azWdV`gIvLaJ1o*DB}&W6LCgX|BycgF5qd z!)}dT#A~4*6{1=Bd5VV(Qa2h4x9m#2X711z(ZN>i&cn`BopG*5P`CD*HfYiQmXNGk zhgqcHPBrJP$Z@PLZ4}d-8^}%X^LtUDHq&;~3}lUyrxxl@|IS={GP&6-qq&Iy5gKW- zC@$}`EEZd}DOSeSD+v_x5r_tpBWfN0gDa21p(@TAIrgWQFo7NO@slI6XOAML_lN;3 zEv~}LlMbGWKu}0s$tO-vR)wD!=olGcA?}vU;lRu4+Zf z?nCD7hBmA5`U9P#W8-*0V1=OT-NI0k&_`UZ87DbpYq_=DBdyNDchZ<|V1f%dbaa7i zf~R+6Xt%G)VXlM@8REfP3u#7UPadWYOBMsQ56fHRv!0p9R6q>Rbx!n|IY0goLb%{+ zzy|5WXk+(d@ChzOWatIV1lc1F!(uEOfEmMd;v`|$Kt3X2Uws;%@OV!E86PN?CeHV& z=4#TX{J8RWaH`)!J<8AUs#Ar{6Am^8M{S( zc%K7y2YbcLUz+*eDTXdthNE)Lm^P&*e^eV zilOS9)TVKgr9_^_M!TJ^44v<YF2NO=h(oOr5jYxVTxWk0XJ8n0{F_SOH%49WMk*Sg7`g6B(=^< z*rLAW;8I5;1?;Fh{N=f;kxjLpj}u^mD|k8lih|G4#}wEG1j`HIG( z8y;BMR3cE01e?(+k8NLR|Z+)#>qR^iMZc=BkcixWSKYmkaHpIFN?s%*74kc&wxwB zrtbYBGz9%pvV6E(uli6j)5ir%#lQkjb3dvlX*rw5tLv#Z>OZm@`Bf2t{r>u^&lRCg z11*w4A;Lyb@q~I(UQMdvrmi=)$OCVYnk+t;^r>c#G8`h!o`YcqH8gU}9po>S=du9c*l_g~>doGE0IcWrED`rvE=z~Ywv@;O-##+DMmBR>lb!~_7 zR`BUxf?+5fruGkiwwu|HbWP^Jzui=9t^Pmg#NmGvp(?!d)5EY<%rIhD=9w5u)G z%IE9*4yz9o$1)VZJQuppnkY)lK!TBiW`sGyfH16#{EV>_Im$y783ui)a;-}3CPRt- zmxO@Yt$vIOrD}k_^|B2lDb2%nl2OWg6Y)59a?)gy#YtpS+gXx?_I|RZ&XPO`M!yl7 z;2IS@aT4!^l`Tped5UGWStOw5PrH#`=se%(ox%gmJUBk18PsN$*-J8S%r51Y$i!4N zQ!rW%cgj44jA~_x%%smSTU2WG_W0c&PB$A5*kl8{$|865+lSIX~uyDT`uI7qnS!BPAg1Wwrc0e)8Usf zv9^E38H&hWSp5!@K8Qinl|)9 zEB?NMaxZK^GB!PUf1TBw+`H&jFSNI=Q@v5$Ryf-y^#IuXO#vsM5R+9@qz#z0fD0GP z9|Hj#E>?<=HTcsF$`xn`je~D&3kF1Qi%dfH{sKh!~(IpgjkDGQn zQx2F9rv{*x2$(@P9v?|JZY)^b9cd+SO6_1#63n-HAY3fE&s(G031g2@Q^a@63@o?I zE_^r%aUvMhsOi=tkW;}Shom;+Nc%cdktxtkh|>BIneNRGIK{m_1`lDB*U=m|M^HGl zWF#z8NRBduQcF-G43k2-5YrD}6~rn2DKdpV0gD%Kl{02J{G3<4zSJ1GFFSXFehumq zyPvyjMp2SLpdE5dG#@%A>+R3%AhLAwyqxjvGd{I7J`Iw{?=KKPRzyrdFeU}Qj{rm{351DoP_;vx zMo*s+!Gwgn;${(LXXO(xyI@$ULPZI|uzYR%`>MmW6Hcr1y2aM5b$grFwW_(9Fzz$Q z$&8dKNdWvBkK=iYWA|0}s1B7>8J$g*Ij_+S9vC1#jy~uA8nr)yY)a+ zoJ=e>Lp`7v3^tQN<&6UpDi{c1b}F~fJ$9r=p=@U^J_7bOck$5}ncVjYB0yEjbWrhe@E`j64yN3X?=k_F3BalH$aN zV=94?wDNv=BKLB<1*xU|65Zl!%51r5sHQ?qCggCw;$2QfCZ$lN40WPL=n^{Prf^QS zjbZ&1MRGgiZ2T)}DpiluFr#q*!AZJ$1v#d10YQ{>wQ5px!y28-1hCZ7lwvQnQYN*U zOg9BpvB0A$WUzFs+KWk1qLiGTrDT-0>DUpFl??l(FqWVz_3_Xzqg9vTpagp- zZcJ!5W?|0G%W|AJVVHJ7`u6@<4yyqMGHj@kpv`P+LV<)%PM__Rz&oq~t-*vV12@NR zoEVPz<2D>O==MlNI`;l8Gmv49&|1`FR!}2`NLRCqA{@`imLz6zrjS4ui0)O;!Pu&?KPAcX)?tDPS26uKvR(ry(p{6kiXPoZbnQ!vx6dLu zZCaj~Ocr$h##KqsD;9;ZiUwhmUd%5lrwczWr1Yn6V>+IK=>51;N7JDkrm1NY-ZBes z;FxeOTb^HAyA+~P2}WvSSu_fzt_K=(m4wUp%c*^hF zEJ+1dP0{0B8bryXR+qApLz43iu?ga<5QQxTa$1gMCBq0W=4|DTv4nY4T*-^Im%>U~ z)98;hc(d7vk0zAML$WnPWsqK>=O-FZSLI3_WQKr*PCK=(i6LelZ$$}XXrD5cb~VXz zT%egX>8e;KZs@jcD>cL9VP(Q}b0r~ST$Mc%mr1cC8mqRUQc|N^9@Weu$Z|KeczK7HhSFeFV0i)MQmwrn7CBL=p`_9n?nh320m}6-MSv3L7I*<*56GR zZ`zI^1zyC7F#*zVL@M)F2+oqxydaiQz?|ODmqs|Ub8%&KXk9P3P7<4tM?X{~!;Ygw zt=h7)AYGDO9F&wV=BhCyD9exr#YM_-<;Fo~iE>IBEXK$%;JCUAEr;lR&3S_DUy_E) z#!oCYdENVE9OaaeaIrPk-odMtvdFG;ocA#`L6AifMu0og^?Oy9F|Et9q6 z8;3_|9+Io@hqYoN;58x1K&OP!9Vd#dzhTRjB2kI?%31ceHb#Q~WqJV5lw;@b>4@Rd z={z1S`d05YdWC*RLc7sR0bVGSytn-a3`JZL3|d8KC?vj_70Vi4ohP9QbU&Q4?Zjd0 zSZA?KbqLBsJg(qj>fycto3`zN-)lDe4{Ij-QfoBn@rT_tTszA+CnM~xWmE(4zfpCQ z;zPJfl3=ctrggYM!KQg;V{J;utMMF9&BfOe!<{wU0ph?-VQ%cv3B%fFiW?6xBPdf0 zD-HhEU?0C`G@7e+b-=8fj=TP3mdz&SIQ}Nd`*G#DTz9Y@b zaoDF}Gx7ZhPzpDhi^fA7WZ)EAEFv;N2*bKp0T za0t<^1|Zc#`A+?s$!$8eO4CK~PUFECC3BwNR4f)!V&-Y>$xg(%T{MtrH|CPcO(Lf> zE_meE1?6S-qlV^p2fh! zT11Ub)hHw!_mpFDMIAFB`%Yal+`1IXV>b?%!q^Ps%8nh8wtjVGlF-!5x*D29WJ4=M zZ7X(QvKe$YZNgM(HibD7+VO5Q29?@HzS?k$c|3B@JI6dlLgu5S&LbU4=4p-Yn||z@ z4p05vq*k*pbOV9QjVTMp8`c$?t@~!$8&5AP_sz@tk%a$nWHMh-Gm{WS5+q)5W6pU# za@YZXJCLTpZ}zb=$HCYbIm->?Hu6XIBz_d7)n1+3eSLzGVoNQCTHcu9qS2@({0sxc zu<-mhx@Xz_*(S1DEL|d0`YV7uNevL*Y6|DAQmvSp{4DzPL@>hqJ?`FjvIU;<&}YEKDmFUGSBYjRmK{Km-1m%-t=fFfI9kV|POH|SxvO=P+><+1JK_lt5F6fTPf8PXU+lYEJz__** z&>`4F2F8EWE+k7ZsZx9%!?A56{lsk1juYw5zN)V+g$d^Q^Gm}fnHKA6L^36=`e;p% zp{;JD$X3%}O7qINR*2<>a422}_hmc=)-A7B-1#2v85jN5K31t0DtmqON-Dim`XIR; zOo`KRv)gtn?stp*`^f>}UDnGYGnJAbl(4srd>(5fo2#oqi>#bus86EHfeItFIu$+% z;lE|3gjQA`BXHEE5JdcjCoethN`@NEc~zm6CYf@LJ|hT^1>l}gRl7oDHMnw!*5*IC z@@Mi=gO=lZSnWln`dX^4Bd{9zYG{HNIX-87A#5OM%xu*%V?7K3j3CHcN*t!zNK4N4 z!U2?a>0`8m8}UQshILC0g6-k>8~;SRIJ?vQKDj z@U{DrstWIT7ufyRYox^&*IyHYb$3wtB}V^0sS|1OyK#sDc%sh+(gy&NT9j4Aa7J0C zPe$02TylMjad&|{_oe3`zx)Cqns?6qThYue6U=~j5+l0Po4`bX*&9V@a<-O;;vCzm z(af&;e<^}?5$7&MRW$eb*P< zX|33QmDvFSDFK-qMz|RF|Eedum@~W zt~8C1@i8@LammTr)rAgKm8X_SczCg@+@LeWpcmx;VL;iLQJ;t%Z*|XbNWUnHX|o=Q z%bsXc%bw=pk~8%3aV-w(7E$co9_cHQ$!}Ep6YcoCb7~GQBWl#4D!T8A5!P*tSl4FK zK2CX0mjmosg6TSK@-E-He{dm0?9h{&v~}OX15xgF<1-w4DCypYo22%@;uRq`ZFld- z{Uqof@a@P5dW@kfF-`1B1(!R>(DHb&$UXY%Gd+6r?w8klhP&ldzG*6#l#VuM&`)ki z)f$+Rp?YYog9u==<#MC%1daG#%3EOX9A{7$`_(s#_4mV`xZaB+6YlX`H4{}vq;)TF zo~fR@do6EZIR?413A$V6o^fq&QV7P(bB(9m1969szOosyhZRYciAWXe4@u-}s(LeJpuIkSx)XvjXmvVEseG zJvWN4s|$6r;s(3F+cgeh4DMEq??h!$eb^5h#`whT5d03qfYpol8dCim)A^NG1-H}} z!b)V8DTL2Q8@R2p`y4@CeSVj9;8B5#O?jfl-j<$Quv?Ztwp*)GvQ~|W8i6?-ZV@Lf z8$04U_1m{2|AIu+rd8KW`Qk|P1w(}d%}cjG6cxsTJ3Y&*J^_@bQgXwILWY7w zx+z)v81rZv-|mi>y#p$4S7AA760X?)P&0e{iKcWq4xvv@KA@EWjPGdt8CKvh4}p}~ zdUVzuzkBlU2Z+*hTK214><61~h~9zQ3k+-{Pv~w`#4|YdjTFKc{===9Ml7EMFmE!f zH}U3O{Z`DuJrBZbz~OjSVlD6uZSEeNK8epja_LanEh8v;_$Eg9?g*9ihMoat$#qd^ z?;x?a*y3-pW#6|kF^<$w;2^~s!fc;3D~#&#WYZfK@3;bO{MvmN?>qy%_%v`BVCgfC zdwL~(H14Gr6w(1CX|R;zhZh%?*Q{hxJH`MV2)@Jg$pbqjZeL+LO7^vwgi!@3yn@NT zU91-{;BWIi8bV-j-YR|A9Qs?M?e7Ru&Onl1(Sz(kxAw?LEbd+Le%Z43rZgb2h2m|e z^rblc;4r+}?@tC(YIBB_qpQL?_kg{;zO#6JD9{;HSUgf@zIZ)}Bh4wFZIs>meSd}f z4iF~nD$KAV6CVEw+{YOPrW~~y~Y=?snG4dE3edN$~SXh`!c_F zUsQ1M;ARz&v0mIbfP}aLWZ&cBPU+DU{l+0}_>9DZGL{@}lF6QCtgAg;EWUu`D$Evm znblG}kC!}Mw)bR~U;+S}T9TVc6lXWR!LNMm)nmxr*ORkv#&UO$_WQpt0WdX{A=bjC zV^lB~(r;y!C4$Rk0fWUR|09O?KBos@aFQjUx{ODABcj}h5~ObwM_cS>5;iI^I- zPVEP9qrox2CFbG`T5r_GwQQpoI0>mVc_|$o>zdY5vbE~B%oK26jZ)m=1nu_uLEvZ< z8QI_G?ejz`;^ap+REYQzBo}7CnlSHE_DI5qrR!yVx3J1Jl;`UaLnKp2G$R__fAe;R(9%n zC)#)tvvo-9WUBL~r_=XlhpWhM=WS6B0DItw{1160xd;M(JxX_-a&i%PXO@}rnu73_ zObHBZrH%R!#~pjEp~P?qIj4MdAx@sv;E96Doi$eO-~)oUz%Z0Tr4K`-jl06Il!9{s zdjF*1r{XU?)C(%XKPm;UnpnDGD%QL3pgo0ust~+sB0pa|v37>E1dp*Odn)n=DY;5j zDzSAkU9B6F$;|##_mrDe#%hd7pC1u`{9ZKeDdtkyl&4>H=e)Fq@}$UffPt1#cjYZg zd%O%xpg4~brEr>AnKT)kF@`cdX4tMlZ#Vk!l1Xz!G970p`Gkv^lk-|>jmt0W5Wu6woGf?hNA zXO2?BG)<{`NsYAY#3|L^x*=rS7uWU~s<*UhTC8AYc#lGP-=Aw1I)@y(<` znQb^nL~$rlDbsdAc4nc#{+$_;Z4iY;Pi0i9Q;>ZB3+IjWLg_r40-Fso^xF<*_s7Tj zujFrMH{vW3PmCndjQIscnQE%`Qj|E2kidi#c&PcWIMyH+e#7!l`<$_)*pDP$!49pY6w!bN)j8~A1wV%gIakf+vA04 zV)_Q=QMPSj6$M2Ar#KhhxsbZUOq3nZHh8m0?Fr}I6N(Fk zkhXM(f57yOa8vn^97J+g9ISPa=-**6^8ZX&g=z+m&6~x<1>)MyM&tpbWhSf8#+Pcd4rVK#)NSw>1eLKHTO z44A@sc_}Ypi#ggFRbDRFV(IhOnRU&XPrQYh9`mVMo-^U$&AwsXooSRUFqJ7)XUXCK zFpt;gJ}9QTN9xy9$=3OnRkjgUuQZ`X)!}LBm~WUIEKuK-Z%}f?2?+MKucWU<3)>9G zxsz~2pHut1AmH<@66;LdCB9+dSpojE4ggrYS?%icv*Rpi?G0Q($^`(g<1&Z){O_5B$@f#;I2-+Qa1P$a@=u-vOY5vqo z|6G67X;*A|V86ZET9OpFB&02twZtc2K}~ASoQpM_p{vJ{-XvA8UmQa4Ed%fS{D@g( zr_aY0gKw*=2SIGznXXKFo$r0x3)@bq8@4od^U(L0-jvTsK@qYOWX?2G_>N+?;r{TU2{M>V0zid zB_Zu?WSnRl@k?oE*gsgv;jH@+ z-}BDGyR-ls7$dz{e( ztv7lI2|OxNkLD4zc3xGA`!d7LiSdOys4H!8aA(_c0Nm*uLjS4TW%Z3v>am1nwQ_lI zIs85Uufd;cv-(4wi(Js;QsL#|qdv)n;r_?puaK*1>zTC@d=#sK+q1YF_Q(5B%%3TtI8&bNs_e8vIb;oc|Rk`F~u?|A?jj{c={?{Env{mW#q@8 z)#WEgt4B6b&X2?o3=b`ilz;)-h$t4;hsxPDo-%5C(7m#c9tZF-U`vcx0HnVtf_X(}4Tg}4wx(=y!@T7{)4;I_p95mBhikg-|U9z35q`|!1+Zz@97 z(PFE5jCv|=t;^=(CLqYp)k90rV4ZSiFDAhD8YOCzv{}1WDuB?epORibW36);q(Aig ze27@D?lN-ZyjuB4GsebA$;+(KGiOtCe6Bfd%GKRty>dBS1GUe}MXgnu61UdgO=m1& zE(eECPF_%J-lU{;R)eQJot;;}Wch$-8Z|lxN*AAdc;bkpbD`W}F=Z}^Cy(SKyfF#+ zQSalA%JDDAu|77$M3E|kv==3vx~pFPw_<+9xgcE#oigh*>#QsA2}sTYO7uY(h@dhR zHJBi^bb-`1?<1cGFZJa8Akzs{H^$N<)5@hlXeKwt9hD5^5K&`pdHOI92p<7XhS?>| z(5h9KYctN|H+W~Xh2N4W+yjMyBm(AdewjX?PBuRU$^J zS#+U($K6rhFFzf z0q*kJ>B6xI1qAti?H@X@dxtB7_vT+Nj@PNxr?CSK#xqE6jh5S{`nH#zzvjOId=i1X zK(Yjl!7KF(73GXYLVkQA5irn|v-ArCqwi)CM8X&m!#@NQ3bqmQlfurU4qT`zl_m^C zhpk?mfVvy9L|)*+bW8&NY4lG$@0_PKfO9+~(zrbn?wECGi7472W{H&dRPZum^Qf z73C-TR6$#q>XJgYnUgV!WkbmRas;`TY#7CxPXIEGwT6VPBDKbyr#|C2M%q|7l#Ql< zuM}j=2{D+?SxT8?ZJn&Z%cRN8Gu@y(`zV(lfj1T%g44(d#-g&@O0FL5;I9=?bW>!M z%c3J&e}GThdean-<||jUh zlLP`UeKBhhrQ?HHjM3}kfO7Z=EKB%+rs*t+nuBoeuD2yk%n32SA?-s)4+DsTV7U&K zyKQO2b2*tQT}#((=#fkb%hkRkt^%tY&VK$hcs91+hld zJ%lgC!ooILC&|(Z9$zzk=Q0*%&l7wwyf%nv=`C=OcPjb|Q%@9*XkPGFrn+bxp?t^D z!_qO=e-;bnT)^0d|Ex9X&svN9S8M&R>5l*5Df2H@r2l)VfBO@LqeVw`Fz6TSwAt^I z5Wu6A>LNnF7hq4Ow=7D7LEDv3A))d5!M=lT3ConlFN`5eTQMexVVs* zH0tx-*R+-B@&Lp`0V4j6Uy=LJmLQRY_6tH4vnV{_am%kkv|{CYkF}4Wn6U+|9Xre$ zJkO;_=dtw`@aEs|^GlO-zvpp-73H;PYk}V5RrH83G4SVkRJ0YSluQa8pKejcqB4u~ z^9^lDR|?7vEo|jITtaIFI6}1;vTI6n(d0kDGQUJuk>>sqdd7#VBF;?_dM5i<+VMEq zc>habJK}_0eEsOkdwv48d43jKMnqYFMnYDU&c?vi#Fp+S)sxo1-oVJ*g!X^^K! z>z!G8?KfU{qOnLHhaEF4QRHgOpfvoo7@=FG(2ZefYJk- zZuA9ubiTTP9jw9Uzpx8FfJBFt+NNE9dTlM!$g$|lTD za4LMNxWhw8!AV(x;U`IV-(bK@iQ%#QSmq8D$YqLgt?V#|~% z;{ST}6aQbOoewMKYzZT@8|Qq z@9SNBu1UErolMjrhJW-Id&7y<0I<+Z-lr`IHMh1;M)n@g|hx_T-maO`s{Tuhax}EjC zS;1kdL*A3BW5YZXgD|0zm)g3_3vMs>5xgHUhQDl19lfQWMcfLTsw$)amgDs>bW*Oe+$UK^`ioL%F0Ua5vb%II+EGS>*I zw)AmqcWBZpWH&Aswk_FJT=J|^Gn=MfnDTIzMdnoRUB91MeW?e>+C)g3_FDN8rN$(? zL+kH!*L}rq`MK`KDt^v4nUJg3Ce-`IW0Ph0?|}Puq5WIS_a7iEO;~mGQqqo=Ey;ND zhBXA^$ZrCc#&0}dMA&@)&TCq5PMzgJPafZCg-6$R zRqJ2+_t+dGUAY@~xPzU3`od7-(8nnuMfM-4#u`Q~`l-CUGC7u*^5VwH`ot;Ck#R1% zRr%?;!NrB$w^}NW=GGR}m!3a9bh#wXrq?fF7j-IS?E_!GaD3KYzcXhCUHhjEl-6b# zCmIF#4y@HN=^#uIz zRFl8D)Ri1<(Kr~Hoi_MtXWP8^AyTKxi1)ew88bV{*Ok8w8YLXBFW0sRJ<(vU{$ym| zz)feLQbz3k;_}2_{-bW`h~t&2$ObtlbS?k2k|5Kbu?FZLDMTVW_Z6p#A)c)`3DD?a*hxHS2Zj zcIiebfsINfWvwY7Z{YOlIQ61b`j=%6{>MPs+`()Q{wq0z0?|jwRN(1IrMQsj40BHx zvBC_Xfcr;55&}MeoP_@#nz$avCh%FJfE5NNAE~fW@L7~f8Y=?Wno31128EYOK8+O! zc4Vaj-DCsB6CPH$?pQQVbb_(tg^x{$STYM_WKLtrh-_-Hq-M%Ubpt6$mCHY!B{ISD zz}grIo^bNVDw4={SA2*nDNq5`e@ZO5r4TbQpHM)~qfD9!s0h(Jf>vYd;I~j<2fD4)_>ctbwNX6S*8>i^*4 zYKI5<4}d;hM!!N|A$@eg09J|HV;!UUVIau_I~dxZp#?a3u0G)pts6GKdCNk>FKxdh_`Xu!>zO3Kv?u+W6cYJPy!@=PuY868>3|Zg} z$7galV~M`d!q(`I{;CJsq6G9>W0}H6gVY`q7S@9s8ak1r{>}*Q0JyH&f!f8(NZxhC zkn|KS64r^A1fniFel2KkxYByk%erCx9UgFLI)`yuA)X z8SU?6kj!numPNCAj}>1ipax(t{%rxU;6`(Nqt$~Z4~76TQ$9d8l`yJ}rniII%HbH= zlS_7o!qB{55at^>N!Voer%)`KMh9Yd@Z?~nc19*hs)NGN954`O9zA&&vJHbm&|D@E za(&z6A=3NfC;>I)hlI@ulP8E@W-ziGe{iCf_mHvWGldxw8{ng-hI({EtOdALnD9zG ze)fU?I(DNt)Bzdd9Cs^>!|+2!xv1SK=I zJ+y_;=Sq-zqD~GKy@{5(my&aPgFfGY&_mayR_)?dF_^Fwc-n!UAG+fQQGfjWE-1MF YM{}PByk10KD_nuQ4E7Du?}+~TKh4V)`~Uy| literal 50710 zcmbTd1CVCTmM+|7+wQV$+qP}n>auOywyU~q+qUhh+uxis_~*a##hm*_WW?9E7Pb7N%LRFiwbEGCJ0XP=%-6oeT$XZcYgtzC2~q zk(K08IQL8oTl}>>+hE5YRgXTB@fZ4TH9>7=79e`%%tw*SQUa9~$xKD5rS!;ZG@ocK zQdcH}JX?W|0_Afv?y`-NgLum62B&WSD$-w;O6G0Sm;SMX65z)l%m1e-g8Q$QTI;(Q z+x$xth4KFvH@Bs6(zn!iF#nenk^Y^ce;XIItAoCsow38eq?Y-Auh!1in#Rt-_D>H^ z=EjbclGGGa6VnaMGmMLj`x3NcwA43Jb(0gzl;RUIRAUDcR1~99l2SAPkVhoRMMtN} zXvC<tOmX83grD8GSo_Lo?%lNfhD#EBgPo z*nf@ppMC#B!T)Ae0RG$mlJWmGl7CkuU~B8-==5i;rS;8i6rJ=PoQxf446XDX9g|c> zU64ePyMlsI^V5Jq5A+BPe#e73+kpc_r1tv#B)~EZ;7^67F0*QiYfrk0uVW;Qb=NsG zN>gsuCwvb?s-KQIppEaeXtEMdc9dy6Dfduz-tMTms+i01{eD9JE&h?Kht*$eOl#&L zJdM_-vXs(V#$Ed;5wyNWJdPNh+Z$+;$|%qR(t`4W@kDhd*{(7-33BOS6L$UPDeE_53j${QfKN-0v-HG z(QfyvFNbwPK%^!eIo4ac1;b>c0vyf9}Xby@YY!lkz-UvNp zwj#Gg|4B~?n?G^{;(W;|{SNoJbHTMpQJ*Wq5b{l9c8(%?Kd^1?H1om1de0Da9M;Q=n zUfn{f87iVb^>Exl*nZ0hs(Yt>&V9$Pg`zX`AI%`+0SWQ4Zc(8lUDcTluS z5a_KerZWe}a-MF9#Cd^fi!y3%@RFmg&~YnYZ6<=L`UJ0v={zr)>$A;x#MCHZy1st7 ztT+N07NR+vOwSV2pvWuN1%lO!K#Pj0Fr>Q~R40{bwdL%u9i`DSM4RdtEH#cW)6}+I-eE< z&tZs+(Ogu(H_;$a$!7w`MH0r%h&@KM+<>gJL@O~2K2?VrSYUBbhCn#yy?P)uF3qWU z0o09mIik+kvzV6w>vEZy@&Mr)SgxPzUiDA&%07m17udz9usD82afQEps3$pe!7fUf z0eiidkJ)m3qhOjVHC_M(RYCBO%CZKZXFb8}s0-+}@CIn&EF(rRWUX2g^yZCvl0bI} zbP;1S)iXnRC&}5-Tl(hASKqdSnO?ASGJ*MIhOXIblmEudj(M|W!+I3eDc}7t`^mtg z)PKlaXe(OH+q-)qcQ8a@!llRrpGI8DsjhoKvw9T;TEH&?s=LH0w$EzI>%u;oD@x83 zJL7+ncjI9nn!TlS_KYu5vn%f*@qa5F;| zEFxY&B?g=IVlaF3XNm_03PA)=3|{n-UCgJoTr;|;1AU9|kPE_if8!Zvb}0q$5okF$ zHaJdmO&gg!9oN|M{!qGE=tb|3pVQ8PbL$}e;NgXz<6ZEggI}wO@aBP**2Wo=yN#ZC z4G$m^yaM9g=|&!^ft8jOLuzc3Psca*;7`;gnHm}tS0%f4{|VGEwu45KptfNmwxlE~ z^=r30gi@?cOm8kAz!EylA4G~7kbEiRlRIzwrb~{_2(x^$-?|#e6Bi_**(vyr_~9Of z!n>Gqf+Qwiu!xhi9f53=PM3`3tNF}pCOiPU|H4;pzjcsqbwg*{{kyrTxk<;mx~(;; z1NMrpaQ`57yn34>Jo3b|HROE(UNcQash!0p2-!Cz;{IRv#Vp5!3o$P8!%SgV~k&Hnqhp`5eLjTcy93cK!3Hm-$`@yGnaE=?;*2uSpiZTs_dDd51U%i z{|Zd9ou-;laGS_x=O}a+ zB||za<795A?_~Q=r=coQ+ZK@@ zId~hWQL<%)fI_WDIX#=(WNl!Dm$a&ROfLTd&B$vatq!M-2Jcs;N2vps$b6P1(N}=oI3<3luMTmC|0*{ zm1w8bt7vgX($!0@V0A}XIK)w!AzUn7vH=pZEp0RU0p?}ch2XC-7r#LK&vyc2=-#Q2 z^L%8)JbbcZ%g0Du;|8=q8B>X=mIQirpE=&Ox{TiuNDnOPd-FLI^KfEF729!!0x#Es z@>3ursjFSpu%C-8WL^Zw!7a0O-#cnf`HjI+AjVCFitK}GXO`ME&on|^=~Zc}^LBp9 zj=-vlN;Uc;IDjtK38l7}5xxQF&sRtfn4^TNtnzXv4M{r&ek*(eNbIu!u$>Ed%` z5x7+&)2P&4>0J`N&ZP8$vcR+@FS0126s6+Jx_{{`3ZrIMwaJo6jdrRwE$>IU_JTZ} z(||hyyQ)4Z1@wSlT94(-QKqkAatMmkT7pCycEB1U8KQbFX&?%|4$yyxCtm3=W`$4fiG0WU3yI@c zx{wfmkZAYE_5M%4{J-ygbpH|(|GD$2f$3o_Vti#&zfSGZMQ5_f3xt6~+{RX=$H8at z?GFG1Tmp}}lmm-R->ve*Iv+XJ@58p|1_jRvfEgz$XozU8#iJS})UM6VNI!3RUU!{5 zXB(+Eqd-E;cHQ>)`h0(HO_zLmzR3Tu-UGp;08YntWwMY-9i^w_u#wR?JxR2bky5j9 z3Sl-dQQU$xrO0xa&>vsiK`QN<$Yd%YXXM7*WOhnRdSFt5$aJux8QceC?lA0_if|s> ze{ad*opH_kb%M&~(~&UcX0nFGq^MqjxW?HJIP462v9XG>j(5Gat_)#SiNfahq2Mz2 zU`4uV8m$S~o9(W>mu*=h%Gs(Wz+%>h;R9Sg)jZ$q8vT1HxX3iQnh6&2rJ1u|j>^Qf`A76K%_ubL`Zu?h4`b=IyL>1!=*%!_K)=XC z6d}4R5L+sI50Q4P3upXQ3Z!~1ZXLlh!^UNcK6#QpYt-YC=^H=EPg3)z*wXo*024Q4b2sBCG4I# zlTFFY=kQ>xvR+LsuDUAk)q%5pEcqr(O_|^spjhtpb1#aC& zghXzGkGDC_XDa%t(X`E+kvKQ4zrQ*uuQoj>7@@ykWvF332)RO?%AA&Fsn&MNzmFa$ zWk&&^=NNjxLjrli_8ESU)}U|N{%j&TQmvY~lk!~Jh}*=^INA~&QB9em!in_X%Rl1&Kd~Z(u z9mra#<@vZQlOY+JYUwCrgoea4C8^(xv4ceCXcejq84TQ#sF~IU2V}LKc~Xlr_P=ry zl&Hh0exdCbVd^NPCqNNlxM3vA13EI8XvZ1H9#bT7y*U8Y{H8nwGpOR!e!!}*g;mJ#}T{ekSb}5zIPmye*If(}}_=PcuAW#yidAa^9-`<8Gr0 z)Fz=NiZ{)HAvw{Pl5uu)?)&i&Us$Cx4gE}cIJ}B4Xz~-q7)R_%owbP!z_V2=Aq%Rj z{V;7#kV1dNT9-6R+H}}(ED*_!F=~uz>&nR3gb^Ce%+0s#u|vWl<~JD3MvS0T9thdF zioIG3c#Sdsv;LdtRv3ml7%o$6LTVL>(H`^@TNg`2KPIk*8-IB}X!MT0`hN9Ddf7yN z?J=GxPL!uJ7lqwowsl?iRrh@#5C$%E&h~Z>XQcvFC*5%0RN-Opq|=IwX(dq(*sjs+ zqy99+v~m|6T#zR*e1AVxZ8djd5>eIeCi(b8sUk)OGjAsKSOg^-ugwl2WSL@d#?mdl zib0v*{u-?cq}dDGyZ%$XRY=UkQwt2oGu`zQneZh$=^! zj;!pCBWQNtvAcwcWIBM2y9!*W|8LmQy$H~5BEx)78J`4Z0(FJO2P^!YyQU{*Al+fs z){!4JvT1iLrJ8aU3k0t|P}{RN)_^v%$$r;+p0DY7N8CXzmS*HB*=?qaaF9D@#_$SN zSz{moAK<*RH->%r7xX~9gVW$l7?b|_SYI)gcjf0VAUJ%FcQP(TpBs; zg$25D!Ry_`8xpS_OJdeo$qh#7U+cepZ??TII7_%AXsT$B z=e)Bx#v%J0j``00Zk5hsvv6%T^*xGNx%KN-=pocSoqE5_R)OK%-Pbu^1MNzfds)mL zxz^F4lDKV9D&lEY;I+A)ui{TznB*CE$=9(wgE{m}`^<--OzV-5V4X2w9j(_!+jpTr zJvD*y6;39&T+==$F&tsRKM_lqa1HC}aGL0o`%c9mO=fts?36@8MGm7Vi{Y z^<7m$(EtdSr#22<(rm_(l_(`j!*Pu~Y>>xc>I9M#DJYDJNHO&4=HM%YLIp?;iR&$m z#_$ZWYLfGLt5FJZhr3jpYb`*%9S!zCG6ivNHYzNHcI%khtgHBliM^Ou}ZVD7ehU9 zS+W@AV=?Ro!=%AJ>Kcy9aU3%VX3|XM_K0A+ZaknKDyIS3S-Hw1C7&BSW5)sqj5Ye_ z4OSW7Yu-;bCyYKHFUk}<*<(@TH?YZPHr~~Iy%9@GR2Yd}J2!N9K&CN7Eq{Ka!jdu; zQNB*Y;i(7)OxZK%IHGt#Rt?z`I|A{q_BmoF!f^G}XVeTbe1Wnzh%1g>j}>DqFf;Rp zz7>xIs12@Ke0gr+4-!pmFP84vCIaTjqFNg{V`5}Rdt~xE^I;Bxp4)|cs8=f)1YwHz zqI`G~s2~qqDV+h02b`PQpUE#^^Aq8l%y2|ByQeXSADg5*qMprEAE3WFg0Q39`O+i1 z!J@iV!`Y~C$wJ!5Z+j5$i<1`+@)tBG$JL=!*uk=2k;T<@{|s1$YL079FvK%mPhyHV zP8^KGZnp`(hVMZ;s=n~3r2y;LTwcJwoBW-(ndU-$03{RD zh+Qn$ja_Z^OuMf3Ub|JTY74s&Am*(n{J3~@#OJNYuEVVJd9*H%)oFoRBkySGm`hx! zT3tG|+aAkXcx-2Apy)h^BkOyFTWQVeZ%e2@;*0DtlG9I3Et=PKaPt&K zw?WI7S;P)TWED7aSH$3hL@Qde?H#tzo^<(o_sv_2ci<7M?F$|oCFWc?7@KBj-;N$P zB;q!8@bW-WJY9do&y|6~mEruZAVe$!?{)N9rZZxD-|oltkhW9~nR8bLBGXw<632!l z*TYQn^NnUy%Ds}$f^=yQ+BM-a5X4^GHF=%PDrRfm_uqC zh{sKwIu|O0&jWb27;wzg4w5uA@TO_j(1X?8E>5Zfma|Ly7Bklq|s z9)H`zoAGY3n-+&JPrT!>u^qg9Evx4y@GI4$n-Uk_5wttU1_t?6><>}cZ-U+&+~JE) zPlDbO_j;MoxdLzMd~Ew|1o^a5q_1R*JZ=#XXMzg?6Zy!^hop}qoLQlJ{(%!KYt`MK z8umEN@Z4w!2=q_oe=;QttPCQy3Nm4F@x>@v4sz_jo{4m*0r%J(w1cSo;D_hQtJs7W z><$QrmG^+<$4{d2bgGo&3-FV}avg9zI|Rr(k{wTyl3!M1q+a zD9W{pCd%il*j&Ft z5H$nENf>>k$;SONGW`qo6`&qKs*T z2^RS)pXk9b@(_Fw1bkb)-oqK|v}r$L!W&aXA>IpcdNZ_vWE#XO8X`#Yp1+?RshVcd zknG%rPd*4ECEI0wD#@d+3NbHKxl}n^Sgkx==Iu%}HvNliOqVBqG?P2va zQ;kRJ$J6j;+wP9cS za#m;#GUT!qAV%+rdWolk+)6kkz4@Yh5LXP+LSvo9_T+MmiaP-eq6_k;)i6_@WSJ zlT@wK$zqHu<83U2V*yJ|XJU4farT#pAA&@qu)(PO^8PxEmPD4;Txpio+2)#!9 z>&=i7*#tc0`?!==vk>s7V+PL#S1;PwSY?NIXN2=Gu89x(cToFm))7L;< z+bhAbVD*bD=}iU`+PU+SBobTQ%S!=VL!>q$rfWsaaV}Smz>lO9JXT#`CcH_mRCSf4%YQAw`$^yY z3Y*^Nzk_g$xn7a_NO(2Eb*I=^;4f!Ra#Oo~LLjlcjke*k*o$~U#0ZXOQ5@HQ&T46l z7504MUgZkz2gNP1QFN8Y?nSEnEai^Rgyvl}xZfMUV6QrJcXp;jKGqB=D*tj{8(_pV zqyB*DK$2lgYGejmJUW)*s_Cv65sFf&pb(Yz8oWgDtQ0~k^0-wdF|tj}MOXaN@ydF8 zNr={U?=;&Z?wr^VC+`)S2xl}QFagy;$mG=TUs7Vi2wws5zEke4hTa2)>O0U?$WYsZ z<8bN2bB_N4AWd%+kncgknZ&}bM~eDtj#C5uRkp21hWW5gxWvc6b*4+dn<{c?w9Rmf zIVZKsPl{W2vQAlYO3yh}-{Os=YBnL8?uN5(RqfQ=-1cOiUnJu>KcLA*tQK3FU`_bM zM^T28w;nAj5EdAXFi&Kk1Nnl2)D!M{@+D-}bIEe+Lc4{s;YJc-{F#``iS2uk;2!Zp zF9#myUmO!wCeJIoi^A+T^e~20c+c2C}XltaR!|U-HfDA=^xF97ev}$l6#oY z&-&T{egB)&aV$3_aVA51XGiU07$s9vubh_kQG?F$FycvS6|IO!6q zq^>9|3U^*!X_C~SxX&pqUkUjz%!j=VlXDo$!2VLH!rKj@61mDpSr~7B2yy{>X~_nc zRI+7g2V&k zd**H++P9dg!-AOs3;GM`(g<+GRV$+&DdMVpUxY9I1@uK28$az=6oaa+PutlO9?6#? zf-OsgT>^@8KK>ggkUQRPPgC7zjKFR5spqQb3ojCHzj^(UH~v+!y*`Smv)VpVoPwa6 zWG18WJaPKMi*F6Zdk*kU^`i~NNTfn3BkJniC`yN98L-Awd)Z&mY? zprBW$!qL-OL7h@O#kvYnLsfff@kDIegt~?{-*5A7JrA;#TmTe?jICJqhub-G@e??D zqiV#g{)M!kW1-4SDel7TO{;@*h2=_76g3NUD@|c*WO#>MfYq6_YVUP+&8e4|%4T`w zXzhmVNziAHazWO2qXcaOu@R1MrPP{t)`N)}-1&~mq=ZH=w=;-E$IOk=y$dOls{6sRR`I5>|X zpq~XYW4sd;J^6OwOf**J>a7u$S>WTFPRkjY;BfVgQst)u4aMLR1|6%)CB^18XCz+r ztkYQ}G43j~Q&1em(_EkMv0|WEiKu;z2zhb(L%$F&xWwzOmk;VLBYAZ8lOCziNoPw1 zv2BOyXA`A8z^WH!nXhKXM`t0;6D*-uGds3TYGrm8SPnJJOQ^fJU#}@aIy@MYWz**H zvkp?7I5PE{$$|~{-ZaFxr6ZolP^nL##mHOErB^AqJqn^hFA=)HWj!m3WDaHW$C)i^ z9@6G$SzB=>jbe>4kqr#sF7#K}W*Cg-5y6kun3u&0L7BpXF9=#7IN8FOjWrWwUBZiU zT_se3ih-GBKx+Uw0N|CwP3D@-C=5(9T#BH@M`F2!Goiqx+Js5xC92|Sy0%WWWp={$(am!#l~f^W_oz78HX<0X#7 zp)p1u~M*o9W@O8P{0Qkg@Wa# z2{Heb&oX^CQSZWSFBXKOfE|tsAm#^U-WkDnU;IowZ`Ok4!mwHwH=s|AqZ^YD4!5!@ zPxJj+Bd-q6w_YG`z_+r;S86zwXb+EO&qogOq8h-Ect5(M2+>(O7n7)^dP*ws_3U6v zVsh)sk^@*c>)3EML|0<-YROho{lz@Nd4;R9gL{9|64xVL`n!m$-Jjrx?-Bacp!=^5 z1^T^eB{_)Y<9)y{-4Rz@9_>;_7h;5D+@QcbF4Wv7hu)s0&==&6u)33 zHRj+&Woq-vDvjwJCYES@$C4{$?f$Ibi4G()UeN11rgjF+^;YE^5nYprYoJNoudNj= zm1pXSeG64dcWHObUetodRn1Fw|1nI$D9z}dVEYT0lQnsf_E1x2vBLql7NrHH!n&Sq z6lc*mvU=WS6=v9Lrl}&zRiu_6u;6g%_DU{9b+R z#YHqX7`m9eydf?KlKu6Sb%j$%_jmydig`B*TN`cZL-g!R)iE?+Q5oOqBFKhx z%MW>BC^(F_JuG(ayE(MT{S3eI{cKiwOtPwLc0XO*{*|(JOx;uQOfq@lp_^cZo=FZj z4#}@e@dJ>Bn%2`2_WPeSN7si^{U#H=7N4o%Dq3NdGybrZgEU$oSm$hC)uNDC_M9xc zGzwh5Sg?mpBIE8lT2XsqTt3j3?We8}3bzLBTQd639vyg^$0#1epq8snlDJP2(BF)K zSx30RM+{f+b$g{9usIL8H!hCO117Xgv}ttPJm9wVRjPk;ePH@zxv%j9k5`TzdXLeT zFgFX`V7cYIcBls5WN0Pf6SMBN+;CrQ(|EsFd*xtwr#$R{Z9FP`OWtyNsq#mCgZ7+P z^Yn$haBJ)r96{ZJd8vlMl?IBxrgh=fdq_NF!1{jARCVz>jNdC)H^wfy?R94#MPdUjcYX>#wEx+LB#P-#4S-%YH>t-j+w zOFTI8gX$ard6fAh&g=u&56%3^-6E2tpk*wx3HSCQ+t7+*iOs zPk5ysqE}i*cQocFvA68xHfL|iX(C4h*67@3|5Qwle(8wT&!&{8*{f%0(5gH+m>$tq zp;AqrP7?XTEooYG1Dzfxc>W%*CyL16q|fQ0_jp%%Bk^k!i#Nbi(N9&T>#M{gez_Ws zYK=l}adalV(nH}I_!hNeb;tQFk3BHX7N}}R8%pek^E`X}%ou=cx8InPU1EE0|Hen- zyw8MoJqB5=)Z%JXlrdTXAE)eqLAdVE-=>wGHrkRet}>3Yu^lt$Kzu%$3#(ioY}@Gu zjk3BZuQH&~7H+C*uX^4}F*|P89JX;Hg2U!pt>rDi(n(Qe-c}tzb0#6_ItoR0->LSt zR~UT<-|@TO%O`M+_e_J4wx7^)5_%%u+J=yF_S#2Xd?C;Ss3N7KY^#-vx+|;bJX&8r zD?|MetfhdC;^2WG`7MCgs>TKKN=^=!x&Q~BzmQio_^l~LboTNT=I zC5pme^P@ER``p$2md9>4!K#vV-Fc1an7pl>_|&>aqP}+zqR?+~Z;f2^`a+-!Te%V? z;H2SbF>jP^GE(R1@%C==XQ@J=G9lKX+Z<@5}PO(EYkJh=GCv#)Nj{DkWJM2}F&oAZ6xu8&g7pn1ps2U5srwQ7CAK zN&*~@t{`31lUf`O;2w^)M3B@o)_mbRu{-`PrfNpF!R^q>yTR&ETS7^-b2*{-tZAZz zw@q5x9B5V8Qd7dZ!Ai$9hk%Q!wqbE1F1c96&zwBBaRW}(^axoPpN^4Aw}&a5dMe+*Gomky_l^54*rzXro$ z>LL)U5Ry>~FJi=*{JDc)_**c)-&faPz`6v`YU3HQa}pLtb5K)u%K+BOqXP0)rj5Au$zB zW1?vr?mDv7Fsxtsr+S6ucp2l#(4dnr9sD*v+@*>g#M4b|U?~s93>Pg{{a5|rm2xfI z`>E}?9S@|IoUX{Q1zjm5YJT|3S>&09D}|2~BiMo=z4YEjXlWh)V&qs;*C{`UMxp$9 zX)QB?G$fPD6z5_pNs>Jeh{^&U^)Wbr?2D6-q?)`*1k@!UvwQgl8eG$r+)NnFoT)L6 zg7lEh+E6J17krfYJCSjWzm67hEth24pomhz71|Qodn#oAILN)*Vwu2qpJirG)4Wnv}9GWOFrQg%Je+gNrPl8mw7ykE8{ z=|B4+uwC&bpp%eFcRU6{mxRV32VeH8XxX>v$du<$(DfinaaWxP<+Y97Z#n#U~V zVEu-GoPD=9$}P;xv+S~Ob#mmi$JQmE;Iz4(){y*9pFyW-jjgdk#oG$fl4o9E8bo|L zWjo4l%n51@Kz-n%zeSCD`uB?T%FVk+KBI}=ve zvlcS#wt`U6wrJo}6I6Rwb=1GzZfwE=I&Ne@p7*pH84XShXYJRgvK)UjQL%R9Zbm(m zxzTQsLTON$WO7vM)*vl%Pc0JH7WhP;$z@j=y#avW4X8iqy6mEYr@-}PW?H)xfP6fQ z&tI$F{NNct4rRMSHhaelo<5kTYq+(?pY)Ieh8*sa83EQfMrFupMM@nfEV@EmdHUv9 z35uzIrIuo4#WnF^_jcpC@uNNaYTQ~uZWOE6P@LFT^1@$o&q+9Qr8YR+ObBkpP9=F+$s5+B!mX2~T zAuQ6RenX?O{IlLMl1%)OK{S7oL}X%;!XUxU~xJN8xk z`xywS*naF(J#?vOpB(K=o~lE;m$zhgPWDB@=p#dQIW>xe_p1OLoWInJRKbEuoncf; zmS1!u-ycc1qWnDg5Nk2D)BY%jmOwCLC+Ny>`f&UxFowIsHnOXfR^S;&F(KXd{ODlm z$6#1ccqt-HIH9)|@fHnrKudu!6B$_R{fbCIkSIb#aUN|3RM>zuO>dpMbROZ`^hvS@ z$FU-;e4W}!ubzKrU@R*dW*($tFZ>}dd*4_mv)#O>X{U@zSzQt*83l9mI zI$8O<5AIDx`wo0}f2fsPC_l>ONx_`E7kdXu{YIZbp1$(^oBAH({T~&oQ&1{X951QW zmhHUxd)t%GQ9#ak5fTjk-cahWC;>^Rg7(`TVlvy0W@Y!Jc%QL3Ozu# zDPIqBCy&T2PWBj+d-JA-pxZlM=9ja2ce|3B(^VCF+a*MMp`(rH>Rt6W1$;r{n1(VK zLs>UtkT43LR2G$AOYHVailiqk7naz2yZGLo*xQs!T9VN5Q>eE(w zw$4&)&6xIV$IO^>1N-jrEUg>O8G4^@y+-hQv6@OmF@gy^nL_n1P1-Rtyy$Bl;|VcV zF=p*&41-qI5gG9UhKmmnjs932!6hceXa#-qfK;3d*a{)BrwNFeKU|ge?N!;zk+kB! zMD_uHJR#%b54c2tr~uGPLTRLg$`fupo}cRJeTwK;~}A>(Acy4k-Xk&Aa1&eWYS1ULWUj@fhBiWY$pdfy+F z@G{OG{*v*mYtH3OdUjwEr6%_ZPZ3P{@rfbNPQG!BZ7lRyC^xlMpWH`@YRar`tr}d> z#wz87t?#2FsH-jM6m{U=gp6WPrZ%*w0bFm(T#7m#v^;f%Z!kCeB5oiF`W33W5Srdt zdU?YeOdPG@98H7NpI{(uN{FJdu14r(URPH^F6tOpXuhU7T9a{3G3_#Ldfx_nT(Hec zo<1dyhsVsTw;ZkVcJ_0-h-T3G1W@q)_Q30LNv)W?FbMH+XJ* zy=$@39Op|kZv`Rt>X`zg&at(?PO^I=X8d9&myFEx#S`dYTg1W+iE?vt#b47QwoHI9 zNP+|3WjtXo{u}VG(lLUaW0&@yD|O?4TS4dfJI`HC-^q;M(b3r2;7|FONXphw-%7~* z&;2!X17|05+kZOpQ3~3!Nb>O94b&ZSs%p)TK)n3m=4eiblVtSx@KNFgBY_xV6ts;NF;GcGxMP8OKV^h6LmSb2E#Qnw ze!6Mnz7>lE9u{AgQ~8u2zM8CYD5US8dMDX-5iMlgpE9m*s+Lh~A#P1er*rF}GHV3h z=`STo?kIXw8I<`W0^*@mB1$}pj60R{aJ7>C2m=oghKyxMbFNq#EVLgP0cH3q7H z%0?L93-z6|+jiN|@v>ix?tRBU(v-4RV`}cQH*fp|)vd3)8i9hJ3hkuh^8dz{F5-~_ zUUr1T3cP%cCaTooM8dj|4*M=e6flH0&8ve32Q)0dyisl))XkZ7Wg~N}6y`+Qi2l+e zUd#F!nJp{#KIjbQdI`%oZ`?h=5G^kZ_uN`<(`3;a!~EMsWV|j-o>c?x#;zR2ktiB! z);5rrHl?GPtr6-o!tYd|uK;Vbsp4P{v_4??=^a>>U4_aUXPWQ$FPLE4PK$T^3Gkf$ zHo&9$U&G`d(Os6xt1r?sg14n)G8HNyWa^q8#nf0lbr4A-Fi;q6t-`pAx1T*$eKM*$ z|CX|gDrk#&1}>5H+`EjV$9Bm)Njw&7-ZR{1!CJTaXuP!$Pcg69`{w5BRHysB$(tWUes@@6aM69kb|Lx$%BRY^-o6bjH#0!7b;5~{6J+jKxU!Kmi# zndh@+?}WKSRY2gZ?Q`{(Uj|kb1%VWmRryOH0T)f3cKtG4oIF=F7RaRnH0Rc_&372={_3lRNsr95%ZO{IX{p@YJ^EI%+gvvKes5cY+PE@unghjdY5#9A!G z70u6}?zmd?v+{`vCu-53_v5@z)X{oPC@P)iA3jK$`r zSA2a7&!^zmUiZ82R2=1cumBQwOJUPz5Ay`RLfY(EiwKkrx%@YN^^XuET;tE zmr-6~I7j!R!KrHu5CWGSChO6deaLWa*9LLJbcAJsFd%Dy>a!>J`N)Z&oiU4OEP-!Ti^_!p}O?7`}i7Lsf$-gBkuY*`Zb z7=!nTT;5z$_5$=J=Ko+Cp|Q0J=%oFr>hBgnL3!tvFoLNhf#D0O=X^h+x08iB;@8pXdRHxX}6R4k@i6%vmsQwu^5z zk1ip`#^N)^#Lg#HOW3sPI33xqFB4#bOPVnY%d6prwxf;Y-w9{ky4{O6&94Ra8VN@K zb-lY;&`HtxW@sF!doT5T$2&lIvJpbKGMuDAFM#!QPXW87>}=Q4J3JeXlwHys?!1^#37q_k?N@+u&Ns20pEoBeZC*np;i;M{2C0Z4_br2gsh6eL z#8`#sn41+$iD?^GL%5?cbRcaa-Nx0vE(D=*WY%rXy3B%gNz0l?#noGJGP728RMY#q z=2&aJf@DcR?QbMmN)ItUe+VM_U!ryqA@1VVt$^*xYt~-qvW!J4Tp<-3>jT=7Zow5M z8mSKp0v4b%a8bxFr>3MwZHSWD73D@+$5?nZAqGM#>H@`)mIeC#->B)P8T$zh-Pxnc z8)~Zx?TWF4(YfKuF3WN_ckpCe5;x4V4AA3(i$pm|78{%!q?|~*eH0f=?j6i)n~Hso zmTo>vqEtB)`%hP55INf7HM@taH)v`Fw40Ayc*R!T?O{ziUpYmP)AH`euTK!zg9*6Z z!>M=$3pd0!&TzU=hc_@@^Yd3eUQpX4-33}b{?~5t5lgW=ldJ@dUAH%`l5US1y_`40 zs(X`Qk}vvMDYYq+@Rm+~IyCX;iD~pMgq^KY)T*aBz@DYEB={PxA>)mI6tM*sx-DmGQHEaHwRrAmNjO!ZLHO4b;;5mf@zzlPhkP($JeZGE7 z?^XN}Gf_feGoG~BjUgVa*)O`>lX=$BSR2)uD<9 z>o^|nb1^oVDhQbfW>>!;8-7<}nL6L^V*4pB=>wwW+RXAeRvKED(n1;R`A6v$6gy0I(;Vf?!4;&sgn7F%LpM}6PQ?0%2Z@b{It<(G1CZ|>913E0nR2r^Pa*Bp z@tFGi*CQ~@Yc-?{cwu1 zsilf=k^+Qs>&WZG(3WDixisHpR>`+ihiRwkL(3T|=xsoNP*@XX3BU8hr57l3k;pni zI``=3Nl4xh4oDj<%>Q1zYXHr%Xg_xrK3Nq?vKX3|^Hb(Bj+lONTz>4yhU-UdXt2>j z<>S4NB&!iE+ao{0Tx^N*^|EZU;0kJkx@zh}S^P{ieQjGl468CbC`SWnwLRYYiStXm zOxt~Rb3D{dz=nHMcY)#r^kF8|q8KZHVb9FCX2m^X*(|L9FZg!5a7((!J8%MjT$#Fs)M1Pb zq6hBGp%O1A+&%2>l0mpaIzbo&jc^!oN^3zxap3V2dNj3x<=TwZ&0eKX5PIso9j1;e zwUg+C&}FJ`k(M|%%}p=6RPUq4sT3-Y;k-<68ciZ~_j|bt>&9ZLHNVrp#+pk}XvM{8 z`?k}o-!if>hVlCP9j%&WI2V`5SW)BCeR5>MQhF)po=p~AYN%cNa_BbV6EEh_kk^@a zD>4&>uCGCUmyA-c)%DIcF4R6!>?6T~Mj_m{Hpq`*(wj>foHL;;%;?(((YOxGt)Bhx zuS+K{{CUsaC++%}S6~CJ=|vr(iIs-je)e9uJEU8ZJAz)w166q)R^2XI?@E2vUQ!R% zn@dxS!JcOimXkWJBz8Y?2JKQr>`~SmE2F2SL38$SyR1^yqj8_mkBp)o$@+3BQ~Mid z9U$XVqxX3P=XCKj0*W>}L0~Em`(vG<>srF8+*kPrw z20{z(=^w+ybdGe~Oo_i|hYJ@kZl*(9sHw#Chi&OIc?w`nBODp?ia$uF%Hs(X>xm?j zqZQ`Ybf@g#wli`!-al~3GWiE$K+LCe=Ndi!#CVjzUZ z!sD2O*;d28zkl))m)YN7HDi^z5IuNo3^w(zy8 zszJG#mp#Cj)Q@E@r-=NP2FVxxEAeOI2e=|KshybNB6HgE^(r>HD{*}S}mO>LuRGJT{*tfTzw_#+er-0${}%YPe@CMJ1Ng#j#)i)SnY@ss3gL;g zg2D~#Kpdfu#G;q1qz_TwSz1VJT(b3zby$Vk&;Y#1(A)|xj`_?i5YQ;TR%jice5E;0 zYHg;`zS5{S*9xI6o^j>rE8Ua*XhIw{_-*&@(R|C(am8__>+Ws&Q^ymy*X4~hR2b5r zm^p3sw}yv=tdyncy_Ui7{BQS732et~Z_@{-IhHDXAV`(Wlay<#hb>%H%WDi+K$862nA@BDtM#UCKMu+kM`!JHyWSi?&)A7_ z3{cyNG%a~nnH_!+;g&JxEMAmh-Z}rC!o7>OVzW&PoMyTA_g{hqXG)SLraA^OP**<7 zjWbr7z!o2n3hnx7A=2O=WL;`@9N{vQIM@&|G-ljrPvIuJHYtss0Er0fT5cMXNUf1B z7FAwBDixt0X7C3S)mPe5g`YtME23wAnbU)+AtV}z+e8G;0BP=bI;?(#|Ep!vVfDbK zvx+|CKF>yt0hWQ3drchU#XBU+HiuG*V^snFAPUp-5<#R&BUAzoB!aZ+e*KIxa26V}s6?nBK(U-7REa573wg-jqCg>H8~>O{ z*C0JL-?X-k_y%hpUFL?I>0WV{oV`Nb)nZbJG01R~AG>flIJf)3O*oB2i8~;!P?Wo_ z0|QEB*fifiL6E6%>tlAYHm2cjTFE@*<);#>689Z6S#BySQ@VTMhf9vYQyLeDg1*F} zjq>i1*x>5|CGKN{l9br3kB0EHY|k4{%^t7-uhjd#NVipUZa=EUuE5kS1_~qYX?>hJ z$}!jc9$O$>J&wnu0SgfYods^z?J4X;X7c77Me0kS-dO_VUQ39T(Kv(Y#s}Qqz-0AH z^?WRL(4RzpkD+T5FG_0NyPq-a-B7A5LHOCqwObRJi&oRi(<;OuIN7SV5PeHU$<@Zh zPozEV`dYmu0Z&Tqd>t>8JVde9#Pt+l95iHe$4Xwfy1AhI zDM4XJ;bBTTvRFtW>E+GzkN)9k!hA5z;xUOL2 zq4}zn-DP{qc^i|Y%rvi|^5k-*8;JZ~9a;>-+q_EOX+p1Wz;>i7c}M6Nv`^NY&{J-> z`(mzDJDM}QPu5i44**2Qbo(XzZ-ZDu%6vm8w@DUarqXj41VqP~ zs&4Y8F^Waik3y1fQo`bVUH;b=!^QrWb)3Gl=QVKr+6sxc=ygauUG|cm?|X=;Q)kQ8 zM(xrICifa2p``I7>g2R~?a{hmw@{!NS5`VhH8+;cV(F>B94M*S;5#O`YzZH1Z%yD? zZ61w(M`#aS-*~Fj;x|J!KM|^o;MI#Xkh0ULJcA?o4u~f%Z^16ViA27FxU5GM*rKq( z7cS~MrZ=f>_OWx8j#-Q3%!aEU2hVuTu(7`TQk-Bi6*!<}0WQi;_FpO;fhpL4`DcWp zGOw9vx0N~6#}lz(r+dxIGZM3ah-8qrqMmeRh%{z@dbUD2w15*_4P?I~UZr^anP}DB zU9CCrNiy9I3~d#&!$DX9e?A});BjBtQ7oGAyoI$8YQrkLBIH@2;lt4E^)|d6Jwj}z z&2_E}Y;H#6I4<10d_&P0{4|EUacwFHauvrjAnAm6yeR#}f}Rk27CN)vhgRqEyPMMS7zvunj2?`f;%?alsJ+-K+IzjJx>h8 zu~m_y$!J5RWAh|C<6+uiCNsOKu)E72M3xKK(a9Okw3e_*O&}7llNV!=P87VM2DkAk zci!YXS2&=P0}Hx|wwSc9JP%m8dMJA*q&VFB0yMI@5vWoAGraygwn){R+Cj6B1a2Px z5)u(K5{+;z2n*_XD!+Auv#LJEM)(~Hx{$Yb^ldQmcYF2zNH1V30*)CN_|1$v2|`LnFUT$%-tO0Eg|c5$BB~yDfzS zcOXJ$wpzVK0MfTjBJ0b$r#_OvAJ3WRt+YOLlJPYMx~qp>^$$$h#bc|`g0pF-Ao43? z>*A+8lx>}L{p(Tni2Vvk)dtzg$hUKjSjXRagj)$h#8=KV>5s)J4vGtRn5kP|AXIz! zPgbbVxW{2o4s-UM;c#We8P&mPN|DW7_uLF!a|^0S=wr6Esx9Z$2|c1?GaupU6$tb| zY_KU`(_29O_%k(;>^|6*pZURH3`@%EuKS;Ns z1lujmf;r{qAN&Q0&m{wJSZ8MeE7RM5+Sq;ul_ z`+ADrd_Um+G37js6tKsArNB}n{p*zTUxQr>3@wA;{EUbjNjlNd6$Mx zg0|MyU)v`sa~tEY5$en7^PkC=S<2@!nEdG6L=h(vT__0F=S8Y&eM=hal#7eM(o^Lu z2?^;05&|CNliYrq6gUv;|i!(W{0N)LWd*@{2q*u)}u*> z7MQgk6t9OqqXMln?zoMAJcc zMKaof_Up})q#DzdF?w^%tTI7STI^@8=Wk#enR*)&%8yje>+tKvUYbW8UAPg55xb70 zEn5&Ba~NmOJlgI#iS8W3-@N%>V!#z-ZRwfPO1)dQdQkaHsiqG|~we2ALqG7Ruup(DqSOft2RFg_X%3w?6VqvV1uzX_@F(diNVp z4{I|}35=11u$;?|JFBEE*gb;T`dy+8gWJ9~pNsecrO`t#V9jW-6mnfO@ff9od}b(3s4>p0i30gbGIv~1@a^F2kl7YO;DxmF3? zWi-RoXhzRJV0&XE@ACc?+@6?)LQ2XNm4KfalMtsc%4!Fn0rl zpHTrHwR>t>7W?t!Yc{*-^xN%9P0cs0kr=`?bQ5T*oOo&VRRu+1chM!qj%2I!@+1XF z4GWJ=7ix9;Wa@xoZ0RP`NCWw0*8247Y4jIZ>GEW7zuoCFXl6xIvz$ezsWgKdVMBH> z{o!A7f;R-@eK9Vj7R40xx)T<2$?F2E<>Jy3F;;=Yt}WE59J!1WN367 zA^6pu_zLoZIf*x031CcwotS{L8bJE(<_F%j_KJ2P_IusaZXwN$&^t716W{M6X2r_~ zaiMwdISX7Y&Qi&Uh0upS3TyEIXNDICQlT5fHXC`aji-c{U(J@qh-mWl-uMN|T&435 z5)a1dvB|oe%b2mefc=Vpm0C%IUYYh7HI*;3UdgNIz}R##(#{(_>82|zB0L*1i4B5j-xi9O4x10rs_J6*gdRBX=@VJ+==sWb&_Qc6tSOowM{BX@(zawtjl zdU!F4OYw2@Tk1L^%~JCwb|e#3CC>srRHQ*(N%!7$Mu_sKh@|*XtR>)BmWw!;8-mq7 zBBnbjwx8Kyv|hd*`5}84flTHR1Y@@uqjG`UG+jN_YK&RYTt7DVwfEDXDW4U+iO{>K zw1hr{_XE*S*K9TzzUlJH2rh^hUm2v7_XjwTuYap|>zeEDY$HOq3X4Tz^X}E9z)x4F zs+T?Ed+Hj<#jY-`Va~fT2C$=qFT-5q$@p9~0{G&eeL~tiIAHXA!f6C(rAlS^)&k<- zXU|ZVs}XQ>s5iONo~t!XXZgtaP$Iau;JT%h)>}v54yut~pykaNye4axEK#5@?TSsQ zE;Jvf9I$GVb|S`7$pG)4vgo9NXsKr?u=F!GnA%VS2z$@Z(!MR9?EPcAqi5ft)Iz6sNl`%kj+_H-X`R<>BFrBW=fSlD|{`D%@Rcbu2?%>t7i34k?Ujb)2@J-`j#4 zLK<69qcUuniIan-$A1+fR=?@+thwDIXtF1Tks@Br-xY zfB+zblrR(ke`U;6U~-;p1Kg8Lh6v~LjW@9l2P6s+?$2!ZRPX`(ZkRGe7~q(4&gEi<$ch`5kQ?*1=GSqkeV z{SA1EaW_A!t{@^UY2D^YO0(H@+kFVzZaAh0_`A`f(}G~EP~?B|%gtxu&g%^x{EYSz zk+T;_c@d;+n@$<>V%P=nk36?L!}?*=vK4>nJSm+1%a}9UlmTJTrfX4{Lb7smNQn@T zw9p2%(Zjl^bWGo1;DuMHN(djsEm)P8mEC2sL@KyPjwD@d%QnZ$ zMJ3cnn!_!iP{MzWk%PI&D?m?C(y2d|2VChluN^yHya(b`h>~GkI1y;}O_E57zOs!{ zt2C@M$^PR2U#(dZmA-sNreB@z-yb0Bf7j*yONhZG=onhx>t4)RB`r6&TP$n zgmN*)eCqvgriBO-abHQ8ECN0bw?z5Bxpx z=jF@?zFdVn?@gD5egM4o$m`}lV(CWrOKKq(sv*`mNcHcvw&Xryfw<{ch{O&qc#WCTXX6=#{MV@q#iHYba!OUY+MGeNTjP%Fj!WgM&`&RlI^=AWTOqy-o zHo9YFt!gQ*p7{Fl86>#-JLZo(b^O`LdFK~OsZBRR@6P?ad^Ujbqm_j^XycM4ZHFyg ziUbIFW#2tj`65~#2V!4z7DM8Z;fG0|APaQ{a2VNYpNotB7eZ5kp+tPDz&Lqs0j%Y4tA*URpcfi z_M(FD=fRGdqf430j}1z`O0I=;tLu81bwJXdYiN7_&a-?ly|-j*+=--XGvCq#32Gh(=|qj5F?kmihk{%M&$}udW5)DHK zF_>}5R8&&API}o0osZJRL3n~>76nUZ&L&iy^s>PMnNcYZ|9*1$v-bzbT3rpWsJ+y{ zPrg>5Zlery96Um?lc6L|)}&{992{_$J&=4%nRp9BAC6!IB=A&=tF>r8S*O-=!G(_( zwXbX_rGZgeiK*&n5E;f=k{ktyA1(;x_kiMEt0*gpp_4&(twlS2e5C?NoD{n>X2AT# zY@Zp?#!b1zNq96MQqeO*M1MMBin5v#RH52&Xd~DO6-BZLnA6xO1$sou(YJ1Dlc{WF zVa%2DyYm`V#81jP@70IJ;DX@y*iUt$MLm)ByAD$eUuji|5{ptFYq(q)mE(5bOpxjM z^Q`AHWq44SG3`_LxC9fwR)XRVIp=B%<(-lOC3jI#bb@dK(*vjom!=t|#<@dZql%>O z15y^{4tQoeW9Lu%G&V$90x6F)xN6y_oIn;!Q zs)8jT$;&;u%Y>=T3hg34A-+Y*na=|glcStr5D;&5*t5*DmD~x;zQAV5{}Ya`?RRGa zT*t9@$a~!co;pD^!J5bo?lDOWFx%)Y=-fJ+PDGc0>;=q=s?P4aHForSB+)v0WY2JH z?*`O;RHum6j%#LG)Vu#ciO#+jRC3!>T(9fr+XE7T2B7Z|0nR5jw@WG)kDDzTJ=o4~ zUpeyt7}_nd`t}j9BKqryOha{34erm)RmST)_9Aw)@ zHbiyg5n&E{_CQR@h<}34d7WM{s{%5wdty1l+KX8*?+-YkNK2Be*6&jc>@{Fd;Ps|| z26LqdI3#9le?;}risDq$K5G3yoqK}C^@-8z^wj%tdgw-6@F#Ju{Sg7+y)L?)U$ez> zoOaP$UFZ?y5BiFycir*pnaAaY+|%1%8&|(@VB)zweR%?IidwJyK5J!STzw&2RFx zZV@qeaCB01Hu#U9|1#=Msc8Pgz5P*4Lrp!Q+~(G!OiNR{qa7|r^H?FC6gVhkk3y7=uW#Sh;&>78bZ}aK*C#NH$9rX@M3f{nckYI+5QG?Aj1DM)@~z_ zw!UAD@gedTlePB*%4+55naJ8ak_;))#S;4ji!LOqY5VRI){GMwHR~}6t4g>5C_#U# ztYC!tjKjrKvRy=GAsJVK++~$|+s!w9z3H4G^mACv=EErXNSmH7qN}%PKcN|8%9=i)qS5+$L zu&ya~HW%RMVJi4T^pv?>mw*Gf<)-7gf#Qj|e#w2|v4#t!%Jk{&xlf;$_?jW*n!Pyx zkG$<18kiLOAUPuFfyu-EfWX%4jYnjBYc~~*9JEz6oa)_R|8wjZA|RNrAp%}14L7fW zi7A5Wym*K+V8pkqqO-X#3ft{0qs?KVt^)?kS>AicmeO&q+~J~ zp0YJ_P~_a8j= zsAs~G=8F=M{4GZL{|B__UorX@MRNQLn?*_gym4aW(~+i13knnk1P=khoC-ViMZk+x zLW(l}oAg1H`dU+Fv**;qw|ANDSRs>cGqL!Yw^`; zv;{E&8CNJcc)GHzTYM}f&NPw<6j{C3gaeelU#y!M)w-utYEHOCCJo|Vgp7K6C_$14 zqIrLUB0bsgz^D%V%fbo2f9#yb#CntTX?55Xy|Kps&Xek*4_r=KDZ z+`TQuv|$l}MWLzA5Ay6Cvsa^7xvwXpy?`w(6vx4XJ zWuf1bVSb#U8{xlY4+wlZ$9jjPk)X_;NFMqdgq>m&W=!KtP+6NL57`AMljW+es zzqjUjgz;V*kktJI?!NOg^s_)ph45>4UDA!Vo0hn>KZ+h-3=?Y3*R=#!fOX zP$Y~+14$f66ix?UWB_6r#fMcC^~X4R-<&OD1CSDNuX~y^YwJ>sW0j`T<2+3F9>cLo z#!j57$ll2K9(%$4>eA7(>FJX5e)pR5&EZK!IMQzOfik#FU*o*LGz~7u(8}XzIQRy- z!U7AlMTIe|DgQFmc%cHy_9^{o`eD%ja_L>ckU6$O4*U**o5uR7`FzqkU8k4gxtI=o z^P^oGFPm5jwZMI{;nH}$?p@uV8FT4r=|#GziKXK07bHJLtK}X%I0TON$uj(iJ`SY^ zc$b2CoxCQ>7LH@nxcdW&_C#fMYBtTxcg46dL{vf%EFCZ~eErMvZq&Z%Lhumnkn^4A zsx$ay(FnN7kYah}tZ@0?-0Niroa~13`?hVi6`ndno`G+E8;$<6^gsE-K3)TxyoJ4M zb6pj5=I8^FD5H@`^V#Qb2^0cx7wUz&cruA5g>6>qR5)O^t1(-qqP&1g=qvY#s&{bx zq8Hc%LsbK1*%n|Y=FfojpE;w~)G0-X4i*K3{o|J7`krhIOd*c*$y{WIKz2n2*EXEH zT{oml3Th5k*vkswuFXdGDlcLj15Nec5pFfZ*0?XHaF_lVuiB%Pv&p7z)%38}%$Gup zVTa~C8=cw%6BKn_|4E?bPNW4PT7}jZQLhDJhvf4z;~L)506IE0 zX!tWXX(QOQPRj-p80QG79t8T2^az4Zp2hOHziQlvT!|H)jv{Ixodabzv6lBj)6WRB z{)Kg@$~~(7$-az?lw$4@L%I&DI0Lo)PEJJziWP33a3azb?jyXt1v0N>2kxwA6b%l> zZqRpAo)Npi&loWbjFWtEV)783BbeIAhqyuc+~>i7aQ8shIXt)bjCWT6$~ro^>99G} z2XfmT0(|l!)XJb^E!#3z4oEGIsL(xd; zYX1`1I(cG|u#4R4T&C|m*9KB1`UzKvho5R@1eYtUL9B72{i(ir&ls8g!pD ztR|25xGaF!4z5M+U@@lQf(12?xGy`!|3E}7pI$k`jOIFjiDr{tqf0va&3pOn6Pu)% z@xtG2zjYuJXrV)DUrIF*y<1O1<$#54kZ#2;=X51J^F#0nZ0(;S$OZDt_U2bx{RZ=Q zMMdd$fH|!s{ zXq#l;{`xfV`gp&C>A`WrQU?d{!Ey5(1u*VLJt>i27aZ-^&2IIk=zP5p+{$q(K?2(b z8?9h)kvj9SF!Dr zoyF}?V|9;6abHxWk2cEvGs$-}Pg}D+ZzgkaN&$Snp%;5m%zh1E#?Wac-}x?BYlGN#U#Mek*}kek#I9XaHt?mz3*fDrRTQ#&#~xyeqJk1QJ~E$7qsw6 z?sV;|?*=-{M<1+hXoj?@-$y+(^BJ1H~wQ9G8C0#^aEAyhDduNX@haoa=PuPp zYsGv8UBfQaRHgBgLjmP^eh>fLMeh{8ic)?xz?#3kX-D#Z{;W#cd_`9OMFIaJg-=t`_3*!YDgtNQ2+QUEAJB9M{~AvT$H`E)IKmCR21H532+ata8_i_MR@ z2Xj<3w<`isF~Ah$W{|9;51ub*f4#9ziKrOR&jM{x7I_7()O@`F*5o$KtZ?fxU~g`t zUovNEVKYn$U~VX8eR)qb`7;D8pn*Pp$(otYTqL)5KH$lUS-jf}PGBjy$weoceAcPp z&5ZYB$r&P$MN{0H0AxCe4Qmd3T%M*5d4i%#!nmBCN-WU-4m4Tjxn-%j3HagwTxCZ9 z)j5vO-C7%s%D!&UfO>bi2oXiCw<-w{vVTK^rVbv#W=WjdADJy8$khnU!`ZWCIU`># zyjc^1W~pcu>@lDZ{zr6gv%)2X4n27~Ve+cQqcND%0?IFSP4sH#yIaXXYAq^z3|cg` z`I3$m%jra>e2W-=DiD@84T!cb%||k)nPmEE09NC%@PS_OLhkrX*U!cgD*;;&gIaA(DyVT4QD+q_xu z>r`tg{hiGY&DvD-)B*h+YEd+Zn)WylQl}<4>(_NlsKXCRV;a)Rcw!wtelM2_rWX`j zTh5A|i6=2BA(iMCnj_fob@*eA;V?oa4Z1kRBGaU07O70fb6-qmA$Hg$ps@^ka1=RO zTbE_2#)1bndC3VuK@e!Sftxq4=Uux}fDxXE#Q5_x=E1h>T5`DPHz zbH<_OjWx$wy7=%0!mo*qH*7N4tySm+R0~(rbus`7;+wGh;C0O%x~fEMkt!eV>U$`i z5>Q(o z=t$gPjgGh0&I7KY#k50V7DJRX<%^X z>6+ebc9efB3@eE2Tr){;?_w`vhgF>`-GDY(YkR{9RH(MiCnyRtd!LxXJ75z+?2 zGi@m^+2hKJ5sB1@Xi@s_@p_Kwbc<*LQ_`mr^Y%j}(sV_$`J(?_FWP)4NW*BIL~sR>t6 zM;qTJZ~GoY36&{h-Pf}L#y2UtR}>ZaI%A6VkU>vG4~}9^i$5WP2Tj?Cc}5oQxe2=q z8BeLa$hwCg_psjZyC2+?yX4*hJ58Wu^w9}}7X*+i5Rjqu5^@GzXiw#SUir1G1`jY% zOL=GE_ENYxhcyUrEt9XlMNP6kx6h&%6^u3@zB8KUCAa18T(R2J`%JjWZ z!{7cXaEW+Qu*iJPu+m>QqW}Lo$4Z+!I)0JNzZ&_M%=|B1yejFRM04bGAvu{=lNPd+ zJRI^DRQ(?FcVUD+bgEcAi@o(msqys9RTCG#)TjI!9~3-dc`>gW;HSJuQvH~d`MQs86R$|SKXHh zqS9Qy)u;T`>>a!$LuaE2keJV%;8g)tr&Nnc;EkvA-RanHXsy)D@XN0a>h}z2j81R; zsUNJf&g&rKpuD0WD@=dDrPHdBoK42WoBU|nMo17o(5^;M|dB4?|FsAGVrSyWcI`+FVw^vTVC`y}f(BwJl zrw3Sp151^9=}B})6@H*i4-dIN_o^br+BkcLa^H56|^2XsT0dESw2 zMX>(KqNl=x2K5=zIKg}2JpGAZu{I_IO}0$EQ5P{4zol**PCt3F4`GX}2@vr8#Y)~J zKb)gJeHcFnR@4SSh%b;c%J`l=W*40UPjF#q{<}ywv-=vHRFmDjv)NtmC zQx9qm)d%0zH&qG7AFa3VAU1S^(n8VFTC~Hb+HjYMjX8r#&_0MzlNR*mnLH5hi}`@{ zK$8qiDDvS_(L9_2vHgzEQ${DYSE;DqB!g*jhJghE&=LTnbgl&Xepo<*uRtV{2wDHN z)l;Kg$TA>Y|K8Lc&LjWGj<+bp4Hiye_@BfU(y#nF{fpR&|Ltbye?e^j0}8JC4#xi% zv29ZR%8%hk=3ZDvO-@1u8KmQ@6p%E|dlHuy#H1&MiC<*$YdLkHmR#F3ae;bKd;@*i z2_VfELG=B}JMLCO-6UQy^>RDE%K4b>c%9ki`f~Z2Qu8hO7C#t%Aeg8E%+}6P7Twtg z-)dj(w}_zFK&86KR@q9MHicUAucLVshUdmz_2@32(V`y3`&Kf8Q2I)+!n0mR=rrDU zXvv^$ho;yh*kNqJ#r1}b0|i|xRUF6;lhx$M*uG3SNLUTC@|htC z-=fsw^F%$qqz4%QdjBrS+ov}Qv!z00E+JWas>p?z@=t!WWU3K*?Z(0meTuTOC7OTx zU|kFLE0bLZ+WGcL$u4E}5dB0g`h|uwv3=H6f+{5z9oLv-=Q45+n~V4WwgO=CabjM% zBAN+RjM65(-}>Q2V#i1Na@a0`08g&y;W#@sBiX6Tpy8r}*+{RnyGUT`?XeHSqo#|J z^ww~c;ou|iyzpErDtlVU=`8N7JSu>4M z_pr9=tX0edVn9B}YFO2y(88j#S{w%E8vVOpAboK*27a7e4Ekjt0)hIX99*1oE;vex z7#%jhY=bPijA=Ce@9rRO(Vl_vnd00!^TAc<+wVvRM9{;hP*rqEL_(RzfK$er_^SN; z)1a8vo8~Dr5?;0X0J62Cusw$A*c^Sx1)dom`-)Pl7hsW4i(r*^Mw`z5K>!2ixB_mu z*Ddqjh}zceRFdmuX1akM1$3>G=#~|y?eYv(e-`Qy?bRHIq=fMaN~fB zUa6I8Rt=)jnplP>yuS+P&PxeWpJ#1$F`iqRl|jF$WL_aZFZl@kLo&d$VJtu&w?Q0O zzuXK>6gmygq(yXJy0C1SL}T8AplK|AGNUOhzlGeK_oo|haD@)5PxF}rV+5`-w{Aag zus45t=FU*{LguJ11Sr-28EZkq;!mJO7AQGih1L4rEyUmp>B!%X0YemsrV3QFvlgt* z5kwlPzaiJ+kZ^PMd-RRbl(Y?F*m`4*UIhIuf#8q>H_M=fM*L_Op-<_r zBZagV=4B|EW+KTja?srADTZXCd3Yv%^Chfpi)cg{ED${SI>InNpRj5!euKv?=Xn92 zsS&FH(*w`qLIy$doc>RE&A5R?u zzkl1sxX|{*fLpXvIW>9d<$ePROttn3oc6R!sN{&Y+>Jr@yeQN$sFR z;w6A<2-0%UA?c8Qf;sX7>>uKRBv3Ni)E9pI{uVzX|6Bb0U)`lhLE3hK58ivfRs1}d zNjlGK0hdq0qjV@q1qI%ZFMLgcpWSY~mB^LK)4GZ^h_@H+3?dAe_a~k*;9P_d7%NEFP6+ zgV(oGr*?W(ql?6SQ~`lUsjLb%MbfC4V$)1E0Y_b|OIYxz4?O|!kRb?BGrgiH5+(>s zoqM}v*;OBfg-D1l`M6T6{K`LG+0dJ1)!??G5g(2*vlNkm%Q(MPABT$r13q?|+kL4- zf)Mi5r$sn;u41aK(K#!m+goyd$c!KPl~-&-({j#D4^7hQkV3W|&>l_b!}!z?4($OA z5IrkfuT#F&S1(`?modY&I40%gtroig{YMvF{K{>5u^I51k8RriGd${z)=5k2tG zM|&Bp5kDTfb#vfuTTd?)a=>bX=lokw^y9+2LS?kwHQIWI~pYgy7 zb?A-RKVm_vM5!9?C%qYdfRAw& zAU7`up~%g=p@}pg#b7E)BFYx3g%(J36Nw(Dij!b>cMl@CSNbrW!DBDbTD4OXk!G4x zi}JBKc8HBYx$J~31PXH+4^x|UxK~(<@I;^3pWN$E=sYma@JP|8YL`L(zI6Y#c%Q{6 z*APf`DU$S4pr#_!60BH$FGViP14iJmbrzSrOkR;f3YZa{#E7Wpd@^4E-zH8EgPc-# zKWFPvh%WbqU_%ZEt`=Q?odKHc7@SUmY{GK`?40VuL~o)bS|is$Hn=<=KGHOsEC5tB zFb|q}gGlL97NUf$G$>^1b^3E18PZ~Pm9kX%*ftnolljiEt@2#F2R5ah$zbXd%V_Ev zyDd{1o_uuoBga$fB@Fw!V5F3jIr=a-ykqrK?WWZ#a(bglI_-8pq74RK*KfQ z0~Dzus7_l;pMJYf>Bk`)`S8gF!To-BdMnVw5M-pyu+aCiC5dwNH|6fgRsIKZcF&)g zr}1|?VOp}I3)IR@m1&HX1~#wsS!4iYqES zK}4J{Ei>;e3>LB#Oly>EZkW14^@YmpbgxCDi#0RgdM${&wxR+LiX}B+iRioOB0(pDKpVEI;ND?wNx>%e|m{RsqR_{(nmQ z3ZS}@t!p4a(BKx_-CYwrcyJ5u1TO9bcXti$8sy>xcLKqKCc#~UOZYD{llKTSFEjJ~ zyNWt>tLU}*>^`TvPxtP%F`ZJQw@W0^>x;!^@?k_)9#bF$j0)S3;mH-IR5y82l|%=F z2lR8zhP?XNP-ucZZ6A+o$xOyF!w;RaLHGh57GZ|TCXhJqY~GCh)aXEV$1O&$c}La1 zjuJxkY9SM4av^Hb;i7efiYaMwI%jGy`3NdY)+mcJhF(3XEiSlU3c|jMBi|;m-c?~T z+x0_@;SxcoY=(6xNgO$bBt~Pj8`-<1S|;Bsjrzw3@zSjt^JC3X3*$HI79i~!$RmTz zsblZsLYs7L$|=1CB$8qS!tXrWs!F@BVuh?kN(PvE5Av-*r^iYu+L^j^m9JG^#=m>@ z=1soa)H*w6KzoR$B8mBCXoU;f5^bVuwQ3~2LKg!yxomG1#XPmn(?YH@E~_ED+W6mxs%x{%Z<$pW`~ON1~2XjP5v(0{C{+6Dm$00tsd3w=f=ZENy zOgb-=f}|Hb*LQ$YdWg<(u7x3`PKF)B7ZfZ6;1FrNM63 z?O6tE%EiU@6%rVuwIQjvGtOofZBGZT1Sh(xLIYt9c4VI8`!=UJd2BfLjdRI#SbVAX ziT(f*RI^T!IL5Ac>ql7uduF#nuCRJ1)2bdvAyMxp-5^Ww5p#X{rb5)(X|fEhDHHW{ zw(Lfc$g;+Q`B0AiPGtmK%*aWfQQ$d!*U<|-@n2HZvCWSiw^I>#vh+LyC;aaVWGbmkENr z&kl*8o^_FW$T?rDYLO1Pyi%>@&kJKQoH2E0F`HjcN}Zlnx1ddoDA>G4Xu_jyp6vuT zPvC}pT&Owx+qB`zUeR|4G;OH(<<^_bzkjln0k40t`PQxc$7h(T8Ya~X+9gDc8Z9{Z z&y0RAU}#_kQGrM;__MK9vwIwK^aoqFhk~dK!ARf1zJqHMxF2?7-8|~yoO@_~Ed;_wvT%Vs{9RK$6uUQ|&@#6vyBsFK9eZW1Ft#D2)VpQRwpR(;x^ zdoTgMqfF9iBl%{`QDv7B0~8{8`8k`C4@cbZAXBu00v#kYl!#_Wug{)2PwD5cNp?K^ z9+|d-4z|gZ!L{57>!Ogfbzchm>J1)Y%?NThxIS8frAw@z>Zb9v%3_3~F@<=LG%r*U zaTov}{{^z~SeX!qgSYow`_5)ij*QtGp4lvF`aIGQ>@3ZTkDmsl#@^5*NGjOuu82}o zzLF~Q9SW+mP=>88%eSA1W4_W7-Q>rdq^?t=m6}^tDPaBRGFLg%ak93W!kOp#EO{6& zP%}Iff5HZQ9VW$~+9r=|Quj#z*=YwcnssS~9|ub2>v|u1JXP47vZ1&L1O%Z1DsOrDfSIMHU{VT>&>H=9}G3i@2rP+rx@eU@uE8rJNec zij~#FmuEBj03F1~ct@C@$>y)zB+tVyjV3*n`mtAhIM0$58vM9jOQC}JJOem|EpwqeMuYPxu3sv}oMS?S#o6GGK@8PN59)m&K4Dc&X% z(;XL_kKeYkafzS3Wn5DD>Yiw{LACy_#jY4op(>9q>>-*9@C0M+=b#bknAWZ37^(Ij zq>H%<@>o4a#6NydoF{_M4i4zB_KG)#PSye9bk0Ou8h%1Dtl7Q_y#7*n%g)?m>xF~( zjqvOwC;*qvN_3(*a+w2|ao0D?@okOvg8JskUw(l7n`0fncglavwKd?~l_ryKJ^Ky! zKCHkIC-o7%fFvPa$)YNh022lakMar^dgL=t#@XLyNHHw!b?%WlM)R@^!)I!smZL@k zBi=6wE5)2v&!UNV(&)oOYW(6Qa!nUjDKKBf-~Da=#^HE4(@mWk)LPvhyN3i4goB$3K8iV7uh zsv+a?#c4&NWeK(3AH;ETrMOIFgu{_@%XRwCZ;L=^8Ts)hix4Pf3yJRQ<8xb^CkdmC z?c_gB)XmRsk`9ch#tx4*hO=#qS7={~Vb4*tTf<5P%*-XMfUUYkI9T1cEF;ObfxxI-yNuA=I$dCtz3ey znVkctYD*`fUuZ(57+^B*R=Q}~{1z#2!ca?)+YsRQb+lt^LmEvZt_`=j^wqig+wz@n@ z`LIMQJT3bxMzuKg8EGBU+Q-6cs5(@5W?N>JpZL{$9VF)veF`L5%DSYTNQEypW%6$u zm_~}T{HeHj1bAlKl8ii92l9~$dm=UM21kLemA&b$;^!wB7#IKWGnF$TVq!!lBlG4 z{?Rjz?P(uvid+|i$VH?`-C&Gcb3{(~Vpg`w+O);Wk1|Mrjxrht0GfRUnZqz2MhrXa zqgVC9nemD5)H$to=~hp)c=l9?#~Z_7i~=U-`FZxb-|TR9@YCxx;Zjo-WpMNOn2)z) zFPGGVl%3N$f`gp$gPnWC+f4(rmts%fidpo^BJx72zAd7|*Xi{2VXmbOm)1`w^tm9% znM=0Fg4bDxH5PxPEm{P3#A(mxqlM7SIARP?|2&+c7qmU8kP&iApzL|F>Dz)Ixp_`O zP%xrP1M6@oYhgo$ZWwrAsYLa4 z|I;DAvJxno9HkQrhLPQk-8}=De{9U3U%)dJ$955?_AOms!9gia%)0E$Mp}$+0er@< zq7J&_SzvShM?e%V?_zUu{niL@gt5UFOjFJUJ}L?$f%eU%jUSoujr{^O=?=^{19`ON zlRIy8Uo_nqcPa6@yyz`CM?pMJ^^SN^Fqtt`GQ8Q#W4kE7`V9^LT}j#pMChl!j#g#J zr-=CCaV%xyFeQ9SK+mG(cTwW*)xa(eK;_Z(jy)woZp~> zA(4}-&VH+TEeLzPTqw&FOoK(ZjD~m{KW05fiGLe@E3Z2`rLukIDahE*`u!ubU)9`o zn^-lyht#E#-dt~S>}4y$-mSbR8{T@}22cn^refuQ08NjLOv?JiEWjyOnzk<^R5%gO zhUH_B{oz~u#IYwVnUg8?3P*#DqD8#X;%q%HY**=I>>-S|!X*-!x1{^l#OnR56O>iD zc;i;KS+t$koh)E3)w0OjWJl_aW2;xF=9D9Kr>)(5}4FqUbk# zI#$N8o0w;IChL49m9CJTzoC!|u{Ljd%ECgBOf$}&jA^$(V#P#~)`&g`H8E{uv52pp zwto`xUL-L&WTAVREEm$0g_gYPL(^vHq(*t1WCH_6alhkeW&GCZ3hL)|{O-jiFOBrF z!EW=Jej|dqQitT6!B-7&io2K)WIm~Q)v@yq%U|VpV+I?{y0@Yd%n8~-NuuM*pM~KA z85YB};IS~M(c<}4Hxx>qRK0cdl&e?t253N%vefkgds>Ubn8X}j6Vpgs>a#nFq$osY z1ZRwLqFv=+BTb=i%D2Wv>_yE0z}+niZ4?rE|*a3d7^kndWGwnFqt+iZ(7+aln<}jzbAQ(#Z2SS}3S$%Bd}^ zc9ghB%O)Z_mTZMRC&H#)I#fiLuIkGa^`4e~9oM5zKPx?zjkC&Xy0~r{;S?FS%c7w< zWbMpzc(xSw?9tGxG~_l}Acq}zjt5ClaB7-!vzqnlrX;}$#+PyQ9oU)_DfePh2E1<7 ztok6g6K^k^DuHR*iJ?jw?bs_whk|bx`dxu^nC6#e{1*m~z1eq7m}Cf$*^Eua(oi_I zAL+3opNhJteu&mWQ@kQWPucmiP)4|nFG`b2tpC;h{-PI@`+h?9v=9mn|0R-n8#t=+Z*FD(c5 zjj79Jxkgck*DV=wpFgRZuwr%}KTm+dx?RT@aUHJdaX-ODh~gByS?WGx&czAkvkg;x zrf92l8$Or_zOwJVwh>5rB`Q5_5}ef6DjS*$x30nZbuO3dijS*wvNEqTY5p1_A0gWr znH<(Qvb!os14|R)n2Ost>jS2;d1zyLHu`Svm|&dZD+PpP{Bh>U&`Md;gRl64q;>{8MJJM$?UNUd`aC>BiLe>*{ zJY15->yW+<3rLgYeTruFDtk1ovU<$(_y7#HgUq>)r0{^}Xbth}V#6?%5jeFYt;SG^ z3qF)=uWRU;Jj)Q}cpY8-H+l_n$2$6{ZR?&*IGr{>ek!69ZH0ZoJ*Ji+ezzlJ^%qL3 zO5a`6gwFw(moEzqxh=yJ9M1FTn!eo&qD#y5AZXErHs%22?A+JmS&GIolml!)rZTnUDM3YgzYfT#;OXn)`PWv3Ta z!-i|-Wojv*k&bC}_JJDjiAK(Ba|YZgUI{f}TdEOFT2+}nPmttytw7j%@bQZDV1vvj z^rp{gRkCDmYJHGrE1~e~AE!-&6B6`7UxVQuvRrfdFkGX8H~SNP_X4EodVd;lXd^>eV1jN+Tt4}Rsn)R0LxBz0c=NXU|pUe!MQQFkGBWbR3&(jLm z%RSLc#p}5_dO{GD=DEFr=Fc% z85CBF>*t!6ugI?soX(*JNxBp+-DdZ4X0LldiK}+WWGvXV(C(Ht|!3$psR=&c*HIM=BmX;pRIpz@Ale{9dhGe(U2|Giv;# zOc|;?p67J=Q(kamB*aus=|XP|m{jN^6@V*Bpm?ye56Njh#vyJqE=DweC;?Rv7faX~ zde03n^I~0B2vUmr;w^X37tVxUK?4}ifsSH5_kpKZIzpYu0;Kv}SBGfI2AKNp+VN#z`nI{UNDRbo-wqa4NEls zICRJpu)??cj^*WcZ^MAv+;bDbh~gpN$1Cor<{Y2oyIDws^JsfW^5AL$azE(T0p&pP z1Mv~6Q44R&RHoH95&OuGx2srIr<@zYJTOMKiVs;Bx3py89I87LOb@%mr`0)#;7_~Z zzcZj8?w=)>%5@HoCHE_&hnu(n_yQ-L(~VjpjjkbT7e)Dk5??fApg(d>vwLRJ-x{um z*Nt?DqTSxh_MIyogY!vf1mU1`Gld-&L)*43f6dilz`Q@HEz;+>MDDYv9u!s;WXeao zUq=TaL$P*IFgJzrGc>j1dDOd zed+=ZBo?w4mr$2)Ya}?vedDopomhW1`#P<%YOJ_j=WwClX0xJH-f@s?^tmzs_j7t!k zK@j^zS0Q|mM4tVP5Ram$VbS6|YDY&y?Q1r1joe9dj08#CM{RSMTU}(RCh`hp_Rkl- zGd|Cv~G@F{DLhCizAm9AN!^{rNs8hu!G@8RpnGx7e`-+K$ffN<0qjR zGq^$dj_Tv!n*?zOSyk5skI7JVKJ)3jysnjIu-@VSzQiP8r6MzudCU=~?v-U8yzo^7 zGf~SUTvEp+S*!X9uX!sq=o}lH;r{pzk~M*VA(uyQ`3C8!{C;)&6)95fv(cK!%Cuz$ z_Zal57H6kPN>25KNiI6z6F)jzEkh#%OqU#-__Xzy)KyH};81#N6OfX$$IXWzOn`Q& z4f$Z1t>)8&8PcYfEwY5UadU1yg+U*(1m2ZlHoC-!2?gB!!fLhmTl))D@dhvkx#+Yj z1O=LV{(T%{^IeCuFK>%QR!VZ4GnO5tK8a+thWE zg4VytZrwcS?7^ zuZfhYnB8dwd%VLO?DK7pV5Wi<(`~DYqOXn8#jUIL^)12*Dbhk4GmL_E2`WX&iT16o zk(t|hok(Y|v-wzn?4x34T)|+SfZP>fiq!><*%vnxGN~ypST-FtC+@TPv*vYv@iU!_ z@2gf|PrgQ?Ktf*9^CnJ(x*CtZVB8!OBfg0%!wL;Z8(tYYre0vcnPGlyCc$V(Ipl*P z_(J!a=o@vp^%Efme!K74(Ke7A>Y}|sxV+JL^aYa{~m%5#$$+R1? zGaQhZTTX!#s#=Xtpegqero$RNt&`4xn3g$)=y*;=N=Qai)}~`xtxI_N*#MMCIq#HFifT zz(-*m;pVH&+4bixL&Bbg)W5FN^bH87pAHp)zPkWNMfTFqS=l~AC$3FX3kQUSh_C?-ZftyClgM)o_D7cX$RGlEYblux0jv5 zTr|i-I3@ZPCGheCl~BGhImF)K4!9@?pC(gi3ozX=a!|r1)LFxy_8c&wY0<^{2cm|P zv6Y`QktY*;I)IUd5y3ne1CqpVanlY45z8hf4&$EUBnucDj16pDa4&GI&TArYhf*xh zdj>*%APH8(h~c>o@l#%T>R$e>rwVx_WUB|~V`p^JHsg*y12lzj&zF}w6W09HwB2yb z%Q~`es&(;7#*DUC_w-Dmt7|$*?TA_m;zB+-u{2;Bg{O}nV7G_@7~<)Bv8fH^G$XG8$(&{A zwXJK5LRK%M34(t$&NI~MHT{UQ9qN-V_yn|%PqC81EIiSzmMM=2zb`mIwiP_b)x+2M z7Gd`83h79j#SItpQ}luuf2uOU`my_rY5T{6P#BNlb%h%<#MZb=m@y5aW;#o1^2Z)SWo+b`y0gV^iRcZtz5!-05vF z7wNo=hc6h4hc&s@uL^jqRvD6thVYtbErDK9k!;+a0xoE0WL7zLixjn5;$fXvT=O3I zT6jI&^A7k6R{&5#lVjz#8%_RiAa2{di{`kx79K+j72$H(!ass|B%@l%KeeKchYLe_ z>!(JC2fxsv>XVen+Y42GeYPxMWqm`6F$(E<6^s|g(slNk!lL*6v^W2>f6hh^mE$s= z3D$)}{V5(Qm&A6bp%2Q}*GZ5Qrf}n7*Hr51?bJOyA-?B4vg6y_EX<*-e20h{=0Mxs zbuQGZ$fLyO5v$nQ&^kuH+mNq9O#MWSfThtH|0q1i!NrWj^S}_P;Q1OkYLW6U^?_7G zx2wg?CULj7))QU(n{$0JE%1t2dWrMi2g-Os{v|8^wK{@qlj%+1b^?NI z$}l2tjp0g>K3O+p%yK<9!XqmQ?E9>z&(|^Pi~aSRwI5x$jaA62GFz9%fmO3t3a>cq zK8Xbv=5Ps~4mKN5+Eqw12(!PEyedFXv~VLxMB~HwT1Vfo51pQ#D8e$e4pFZ{&RC2P z5gTIzl{3!&(tor^BwZfR8j4k{7Rq#`riKXP2O-Bh66#WWK2w=z;iD9GLl+3 zpHIaI4#lQ&S-xBK8PiQ%dwOh?%BO~DCo06pN7<^dnZCN@NzY{_Z1>rrB0U|nC&+!2 z2y!oBcTd2;@lzyk(B=TkyZ)zy0deK05*Q0zk+o$@nun`VI1Er7pjq>8V zNmlW{p7S^Btgb(TA}jL(uR>`0w8gHP^T~Sh5Tkip^spk4SBAhC{TZU}_Z)UJw-}zm zPq{KBm!k)?P{`-(9?LFt&YN4s%SIZ-9lJ!Ws~B%exHOeVFk3~}HewnnH(d)qkLQ_d z6h>O)pEE{vbOVw}E+jdYC^wM+AAhaI(YAibUc@B#_mDss0Ji&BK{WG`4 zOk>vSNq(Bq2IB@s>>Rxm6Wv?h;ZXkpb1l8u|+_qXWdC*jjcPCixq;!%BVPSp#hP zqo`%cNf&YoQXHC$D=D45RiT|5ngPlh?0T~?lUf*O)){K@*Kbh?3RW1j9-T?%lDk@y z4+~?wKI%Y!-=O|_IuKz|=)F;V7ps=5@g)RrE;;tvM$gUhG>jHcw2Hr@fS+k^Zr~>G z^JvPrZc}_&d_kEsqAEMTMJw!!CBw)u&ZVzmq+ZworuaE&TT>$pYsd9|g9O^0orAe8 z221?Va!l1|Y5X1Y?{G7rt1sX#qFA^?RLG^VjoxPf63;AS=_mVDfGJKg73L zsGdnTUD40y(>S##2l|W2Cy!H(@@5KBa(#gs`vlz}Y~$ot5VsqPQ{{YtjYFvIumZzt zA{CcxZLJR|4#{j7k~Tu*jkwz8QA|5G1$Cl895R`Zyp;irp1{KN){kB30O8P1W5;@bG znvX74roeMmQlUi=v9Y%(wl$ZC#9tKNFpvi3!C}f1m6Ct|l2g%psc{TJp)@yu)*e2> z((p0Fg*8gJ!|3WZke9;Z{8}&NRkv7iP=#_y-F}x^y?2m%-D_aj^)f04%mneyjo_;) z6qc_Zu$q37d~X``*eP~Q>I2gg%rrV8v=kDfpp$=%Vj}hF)^dsSWygoN(A$g*E=Do6FX?&(@F#7pbiJ`;c0c@Ul zDqW_90Wm#5f2L<(Lf3)3TeXtI7nhYwRm(F;*r_G6K@OPW4H(Y3O5SjUzBC}u3d|eQ8*8d@?;zUPE+i#QNMn=r(ap?2SH@vo*m z3HJ%XuG_S6;QbWy-l%qU;8x;>z>4pMW7>R}J%QLf%@1BY(4f_1iixd-6GlO7Vp*yU zp{VU^3?s?90i=!#>H`lxT!q8rk>W_$2~kbpz7eV{3wR|8E=8**5?qn8#n`*(bt1xRQrdGxyx2y%B$qmw#>ZV$c7%cO#%JM1lY$Y0q?Yuo> ze9KdJoiM)RH*SB%^;TAdX-zEjA7@%y=!0=Zg%iWK7jVI9b&Dk}0$Af&08KHo+ zOwDhFvA(E|ER%a^cdh@^wLUlmIv6?_3=BvX8jKk92L=Y}7Jf5OGMfh` zBdR1wFCi-i5@`9km{isRb0O%TX+f~)KNaEz{rXQa89`YIF;EN&gN)cigu6mNh>?Cm zAO&Im2flv6D{jwm+y<%WsPe4!89n~KN|7}Cb{Z;XweER73r}Qp2 zz}WP4j}U0&(uD&9yGy6`!+_v-S(yG*iytsTR#x_Rc>=6u^vnRDnf1gP{#2>`ffrAC% zTZ5WQ@hAK;P;>kX{D)mIXe4%a5p=LO1xXH@8T?mz7Q@d)$3pL{{B!2{-v70L*o1AO+|n5beiw~ zk@(>m?T3{2k2c;NWc^`4@P&Z?BjxXJ@;x1qhn)9Mn*IFdt_J-dIqx5#d`NfyfX~m( zIS~5)MfZ2Uy?_4W`47i}u0ZgPh<{D|w_d#;D}Q&U$Q-G}xM1A@1f{#%A$jh6Qp&0hQ<0bPOM z-{1Wm&p%%#eb_?x7i;bol EfAhh=DF6Tf diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 598fb34156..8c79a83ae4 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,2 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar diff --git a/mvnw b/mvnw index 41c0f0c23d..5643201c7d 100755 --- a/mvnw +++ b/mvnw @@ -36,6 +36,10 @@ if [ -z "$MAVEN_SKIP_RC" ] ; then + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi @@ -145,7 +149,7 @@ if [ -z "$JAVACMD" ] ; then JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`which java`" + JAVACMD="`\\unset -f command; \\command -v java`" fi fi @@ -212,9 +216,9 @@ else echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; @@ -233,9 +237,9 @@ else echo "Found wget ... using wget" fi if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi elif command -v curl > /dev/null; then if [ "$MVNW_VERBOSE" = true ]; then @@ -305,6 +309,8 @@ WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd index 86115719e5..23b7079a3d 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -1,182 +1,188 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/mvnwDebug b/mvnwDebug new file mode 100755 index 0000000000..3e66a1ad7b --- /dev/null +++ b/mvnwDebug @@ -0,0 +1,35 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ----------------------------------------------------------------------------- +# Apache Maven Debug Script +# +# Environment Variable Prerequisites +# +# JAVA_HOME (Optional) Points to a Java installation. +# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. +# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. +# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000 +# ----------------------------------------------------------------------------- + +MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}" + +echo Preparing to execute Maven Wrapper in debug mode + +env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvnw" "$@" diff --git a/mvnwDebug.cmd b/mvnwDebug.cmd new file mode 100644 index 0000000000..49ce47151f --- /dev/null +++ b/mvnwDebug.cmd @@ -0,0 +1,44 @@ +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. + +@REM ----------------------------------------------------------------------------- +@REM Apache Maven Debug Script +@REM +@REM Environment Variable Prerequisites +@REM +@REM JAVA_HOME (Optional) Points to a Java installation. +@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. +@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending. +@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. +@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. +@REM MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000 +@REM ----------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% + +@setlocal + +IF "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000 + +@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS% + +@call "%~dp0"mvnw.cmd %* From 65fa0ee274104f7aec4984594c440184dee92df0 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Thu, 17 Feb 2022 14:23:14 +0100 Subject: [PATCH 042/441] #550 ignore plugins which have not version in current POM but in parent POM --- .../invoker.properties | 1 + .../parent/pom.xml | 31 +++++++++++++++ .../pom.xml | 39 +++++++++++++++++++ .../verify.bsh | 25 ++++++++++++ .../versions/DisplayPluginUpdatesMojo.java | 13 +++++-- 5 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties create mode 100644 src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml create mode 100644 src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml create mode 100644 src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties new file mode 100644 index 0000000000..3e9221daf4 --- /dev/null +++ b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml new file mode 100644 index 0000000000..324cc7b8fc --- /dev/null +++ b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + + localhost + it-101-parent + 1.0 + pom + display-plugin-updates-parent + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml new file mode 100644 index 0000000000..315979a01a --- /dev/null +++ b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml @@ -0,0 +1,39 @@ + + 4.0.0 + + + localhost + it-101-parent + 1.0 + parent/pom.xml + + + localhost + it-101 + 1.0 + pom + display-plugin-updates + + Ignore plugin used in this POM without version, which has a version defined in a parent POM. + + + + + + localhost + dummy-maven-plugin + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + + + + diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh new file mode 100644 index 0000000000..a86e44c20e --- /dev/null +++ b/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh @@ -0,0 +1,25 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + + // output should not contain any message like 'localhost:dummy-maven-plugin .....' because this plugin should be ignored due to its version defined in parent POM + Pattern p = Pattern.compile( "\\Qlocalhost:dummy-maven-plugin\\E\\s*\\.+" ); + Matcher m = p.matcher( buf.toString() ); + if ( m.find() ) + { + System.out.println( "dummy-maven-plugin should not be listed in output, version is defined in Parent POM" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 9e6f64f37d..e06f5271ea 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -404,6 +404,13 @@ public void execute() { version = parentPlugins.get( coords ); } + + boolean versionSpecifiedInCurrentPom = pluginsWithVersionsSpecified.contains( coords ); + if ( !versionSpecifiedInCurrentPom && parentPlugins.containsKey( coords ) ) { + getLog().debug( "Skip " + coords + ", version " + version + " is defined in parent POM." ); + continue; + } + getLog().debug( "Checking " + coords + " for updates newer than " + version ); String effectiveVersion = version; @@ -515,7 +522,7 @@ public void execute() String newVersion; - if ( version == null && pluginsWithVersionsSpecified.contains( coords ) ) + if ( version == null && versionSpecifiedInCurrentPom ) { // Hack ALERT! // @@ -530,8 +537,8 @@ public void execute() getLog().debug( "[" + coords + "].version=" + version ); getLog().debug( "[" + coords + "].artifactVersion=" + artifactVersion ); getLog().debug( "[" + coords + "].effectiveVersion=" + effectiveVersion ); - getLog().debug( "[" + coords + "].specified=" + pluginsWithVersionsSpecified.contains( coords ) ); - if ( version == null || !pluginsWithVersionsSpecified.contains( coords ) ) + getLog().debug( "[" + coords + "].specified=" + versionSpecifiedInCurrentPom ); + if ( version == null || !versionSpecifiedInCurrentPom ) { version = superPomPluginManagement.get( coords ); getLog().debug( "[" + coords + "].superPom.version=" + version ); From 8cfe5d00f3caeed84cdf0d49bae074e2e498c487 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 9 Mar 2022 15:59:37 +0100 Subject: [PATCH 043/441] #563 introduce property "versions.displayTerminalWidth" (#564) --- .../invoker.properties | 2 + .../pom.xml | 50 +++++++++++++++++++ .../verify.bsh | 27 ++++++++++ .../invoker.properties | 1 + .../pom.xml | 33 ++++++++++++ .../verify.bsh | 27 ++++++++++ .../invoker.properties | 1 + .../pom.xml | 48 ++++++++++++++++++ .../verify.bsh | 27 ++++++++++ .../versions/AbstractVersionsDisplayMojo.java | 18 +++++++ .../DisplayDependencyUpdatesMojo.java | 6 +-- .../versions/DisplayPluginUpdatesMojo.java | 8 +-- .../versions/DisplayPropertyUpdatesMojo.java | 4 +- 13 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties create mode 100644 src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml create mode 100644 src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh create mode 100644 src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties create mode 100644 src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml create mode 100644 src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh create mode 100644 src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties create mode 100644 src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml create mode 100644 src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties b/src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties new file mode 100644 index 0000000000..a1534ca8be --- /dev/null +++ b/src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts=-Dverbose=true -Dversions.outputFile=./dependencyUpdate.txt -DoutputEncoding=UTF-8 -Dversions.displayTerminalWidth=120 \ No newline at end of file diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml b/src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml new file mode 100644 index 0000000000..9955ecbc5c --- /dev/null +++ b/src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + localhost + it-display-dependency-updates-008-displayTerminalWidth + 1.0 + pom + display-dependency-updates + Validate usage of displayTerminalWidth parameter + http://localhost/ + + + localhost + dummy-api + 1.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh b/src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh new file mode 100644 index 0000000000..956ef51dfb --- /dev/null +++ b/src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh @@ -0,0 +1,27 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + + // validate outputFile + File outputFile = new File( basedir, "dependencyUpdate.txt" ); + if (!outputFile.exists()) { + System.out.println( "outputFile not found: " + outputFile.getPath() ); + return false; + } + buf = FileUtils.fileRead( outputFile ); + if ( !buf.contains("localhost:dummy-api ............................................................................... 1.1 ->") ) + { + System.out.println( "displayTerminalWidth parameter not respected" ); + return false; + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties b/src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties new file mode 100644 index 0000000000..a2c0507fe7 --- /dev/null +++ b/src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.displayTerminalWidth=120 diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml b/src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml new file mode 100644 index 0000000000..2bb5335ad2 --- /dev/null +++ b/src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + localhost + it-display-plugin-updates-012-displayTerminalWidth + 1.0 + pom + display-plugin-updates + + Validate usage of displayTerminalWidth parameter + + + + + + localhost + dummy-maven-plugin + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + + + + diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh b/src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh new file mode 100644 index 0000000000..17f842afab --- /dev/null +++ b/src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh @@ -0,0 +1,27 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + + // validate outputFile + File outputFile = new File( basedir, "dependencyUpdate.txt" ); + if (!outputFile.exists()) { + System.out.println( "outputFile not found: " + outputFile.getPath() ); + return false; + } + buf = FileUtils.fileRead( outputFile ); + if ( !buf.contains("maven-deploy-plugin ............................................................................ 2.3 ->") ) + { + System.out.println( "displayTerminalWidth parameter not respected" ); + return false; + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties b/src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties new file mode 100644 index 0000000000..21a664fe84 --- /dev/null +++ b/src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DautoLinkItems=true ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.displayTerminalWidth=120 diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml b/src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml new file mode 100644 index 0000000000..fffa2f43e1 --- /dev/null +++ b/src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + localhost + it-display-property-updates-002-displayTerminalWidth + 1.0 + pom + display-property-updates + + Validate usage of displayTerminalWidth parameter + + + 1.0 + + + + + + + maven-clean-plugin + 2.2 + + + localhost + dummy-api + [${api},2.1-!) + + + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh b/src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh new file mode 100644 index 0000000000..e42f0cb503 --- /dev/null +++ b/src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh @@ -0,0 +1,27 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + + // validate outputFile + File outputFile = new File( basedir, "dependencyUpdate.txt" ); + if (!outputFile.exists()) { + System.out.println( "outputFile not found: " + outputFile.getPath() ); + return false; + } + buf = FileUtils.fileRead( outputFile ); + if ( !buf.contains("${api} ........................................................................................... 1.0 ->") ) + { + System.out.println( "displayTerminalWidth parameter not respected" ); + return false; + } + +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 1b74352b2d..b300c5cb6a 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -36,6 +36,9 @@ public abstract class AbstractVersionsDisplayMojo extends AbstractVersionsUpdaterMojo { + + private static final int DEFAULT_DISPLAY_TERMINAL_WIDTH = 80; + /** * If specified then the display output will be sent to the specified file. * @@ -60,6 +63,14 @@ public abstract class AbstractVersionsDisplayMojo @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" ) private String outputEncoding; + /** + * Terminal width which should be used to format the padding of the version info list output. + * + * @since 2.10.0 + */ + @Parameter( property = "versions.displayTerminalWidth", defaultValue = AbstractVersionsDisplayMojo.DEFAULT_DISPLAY_TERMINAL_WIDTH + "" ) + private int displayTerminalWidth; + private boolean outputFileError = false; protected void logInit() @@ -150,4 +161,11 @@ protected void logLine( boolean error, String line ) } } + /** + * @return Offset of the configured display terminal width compared to the default with of 80. + */ + protected int getDisplayTerminalWidthOffset() { + return this.displayTerminalWidth - DEFAULT_DISPLAY_TERMINAL_WIDTH; + } + } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index aa0fe87e90..a2c7439d8a 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -436,15 +436,15 @@ private void logUpdates( Map updates, String secti } String right = " " + ( latest == null ? current : current + " -> " + latest ); List t = latest == null ? usingCurrent : withUpdates; - if ( right.length() + left.length() + 3 > INFO_PAD_SIZE ) + if ( right.length() + left.length() + 3 > INFO_PAD_SIZE + getDisplayTerminalWidthOffset() ) { t.add( left + "..." ); - t.add( StringUtils.leftPad( right, INFO_PAD_SIZE ) ); + t.add( StringUtils.leftPad( right, INFO_PAD_SIZE + getDisplayTerminalWidthOffset() ) ); } else { - t.add( StringUtils.rightPad( left, INFO_PAD_SIZE - right.length(), "." ) + right ); + t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getDisplayTerminalWidthOffset() - right.length(), "." ) + right ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index e06f5271ea..d400d8c046 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -476,12 +476,12 @@ public void execute() { // plugin version configured that require a Maven version higher than spec upgradePlugins.put( upgradePluginKey, - pad( upgradePluginKey, INFO_PAD_SIZE, newer ) ); + pad( upgradePluginKey, INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), newer ) ); } else { // plugin that can be upgraded - upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE, + upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), effectiveVersion, " -> ", newer ) ); } } @@ -551,7 +551,7 @@ public void execute() superPomDrivingMinVersion = true; } - pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE, + pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getDisplayTerminalWidthOffset(), superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); } else if ( artifactVersion != null ) @@ -565,7 +565,7 @@ else if ( artifactVersion != null ) if ( version != null && artifactVersion != null && newVersion != null && effectiveVersion != null && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) < 0 ) { - pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE, + pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), effectiveVersion, " -> ", newVersion ) ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 2924a881d6..bb21169a21 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -148,7 +148,7 @@ public void execute() buf.append( property.getName() ); buf.append( "} " ); final String newVersion = winner.toString(); - int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4; + int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getDisplayTerminalWidthOffset(); while ( buf.length() < padding ) { buf.append( '.' ); @@ -165,7 +165,7 @@ public void execute() buf.append( "${" ); buf.append( property.getName() ); buf.append( "} " ); - int padding = INFO_PAD_SIZE - currentVersion.length(); + int padding = INFO_PAD_SIZE - currentVersion.length() + getDisplayTerminalWidthOffset(); while ( buf.length() < padding ) { buf.append( '.' ); From ba4e673214d7fd18bbb8d4ff0ea87d61d636ee40 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 9 Mar 2022 15:57:50 +0100 Subject: [PATCH 044/441] #568 introduce updateBuildOutputTimestamp property to make it configurable whether project.build.outputTimestamp is updated or not --- .../invoker.properties | 1 + src/it/it-set-020-outputTimestamp-disabled/pom.xml | 14 ++++++++++++++ .../verify.groovy | 4 ++++ .../java/org/codehaus/mojo/versions/SetMojo.java | 14 ++++++++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/it/it-set-020-outputTimestamp-disabled/invoker.properties create mode 100644 src/it/it-set-020-outputTimestamp-disabled/pom.xml create mode 100644 src/it/it-set-020-outputTimestamp-disabled/verify.groovy diff --git a/src/it/it-set-020-outputTimestamp-disabled/invoker.properties b/src/it/it-set-020-outputTimestamp-disabled/invoker.properties new file mode 100644 index 0000000000..fa92007c10 --- /dev/null +++ b/src/it/it-set-020-outputTimestamp-disabled/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=2.0 -DupdateBuildOutputTimestamp=false diff --git a/src/it/it-set-020-outputTimestamp-disabled/pom.xml b/src/it/it-set-020-outputTimestamp-disabled/pom.xml new file mode 100644 index 0000000000..8c98b0e609 --- /dev/null +++ b/src/it/it-set-020-outputTimestamp-disabled/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + localhost + it-set-020-outputTimestamp-disabled + 1.0 + pom + set + + + 10 + + diff --git a/src/it/it-set-020-outputTimestamp-disabled/verify.groovy b/src/it/it-set-020-outputTimestamp-disabled/verify.groovy new file mode 100644 index 0000000000..0809df1b35 --- /dev/null +++ b/src/it/it-set-020-outputTimestamp-disabled/verify.groovy @@ -0,0 +1,4 @@ +pom = new File( basedir, "pom.xml" ).text; + +// expect outputTimestamp to be untouched +assert pom =~ /10<.project.build.outputTimestamp>/ diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index ee0f7c7c74..a94632fd50 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -202,6 +202,14 @@ public class SetMojo @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) private boolean processFromLocalAggregationRoot; + /** + * Whether to update the project.build.outputTimestamp property in the POM when setting version. + * + * @since 2.10 + */ + @Parameter( property = "updateBuildOutputTimestamp", defaultValue = "true" ) + private boolean updateBuildOutputTimestamp; + /** * The changes to module coordinates. Guarded by this. */ @@ -506,8 +514,10 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) { changer.apply( versionChange ); - // also update project.build.outputTimestamp - updateBuildOutputTimestamp( pom, model ); + if (updateBuildOutputTimestamp) { + // also update project.build.outputTimestamp + updateBuildOutputTimestamp( pom, model ); + } } } catch ( IOException e ) From d0eb53ced829df1af9cfd927540dbf0a3ce4622c Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 11 Mar 2022 12:44:26 +0100 Subject: [PATCH 045/441] #563 rename parameter versions.displayTerminalWidth to versions.outputLineWidth --- .../invoker.properties | 2 +- .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 2 +- .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 2 +- .../pom.xml | 0 .../verify.bsh | 0 .../mojo/versions/AbstractVersionsDisplayMojo.java | 14 +++++++------- .../versions/DisplayDependencyUpdatesMojo.java | 6 +++--- .../mojo/versions/DisplayPluginUpdatesMojo.java | 8 ++++---- .../mojo/versions/DisplayPropertyUpdatesMojo.java | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-) rename src/it/{it-display-dependency-updates-008-displayTerminalWidth => it-display-dependency-updates-008-outputLineWidth}/invoker.properties (69%) rename src/it/{it-display-dependency-updates-008-displayTerminalWidth => it-display-dependency-updates-008-outputLineWidth}/pom.xml (100%) rename src/it/{it-display-dependency-updates-008-displayTerminalWidth => it-display-dependency-updates-008-outputLineWidth}/verify.bsh (100%) rename src/it/{it-display-plugin-updates-012-displayTerminalWidth => it-display-plugin-updates-012-outputLineWidth}/invoker.properties (71%) rename src/it/{it-display-plugin-updates-012-displayTerminalWidth => it-display-plugin-updates-012-outputLineWidth}/pom.xml (100%) rename src/it/{it-display-plugin-updates-012-displayTerminalWidth => it-display-plugin-updates-012-outputLineWidth}/verify.bsh (100%) rename src/it/{it-display-property-updates-002-displayTerminalWidth => it-display-property-updates-002-outputLineWidth}/invoker.properties (63%) rename src/it/{it-display-property-updates-002-displayTerminalWidth => it-display-property-updates-002-outputLineWidth}/pom.xml (100%) rename src/it/{it-display-property-updates-002-displayTerminalWidth => it-display-property-updates-002-outputLineWidth}/verify.bsh (100%) diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties b/src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties similarity index 69% rename from src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties rename to src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties index a1534ca8be..3a78145dd3 100644 --- a/src/it/it-display-dependency-updates-008-displayTerminalWidth/invoker.properties +++ b/src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties @@ -1,2 +1,2 @@ invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -invoker.mavenOpts=-Dverbose=true -Dversions.outputFile=./dependencyUpdate.txt -DoutputEncoding=UTF-8 -Dversions.displayTerminalWidth=120 \ No newline at end of file +invoker.mavenOpts=-Dverbose=true -Dversions.outputFile=./dependencyUpdate.txt -DoutputEncoding=UTF-8 -Dversions.outputLineWidth=120 \ No newline at end of file diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml b/src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-008-displayTerminalWidth/pom.xml rename to src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml diff --git a/src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh b/src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-008-displayTerminalWidth/verify.bsh rename to src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties b/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties similarity index 71% rename from src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties rename to src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties index a2c0507fe7..af55d25b87 100644 --- a/src/it/it-display-plugin-updates-012-displayTerminalWidth/invoker.properties +++ b/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties @@ -1 +1 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.displayTerminalWidth=120 +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.outputLineWidth=120 diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml b/src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-012-displayTerminalWidth/pom.xml rename to src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml diff --git a/src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh b/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-012-displayTerminalWidth/verify.bsh rename to src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties b/src/it/it-display-property-updates-002-outputLineWidth/invoker.properties similarity index 63% rename from src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties rename to src/it/it-display-property-updates-002-outputLineWidth/invoker.properties index 21a664fe84..ff42f5409c 100644 --- a/src/it/it-display-property-updates-002-displayTerminalWidth/invoker.properties +++ b/src/it/it-display-property-updates-002-outputLineWidth/invoker.properties @@ -1 +1 @@ -invoker.goals=-DautoLinkItems=true ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.displayTerminalWidth=120 +invoker.goals=-DautoLinkItems=true ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.outputLineWidth=120 diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml b/src/it/it-display-property-updates-002-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-property-updates-002-displayTerminalWidth/pom.xml rename to src/it/it-display-property-updates-002-outputLineWidth/pom.xml diff --git a/src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh b/src/it/it-display-property-updates-002-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-property-updates-002-displayTerminalWidth/verify.bsh rename to src/it/it-display-property-updates-002-outputLineWidth/verify.bsh diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index b300c5cb6a..3846430a23 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -37,7 +37,7 @@ public abstract class AbstractVersionsDisplayMojo extends AbstractVersionsUpdaterMojo { - private static final int DEFAULT_DISPLAY_TERMINAL_WIDTH = 80; + private static final int DEFAULT_OUTPUT_LINE_WIDTH = 80; /** * If specified then the display output will be sent to the specified file. @@ -64,12 +64,12 @@ public abstract class AbstractVersionsDisplayMojo private String outputEncoding; /** - * Terminal width which should be used to format the padding of the version info list output. + * Line width which should be used to format the padding of the version info list output. * * @since 2.10.0 */ - @Parameter( property = "versions.displayTerminalWidth", defaultValue = AbstractVersionsDisplayMojo.DEFAULT_DISPLAY_TERMINAL_WIDTH + "" ) - private int displayTerminalWidth; + @Parameter( property = "versions.outputLineWidth", defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "" ) + private int outputLineWidth; private boolean outputFileError = false; @@ -162,10 +162,10 @@ protected void logLine( boolean error, String line ) } /** - * @return Offset of the configured display terminal width compared to the default with of 80. + * @return Offset of the configured output line width compared to the default with of 80. */ - protected int getDisplayTerminalWidthOffset() { - return this.displayTerminalWidth - DEFAULT_DISPLAY_TERMINAL_WIDTH; + protected int getOutputLineWidthOffset() { + return this.outputLineWidth - DEFAULT_OUTPUT_LINE_WIDTH; } } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index a2c7439d8a..34c4c64740 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -436,15 +436,15 @@ private void logUpdates( Map updates, String secti } String right = " " + ( latest == null ? current : current + " -> " + latest ); List t = latest == null ? usingCurrent : withUpdates; - if ( right.length() + left.length() + 3 > INFO_PAD_SIZE + getDisplayTerminalWidthOffset() ) + if ( right.length() + left.length() + 3 > INFO_PAD_SIZE + getOutputLineWidthOffset() ) { t.add( left + "..." ); - t.add( StringUtils.leftPad( right, INFO_PAD_SIZE + getDisplayTerminalWidthOffset() ) ); + t.add( StringUtils.leftPad( right, INFO_PAD_SIZE + getOutputLineWidthOffset() ) ); } else { - t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getDisplayTerminalWidthOffset() - right.length(), "." ) + right ); + t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), "." ) + right ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index d400d8c046..18804e7f23 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -476,12 +476,12 @@ public void execute() { // plugin version configured that require a Maven version higher than spec upgradePlugins.put( upgradePluginKey, - pad( upgradePluginKey, INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), newer ) ); + pad( upgradePluginKey, INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); } else { // plugin that can be upgraded - upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), + upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE + getOutputLineWidthOffset(), effectiveVersion, " -> ", newer ) ); } } @@ -551,7 +551,7 @@ public void execute() superPomDrivingMinVersion = true; } - pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getDisplayTerminalWidthOffset(), + pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getOutputLineWidthOffset(), superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); } else if ( artifactVersion != null ) @@ -565,7 +565,7 @@ else if ( artifactVersion != null ) if ( version != null && artifactVersion != null && newVersion != null && effectiveVersion != null && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) < 0 ) { - pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getDisplayTerminalWidthOffset(), + pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getOutputLineWidthOffset(), effectiveVersion, " -> ", newVersion ) ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index bb21169a21..2ac1607ea4 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -148,7 +148,7 @@ public void execute() buf.append( property.getName() ); buf.append( "} " ); final String newVersion = winner.toString(); - int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getDisplayTerminalWidthOffset(); + int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getOutputLineWidthOffset(); while ( buf.length() < padding ) { buf.append( '.' ); @@ -165,7 +165,7 @@ public void execute() buf.append( "${" ); buf.append( property.getName() ); buf.append( "} " ); - int padding = INFO_PAD_SIZE - currentVersion.length() + getDisplayTerminalWidthOffset(); + int padding = INFO_PAD_SIZE - currentVersion.length() + getOutputLineWidthOffset(); while ( buf.length() < padding ) { buf.append( '.' ); From e15c8420e9afae98709516ee6a88edda1ca074b9 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 11 Mar 2022 22:39:48 +0100 Subject: [PATCH 046/441] [maven-release-plugin] prepare release versions-maven-plugin-2.10.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 95ed6e29ee..400061b7cb 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.9.1-SNAPSHOT + 2.10.0 maven-plugin Versions Maven Plugin @@ -88,7 +88,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/${project.scm.tag} - versions-maven-plugin-2.9.0 + versions-maven-plugin-2.10.0 github @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2022-01-18T09:14:02Z + 2022-03-11T21:39:08Z From 96bacee6aefd0209610f1914f82fde5511d5695c Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 11 Mar 2022 22:40:35 +0100 Subject: [PATCH 047/441] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 400061b7cb..c4e16dae60 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.10.0 + 2.10.1-SNAPSHOT maven-plugin Versions Maven Plugin @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2022-03-11T21:39:08Z + 2022-03-11T21:40:34Z From 09a47c7c333e2426c286232c43f8557647fe330d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:59:17 +0000 Subject: [PATCH 048/441] Bump actions/stale from 4 to 5 Bumps [actions/stale](https://github.com/actions/stale) from 4 to 5. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 49f73e8e29..45a9164075 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' From 4930dc9d8ed900bba59038741dfb36b2288595b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 13:59:13 +0000 Subject: [PATCH 049/441] Bump actions/setup-java from 2 to 3 Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2 to 3. - [Release notes](https://github.com/actions/setup-java/releases) - [Commits](https://github.com/actions/setup-java/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-java dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9ee27d6e29..829cd12efe 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -33,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v3 with: distribution: ${{ matrix.jdk }} java-version: ${{ matrix.java }} From 5e4c08e789e0ee4e436bccda8c780fcce4c6d049 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Apr 2022 13:28:08 +0000 Subject: [PATCH 050/441] Bump mockito-core from 4.4.0 to 4.5.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.4.0 to 4.5.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.4.0...v4.5.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c4e16dae60..68c9c926a0 100644 --- a/pom.xml +++ b/pom.xml @@ -256,7 +256,7 @@ org.mockito mockito-core - 4.4.0 + 4.5.0 test From 14e4baa7bd6d0a36659731af72c8a3ae687420f6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Apr 2022 13:16:19 +0000 Subject: [PATCH 051/441] Bump mockito-core from 4.5.0 to 4.5.1 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.5.0...v4.5.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68c9c926a0..b01df16dd7 100644 --- a/pom.xml +++ b/pom.xml @@ -256,7 +256,7 @@ org.mockito mockito-core - 4.5.0 + 4.5.1 test From a57fabfc0a646cb379e12e4667568434be27d797 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Apr 2022 13:36:22 +0000 Subject: [PATCH 052/441] Bump mojo-parent from 65 to 67 Bumps [mojo-parent](https://github.com/mojohaus/mojo-parent) from 65 to 67. - [Release notes](https://github.com/mojohaus/mojo-parent/releases) - [Commits](https://github.com/mojohaus/mojo-parent/commits) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mojo-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b01df16dd7..454a97461b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codehaus.mojo mojo-parent - 65 + 67 versions-maven-plugin From bf4fb54bbd8146ce65bfa2445b5280c2d7d1d8e3 Mon Sep 17 00:00:00 2001 From: Cyril POTTIERS Date: Fri, 15 Apr 2022 16:25:59 +0200 Subject: [PATCH 053/441] Ignoring dependency with no version in useReleases Closes #584 #584 --- .../invoker.properties | 1 + src/it/it-use-releases-issue-583/pom.xml | 21 +++++++++++++++++ src/it/it-use-releases-issue-583/verify.bsh | 23 +++++++++++++++++++ ...AbstractVersionsDependencyUpdaterMojo.java | 9 ++++---- .../mojo/versions/UseReleasesMojo.java | 5 ++++ 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/it/it-use-releases-issue-583/invoker.properties create mode 100644 src/it/it-use-releases-issue-583/pom.xml create mode 100644 src/it/it-use-releases-issue-583/verify.bsh diff --git a/src/it/it-use-releases-issue-583/invoker.properties b/src/it/it-use-releases-issue-583/invoker.properties new file mode 100644 index 0000000000..8e97d76cf8 --- /dev/null +++ b/src/it/it-use-releases-issue-583/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:use-releases -DallowRangeMatching=true -DfailIfNotReplaced=true diff --git a/src/it/it-use-releases-issue-583/pom.xml b/src/it/it-use-releases-issue-583/pom.xml new file mode 100644 index 0000000000..ce037a5fa1 --- /dev/null +++ b/src/it/it-use-releases-issue-583/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + localhost + it-use-releases-issue-583 + 1.0 + pom + Skip a dependency without version + + + + + localhost + dummy-api + provided + + + + + diff --git a/src/it/it-use-releases-issue-583/verify.bsh b/src/it/it-use-releases-issue-583/verify.bsh new file mode 100644 index 0000000000..73a06b17a1 --- /dev/null +++ b/src/it/it-use-releases-issue-583/verify.bsh @@ -0,0 +1,23 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + Pattern p = Pattern.compile( "\\QIgnoring dependency with no version: localhost:dummy-api:jar\\E" ); + Matcher m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "cannot find skipping of dummy-api dependency" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 3114a07e00..8decb68817 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -188,10 +188,11 @@ public boolean isExcludeReactor() * @return true if the version starts with '${' * @since 2.8 */ - protected boolean isHandledByProperty(Dependency dependency) { - String version = dependency.getVersion(); - return version.startsWith("${"); - } + protected boolean isHandledByProperty( Dependency dependency ) + { + String version = dependency.getVersion(); + return version != null && version.startsWith( "${" ); + } /** * Try to find the dependency artifact that matches the given dependency. diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 127bf7809e..7fd4f64688 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -209,6 +209,11 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection } String version = dep.getVersion(); + if ( version == null ) + { + getLog().info( "Ignoring dependency with no version: " + toString( dep ) ); + continue; + } Matcher versionMatcher = matchSnapshotRegex.matcher( version ); if ( versionMatcher.matches() ) { From a6a2d7569ec1a4fbad084937d3b6ca3c8c65136a Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Sun, 7 Jul 2019 16:04:38 +0100 Subject: [PATCH 054/441] Provide a "change recorder" for updates This provides a ChangeRecorder interface that logs changes to a machine-readable XML file whenever a pom.xml file is updated. Closes #416 #356 --- pom.xml | 2 +- .../invoker.properties | 1 + .../it-changerecord-update-parent-001/pom.xml | 40 ++++++ .../verify.bsh | 22 ++++ .../invoker.properties | 1 + .../pom.xml | 59 +++++++++ .../verify.bsh | 21 ++++ .../invoker.properties | 1 + .../pom.xml | 21 ++++ .../verify.bsh | 21 ++++ .../invoker.properties | 1 + .../pom.xml | 21 ++++ .../verify.bsh | 21 ++++ .../invoker.properties | 1 + .../pom.xml | 21 ++++ .../verify.bsh | 21 ++++ .../invoker.properties | 1 + .../pom.xml | 21 ++++ .../verify.bsh | 21 ++++ .../versions/AbstractVersionsUpdaterMojo.java | 100 +++++++++++++-- .../mojo/versions/UnlockSnapshotsMojo.java | 27 ++-- .../mojo/versions/UpdateParentMojo.java | 24 ++-- .../mojo/versions/UpdatePropertiesMojo.java | 62 ++++++---- .../mojo/versions/UpdatePropertyMojo.java | 13 +- .../mojo/versions/UseDepVersionMojo.java | 40 +++--- .../mojo/versions/UseLatestReleasesMojo.java | 3 + .../mojo/versions/UseLatestSnapshotsMojo.java | 11 +- .../mojo/versions/UseLatestVersionsMojo.java | 8 +- .../mojo/versions/UseNextReleasesMojo.java | 3 + .../mojo/versions/UseNextSnapshotsMojo.java | 3 + .../mojo/versions/UseNextVersionsMojo.java | 3 + .../mojo/versions/UseReleasesMojo.java | 20 ++- .../versions/recording/ChangeRecorder.java | 51 ++++++++ .../recording/ChangeRecorderNull.java | 63 ++++++++++ .../versions/recording/ChangeRecorderXML.java | 116 ++++++++++++++++++ .../mojo/versions/recording/schema-1.0.xsd | 37 ++++++ src/site/apt/examples/recording-changes.apt | 49 ++++++++ src/site/apt/index.apt | 3 + .../recording/ChangeRecorderXMLTest.java | 98 +++++++++++++++ .../mojo/versions/recording/expectedFile.xml | 6 + 40 files changed, 978 insertions(+), 80 deletions(-) create mode 100644 src/it/it-changerecord-update-parent-001/invoker.properties create mode 100644 src/it/it-changerecord-update-parent-001/pom.xml create mode 100644 src/it/it-changerecord-update-parent-001/verify.bsh create mode 100644 src/it/it-changerecord-update-properties-001/invoker.properties create mode 100644 src/it/it-changerecord-update-properties-001/pom.xml create mode 100644 src/it/it-changerecord-update-properties-001/verify.bsh create mode 100644 src/it/it-changerecord-use-latest-releases-001/invoker.properties create mode 100644 src/it/it-changerecord-use-latest-releases-001/pom.xml create mode 100644 src/it/it-changerecord-use-latest-releases-001/verify.bsh create mode 100644 src/it/it-changerecord-use-latest-snapshots-001/invoker.properties create mode 100644 src/it/it-changerecord-use-latest-snapshots-001/pom.xml create mode 100644 src/it/it-changerecord-use-latest-snapshots-001/verify.bsh create mode 100644 src/it/it-changerecord-use-latest-versions-001/invoker.properties create mode 100644 src/it/it-changerecord-use-latest-versions-001/pom.xml create mode 100644 src/it/it-changerecord-use-latest-versions-001/verify.bsh create mode 100644 src/it/it-changerecord-use-next-versions-001/invoker.properties create mode 100644 src/it/it-changerecord-use-next-versions-001/pom.xml create mode 100644 src/it/it-changerecord-use-next-versions-001/verify.bsh create mode 100644 src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java create mode 100644 src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java create mode 100644 src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java create mode 100644 src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd create mode 100644 src/site/apt/examples/recording-changes.apt create mode 100644 src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java create mode 100644 src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml diff --git a/pom.xml b/pom.xml index 454a97461b..93cedb4b22 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.10.1-SNAPSHOT + 2.11.0-SNAPSHOT maven-plugin Versions Maven Plugin diff --git a/src/it/it-changerecord-update-parent-001/invoker.properties b/src/it/it-changerecord-update-parent-001/invoker.properties new file mode 100644 index 0000000000..5ab6491f40 --- /dev/null +++ b/src/it/it-changerecord-update-parent-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:update-parent diff --git a/src/it/it-changerecord-update-parent-001/pom.xml b/src/it/it-changerecord-update-parent-001/pom.xml new file mode 100644 index 0000000000..10de782fb5 --- /dev/null +++ b/src/it/it-changerecord-update-parent-001/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + + + localhost + dummy-parent + 1.0 + + + localhost + it-201 + 1.0 + pom + update-parent basic test + + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + diff --git a/src/it/it-changerecord-update-parent-001/verify.bsh b/src/it/it-changerecord-update-parent-001/verify.bsh new file mode 100644 index 0000000000..29363fa9d6 --- /dev/null +++ b/src/it/it-changerecord-update-parent-001/verify.bsh @@ -0,0 +1,22 @@ +import java.io.*; +import java.util.regex.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-changerecord-update-properties-001/invoker.properties b/src/it/it-changerecord-update-properties-001/invoker.properties new file mode 100644 index 0000000000..0b22a29163 --- /dev/null +++ b/src/it/it-changerecord-update-properties-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:update-properties diff --git a/src/it/it-changerecord-update-properties-001/pom.xml b/src/it/it-changerecord-update-properties-001/pom.xml new file mode 100644 index 0000000000..21aa2d7b84 --- /dev/null +++ b/src/it/it-changerecord-update-properties-001/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + + localhost + it-001 + 1.0 + pom + update-properties with one property only + + + 1.0 + + + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + api + + + localhost + dummy-api + + + + + + + + + + diff --git a/src/it/it-changerecord-update-properties-001/verify.bsh b/src/it/it-changerecord-update-properties-001/verify.bsh new file mode 100644 index 0000000000..f1c83a4db1 --- /dev/null +++ b/src/it/it-changerecord-update-properties-001/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-changerecord-use-latest-releases-001/invoker.properties b/src/it/it-changerecord-use-latest-releases-001/invoker.properties new file mode 100644 index 0000000000..623fbd9892 --- /dev/null +++ b/src/it/it-changerecord-use-latest-releases-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases diff --git a/src/it/it-changerecord-use-latest-releases-001/pom.xml b/src/it/it-changerecord-use-latest-releases-001/pom.xml new file mode 100644 index 0000000000..c6010a4883 --- /dev/null +++ b/src/it/it-changerecord-use-latest-releases-001/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + localhost + it-use-latest-releases-001 + 1.0 + pom + Update a dependency to the latest release version + + + + + localhost + dummy-api + 1.1.1-2 + + + + + diff --git a/src/it/it-changerecord-use-latest-releases-001/verify.bsh b/src/it/it-changerecord-use-latest-releases-001/verify.bsh new file mode 100644 index 0000000000..8a1cf60042 --- /dev/null +++ b/src/it/it-changerecord-use-latest-releases-001/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties b/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties new file mode 100644 index 0000000000..629cea24d8 --- /dev/null +++ b/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-snapshots -DallowMinorUpdates=true diff --git a/src/it/it-changerecord-use-latest-snapshots-001/pom.xml b/src/it/it-changerecord-use-latest-snapshots-001/pom.xml new file mode 100644 index 0000000000..5eab422379 --- /dev/null +++ b/src/it/it-changerecord-use-latest-snapshots-001/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + localhost + it-use-latest-snapshots-001 + 1.0 + pom + Update a release dependency to the latest snapshot version + + + + + localhost + dummy-api + 1.0 + + + + + diff --git a/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh b/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh new file mode 100644 index 0000000000..c8050feffc --- /dev/null +++ b/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-changerecord-use-latest-versions-001/invoker.properties b/src/it/it-changerecord-use-latest-versions-001/invoker.properties new file mode 100644 index 0000000000..2ca3daeb28 --- /dev/null +++ b/src/it/it-changerecord-use-latest-versions-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-latest-versions diff --git a/src/it/it-changerecord-use-latest-versions-001/pom.xml b/src/it/it-changerecord-use-latest-versions-001/pom.xml new file mode 100644 index 0000000000..18b67695cd --- /dev/null +++ b/src/it/it-changerecord-use-latest-versions-001/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + localhost + it-use-latest-versions-001 + 1.0 + pom + Update a dependency to the next release version + + + + + localhost + dummy-api + 1.1.1-2 + + + + + diff --git a/src/it/it-changerecord-use-latest-versions-001/verify.bsh b/src/it/it-changerecord-use-latest-versions-001/verify.bsh new file mode 100644 index 0000000000..9ce59b8bb8 --- /dev/null +++ b/src/it/it-changerecord-use-latest-versions-001/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-changerecord-use-next-versions-001/invoker.properties b/src/it/it-changerecord-use-next-versions-001/invoker.properties new file mode 100644 index 0000000000..eb678c4bed --- /dev/null +++ b/src/it/it-changerecord-use-next-versions-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=-DchangeRecorderFormat=xml ${project.groupId}:${project.artifactId}:${project.version}:use-next-versions diff --git a/src/it/it-changerecord-use-next-versions-001/pom.xml b/src/it/it-changerecord-use-next-versions-001/pom.xml new file mode 100644 index 0000000000..675d67e716 --- /dev/null +++ b/src/it/it-changerecord-use-next-versions-001/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + + localhost + it-use-next-versions-001 + 1.0 + pom + Update a dependency to the next versions + + + + + localhost + dummy-api + 1.1.1-2 + + + + + diff --git a/src/it/it-changerecord-use-next-versions-001/verify.bsh b/src/it/it-changerecord-use-next-versions-001/verify.bsh new file mode 100644 index 0000000000..659cbeff01 --- /dev/null +++ b/src/it/it-changerecord-use-next-versions-001/verify.bsh @@ -0,0 +1,21 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; + +try +{ + File file = new File( basedir, "target/versions-changes.xml" ); + String buf = FileUtils.fileRead( file, "UTF-8" ); + + if ( buf.indexOf( "" ) < 0 ) + { + System.err.println( "Version change recorded" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 75027618a8..cdfe1a708f 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -44,6 +44,9 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.codehaus.mojo.versions.recording.ChangeRecorderNull; +import org.codehaus.mojo.versions.recording.ChangeRecorderXML; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; @@ -53,6 +56,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.Writer; import java.util.List; @@ -191,6 +195,26 @@ public abstract class AbstractVersionsUpdaterMojo @Component protected ArtifactResolver artifactResolver; + /** + * The format used to record changes. If "none" is specified, no changes are recorded. + * + * @since 2.11 + */ + @Parameter( property = "changeRecorderFormat", + defaultValue = "none" ) + private String changeRecorderFormat = "none"; + /** + * The output file used to record changes. + * + * @since 2.11 + */ + @Parameter( property = "changeRecorderOutputFile", + defaultValue = "${project.build.directory}/versions-changes.xml" ) + private File changeRecorderOutputFile; + /** + * The change recorder implementation. + */ + private ChangeRecorder changeRecorder; // --------------------- GETTER / SETTER METHODS --------------------- @@ -335,6 +359,8 @@ protected void process( File outFile ) } writeFile( outFile, input ); } + + saveChangeRecorderResults(); } catch ( IOException | XMLStreamException e ) { @@ -504,16 +530,9 @@ else if ( allowIncrementalUpdates ) return segment; } - protected void updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, - PropertyVersions version, String currentVersion ) - throws MojoExecutionException, XMLStreamException - { - updatePropertyToNewestVersion( pom, property, version, currentVersion, false, -1 ); - } - - protected void updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, - PropertyVersions version, String currentVersion, - boolean allowDowngrade, int segment ) + protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, + PropertyVersions version, String currentVersion, + boolean allowDowngrade, int segment ) throws MojoExecutionException, XMLStreamException { ArtifactVersion winner = @@ -528,5 +547,66 @@ else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.ge { getLog().info( "Updated ${" + property.getName() + "} from " + currentVersion + " to " + winner ); } + + return winner; + } + + /** + * Configure and return the change recorder. + * + * @return The change recorder + * @throws MojoExecutionException If the provided change recorder format is not valid + */ + + protected ChangeRecorder getChangeRecorder() throws MojoExecutionException + { + if ( changeRecorder == null ) + { + if ( "none".equals( this.changeRecorderFormat ) ) + { + changeRecorder = ChangeRecorderNull.create(); + } + else if ( "xml".equals( this.changeRecorderFormat ) ) + { + changeRecorder = ChangeRecorderXML.create(); + } + else + { + throw new MojoExecutionException( "Only 'xml' or 'none' formats are supported for change recordings" ); + } + } + + return changeRecorder; + } + + /** + * Save all of the changes recorded by the change recorder. + * + * @throws IOException On I/O errors + */ + + protected void saveChangeRecorderResults() throws IOException + { + /* + * Nobody did anything that required a change recorder. + */ + + if ( this.changeRecorder == null ) + { + return; + } + + if ( "none".equals( this.changeRecorderFormat ) ) + { + return; + } + + this.getLog().debug( "writing change record to " + this.changeRecorderOutputFile ); + + this.changeRecorderOutputFile.getParentFile().mkdirs(); + try ( FileOutputStream outputStream = new FileOutputStream( this.changeRecorderOutputFile ) ) + { + this.changeRecorder.serialize( outputStream ); + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 317eadd75c..5190760ebb 100644 --- a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -42,9 +42,11 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "unlock-snapshots", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) -public class UnlockSnapshotsMojo - extends AbstractVersionsDependencyUpdaterMojo +@Mojo( name = "unlock-snapshots", + requiresProject = true, + requiresDirectInvocation = true, + threadSafe = true ) +public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { // ------------------------------ FIELDS ------------------------------ @@ -59,12 +61,11 @@ public class UnlockSnapshotsMojo /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) @@ -81,8 +82,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) - throws XMLStreamException, MojoExecutionException + private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) throws XMLStreamException, MojoExecutionException { for ( Dependency dep : dependencies ) { @@ -109,16 +109,17 @@ private void unlockSnapshots( ModifiedPomXMLEventReader pom, List de { String unlockedVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - unlockedVersion, getProject().getModel() ) ) + unlockedVersion, getProject().getModel() ) ) { + getChangeRecorder().recordUpdate( "unlockSnapshot", dep.getGroupId(), dep.getArtifactId(), + dep.getVersion(), unlockedVersion ); getLog().info( "Unlocked " + toString( dep ) + " to version " + unlockedVersion ); } } } } - private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, MojoExecutionException + private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) throws XMLStreamException, MojoExecutionException { if ( parent == null ) { @@ -143,6 +144,8 @@ private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject p { getLog().info( "Unlocked parent " + parentArtifact + " to version " + unlockedParentVersion ); + getChangeRecorder().recordUpdate( "unlockParentVersion", parentArtifact.getGroupId(), + parentArtifact.getArtifactId(), parentArtifact.getVersion(), unlockedParentVersion ); } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 7d31379507..6b53757f35 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -39,9 +39,11 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-parent", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) -public class UpdateParentMojo - extends AbstractVersionsUpdaterMojo +@Mojo( name = "update-parent", + requiresProject = true, + requiresDirectInvocation = true, + threadSafe = true ) +public class UpdateParentMojo extends AbstractVersionsUpdaterMojo { // ------------------------------ FIELDS ------------------------------ @@ -51,7 +53,8 @@ public class UpdateParentMojo * * @since 1.0-alpha-1 */ - @Parameter( property = "parentVersion", defaultValue = "null" ) + @Parameter( property = "parentVersion", + defaultValue = "null" ) protected String parentVersion = null; /** @@ -67,13 +70,12 @@ public class UpdateParentMojo /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( getProject().getParent() == null ) { @@ -106,8 +108,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } Artifact artifact = artifactFactory.createDependencyArtifact( getProject().getParent().getGroupId(), - getProject().getParent().getArtifactId(), - versionRange, "pom", null, null ); + getProject().getParent().getArtifactId(), versionRange, "pom", null, null ); ArtifactVersion artifactVersion; try @@ -129,6 +130,9 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( PomHelper.setProjectParentVersion( pom, artifactVersion.toString() ) ) { getLog().debug( "Made an update from " + currentVersion + " to " + artifactVersion ); + + this.getChangeRecorder().recordUpdate( "updateParent", artifact.getGroupId(), artifact.getArtifactId(), + currentVersion, artifactVersion.toString() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index f80ae7243c..033f6623f5 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -36,9 +37,11 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-properties", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) -public class UpdatePropertiesMojo - extends AbstractVersionsDependencyUpdaterMojo +@Mojo( name = "update-properties", + requiresProject = true, + requiresDirectInvocation = true, + threadSafe = true ) +public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo { // ------------------------------ FIELDS ------------------------------ @@ -72,16 +75,18 @@ public class UpdatePropertiesMojo * * @since 1.0-alpha-2 */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) + @Parameter( property = "autoLinkItems", + defaultValue = "true" ) private boolean autoLinkItems; /** * If a property points to a version like 1.2.3-SNAPSHOT and your repo contains a version like * 1.1.0 without settings this to true the property will not being changed. - * + * * @since 2.4 */ - @Parameter( property = "allowDowngrade", defaultValue = "false" ) + @Parameter( property = "allowDowngrade", + defaultValue = "false" ) private boolean allowDowngrade; /** @@ -89,7 +94,8 @@ public class UpdatePropertiesMojo * * @since 2.4 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter( property = "allowMajorUpdates", + defaultValue = "true" ) protected boolean allowMajorUpdates; /** @@ -97,7 +103,8 @@ public class UpdatePropertiesMojo * * @since 2.4 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter( property = "allowMinorUpdates", + defaultValue = "true" ) protected boolean allowMinorUpdates; /** @@ -105,7 +112,8 @@ public class UpdatePropertiesMojo * * @since 2.4 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter( property = "allowIncrementalUpdates", + defaultValue = "true" ) protected boolean allowIncrementalUpdates; // -------------------------- STATIC METHODS -------------------------- @@ -115,17 +123,15 @@ public class UpdatePropertiesMojo /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, excludeProperties, - autoLinkItems ); + Map propertyVersions = this.getHelper().getVersionPropertiesMap( getProject(), + properties, includeProperties, excludeProperties, autoLinkItems ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); @@ -141,9 +147,8 @@ protected void update( ModifiedPomXMLEventReader pom ) { if ( !( isIncluded( association.getArtifact() ) ) ) { - getLog().info( "Not updating the property ${" + property.getName() - + "} because it is used by artifact " + association.getArtifact().toString() - + " and that artifact is not included in the list of " + " allowed artifacts to be updated." ); + getLog().info( + "Not updating the property ${" + property.getName() + "} because it is used by artifact " + association.getArtifact().toString() + " and that artifact is not included in the list of " + " allowed artifacts to be updated." ); canUpdateProperty = false; break; } @@ -151,9 +156,22 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( canUpdateProperty ) { - int segment = - determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - updatePropertyToNewestVersion( pom, property, version, currentVersion, allowDowngrade, segment ); + int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); + ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, + allowDowngrade, segment ); + + if (targetVersion != null) + { + for ( final ArtifactAssociation association : version.getAssociations() ) + { + if ( ( isIncluded( association.getArtifact() ) ) ) + { + this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), + association.getArtifactId(), currentVersion, targetVersion.toString() ); + } + } + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 94f8fb4a3a..1e3127aa28 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -19,10 +19,12 @@ * under the License. */ +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -143,8 +145,17 @@ protected void update( ModifiedPomXMLEventReader pom ) } int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - updatePropertyToNewestVersion( pom, property, version, currentVersion, allowDowngrade, segment ); + ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, + allowDowngrade, segment ); + if (targetVersion != null) + { + for ( final ArtifactAssociation association : version.getAssociations() ) + { + this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), + association.getArtifactId(), currentVersion, targetVersion.toString() ); + } + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 317eba5e9d..494b649be4 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -34,42 +34,50 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import javax.xml.stream.XMLStreamException; +import java.util.Collection; + /** * @author Dan Arcari * @since 2.3 */ -@Mojo( name = "use-dep-version", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) -public class UseDepVersionMojo - extends AbstractVersionsDependencyUpdaterMojo +@Mojo( name = "use-dep-version", + requiresProject = true, + requiresDirectInvocation = true, + threadSafe = true ) +public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo { /** * The exact version to be applied for the included dependencies */ - @Parameter( property = "depVersion", required = true ) + @Parameter( property = "depVersion", + required = true ) protected String depVersion; /** * If set to true, will use whatever version is supplied without attempting to validate that such a version is * obtainable from the repository chain. */ - @Parameter( property = "forceVersion", defaultValue = "false" ) + @Parameter( property = "forceVersion", + defaultValue = "false" ) protected boolean forceVersion; @SuppressWarnings( "unchecked" ) @Override - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { if ( depVersion == null || depVersion.equals( "" ) ) { - throw new IllegalArgumentException( "depVersion must be supplied with use-specific-version, and cannot be blank." ); + throw new IllegalArgumentException( + "depVersion must be supplied with use-specific-version, and cannot be blank." ); } if ( !forceVersion && !hasIncludes() ) { - throw new IllegalArgumentException( "The use-specific-version goal is intended to be used with a single artifact. Please specify a value for the 'includes' parameter, or use -DforceVersion=true to override this check." ); + throw new IllegalArgumentException( + "The use-specific-version goal is intended to be used with a single artifact. Please specify a value for the 'includes' parameter, or use -DforceVersion=true to override this check." ); } try @@ -90,8 +98,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException + private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException { for ( Dependency dep : dependencies ) { @@ -117,18 +124,21 @@ private void useDepVersion( ModifiedPomXMLEventReader pom, Collection } private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, String version, String releaseVersion, - ArtifactVersions versions ) - throws XMLStreamException + ArtifactVersions versions ) throws XMLStreamException, MojoExecutionException { ArtifactVersion finalVersion = null; for ( ArtifactVersion proposedVersion : versions.getVersions( false ) ) @@ -261,6 +264,9 @@ private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Strin finalVersion.toString(), getProject().getModel() ) ) { getLog().info( "Updated " + toString( dep ) + " to version " + finalVersion ); + + this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), + dep.getArtifactId(), version, finalVersion.toString() ); } } else @@ -275,8 +281,7 @@ private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Strin } private void noRangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, String version, String releaseVersion, - ArtifactVersions versions ) - throws XMLStreamException + ArtifactVersions versions ) throws XMLStreamException, MojoExecutionException { if ( versions.containsVersion( releaseVersion ) ) { @@ -284,6 +289,9 @@ private void noRangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Str getProject().getModel() ) ) { getLog().info( "Updated " + toString( dep ) + " to version " + releaseVersion ); + + this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), + dep.getArtifactId(), version, releaseVersion ); } } else if ( failIfNotReplaced ) diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java new file mode 100644 index 0000000000..32483c4906 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java @@ -0,0 +1,51 @@ +package org.codehaus.mojo.versions.recording; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.io.OutputStream; + +/** + * A recorder of version updates. + */ + +public interface ChangeRecorder +{ + /** + * Record that a dependency was updated. + * + * @param kind The kind of version change + * @param groupId The dependency group ID + * @param artifactId The dependency artifact ID + * @param oldVersion The old version of the dependency + * @param newVersion The new version of the dependency + */ + + void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ); + + /** + * Serialize the current set of changes to the given output stream. + * + * @param outputStream The output stream + * @throws IOException On serialization and/or I/O errors + */ + + void serialize( OutputStream outputStream ) throws IOException; +} diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java new file mode 100644 index 0000000000..f023e0df58 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -0,0 +1,63 @@ +package org.codehaus.mojo.versions.recording; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Objects; + +/** + * A recorder that ignores updates. + */ + +public class ChangeRecorderNull implements ChangeRecorder +{ + /** + * Create a new change recorder that serializes to XML. + * + * @return A new change recorder + */ + + public static ChangeRecorder create() + { + return new ChangeRecorderNull(); + } + + private ChangeRecorderNull() + { + + } + + @Override + public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) + { + Objects.requireNonNull( kind, "kind" ); + Objects.requireNonNull( groupId, "groupId" ); + Objects.requireNonNull( artifactId, "artifactId" ); + Objects.requireNonNull( oldVersion, "oldVersion" ); + Objects.requireNonNull( newVersion, "newVersion" ); + } + + @Override + public final void serialize( final OutputStream outputStream ) throws IOException + { + + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java new file mode 100644 index 0000000000..3f88ccc38a --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -0,0 +1,116 @@ +package org.codehaus.mojo.versions.recording; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Objects; + +/** + * A recorder of version updates. + */ + +public class ChangeRecorderXML implements ChangeRecorder +{ + /** + * The XML namespace used for serialized changes. + */ + + public static final String CHANGES_NAMESPACE = "http://www.mojohaus.org/versions-maven-plugin/schema/updates/1.0"; + + private final Document document; + private final Element root; + + /** + * Create a new change recorder that serializes to XML. + * + * @return A new change recorder + */ + + public static ChangeRecorder create() + { + try + { + final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); + final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); + final Document document = documentBuilder.newDocument(); + final Element root = document.createElementNS( CHANGES_NAMESPACE, "updates" ); + document.appendChild( root ); + return new ChangeRecorderXML( document, root ); + } + catch ( final ParserConfigurationException | DOMException e ) + { + throw new IllegalStateException( e ); + } + } + + private ChangeRecorderXML( final Document document, final Element root ) + { + this.document = Objects.requireNonNull( document, "document" ); + this.root = Objects.requireNonNull( root, "root" ); + } + + @Override + public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) + { + Objects.requireNonNull( kind, "kind" ); + Objects.requireNonNull( groupId, "groupId" ); + Objects.requireNonNull( artifactId, "artifactId" ); + Objects.requireNonNull( oldVersion, "oldVersion" ); + Objects.requireNonNull( newVersion, "newVersion" ); + + final Element update = this.document.createElementNS( CHANGES_NAMESPACE, "update" ); + update.setAttribute( "kind", kind ); + update.setAttribute( "groupId", groupId ); + update.setAttribute( "artifactId", artifactId ); + update.setAttribute( "oldVersion", oldVersion ); + update.setAttribute( "newVersion", newVersion ); + this.root.appendChild( update ); + } + + @Override + public final void serialize( final OutputStream outputStream ) throws IOException + { + try + { + final Transformer transformer = TransformerFactory.newInstance().newTransformer(); + final Source source = new DOMSource( this.document ); + transformer.transform( source, new StreamResult( outputStream ) ); + outputStream.flush(); + } + catch ( final TransformerException ex ) + { + throw new IOException( ex ); + } + } +} diff --git a/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd b/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd new file mode 100644 index 0000000000..10d0926b3d --- /dev/null +++ b/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd @@ -0,0 +1,37 @@ + + + + + + The 'update' element specifies a single version change. The 'kind' attribute describes the + operation that produced the version update, such as unlocking a snapshot version or upgrading to the next + release. + + + + + + + + + + + + + + + The 'updates' element specifies a set of version changes that occurred. + + + + + + + + + + + \ No newline at end of file diff --git a/src/site/apt/examples/recording-changes.apt b/src/site/apt/examples/recording-changes.apt new file mode 100644 index 0000000000..a7b559476b --- /dev/null +++ b/src/site/apt/examples/recording-changes.apt @@ -0,0 +1,49 @@ + ~~ Licensed to the Apache Software Foundation (ASF) under one + ~~ or more contributor license agreements. See the NOTICE file + ~~ distributed with this work for additional information + ~~ regarding copyright ownership. The ASF licenses this file + ~~ to you under the Apache License, Version 2.0 (the + ~~ "License"); you may not use this file except in compliance + ~~ with the License. You may obtain a copy of the License at + ~~ + ~~ http://www.apache.org/licenses/LICENSE-2.0 + ~~ + ~~ Unless required by applicable law or agreed to in writing, + ~~ software distributed under the License is distributed on an + ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~~ KIND, either express or implied. See the License for the + ~~ specific language governing permissions and limitations + ~~ under the License. + + ----- + Recording Changes + ----- + Mark Raynsford + ------ + 2020-06-27 + ------ + +Recording Changes + + Here's an example: + +--- +mvn versions:use-latest-releases -DchangeRecorderFormat=xml +--- + + Which writes a file to <<>> that looks something + like: + +--- + + + + +--- + + The contents of this file records the fact that <<>> + was upgraded to <<<3.0>>>. diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index a694163d3c..6b2499ff17 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -164,3 +164,6 @@ Versions Maven Plugin * {{{./examples/use-releases.html}Replacing -SNAPSHOT versions with their corresponding releases}} * {{{./examples/set.html}Changing the project version}} + + * {{{./examples/recording-changes.html}Recording version changes}} + diff --git a/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java new file mode 100644 index 0000000000..fdd2c05fc2 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -0,0 +1,98 @@ +package org.codehaus.mojo.versions.recording; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public final class ChangeRecorderXMLTest +{ + private static void copyResource( final String name, final File output ) throws IOException + { + try ( FileOutputStream outputStream = new FileOutputStream( output ) ) + { + try ( InputStream inputStream = ChangeRecorderXMLTest.class.getResourceAsStream( name ) ) + { + IOUtils.copy( inputStream, outputStream ); + } + } + } + + private static Document parseXML( final File file ) throws ParserConfigurationException, IOException, SAXException + { + final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); + final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); + return documentBuilder.parse( file ); + } + + @Test + public void testChanges() throws Exception + { + final File file0 = File.createTempFile( "ChangeRecorderTest", ".xml" ); + final File file1 = File.createTempFile( "ChangeRecorderTest", ".xml" ); + + copyResource( "expectedFile.xml", file0 ); + + final ChangeRecorder recorder = ChangeRecorderXML.create(); + recorder.recordUpdate( "exampleKind", "org.codehaus", "example0", "0.0.1", "0.0.2" ); + recorder.recordUpdate( "exampleKind", "org.codehaus", "example1", "1.0.0", "2.0.0" ); + + try ( FileOutputStream outputStream = new FileOutputStream( file1 ) ) + { + recorder.serialize( outputStream ); + } + + final Document document0 = parseXML( file0 ); + final Document document1 = parseXML( file1 ); + + final NodeList elements0 = document0.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); + final NodeList elements1 = document1.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); + + Assert.assertEquals( "Correct number of updates", elements0.getLength(), elements1.getLength() ); + + for ( int index = 0; index < elements0.getLength(); ++index ) + { + final Element element0 = (Element) elements0.item( index ); + final Element element1 = (Element) elements1.item( index ); + + Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ), + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ) ); + Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ), + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ) ); + Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ), + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ) ); + Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ), + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ) ); + } + } +} diff --git a/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml b/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml new file mode 100644 index 0000000000..868b406073 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 7a5df14464c37eeeb8058868b5863cc7c681ddca Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 23 Apr 2022 22:19:23 +0200 Subject: [PATCH 055/441] Bump plexus-utils from 3.3.1 to 3.4.1 --- pom.xml | 3 +-- .../mojo/versions/AbstractVersionsDisplayMojo.java | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 93cedb4b22..e08daa027c 100644 --- a/pom.xml +++ b/pom.xml @@ -213,8 +213,7 @@ org.codehaus.plexus plexus-utils - - 3.3.1 + 3.4.1 org.codehaus.plexus diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 3846430a23..d912f25e2d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -21,12 +21,13 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; import java.util.LinkedHashSet; import java.util.Set; import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugins.annotations.Parameter; -import org.codehaus.plexus.util.FileUtils; /** * Abstract base class for the Display___ mojos. @@ -36,6 +37,7 @@ public abstract class AbstractVersionsDisplayMojo extends AbstractVersionsUpdaterMojo { + String NL = System.getProperty( "line.separator" ); private static final int DEFAULT_OUTPUT_LINE_WIDTH = 80; @@ -149,9 +151,9 @@ protected void logLine( boolean error, String line ) { try { - FileUtils.fileAppend( outputFile.getAbsolutePath(), outputEncoding, - error ? "> " + line + System.getProperty( "line.separator" ) - : line + System.getProperty( "line.separator" ) ); + Files.write( outputFile.toPath(), + ( error ? "> " + line + NL : line + NL ).getBytes( outputEncoding ), + StandardOpenOption.APPEND, StandardOpenOption.CREATE ); } catch ( IOException e ) { From 257d33c5f9ec7b91ee9559d95b5c51f999fe6f8d Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Thu, 5 May 2022 12:51:02 +0200 Subject: [PATCH 056/441] #291 display-dependency-updates: introduce switch processDependencyManagementTransitive (#588) --- src/it-repo/dummy-api-impl-bom-pom-1.0.pom | 25 ++++++++ src/it-repo/dummy-api-impl-bom-pom-2.0.pom | 25 ++++++++ .../invoker.properties | 2 + .../pom.xml | 58 +++++++++++++++++++ .../verify.bsh | 45 ++++++++++++++ .../invoker.properties | 2 + .../pom.xml | 58 +++++++++++++++++++ .../verify.bsh | 45 ++++++++++++++ .../DisplayDependencyUpdatesMojo.java | 35 +++++++++-- 9 files changed, 290 insertions(+), 5 deletions(-) create mode 100644 src/it-repo/dummy-api-impl-bom-pom-1.0.pom create mode 100644 src/it-repo/dummy-api-impl-bom-pom-2.0.pom create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml create mode 100644 src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh diff --git a/src/it-repo/dummy-api-impl-bom-pom-1.0.pom b/src/it-repo/dummy-api-impl-bom-pom-1.0.pom new file mode 100644 index 0000000000..b46e97d9e5 --- /dev/null +++ b/src/it-repo/dummy-api-impl-bom-pom-1.0.pom @@ -0,0 +1,25 @@ + + 4.0.0 + + localhost + dummy-api-impl-bom-pom + 1.0 + pom + + + + + localhost + dummy-api + 1.1 + + + localhost + dummy-impl + 1.2 + + + + + diff --git a/src/it-repo/dummy-api-impl-bom-pom-2.0.pom b/src/it-repo/dummy-api-impl-bom-pom-2.0.pom new file mode 100644 index 0000000000..b078dabc4f --- /dev/null +++ b/src/it-repo/dummy-api-impl-bom-pom-2.0.pom @@ -0,0 +1,25 @@ + + 4.0.0 + + localhost + dummy-api-impl-bom-pom + 2.0 + pom + + + + + localhost + dummy-api + 2.0 + + + localhost + dummy-impl + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties new file mode 100644 index 0000000000..e4813a9162 --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts=-DprocessDependencyManagementTransitive=false diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml new file mode 100644 index 0000000000..d22ccbd936 --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + localhost + it-display-dependency-updates-001 + 1.0 + pom + display-dependency-updates + http://localhost/ + + + localhost + dummy-api + + + + + + localhost + dummy-api-impl-bom-pom + 1.0 + pom + import + + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh new file mode 100644 index 0000000000..c44a94c018 --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh @@ -0,0 +1,45 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + + Pattern p; + Matcher m; + + p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" ); + m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-api to version 3.0" ); + return false; + } + System.out.println( m.group( 0 ) ); + + p = Pattern.compile( "\\Qlocalhost:dummy-impl\\E\\s*\\.*\\s*1\\.2\\s+->\\s+2\\.2" ); + m = p.matcher( buf.toString() ); + if ( m.find() ) + { + System.out.println( "Did suggest updating dummy-impl to version 2.2" ); + return false; + } + + p = Pattern.compile( "\\Qlocalhost:dummy-api-impl-bom-pom\\E\\s*\\.*\\s*1\\.0\\s+->\\s+2\\.0" ); + m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-api-impl-bom-pom to version 2.0" ); + return false; + } + System.out.println( m.group( 0 ) ); +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties new file mode 100644 index 0000000000..fa969d852b --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts=-DprocessDependencyManagementTransitive=true diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml new file mode 100644 index 0000000000..d22ccbd936 --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + localhost + it-display-dependency-updates-001 + 1.0 + pom + display-dependency-updates + http://localhost/ + + + localhost + dummy-api + + + + + + localhost + dummy-api-impl-bom-pom + 1.0 + pom + import + + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh new file mode 100644 index 0000000000..7aaf3d73b7 --- /dev/null +++ b/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh @@ -0,0 +1,45 @@ +import java.io.*; +import org.codehaus.plexus.util.FileUtils; +import java.util.regex.*; + +try +{ + File file = new File( basedir, "build.log" ); + String buf = FileUtils.fileRead( file ); + + Pattern p; + Matcher m; + + p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" ); + m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-api to version 3.0" ); + return false; + } + System.out.println( m.group( 0 ) ); + + p = Pattern.compile( "\\Qlocalhost:dummy-impl\\E\\s*\\.*\\s*1\\.2\\s+->\\s+2\\.2" ); + m = p.matcher( buf.toString() ); + if ( !m.find() ) + { + System.out.println( "Did not suggest updating dummy-impl to version 2.2" ); + return false; + } + System.out.println( m.group( 0 ) ); + + p = Pattern.compile( "\\Qlocalhost:dummy-api-impl-bom-pom\\E\\s*\\.*\\s*1\\.0\\s+->\\s+2\\.0" ); + m = p.matcher( buf.toString() ); + if ( m.find() ) + { + System.out.println( "Did suggest updating dummy-api-impl-bom-pom to version 2.0" ); + return false; + } +} +catch( Throwable t ) +{ + t.printStackTrace(); + return false; +} + +return true; diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 34c4c64740..c5ca6344c4 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -25,11 +25,13 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -76,6 +78,19 @@ public class DisplayDependencyUpdatesMojo @Parameter( property = "processDependencyManagement", defaultValue = "true" ) private boolean processDependencyManagement; + /** + * Whether to process the depdendencyManagement part transitive or not. + * In case of <type>pom</type>and + * <scope>import</scope> this means + * by default to report also the imported dependencies. + * If processTransitive is set to false the report will only show + * updates of the imported pom it self. + * + * @since 2.11 + */ + @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) + private boolean processDependencyManagementTransitive; + /** * Whether to process the dependencies section of the project. * @@ -283,10 +298,11 @@ public void execute() logInit(); Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); - if ( getProject().getDependencyManagement() != null ) + DependencyManagement projectDependencyManagement = getProjectDependencyManagement(getProject()); + if ( projectDependencyManagement != null ) { - List dependenciesFromPom = getProject().getDependencyManagement().getDependencies(); + List dependenciesFromPom = projectDependencyManagement.getDependencies(); for ( Dependency dependency : dependenciesFromPom ) { getLog().debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() @@ -297,10 +313,10 @@ public void execute() if ( getProject().hasParent() ) { getLog().debug( "Reading parent dependencyManagement information" ); - if ( getProject().getParent().getDependencyManagement() != null ) + DependencyManagement parentProjectDependencyManagement = getProjectDependencyManagement(getProject().getParent()); + if ( parentProjectDependencyManagement != null ) { - List parentDeps = - getProject().getParent().getDependencyManagement().getDependencies(); + List parentDeps = parentProjectDependencyManagement.getDependencies(); for ( Dependency parentDep : parentDeps ) { // only groupId && artifactId needed cause version is null @@ -378,6 +394,15 @@ public void execute() } } + private DependencyManagement getProjectDependencyManagement(MavenProject project) { + if (processDependencyManagementTransitive) { + return project.getDependencyManagement(); + } + else { + return project.getOriginalModel().getDependencyManagement(); + } + } + private UpdateScope calculateUpdateScope() { UpdateScope result = UpdateScope.ANY; From 5b948bbeb71b77600c016a6f26745fe7f2e42e17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 May 2022 13:17:51 +0000 Subject: [PATCH 057/441] Bump plexus-utils from 3.4.1 to 3.4.2 Bumps [plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.4.1 to 3.4.2. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.4.1...plexus-utils-3.4.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e08daa027c..a4845ddc91 100644 --- a/pom.xml +++ b/pom.xml @@ -213,7 +213,7 @@ org.codehaus.plexus plexus-utils - 3.4.1 + 3.4.2 org.codehaus.plexus From 31907e5bce77ec503026f76904f1ca313f739a37 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 20 May 2022 14:02:39 +0200 Subject: [PATCH 058/441] use-dep-version mojo: add a description include in in the goal list in index.apt also remove deprecated/unused requiresDirectInvocation parameter --- .../java/org/codehaus/mojo/versions/UseDepVersionMojo.java | 7 ++----- src/site/apt/index.apt | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 494b649be4..df965e464c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -34,16 +34,14 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.Collection; - /** + * Updates a dependency to a specific version. + * This can be useful if you have to manage versions for a very large (100+ module) projects where you can’t always use the most up-to-date version of a particular third party component. * @author Dan Arcari * @since 2.3 */ @Mojo( name = "use-dep-version", requiresProject = true, - requiresDirectInvocation = true, threadSafe = true ) public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo { @@ -63,7 +61,6 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo defaultValue = "false" ) protected boolean forceVersion; - @SuppressWarnings( "unchecked" ) @Override protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index 6b2499ff17..66d643fe39 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -95,6 +95,8 @@ Versions Maven Plugin * {{{./use-latest-versions-mojo.html}versions:use-latest-versions}} searches the pom for all versions which have been a newer version and replaces them with the latest version. + * {{{./use-dep-version-mojo.html}versions:use-dep-version}} updates a dependency to a specific version. + * {{{./commit-mojo.html}versions:commit}} removes the <<>> files. Forms one half of the built-in "Poor Man's SCM". From 615547e70dc09b359c78cfd9ae867f26239084bd Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 20 May 2022 14:53:09 +0200 Subject: [PATCH 059/441] [maven-release-plugin] prepare release versions-maven-plugin-2.11.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a4845ddc91..fc53a94f68 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.11.0-SNAPSHOT + 2.11.0 maven-plugin Versions Maven Plugin @@ -88,7 +88,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/${project.scm.tag} - versions-maven-plugin-2.10.0 + versions-maven-plugin-2.11.0 github @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2022-03-11T21:40:34Z + 2022-05-20T12:52:24Z From d48d9e124e9e568d8b2160c54694401a64e3cb3b Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 20 May 2022 15:01:34 +0200 Subject: [PATCH 060/441] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fc53a94f68..44d896e6d2 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.11.0 + 2.11.1-SNAPSHOT maven-plugin Versions Maven Plugin @@ -105,7 +105,7 @@ 1.11.1 ${project.version} 3.7 - 2022-05-20T12:52:24Z + 2022-05-20T13:01:33Z From 0c04e75b89a8b6ab6e314080b9aff9dc43e125ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 13:17:40 +0000 Subject: [PATCH 061/441] Bump mockito-core from 4.5.1 to 4.6.1 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.5.1 to 4.6.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.5.1...v4.6.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44d896e6d2..f2a5941a8c 100644 --- a/pom.xml +++ b/pom.xml @@ -255,7 +255,7 @@ org.mockito mockito-core - 4.5.1 + 4.6.1 test From 127a0f0d41019a8f9d71f9a668be81ce38aea778 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jun 2022 13:25:13 +0000 Subject: [PATCH 062/441] Bump maven-common-artifact-filters from 3.2.0 to 3.3.0 Bumps [maven-common-artifact-filters](https://github.com/apache/maven-common-artifact-filters) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/apache/maven-common-artifact-filters/releases) - [Commits](https://github.com/apache/maven-common-artifact-filters/compare/maven-common-artifact-filters-3.2.0...maven-common-artifact-filters-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-common-artifact-filters dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2a5941a8c..b16b6b9674 100644 --- a/pom.xml +++ b/pom.xml @@ -177,7 +177,7 @@ org.apache.maven.shared maven-common-artifact-filters - 3.2.0 + 3.3.0 org.apache.maven.wagon From 1e9cc000560ac3c553715c41345dc7f3225d2167 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jun 2022 13:29:11 +0000 Subject: [PATCH 063/441] Bump mojo-parent from 67 to 68 Bumps [mojo-parent](https://github.com/mojohaus/mojo-parent) from 67 to 68. - [Release notes](https://github.com/mojohaus/mojo-parent/releases) - [Commits](https://github.com/mojohaus/mojo-parent/commits) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mojo-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b16b6b9674..3b9dc065c4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codehaus.mojo mojo-parent - 67 + 68 versions-maven-plugin From a6e69a152d404d306708029ed6bf33bbffc588ce Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Wed, 6 Jul 2022 02:17:26 +0800 Subject: [PATCH 064/441] bugfix for parentVersion wrongly be String "null" when be missing and should be null be default --- src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 6b53757f35..84d3222695 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -53,8 +53,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 1.0-alpha-1 */ - @Parameter( property = "parentVersion", - defaultValue = "null" ) + @Parameter( property = "parentVersion" ) protected String parentVersion = null; /** From 49f1d6cbdfe44b3bf30833057263e6eb9722388f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 14 Jul 2022 06:57:25 +0200 Subject: [PATCH 065/441] Add message for stale issues --- .github/workflows/stale.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 45a9164075..52afe49d4d 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: 'Close stale PR' +name: 'Close stale PR and Issues' on: schedule: - cron: '30 1 * * *' @@ -9,7 +9,10 @@ jobs: steps: - uses: actions/stale@v5 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' - days-before-stale: 365 + days-before-pr-stale: 365 days-before-pr-close: 30 + stale-issue-message: 'This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' + days-before-issue-stale: 365 + days-before-issue-close: 30 + From fffbc13001fb79319321c7ed2b9389a6f0148173 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jul 2022 13:39:08 +0000 Subject: [PATCH 066/441] Bump mojo-parent from 68 to 69 Bumps [mojo-parent](https://github.com/mojohaus/mojo-parent) from 68 to 69. - [Release notes](https://github.com/mojohaus/mojo-parent/releases) - [Commits](https://github.com/mojohaus/mojo-parent/commits) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mojo-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b9dc065c4..afaaa94ed3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codehaus.mojo mojo-parent - 68 + 69 versions-maven-plugin From 199c79ea42987fe58692f49276be6544bf57cfc7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 14 Jul 2022 21:30:22 +0200 Subject: [PATCH 067/441] Build project by Maven 3.2.5 and 3.8.6 - use shared Maven actions - refresh Maven wrapper --- .github/workflows/maven.yml | 25 +++++-------------------- .mvn/wrapper/maven-wrapper.jar | Bin 58727 -> 59925 bytes .mvn/wrapper/maven-wrapper.properties | 4 ++-- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 829cd12efe..218d4832bd 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,23 +21,8 @@ on: [push, pull_request] jobs: build: - - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - java: [8, 11, 17] - jdk: ['temurin'] - fail-fast: false - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: ${{ matrix.jdk }} - java-version: ${{ matrix.java }} - cache: 'maven' - - - name: Build with Maven - run: mvn verify -e -B -V -P run-its javadoc:javadoc site site:stage + name: Verify + uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 + with: + ff-maven: "3.8.6" # Maven version for fail-fast-build + maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index c1dd12f17644411d6e840bd5a10c6ecda0175f18..bf82ff01c6cdae4a1bb754a6e062954d77ac5c11 100644 GIT binary patch delta 26989 zcmZ6yV~}RS5-r-cZQHhc+Mc$iZQK1#+qP}nwr$(C-`sQVk9ThET@mX?#*WC!tcc8& zYoCmRCM|;UD9V6>!2kh40Rf#zm8t;!{}%K=EGMQSOfMxb&iH@K(Egc0{m1O>Ya-WAQkQGI!4pNF4rE|{FAW|AO}iT&jL**%l6|ym*0+*e6#DCz)LE@sRC!5R z+%jb)52+0PqA0Zus_kx^jkVn&>$B9CK=u=-v`qE{EMb_EkJ#8cDOe(3hk|VO^_u(( zr3plp#-LMG%VSE+w^Q*U@c+7*01r$6_J90MU<4-rFVFy{{VxasX8kYd2Il-Pcmt;X zFQ5Ps`7f{rQT#9H1tOnY z;QsFME5s>5Zg|?-l5j!EV`PdlJ|m2i7g`|h{6W^q`aU`c!L8D{H7FbpR%hXg=%$Mq zV|M-+U~neZ&%siV9-wsd@FX|t9Q{q=kqk0h!dH+!XksroX_A^e$~rBG<8dUFNE$!z zgJ~PzL9o%hygr-4ZfMkD1GEeOzk$?{E#4u81OmE200Lr7aInQoSVqMISa_kXp!?P| zMUo*xBL`~~A{8wX;c82p6NO#QBZUn8YA%~X327YDz|jW1k4(j0Ytx=Y1X|IDdGjb;Y5Jv48xeFsO4kP`=7@)g%r23UBGp+;n5Z^%sNgC|LMJP<| z5B_E&u1`%x>rNMJ)0*2G-RFlZEY@cTC)0}6SDz`k9i_0Fu=R>2Kp&EV)=5X5g62&T zEa0uycas0g*NxPNY4nQHjWvGa zYA;Pds;yvMdQH47gdycfv!+uJu68t@+8r}e1>PPGwAKb9#wN(rZ`q4m{cC7nA@b6j zX#Oi zxj$j)E3q%2aDT*Ibr(5VlxIeS#uA-Um*EVP`>5!ie1ZWz)42?%+nGL^#@9c`Q}dVX zf|zMtc+TDljj!Jd+UM_~8hbf?rve1i+f1RCN&{1jXAeCZ->98hSz{U&1+99iA-g*s zmrZho>1@(l7~hipmse15vo8H-j)NI_d*As9L2v*-0;p_>d-;Hm`aTqN2s1(tme%d>NA zW>y*roTyYsu}Vx=(OW3VykvW9W&Ls0@yTnWTxM&O9z_s}Lrt&BkWK&ABCW}4j842f z$jIogvbs#oxJTEfDff9{!@p22x{JP!c0C1bZYbm8VbVM3+HCohJ$DpL2@^QSSmCF; zRQ?`XGRdyDDp|fLsXn@}U~l(jWpBLzoh&aRq_mD`J7j?6+wLoknyS1|v(8dusNX7D zeyLnC#%@_xeKLluYq0tIXy=^wRNXQ%5@f)jbz-rF8a49jQ*xF{Q`VEELL1zUT8|81 zir)%Wt|9mH!LR9Updak0vTpt1PR=f4Y+5>)i%$RMY`(%Y<~Pw|)F>+DMwKX*~XW74Hg!FG_KZ0;&MhPm4?74`EN@r;3g`<;=V$w#f{P^C=| zttEGKn`y#m&UT)r(lI!Uy+EA!>lNtk?|Uj(RbYULz&})$>|kSZ2h~O8L{5d?7O|&bY7CC;h3Q|Y zP*g)|^E2mY4c8!P^}qhbR9&sF%z@TpW)J@Y^G7iQT+Lx8&E1=++XS9p*Sr`&DRNh( z(rH71)C2GY?^?4bp_7!H1be>s`bfLT)|iAPB`RI z2^!z=3im1~1e5Ye*Lp>{7rp?56Ya0PZg0PWX4f19_-VWE(75UhT?E`^Rk+)W7zYG0 zQOClQi&(i!?$RKPE`5O8&FHS(&UUOOL3Ky`srM1u#c4K8`o$z%>82;TNJ-Ie7kjlv z(R`qSB^$`s9KgQs>mi+dxUnV)Iiw{0D+5i!c4sgjns@&Glqa z?4*9Ac;bI5BD7_8PgBC#!VzVwN%uD>Ka^2ABe;hB3crC&luA+wfMl=sK}AeZB8~0y zU?`e>`|HNz-@k+`xo}bFR!!cIZ+T69$T1TUC>T)r6eTFtGnAZ?(>UC!%uFrW4G;p3>qeOxclA;f=?9pZK^ z!mj^`8DQE_yzjMhX?lHti;KjLG|nO4tv^y#;K}1EWG*m6y-ziuRtE62;99ot%Dot# zyT$rO8<42HajbAxy+OmP3~x;&q{;xj+}py#G6^E|#!EdQ97fHh^rAs!cG8E-4No%w z1~s11;t;>mD~yd)K&?r|Tul{&tWqJ~vxP~0*VFI~ZIq39ihD@jDO`?N4XGn0DF+pp zzrW!){Giq_$tnUb8aZ&>&1Sg*V|K-RJP|l8qV_Rtm5Ydr`mPoZDF3$z%TWB?OAi7B zv;hVLr2L;E>;jh$u%mz~jP%`1uhT`)l)WA<2n1YLwOWubu52VCEh||bpGy{8Qlz`V zdZpXYQuNp}k4c<<8_4*rG`wat1d%R;dc9}rdYoa`y|woBbuxndSCx-5t~U}ImKDPE zAeGgD@WFv@uqk|Ozb_7|Eas0U~a7KL70cEumoUkzNqw$4Yr0UmFdWwD%}}t#AOW=+Hi#tQ_E*`WjJTG!002k ztnfq=QxMs}CHFjbJbcl5P_saCj9)ASfi_idUfq|%XNAdM`D!dGEq8y_t-~@uGdMd& z7qZ3*)U6VfiGxgZQJO;w$C~TM4HmM;+K(wOIGMF^0Mak1m5LNcGf_B3aUe#GbRK+C zH1WD@PO^}4D#2_w87{WDVF7#5$6r5+tF7Uz+DqHeo)BDPn|qYeJs#Oj7>8Hb z|4pfhXC03`I3S>FY#<<}|D;p|0S>?&cL@D^B)Q4T!vXK89z`;7qs8Gb*rokyv=oSd z{}ETJkO8TkHTk`Cr5g9&=Ei?Zh^i3M!f)H}_j;_qQ7&GWh>Xn5NB2#@HYVGbnOZ!# zb}-UN2d~{W`_0$Q)Z~fT_sc0N&@>W0&NWOfyj#iv$|fn{4Z`gm!JB(cG~fmN*4JBT z01}jHWDn?i$cIOOEbQgtwKf$!sQ+lArD%g331y| zrzIQG*a`~N9#Y#z0QDI!JkFzz>6{w8Q_h=Pv8z@isK>QOvn$F4&|YTNWLFx>D>a=A zRdLaoC=OGn*95F-%uPg;Y)N{A(^QxmX__TAZByDGoMy}BBPdh6Mh+Do5ogims+PyM zwMIp!o+f#Jg@$UA9F1JXUp5VKz(90A^3{IVD~hQuf17SJ0q`~=7m8A+Qnij#d-)VV z(XE>kELKRB#Vppt6qtA9>SHDfx6VO4DJ|4g(n%#ucucsjNF#f5u@$sov}df`g$I7v zGGi5w-ft@@0(-ry8wO;D@|BI$wD}YlCdc%_^V^u!DXQ$6-6)_I@lD6Iyi8N@Rbw?( z!Hk-Qa<$kE0d3i_3r1}P(8o3g1UW`mkqcT4oD#kRzb7^SOyTkb1FEE%+f=*T73!b44(68~CoSZHcK_OG*+7K*6O z5Tty@g0CTT4(*;3tl| zUzhYCNm8(O%P&yDkSfe7buo}l-u$!}+8{$m;b%?uiovsafZ#Ws zw6n3j05A!4w3s8cwTSuE{Pbj}FX)9$&?pHCtY&Rcp#QVERgzmA1|y2KkCt3YOfy91 zS|*~lVDiVUP`5%exQm~c=NhmKIv&1BNtD#l6BvghgmuX2QRfeH^ zz2tx`Nv4gIfjCKJJPJW{5#N-t1&m#ocI6-HBtWq1z0gNk~TryaPnZNh@xN( zisS}4Y{Q^m{h3msh><*DUG;mohD91CyBM3}kE4MUnXBw+$4&Z{QqF}&4ytXwOPBq@ z8UT7rxK5lE+bYWX$?8}uD>+_=}pY0M`xXU5oTe2 zXXa8tFTO35Wl&FW_W2yTd-IdZj+4slr^Zz>-T`_U zFBYM&zdD4r#xR?E@6*yAS|dN3XE+4DIu%D3rnUP*ek@k6NCQ3qLiKl`j*UyS$2{Hvwv1*e!zCXbVakm!Fp$yib{&yyIxC%fYDwXmy}c z4PTTdHo?W)909~ZoyY0TbRVR6XNAUl5+>Po0ac@IrH`|>~W~BQEr$-L^srkUo=7<({6x=+Fv%xgTSAGNSf@`8LAoT6^>jQ2_?GQ7j zZx5q|2|qfTom<>ob=O?Zjz@csx1;#1TzV2y-D2hE)1uhL~%n`C*X)o0j7+=njt!?q&txW!_7 zx+Iy=I)Lb=Oqh8rdB9G|1Ui{h{xrMn_S4QxZ}HxzvC7)~Iplrrs6WPBnVi(1ZFy_Q z?9s>U-(O6h#+2!{UP-`&t;v}{m1t=9o6vRx=E(u1?w+Dyp9h64) zd_!`p`d@i71m?`J-|oScbD<`2MbNAm3M}tAP6zU{w}R9FEvB&1{@XhJgnuYlOg~2H zPmUp)pif7X-mu0)0E5h66pF+)$ut>B(q_2MnGxJvdTY#lZISrOcj4SB-J~Ua=}O%s z=CZqq2O4;lDmQQAs|)k1mBiK6<-HoQGN3$f+kY)}LXTGC&FsbU`i{uNnPnU1cdy8# z6js<01)|qbp|+uS0^nox5o%&%jIP0sZD6Ns2uJ)KR0#bE0B~~p2D&~2%yj8&Jy-@@Pbz$U zbZYj;L|xoXEe?1kP4DODqTNOslYi+f=waXd_Y~K-l7qbuG?vdXtF%UUcD?W>LZo91 z#f(8{8R6ez07h1lywTvqKU`|~!^LX+g+Y%Fi+IEDa96VP&M+4W&B-!;MQRs7Z&)XemH-B_SF8VCzhZk2PG!wKYppL}f(2dSrnO!=d zf0(5ys4^xc$s8c7)tEO2xmIH9aUFtA1KP|9CdD4~0Tk&bTtXHZ%QW_=PvqEhmY$C6 z4=TlmHll*UAujOI5ZmwWP107Y1qL<2J~+>!w@P(!F>;^$!f24D##414^0UnVo*Wu= z#)_5L0QC;IUBp>j=5G{CO@~a0=qH7}Pf|3SlzjZ4eBvA`!1(sL7hINTA3VynuEM-jmQ8&QI!azc z&E5vA6lD2pXIKL#>qd({vMu>M!YaaxO-qGO8YSlrj6f^4KeAuFu6%+p?txEc?f`|zLPNKJN!>Sg0r9FLGH zfPXcZ!!boCwer~$6}PauG`b2@0jJF8rni5yH#Z7&xHR&gY1Y5ogK?8K5$Cb|<$})~ zcq8${2O5cfa-eg+mw2LKarsyA3?^3HjbZE&SestvUp`jjZX`enMnUCerav&=8T}4Q zMq0|cdV8hCSzt3^LNRA^Ka*D5vihDr0p8IhJUas}hO?SrLKe zCVB}+?JX9Q2P({0Bwa78hQ4n2W(nC^azTG_zVhU?o3~_5Q|y+O02(RuP2HXH-^tt= zXWkiFrtIzLI^K)(VzZ+V^)M%U^1g3n4){(iqtevGv4w;;{eRaJq=|l_QT;wQBHv#C z|J&L)PxAh4`8QZO`?sn8)7lu)p#b_U`xTMIZdMmp8*_Il(ek#OF&G-Ez=ajjItUL` zQ1`v|(#m&^`w?#o3K>z-{S1!b{?RSl)0jY_oq_H!$jCfaUTkei>;|_SV~0f6jfY3x zcq@ro-%?ITX^9)JUl~YI@?jVzmQwWQqAMM z+@*U33Hgd6QHir1AxDNBe7Yv-iGjXO?+VtaQ1mKdzG}X7^?&+t=#90f)@UxOE7C5_Oz&b>v~RCuMx3 z@202wN*aI#-#dLszHnGTlMnwaDJ1V=6IHOI2llyu+r#Fi#lpcXB2SLc#@?&EiR@OE+j`I%Dii3--K$SiJxd~6 zT=Dq(Vqy^1WWQ8FrdFm{|}}QH)ka$vLqs-?&458$EcCt!P=*6sx3Fu}pS{ zx+W&{^N34>f?ne$<%~#;*A_3NC=)uunB}%7?0R=2V7qrY#FwUyP?!|OI7IOO-V3z< zJ8lMw{0)_Z3NpX6+F9k7tb_sm<0iyH{I3fNx z?GtXjQhqK+arv6AJ?0v)_ zF?cXq`yf(Db?f7vYk^ESAbfD}<~7zq>^I%P6LVi|m^}5|OhP8h8nv=B*HWwnLmC4? zNv6Rl+&Ya}yMw^C+HphTzBPW<0a^_)>sIMtMY)Mu++?x?PkKSl$+>ej@xzt|W6^k1 zFSUuKWt%cayGb0K+B%Hrw97b330+aeAzukyfrLrhxn5rSjN3Rk;Qfz9=uDJNy>yyd zMJg=3X2DIwW~+`sUd%X&CavmwDM#UOl&fY57$$E0Hg%KjMUW5wu4_uyQ!{;)7Ej;Qj=T; z=Tf!JwoXT#ftk?};P}aZ%*E^L;|qOHs4$-tsgVZfD~!JatLj-&oeS%(1@?GZ%&>#@ zQwgv^P(gCIV;4l*Zuo7!7_O>P5?YC+IV?7&B^8yYD@;p4g`ZKwoDp9cQ~|mtWEhou zhbF5zF0X#?PY)uYTDXN0Spyqb6+Au5K-;`F6XPG>E}0<+XdNPiJ>_dUmAr(WHF6qW zR>X~_{Ol{-x^7NAQqWlPa~Dx`g4xiHzbTh&C9UmXJyrlC*;9oTck4o4CtS|cGDijb z+S@{x3)3L#)OMi|nX~abZU38|u|tqsGSXx+fv(~$D|(vcYDWXXtf8ow$ucdi z!e&=aE`>Y=IA1pwBOROh)=%l7{F60?vNqf(!@vassEDtVMZOkWrBjXDO?R7R z`s*Zex5%Wpit+%}jmL#P-Q;w*d`SwSJv=Teb`#Sh0R11y^wk6HQ+CG*U>JQh5k{^f%H0g46BIM#p#k98}xWi=)uW2_+NkZieS< zsb8_*>p44}o%1RtM(X9i+J<8%)?nb*#_(%wVT;#+zoao+Gf1-PIA|>t93TLg6?~{G z2k5Bk2RNuJ`#fry)as#nwfeF`WheFQyG%RkzLq`;!j>GcZ! z#esqDSi~goEsKezIu_EhSR|~tL2a7E&(cBE&}VEWf)KK2{eOwK+Aj!{tK%!uAlu3Y zhgQXQ*wD7ko##I8rIJ_a%XTR`U5PmWF0Ig1h@n?kJfLN##3-qK5GbkXld z(8>bzoay)2ZDX++*idhmP@v@`bJ>l+Ijlz*Z=KXFFPjHrSE89W1F zLjM8~NUX(ypGzH%h5j4&#UD&a7h*l~#Kk8hL~H&0NK9?F?$18Viw zSe44A5|~t%+9T1op4f3jVAutqeqkYU%-OUX=e(0nU*+(4$kr&7QC>@gJQPNqv9Q7F z0NH~ffMvtCBO4uTZ#Rl~%ppchyRXG#InutrYRuI6i;<`*#uISWY_^7GZr4uhULb1I zw}Bk?hBf_w;e{KJENIJ&_lLir43;OYkAGVzq=j<+?CQQ@xAjeaepLXVV?9o)#UM`B z%_XbDaimmrKHwNa9W!?DIh!mhC{U1E(e7JD+iw}=bX0?r%OE-MlJ@(}<$ ztTXhgk^53!ZMM|iX4C}WU~gdIXFcL39(lOeRqm$TX>nMUv=O9qNx&N2UjaKJK88&1 zWlTNoQ}x#*yb|sM|Jg~%)}I^US*}+Ms);QcIbb ze##@5N|>;vjq6B(E`kltscqQWL{-o@q$MN79iP2p`e3NlZ@d8bA&0I6=0iWfiMWJi zyJBQv*p=6uZ80KCg?Kogl}b-zvm&{~ZFR7ZM+>zEblHrXmp}bV39VI+z7^Rj-;7o- z`G9WG-ooV_j#ZUe4RgB=FS*S6t;O4}Zm7nGvN`iGP+6B1haM)>>A3n;%+;0Hy*0_( z#fNeE@%qx=v&#ZFG#xgs7EzWNX*H4`*HyJ7;LsV|Pq(GFCO8o1FR~?U=5lV$1DpTYDcLl#nP01$7A86Li zq2I8rllN&pXaKy|8XXRfCuayWa~2^8z(jn*I|`i-PvW3!znp)|GBQtAA=k#$%^@S| zn5?ZJ?aKnBR?l(fAd+*=dA!46J(P&DH48xiULQ<TVKrDAGpXmvtA^7svcjX3cX!ReWL;reKkA7SRjdskrV={VJ7P4L6Vd5`)nS%@!}oMm_!x?A=(H_JXKOcJG+^($_$%<5%u zeiNO2EI~Q4P5teza^zidvK(5=ld_03ypcg!d70KH>z5j*8@9}#HVDi-1H7N0X@acm z&mxgbh(Y^~Bix@+Y$xSn-$8`D9)EaF^3AS>O;Jw|eNqa8|8_CFvKus$c z+*uzq5(@~F@pw&~I^JCvIiYE-#TjZv$^jgQbB+b$-eLC=l;PA#lvBkVWZ1Lrs3iRG zEkzfMz8!VhFQ%Y9_nB)rqu^pZ^?M+xQtn#vBe+Q^G0HNebz!Z9><4vW?L>@L+wesht(W(gmjvu184vfB|?*$ab6EBnnD`G|m=j(bMRBG2{ZQHmAS0GSWKg zSYkZzPVjL)mD0`AP_QlX6 zCX^y*ta~vQjUaJqVWXh-e-F+D&g5b5^sDiWU;099+`<0-gihJh)nN!)rCx9dniS7S z%+pQI7hN`p(O9MB)X&+B%-!^l#S_)Y7W?%_Nac@+?DnsePi%ez@_aonM}K73^3UuN%sO&tKXyL&H5_p=?h zT_F?UW(#>ZD19v!ucXd4-OEj%iL97CcmjUXrVH!u_bNDqy?yrrD(s;%b)|$$lS?29 z!Zhk97gR|Vbn|2qQ@|KWCAEYX_p^@Xwt`%ZxP0Sl+r_y__c{XJCYYYrVhj^a7EVp+HIDtmX@EHB=ZEx23w zG%}sZMbNoPDZY%szf=0|>MW`3a7Lh@Zq#k5_E0dW zJsveTC>aOu>Elk57 z74N7hf^_H&?rbS%A@&Au(QF+avCJ;}DSnR|u8_kQ+RVdSfo5$puUhDsTM+Yi^pa+W4p~I2vV2 zQ>b(L=8`dWFijbH&F-4WYYqFR$vSUaakK%ka)uSPPy4IX*4fmV^D5D!yXO?TtjzeS z<^MH^@A-p{-(+FX+>ps9&Pd1G%OMysHb!zjYBXQ(b!{sr;SsYXB$*L;;{XQX-2MUt zg9tBh=>T{}RqG=`d?sG(_djf@ogud-Wr#_*DDnxlerlD^Upo*Oi=LK8op3HKQ4rv<@B<;ELwF5OGBD*BFy3)ziBynUW>>iDMFxnUI1Cr3m^)BfJq|5?q(lx`x#Qc} zf0O)KZsRh^l-=D7Ks1p*?+U%3HHlI&?3#>&$ttllfK>v0#b!Mw|NWi$_9c_3G!N4$ zvaMIw*Aa8vdHZ|R-2Xt&GX8HRX=(bV;8%ub5+Ti_{w8z8QtjL6QxAThOPbh8Vq1`Jpe;#0S4G#h!}+CN>!vlKpD+?FZSso zabM>6umwW=w>63jf!VZQU*j4jzsAtdN3|&?ft4x0lk;Q@rLg;Cei9Q0-M__wSn9)*R)mill@%^q?B#TlZkv%5)+Wf^;w10YIgwwC;oNt`L2f=$Ahh3Id< zWw(~^K3fX&0$;OCoqv>tQF%W#L7e8MqkJOwX9LwUfDlGo(9xrTT8IB8 zwb;Hv#d56!Vc-`{&kSPQpOfY?+-$2g)8!L*POV~vdxdy|(OdT`BR@_BshCzP*3mXC zesf*sOaN#L1qYoV|7wxWbDT<~zKR&$0LpcFYsg39&KjL<;`S6nBL4wS9!;l1Q6|2jOVdK6AFDd-*=Ld3oB8 zcfa7i*HPGP*$Zd|Z#5}gD<4#k5kaTnen4{(8649@9emqNTE@t*ZL^ww}DGds{< zRBTv$8|X7yyJ{ErwamF5QN=B4G40Mn9bslE)ma` zPmYT+?e@c8AP;2bG0NIija(>mg=O-iHHKsg`*phtb&g^aC}7kXRf`e!DfDQ=W#lbZ zX|sP2#Ov-*-wU@ydG@u*y$Mz)8<%yxST9A=>MDLqLNvP`%l1a%+@cypSNjXKXu8i5 zxH9s>tYO-XMJ11#5{u989X#(KnxiYO9kd80 zKm*cSc?AD^`eJNmM&B4Nm0GR#h!_N#I2ef!3~Qnw+d;&h@VNn5(la_3URTNurTuq$ zbfetHY;yA%krZu4EA*N4y7NufhV#vq>0`%>v6Y77SPiiA%k?$j=k9A{>+Uq+MG#8A z+S=Bx9|{9H`R#V?^_dey*_nSfH%CJ z`W?Kt@=(jI4fu}ItuA`Xffs_e-VoxgXxoXz&?~d=ey;-hr))HUfto=14)$~2Pftp` zN9`6D(zhZXI)?f+tMNI~+V`gSs{SVc^q-)f@>6q2?^Ycgpgb4dL;D&6`ja^Mebn1S zu2J|Ab4kcZL7+h8{u{<)oOl-rAfm6NZuX(5?q-(K($TWCLAv{hzd-4%AcPp@;hAp$ zFt<(-vS`2#|MjHUsE0TR=XXTE?GxqGy`A?w>}xlos29`Xbt+`mp{`%n#ec}jU-12R z?`*z6Vocu!Vy|+vFOTDf=*@(|i}(Esy{fCnNWXMvV{38kz-1T8rOuQLU?E||TOw{+ z(vIWh3Bl8$jfa)BwQ_ZJetGfCZLgAR-XeGybB#P&Q+|y}WzHdCK4zFBXzV=bFA-^9 z<4dM52{dWIKU)*><(QdD7fSFX0cPoK>ONTzb1@(Rub`O2B$7Q=D9hJ~4H%5pcZWKjFst_?E?>a7>v;=rNF= zzDL;)+WpqiJTxY=1nW3c@%}ldE?+X|^ZIQaeB8XSR-% zpytRAUlG#=f-D&{}?%O*hFxS9y{UE6zY|&Ri@NFtL9sUF&R-FG-bdzuQO> z&Yl;JB4(aWg&x7S8JfXXr;%vk&TXqUh$6=&*47)GxwlSZ=JqsBg6=|x5^h^q{){@ed;d= ztx9iIu~r^*mD8bMz|?3GT8FNb4c2p`LwkaZY7;vHl;A%$$vPhAQ&jg_$X%kT)8q@I zb`0A3@lSbD8H?+ZLd3zNu&me%#rzsRb6+XNb|r6gy`yrBs!#0*_HZVcBMr8iI37** z>`zA9@iu^bj5WplDeY#JFj^Hn=M>lZj=jL16GMh%o1;OfueHdBAMvmzQ#$3x;h;1bTMATo@8FY>It1Rd z9tI(;b~c-7=gjlyder`~cBqbF_BfBJ*LMU^93&TqA=K#&7{C<;{nZ63TH*CDF20

CQc&~!Gj&X;DJxp$6WY?-UY-eg|JhF$(_U(!z?|u5T0Vn^+hAEF z$YxoeZk8~YW81CTt)V>}X?{M}oL|nf!d@B5!2tonR!eihLgt~adl?nUl3ER#R?-FV zDZH9;FmcCO>7v(+oI#LKSGDaPLp4{o&2JPPF)YJMCTSeZxjIhDSlT>m1(IuS7>}o^ z$uIb3z8G%t0WPTD!6FZF9Ot0?5E&6|>{#fggSD>E0(#R~nGw10oRUueI&UNTS7J-T zsNXB2yjc4s{}`-)Zk2_Ztay(pZm$7AP*v(^+!#!^xmu1BGd+;Gg!Y!{OESyYf7&}e z@?;#&A4DjM2{=U9IstT{KtpvgQxB|y}IG&9L8 zlS3+Oz?NcAc!qyPSO{WpPO61L74ToiWIr0u$9}8_QD3f;?zB8-CC}V==p+Ct4qHf8 z(&1z6uB8+?UaV_jn(Wj)_nw)>3yM{HS*ea548&+MolcUnOy~cJoX-MD4uVq&LX8*K ze?_Y5@oHPqhiECdyz$*!UtVT?^h6|*YwBpC2JmdHsj&k*x^Jo{NZ2w$CQe3hT&7Ei z@3S&&y`o1`kZ1XCl9aP}U5)`=-Y~|*awHjb3~}^Q*&>u46FsG*zq_#$B-e<3Ri<_m zA0y)8o0gJNC{$!=;x#h;v`H&*;W3#|(JI(fQ9U+0Pr?01|KsKyc17l*I?#ALIlBKc5@L&_& z)6vKA=uWpdY-ylAO%*o~?Sl)4D9Po*cR*9es0|a%5+7r04DKHnd0~@2&`{xw8fsdg zvZ5-dbDYs1+l9*vn7#*$`%}|p2@mbECCeGSp{Y&g#&4<(*U^+6ASBjz;ednHU`1&J znkE*2+g=uEe$=5>1-8S>-R|KuqCyZ(T{l|u=wC!Zv(u|bpP88S>nEFhQng4~hC zQVh8NM5e?J$j}Qg7SMQ4Qu6T)>(2XSK=a=@+X}?U+%rYd59TOeH-?e5ThRw1C`~>M zz9A`bO)BE-e;NR+4MQnNjT(Ybshm+-$O5mW1D8-g1%dt4Tu*n*HbtZRcZ>6Khv7KxBE5rspEVDcLrp&d}+0c0ha1Si{EI2(a8Ur^F!vuvl<*&-7`*zVXiAL}NeS2ZpK zp#@C^(;fhO92-yo7nWfYt|Scsl27%7L|Xu2-yO+K+kP92a$EoXesp*Ixaosv zoK5+3ZxHsdl>_*~R%r6ghhebp6;U4$TC`57K756^?%8jZTT^hmJwd4G#m|yax|u)q zrdo9OEL36K-)Xw_VZ=Q<(yZ5+5p6&vCb`zmt_lSuQQb7I&+-K`@9mghW=i|h03gtX zR`EZ<4N)Np&wo8Jm5h>5#z&nw8Y60hFA>Q}j~o(}j`qJ`w#5T>vVU(s(DkP9YRY(_ zuw<@iVFL)?P1++856jFx5NPwR-~XTg!lE8?SqgxGfUpx7MmZh+E9k`_U^W1Ky+(+cT2l|*7z9TDA=E5j# z*WJVYudg+IIjQ-81oB#?A_++X!RuT$SQ^sCw1Tshpg1eSW1-`C_nr)p9PUek6SE&* z*xrM)r$ZP0E{FsezlY_ijrp5Sxn{u0^It;+{}vVBpD>?AInQhnNq>!Mof@D}|NYXC zm+)-d&tx|pZP658r9^WO+V_DcCbA@&P3BJo8KvO@DsXs}4F%y%m%poZx2H(e@DZvA z8n3c3Q+TT8t6m6*o&-;!?O3x@BxCEE3tL2pFuRj%8fpaGj!gn{n=V!63qJLHM{uGDNzi)ECL(;vjBdT_DNUTAS)`*2OmUR#X z%C)Iv9g62iZGL}L)9=1Q9u$`X(D_eM&(sa${uaERw%L!@b z9F@1!`hE&x%w+6wlAg)|vkJenvW`9P9Nu6X!^%)F6v%4oE%o8vtGa{zFG1me0lkXw zPnmW6uU(}3Ppc@n3J>_NEGtXRLLJo%?fqG3*UzD-W_+(H~&mM)xWN)>7D7G>7A+e4hoRLeHI;( zMO|yAD-6h;R%0j><3tdC)1g!oCl?DX9-GX~CUnrM-856~{MqA9YQ#Kra^l?MUg}<0 zUj8Q^TM(-7%X5+Cv(}ND#qH$_x!;2=<&(m6Uz?tWlcKQ%QzuC;XVuIF-c2fi+NApK$P?YwLS~X$<%WaebfY zqr{jPKc`VJF?t-w`4k+#h%$BKr_yJlY;jFLV{$zv-LD3muTl^)ITpT}L{}=7V3E-c zHI)@p<_SSljXyh#Gs3NEZ-4#4BAbhsjc_0IDs7jDa4#)1B0@a7famfVlVrFOH${=- z8g82UHZQk|lV!1iR51@pUKMNbUd-5<@ABd2+oIx{8tRgbpwbIVbJoIYMHMlm5n37^ ze$wQVfDNAV!Z5d3f4Wir_V%SRioSXi1;y`XoUankSZLB?@esDY2ISIN9nv=rxdkSH z;Gc1LG1437erqQ9QjV-Qo+l$dU8XG;12V6g*=@XjLjye6`ouG*Q!&y3T9um@2xTrA zGx;tR%%DdoFZ7I`wI8NweeAPnfa7g15-hXlGAx`!{I6_m=j@`!gGw6xBb{zUxsXv<-2^unl!hVQBL&u>x+`9o%mb86K5~ygRj@RXcbUbs^duWyvpydQ2j? ze*8H^{)nb;mU5j}5aXDq74?{c%+WvQ3Q?V!Rhvvih=G=$w6&XyyiHk=I;C1gY(6$@ zctaa)#lWX?m?Jhvb4q1A4g-P55cE3j`u)qsDk<8&@?VwIU${aq312JJr(ovLlrR>~ zQ%L&~&G5V?Xd|YgR@eHuM}sPw*}!dGhclJHNXM`Tpunh|b^Yd!`1>m*&(=b{)ckH$ zRvz|ltp2W_Ixze@Pdsc&I@@Px5efs&lDq}3a^+-aG~(b$^pWk`1id(oLV8H50{$t? z8?eyIORYj(n6Scp{vN+~<`#FqVj~6&B#4!i&ZVwVKA~~YFd>hymY~NyZ|msoMuzVr z3W*DP-!+^NfrWW~kXCGE;iBQX8LmlVjHzo>pd)e8a8_|tWzcVqZzVcIy)ift@YO+H zR>|9@2*4|!X^1gHxs%bscx?%SsUP*huJIGWAL<{KJh5x{b;&P-bJ0 z3kTb!ic^jHgK@v+a7zcKHH_I}3^uXII#Y#s!*%yo#YbDBQrxJ;W~Phok&|=XY1xI% zJ9MCpiIKh3953jw=a=IH*-$D~b~$)zvv2-Ju2n9do@Ka92=ADXt~=AT@;fi$$8U3D zGmXHlV67@8CBjW%J#Vo)5mEBIGOAe)LSq9Tp*>yv+2me}uuYN{S-ehXSl6=#n zq7(lX&v>A9>D(&iXREfE!=ZL-gn)A0XBXPw8?PI+$_%UX8x)0VKYt$B-@P}71v`Lk z8tjQvb`xqQ@&kXJuYAQ+BgMhLLUzA4Q!!5QnSmC6nfei8Ck~n!?wuY5{OcRIxiJN^QyBj2@_SylJ1qTayT5O z?SzQK!YSqQ;^;I2+_syV!qCsw1Ez)r)yq@dnSgq$VRXujLQ$~u3oaSY;X9E?q{OX3NUF*a-+DB zb1b1W%Q6ec&k4WJ_edQv6V|OEpl~y;zeSTr(AdL2cZ0ufk!Ws$hv$2C4a@D`y=hoQ zmrqBM*bT7i{~qs@W)3Qr@Trwm#PTYD0#_SI`ZNge_nSo$iWz%-4n@mH?k6LORXGi~ zb1;*f#uR*q`spka9jmf|suWJgLG&Cx*-}`rTV*DfQi4>*@hU%uH|5B}0Jwt~?%cO$ z7GhpwXY8}vpas33ilC=Tall&~fP2BdW8ORarh+1TpLwmEf2{^@hiFFDzA5znY|8g$!nM70^#j7vtA)lYkrjlv&c)@z#hbWtW-5E zoLD=x6H}YdC+h=Ex*;~qB%nqAj$zrF5x9y?WB>8RYX8gan=R>j-6HwKyA2})SCaLB z5b%dMQGVH;Zf=&5=hWvk(5lmhz=npOYL|8c0}J!FS#XUDUTaBPrlFXVjKULYg5d#_ z>`2t|Omh?x{^DwCMmOTYCe16ENg<{b{K4BaO@ZiO(>WrLfklT>2a>B|hqP<5AL$xa z>jz_ZHh&=o{ysyhHPz+>72^}_ul+UcZ)B$85fZX=((ykDuu!n~Bedm@^hdkvB(jxt`<))E#lY9Ogrxhm1iN%n`+~SPS-W$SWGinE!lP$@_JI$-);%1g zXH(e|(4=RvXp?cwuZ~n)<37q>}uS=>cIJJ66!T> zO|?zfvnxUJ;P>BNVvLD@JqO@5yU8irqu#BBhS-bS2&Vv;fTj6$VDLK|6*#wuEG7&u zWrTt+f#QsNaC;09I3zlmQKU6WmK*_=Z;{4}gqQOTZ`;U6FHo(X53F{@tQE+s{Ky|PXxaK@lD%mNrUs9&+L&df(| zA2+P;AzTwGip_;kQC}ADF5b8NLwEo-a!s!o%6>fF4GnAw zRnUN#ik^9-;T65w^Bv3NK#{LB8-{s4dI}qy_dZ&|ZrDzM^?HU#RnH&Xd-4V?o$n(J zYZvw^yX|i@Rk(Oc2^zZJ48Jc!fH&D{v*ndvYs4TtfUVdln{68<${l5u+|M}UhAc7qxyw9Y2x%!wse#oXjYbOgZ!)?;b+Szu^dQ>6Sbszs(UPjmbrpp#Fx z1$18JI_UUWj}LnPvOEXoK665H4r-`Aop4>duUk~Dw%(s!HlQpk`H&P;F;;BzYfjkl zN9LS!j6|H|Crhp~&Ra3IFUsrtNATz4gJSG#3bI}RP*jY297M*itEe#jNl z@3Je+;#Mo9OlsEED6Mf%X2FD8BVX+Xll%f0bfH)b#rM{7hp7|A^7y|#pWzcxH(7&$ zf|`M(cVmNmLSyRycDBI*gACxoc5@h@_&95Id@;qg$oA`_DBNTfPm zy!H)MSH(}$`tNzWp!{D_Kg|&@lpJ={TYhdG#p44PCy|$yW0_OlQFVX) z;wF0YIorl8Z*A9?v#{Dfz5Ay%Vbwb@@&_A_VIQwjZS=Too*mkc;J!eZ5o2q*nX-rQ(FE%xmdFyZENs}`iAbYM`IW5eg0f|CS zkI9`7rzJa=MZj{T>Ez(rs=~sUn|h*{tVh2*_?Yle+Vz*(kA%vq3eJ-}xsqZv+A9mw z^%BG^%A82?=dySVx73CRF65v^jQo$SRCq3Kqn$+rw`#@4<^`uR@RJU8S~=o*&I31Y zcyyA1M@r)O7e>tk!K%4NrN>jO%UQvWQ;omcL!Hg!>n(5+%F@PXM8Yh(@v=hP8Qf_@ z>GY=AJ%D6hn}YZn^Rt+(_}83-GA%Z~_cy1hC5+p@_$+cXer_Vxy4QlDttXMbD-~o< zyVz&^o<%>U;*sZ)A%$}vHX71TI9QlDK)owO7``s&0#gplH1e>$-5M-OZ`qnO{BRk>Bm2o)d093HJgz8h`0n0j*jW*Gdl3$bPy&q%AE=RlRq`4K0C<%b& zWqo73ap|LGu4P;q*`okDisSb=APjtY9BqO?r1&vBYjp5pixot2yHIa7YVYmN;AWHB zEZ4QP$q<&lHkOR#*CHIoy^P#{HC|M?Dei`K8AjLh(wiI>;aZ3@kT|M~SmXhSDCT_abxhRXL6_|r(R*AVA?#aXERtR}PfCF1 zkv}_i0S}x}m)illU=I!;TI{u?_VX&CG#nrLYa!malM_fqtYiN+bXxQ?e*y%dR%|+m zuoLIV3THH>yxE`-lSK3l)z2ynEA&c;zW;N9PpMm&=f#|*mX@#+1g-YQq!r6BXicA$%Fm1aa*+R65_HTw{&ii5e!Bi)DD;M4u7x#S| z_k8EnKB|{dVd}w0pYZD8DpZdfnE~}2FW@Rb>c>IM%OPAv^<{*%-9Jd0#k#aRL)NVg zCO0CP*%yn~e;5q5mz{0aD+{{xnYJ;viYP48WHbeCrlT%XY_wE4W(+RB>bPSSB(7S? zS#M`v4u`2aX+>RT+JN6YX-6fDJr?K2W{X$O%x37e1>Wd8}PaWddXx&uDMa+=ABhTBtI$UT2dNA3o4ZUz1t9|yN zUBONc?(4Nv-#Kf*)dH`(Gv!UA$3lrbEojbt`po*=w1gMI)KP7^cP>9hoq1%cLO*3! zRNg*=cbHbunsq|OpITN>ikHi;P;iR!mc^wn7jMgGdZetsl!u2iRi=7bS!vo0`$}D=nz1r&-E1jr zRqn&HW?RYDO^ASn3^uI6P!10*pff1DtxiNZu@12TGd@|>t)nqhJxuGns%PZ%_6x63 zq1tOl^Iy3PUX=y(U}2LW1e+Z)v5lR`NSQDCO$z~Dsb{(CCm#o+4H7LS&+3(9h!EAj zrSt4e(c}RmwavhI3xc($`91s5eli6SixZ=zb@VB``*RG9v&Gw1vC?l~+-*Q1gl0!E zlJPP)TJ5oHXd}W4-^sSk_XpHj;LcE{Oe_NqlZ5Ww$KFRUM95Cn%*neA?E?&T8#8s* zJ6-Z6{kv^iqSLM1+FMwwlG(JAKC2Bczu!6`XP}weDIjloCC6*N@03^UputFw_})}Y z@Ko%3L$$?;+JLldG)Mj#(j_TK>>BG!P?@W+;7nz(iZhIJmcWu6MbTw!5YxunFNd+l zErB1cBXPSNl#j8H^}1#-Yup>frL{!iSQ-!fZmV`OyNtW5a=Hc8#vKwA5UM>A+1Zix zdbmUj)GH+fN~Fd|Lm7aaIU=2^^;(@=$GJfUIyq}%qa2<{EBVdsRfz9E72C+jEA7fa zo3BH_Rytui>RcL&OTyNQHF(!zVO_3zTJOR&iObJH8LI^{N%(_Sv1qJ1I~fS4BXG5@ ztE9h$Q9(2W$bt;sl%YZDM#(+iC@n zbyW3MwsYn9CD#4q5!0=9=RgnZG!-*;*z!b<#H!?E8gR$G>$3BPRNMc12~7FNULe};g=IDYF!qN zu#*^+eTURDse>MuA^oF+-Rs`tWo4N1^+Yuc+qxWdh9A{bI`i42hLq%!P8FssLmOy* zgbk5zc`)+AE1OH}Fe?)g$Y57_UVlFk#|w{2-hO?85%5k%F#z~*Y01U=+xy-{% zm~(*lK0(#gjuVKO0Gs^Ps{1L{8Y{c#uv(X;{2KwkQEz(g$ZOwVw8+8dsXm+v`0|A9 zg9wAXyOO1ts{0|Iy3pzYY=ukj-LuFY;!UO7L`vwlzFvgWX`{_S9}vQ^Uqh6MF zhJ4e0nM1Pdfa|EOlLx%mC{LIsOTqyK6ksI1j;u~I&wUFDvQK66h1=ksS<>D)6xgQ5 zrdfq%$(FEN<{ow#!D-r-CP+tGY{@%ZuA<@p45Km2u^U~#AB}AMEF7hyb_zURc6?5$4U%7kb|2{&WxWI80Z)>}n~mFJ)<)KjevsmS%sXl)G3 zVidR2I~@8;KK)*K;pv#f$V9hagd}id3xQ%wUTk^pu&*N zFDZO@Crx(P=X@bJjXGWZAl{m2TlaQcIxvOE}7b%o%uIo&_n#&)$?rn$mRj> zBI>9Q;HD@Sl@pFE6f^rJrMPf1Qv@;<0dE`F#}l6QeI01hFv)TqfGsyGDKEMynt`eL zp&{fP4b#;~<)|o{LnUm&v{o8Kz;>iGY$5G5ow;tzzlO1_OxowA=rm@8qm6&sIQ!-e zqIXr3y5^Naa(s9gE&VSQg(Iop->UcUPv;-2Q7si<9urpEki-3zK01~{|CRWik{_ix z=Xf}@Kk2M{tm1a6AdiXAkbf@!%vchGk5OMCm1e-eNA4_v^ijh9MDr*~reQqR(96Jj)VXG(JW64CmXD=Z1(1B?f8wi_ zEGb6&E1frk;r~hz-*_KO2YPlMkEpJ17aHYH4c5@?{XNJ_#%;*p@&Pf>itPd?s`reZ zJ=^&xASN#Nm4Z<*Vx26rOOe1gxhBE!aZMAl7~tD3&Y-)Wd`huobHxh+rA!=AD@$G% z$}*=W+M7oqQjRq5q8R;7&@v^B`o+%OKeW{!>qRVoOUJp}yjfBQ`aC>8C0q3LG|+PE5W%p{|Y1_%^oM#H|%We#Ja6Y*>2gr`>yfkVuJ@!`p? z7D!{D{8?_$<#?)8Zb{+LvSuO+Rc=5w1ykCKBCTwbRz*-xEVM@LipZ94MX*`3NRwWM z+#8XpFw;yfkA&ZTo1d3uSu#x0RR>lTX~QrF`>u-@lHSBfx;Eljs*Ky`IBX$m% zU@%LtMbjcJ6n1D!ZG7Pm7wvu9OVD6cfptXQbOy7mL zqK%mI*6x@7B@2FIP@%C{mNRr58D;aBD+>7P`Euko_zKT6o!&cTiD~uZ^3aA~SEhWM zxyj$9diSR9J!{JN?z8R*rsbdD-5a(y{V#dit&8YgNPDdhnSXqc-e3CS&k)SWvPPG# zAW2%H5fuH_!oi>^OH|d)dY~XwTk4Fd-ku?+CC3#oa$$Xw2$J&d`UWK%K3X9mJB)N5 zlAUt)+JvYxvArRUG`M-*qE%u6(fS?t;`gg7vCHkA1s)pg!EIsu1*F`(t9a)Q?PPAH z*QbTv%)&C6+s)xte#!yB7UEQ{ZA}Q6lb9)fkVJBJy@J}G0ZO#1LU6B>uHrsToy5Y zSh%1X+)Ew9RT#2Vu=blUUd85`BEfDUDSWa-dI1>q9DZB(AXPu~OzomqIQgvX3MsQu zKDy{KFrT@cy>Cz~de|f5pJ!J}e=A9jm%O7!k8JE4eFv&3flI6MEQ95O=h!hV79z-R z0beGzcZIK3CAzs(nBVJLDS+MYn({FSfANToo)3M(3Ux4%JF*h;7S{U+_GG$OuL_hQ ztdF5;;7t0d?1gvhFgkG`XtjOtsXZ(KYh6D9BA1XVdcBJ+Ek z8Wd%HIz!MxbnBbG`NNxvgP3-@N;=z$tD(=fo`iX(X8dE`i5Pr0a^}>^xk1`8i@iHk z2I`CPv8e_2hBJDHFUE7=?kL+7dnaH%P->RnREf`PWl0_sRbZp+h@FOM9+xT|Bw;NT z)Ao?bb4Jb&Ed=csc+;I`!Yz195@~%K0nOmmMLh$#ix*}tbKH;iAFc(_AIm6M<~uHE z!{kOX%QBsdia2-v#EtAALgGS%pTH`^9Wl(IEe^YJQ;4@!^SLFgla{z-Co^!7oClW| zlqEA)@b4n=$&SOiLt-bu$TVX;c9g%CW_9X}e&({5 zU31w4zhH?ky&`MPQ&^rbMfE=g5pMIM{>lfbpzy z!tw^jV9E9d7|{ZHSP9|ZD>=Ys_E1oOp~oVO9iX8Uq@e+rF#rE*5Rh>IvY|r#5c;$K zkF_EGRQtEhht(kAo5#o=`e-n49Eb}80c;&iAuq~2^$V662l7%p z78=+Y7@8UX5A!dp5CM`JO>dctL{|6$rq$<4Av_ zL7D&pYM{aG3q*AP9n3$~{_OuO=rB0P{>R`$=4!hsYydX?L)kt)I=FTU1L05ELyltb z*c28Z>eXW*FIZsu?@>L;Hv7a21MveKPKX0ed4!+jZ+Zd~Fg(EP(*zG~^&}nA6A;Mw z2ZVpjjs#X*#Qxj3|CuJ{Nd-}s2g^J&_z&QdZ;hUSG$Ig?3Y;?Y_rSjW=jS0$z(%nL ziwMHl;LAt&UoUt;X4eIuz+6g@vyB=oGfV#9{>hs}Pe4u;2*?O-o&D?n$=}6Kz(}nJ z_s=w5fh8Z^|M$fHKYXq)r@;gKcZ#3rA%uTT_+ddoG5$kB_PM@h#*Z)-cxCSKT>Lo) z1X$VrxjMiCmZaeOjYqxCJP`2J;Zgq_oH5V*V4NbFFi;tC^_oIH=X(9b_>Kz%riDzw zJaz(a7Jz^xw+CI&!r$K}xUK281RUgs6Y>{1`;*EX9uQFY!NZfg(kIZc4|r^a1+21& z@%J*aTm%9peIIm8OK{*8NVcp$r!(q>LqZiKJZ8wcH$qPgdb)o#XH}^&yo-AYuMz9|LLWhzAfalmg7R{Mbm+%Rs>M=m-6NI00C9{qJw9k{xmT z1!ANdvigeDlL*+79$?5c1(<&2(Fp$v5TKX>(Q|>LR!ASB=<*j2=!Y24hZqohV!$OG z0xCa1Icszo)sUZp1aiYG{shX+daxFehW00PSxrjZR*<9UbyQ?UI^NI}=Z-2>f15rUX! z@{oNZ!j^OQ^S11%_9E#t-Cb6Bu-bhK{a2HJIl1f0%O3Zos?|bNQYjm_);ZNxME}l( z7EvXwB#Ojv8gp?sCgYi&b_dlYnz0_6@x z|HnQ4CqC@|+XEtl5VYUry#=oXPj&mqQw9pG%6l|AFf{r-hYq3hos==lZ~Sz zYG2;2X&?84@pZ1QNcz*w4sBq?LI+=`V?i{lK$PlQE#;rc(}{UB{ElLNg7#t?r?4oC zqFZ1GUsoKnzS&d&pEMMfv9^+YKMzka-?YsxWC|fd=Plhh=-A#joX4D=qMM#f+35sL zUD>t<$PENjjd@rZ*dYY*gc76)J0OSr;ix{$jm=0Kw$~ZRtgFNn6NN>A z7Q_T7+a)O;bfk{3A|8`)($X|gX8Kd1+(|-;ImAw!9=+clrD0|X`}-z6Y6ZO$ls}?# z7RQ)MtPg$CNMC{(Rz=Q%N@}+lK9bmZyipzyM4Tu$#Uxdr5WwncDwmT_>q6cY>7RRwenDJkJbiIpT}&i+H!t$PU~359=YYu!9Z=dvhdw{ zY~!6odKygJ6LRKo5jB`)mu)#|s=Q8r`f!vt=2_=n*dG9;*~%*6+E~Y8wS_0i_K<8))T>pgP8;Pj~~CY{J`8q=ZSL|I)re^T8EyYX?K+cn#9wN;b|A7{2$5028W zqwcd8GFPl8m#rEs;#PrJmE-2LS2#T)%7xF!w8)CExp4^)*sd0`+LIM${8{cv;L6b~ zNFfbx-5?SCr#^~Pt(9oEI|3F%brS_3%7|e`SLO-lP~rLGnguUU6v%PfivAdp!l2_5 zPY~khH{nzjn9_V6w199-vpsN0bgjDJ8c$Qb@4Fd)8xVo$l#;=rA`~?=^af-C4 z3D41oCHJgX;?vI3t$vHpOV}n^j-oUD|8JY7W=p1-?wh%g-G+dqF1nubK>LjlamP6sq_QRU@>2c{Peh zsCdUz?-6it^}Wf4&y&;KlCkRnf9=OS50u=dTm(A~UppJ0syX-?uaG>Fn&r+ITFS}_ zapa4T&zL*JEUe0}j`Anm+Q%}YBWUs1m-TG=mkYrn)*=kx6w-4X! zn`4L|&xx!{?z2tQd<2T#ht$O?qHDut>Am4Ipbrx-l)662Ls0EV1h5AH<=3C|pT$$n zY1-&G2)9EVeda53vixOsSDu+M`Z~p3yPJh@zV+O4mx0wVDwsvfkz(wpSI|89eUvH} zKilM7Dco-L&uoiC#uKg78mK$VukcTE9%6X=m|&<` z>BFLp^QU8{*jGAG9g;u*g48?~Ob|?=rK%0osi+`7HWZVTdSjYfT$UV5je{XJF2yxz zBJj&U5e`8extb(FFF;q^6&p9S5S_}YEJEIix>&u=iwbXpMM-=FmZxU8d0Uc>6KSJ4 zs=A$uAjSXor&G7Sw>+}lI%2}8e&uCyO{xEVrhA@nz6$Xic$^*GOJj$m*Zv&Tt71M0^ ziDO`;!ZJ{00U_Q#l?+8%As+KL^0LbZt$5U|i|*{-*h^ST0e0paLo!$0^JMq$s4noW z`MEsD%!Fp%=8_1rE9u@87ybJEBIyNGK5YafbNC zuTEeIu;-Zh0LngI6wTX>U3N3JQrxqf(ecX^jtBUx>Bqe%gzSKPYb@q)k^Y-AIng?O#^cV0C#ttOyod44e%|r8L$HDeY}YT;ars@Ggg4= zr%-bR$$4pVaOWRLIu=iWnlAg?lata>fa|W|qVTY*{I@99fMt{NhTnU;{&qQfxfxt6 z9$nve(hl9?#Rg-G3`R13=>*!D}SXIelixk)^@oQ+)MPqj0p;i(jm(jSa%Oc$ebuBvM;LZl4KiU?T>Ics(`1l zhcg_o%4#{N$P1*@oS|mHKQM^*0e0MBmt~3{qs~iW`2k=vgad7pOqU$9)H%Sf@i?=4 zDIH0xv-{<>fvv$Cs#a1~jwZi9ApTb|0}_(Fj9?%j8xSBMD*qfc1JGuj3Q(n@r-&+y z#=nqkzlBj*(Y*hIh{&GSy{vR@F*ObaHKCl0Dtyn%a>RYgy(LY7`cvbLL<|++AFlY~ z9p%xCj%x`fzZ%-*amD|<$?9U^_x1V&-b<66E@eC{2FnU%j+)Bqgn17`M^;<9$D1yW5y{jq48rq;utr~1BZvDoWc!I#81#+pg3Znk%2BU@} zXyMSi-=jUDC9GEqlhA8KcI$vea~q%7oD zm540i#Cvlb6hX0)zo^N3&WpwbNR}?MlH4A$x*Ko=Dx0aZdp3TyI>s$WiZ0eg9sVqC z~+~_&u8Gx1icN|GfdZi}CxkMCxMgn9;D_sDa6q$yKvsD+E01Qjb+Ms4N zm26z4zVJ>E{H|t}MC6A26i1$G0ePUZI*Ka-H6{W0k77ELNG%8wKmqn(9~?zN=yWM@ zMWNP&Z=uB97~b*c5Y_)8p{j4P{EUBzkp00VNVp)ctg##RrtnpKS3taOo0BXAOeL5V zpv1+tG%jE_d-D&VxZE17s{QL8*7L{4l>RPZbdN@E6WZwo?tf)fnY7yyj_^-bI3OTQ z|71lEU@);Ya&bx0f-yu}@%qYcT*r=v!iR&VN79@mch%n1hvq;*8C?!&l2RQ;z^{U` zx?GwxcgM&pv`b%}zAUucB(=90u|h?8?w9V&ABK@WFr>7bf0xV1K8s)Oifxn^>3Mc< zTu;In=Q) zfbs+HDcfsd`)CfBdcg^gCmYDE-jrI~A&_aDd0BBOW%lBpg z@QwR30vgtGXY$cOW=U{#?ch#kXKT4roP@+jVI=|Gm2|k-Fn(w z+4mN9BZ}noJC6{P!XtHE-Hl08>skSC3nm4WBX6kT_r4{=l2@omf52?sbSW=%Vg!wf zT-=-BlZ5oHUwVbUS6>Hr!9SOJuOtGXXo1qQL)0tSb;q^=qqCyR;uXAh+yK@sm>pSe zR!J#3qm0@vIzq6$0&2=5Le$l*c5QQZvzZ{F(wVH{=#acbli0)KV%zH|_9S)nt-_@2 z+RntxAA@m%8T(MYA-WF58{?W|S{>fg?UuY-_XPO$U00}2khCdJimmqw>rKUWvEB9x z?bE@Fa?=eOP>No9TQvAuK)_Aa;lO}81yfTVRbzrd&d)?RTZE^xRlnz#Rm0km#0~y9 znGI_|Iy?X6npRqpvpN)Defo`>a#q`bf!6TBKxQ4gO=@qLJmXJ{gLh1ld2NX^Cd2Ba z-%^|Yx|6euN%KP)@j)BwylGAba8mBO%T#7=_$@zLm=buO2DOo104THOJb`1w)R1)X zTXUY4t+@e&9U_s6715iys;8My7OfnX&Y0Oe&ai-AgEz z=Xk)EY|K=~lJ>S$n1?H-#w>Bi_A|W_mVacyRZ}cCNETOC`Z@x7fU1x!6(Ye`WvZvq ztjz{UcOiCwWwRhoK=O^(Q!pEXJLdAJ!+L~QxCX6U*Bu8=*6%P87Lf#Z!^Ml1PFES{ zD#kq;j9!$3Jd|O_yiToBauisw5LmaGaC4GaA=C}3G+CW)euBY2rS&Am=pNIJC4p2t zu+R_iO*0(?E$GxL<-h1^tDEu({$yzdL5s4;txh)%R<-w&0W__(^|d9?ICVhsv^jNT z_^!w;%INlvI}7P?Lm(T=A3F*~FlOodj5VjHF(?Mq$C;U<8)4v7C=#4KH5Kqj&vPC> z-0kT4zL!eGdAQaidp%B)lJPpNM zK@-JXbXO>zhktMD;``!(b+>dA9Pa0nX$#E3l6B5P5p9@ujON^RiNGcxAA#{iD(d~# zDvHtw6`BepMuvjf8k`FE*gQIKR&%)6FPe;fKjXIiF0mBq{rphuWC}gT$6^pL&dR^# z+qyJWfOJ7!$2l~~L1onIk%MB-uFZL7rxxlf^1YbZ)4b)Lrj9X=wAADJ`MT@bL?Fx{p zFO2;?%$eXEEAyDLbc!wQn=AaApmxSblSMk^c^kHP8|s#`)=1BVFqWzwTV-AHWJisjbwxuwAuPc;`xTaKGQC!-7&i7 z#_kZE-53HlLCx*a2;9c_rca?TVFqseiI>C}rmotoNU*J%p@6_r-|(VjHI3;XtH;iQ z$&!!3rJM{|ITI9*8MN_^0X3EFQtxp4Ih{qP}4fa&U5 ztj$@|bdmdHN(cOT`Ox3I21`rK{+1F#&ymn&3)SV$?xJgE(#WxBU^>fCb4#|OvODZe z^^IU|ygh$ZWT6hHQ?81iRpYo@WXxwS?K|jOv`spHO^ZJpLA_MNI`L}|FD6}$uo!m1 zb$^uGRX2*ho-Me)$4=c%I@n)!0Q9QK2I&ld1DLuF({~!Sc_M{0w#2*r9D}nz0@H{W+N%z@ zgSaa8dTttI#^6Vyp=;(rMVVi-A_G|smu+5CH&RHzLq-)3wWeJ(6~i( z=nhy@cAjW*L%yVWz%A_wS(mPZKA<@-oU%4+&_CmY!hbfT|DA;2K!mxPrqXFlpTsME zG$!;K6Xu0(V{a&1sL!8~RF_g%7b1OCT{o#2qyrB1!WWJKZ_GO^1Ap~zdzK}JiJhJV zg`co^#d~M@1|l+ZhdpL;30P}>iV?5WX`X|Br7dchWg3&u5+!X|oXk}Fxr@682|C$d zQr6oXgJ&S3%Ok!&M9x^gBXWc+gl9iv@+oCOFmRT}UoADan1X(2ltupcye1`QEk@=FLfqzCY)-YgMrLkKmlG@q;3E+Ke?q};$Lz4r~j##U4 z>=gbkl^gnjn7|Q6>WR8N$s!O@GWzaI*V$EBem$aNDj7K-3pvt~yZfR})rwPxDCpnf zjOmt-Di}s+ywnti<(syzuNjm7)5c+b5CbfLwE3NG=T4C zvm3)cQjQm%c?ZM62*w*I1=*x2mYgX5_VE1g9~=i;L4f_|QV~m9P1=2_&M;D^4<;3< z>pDWgel&Gju`=-`PUR7NHVn?20@Hm915kxv#R8OfLYs+$YQFse{CH9?yy(vEHx;hr zku6gEc<;jx&#?Qkb18?wLC;bZ$1cWLR20vAcHO@jmG-d@C(J@2s5yOOw263$3D3#0 z5~BGi9soX9glBn)5VCv(gA|xytIZk9*fL`Q^g&BTS$spoTUOh8%DQl~onS;30Y%`u z#h5Sl!3&kiBYcrxz}yEpddm;&a17^9EYRF^l#N?dAGrAWz?{J!sY6=B?LywPc64er(7R_n-4AGR?VEdaoVnM=b%F3% zCBPw@;>OMJPv4qTI5W4GM72l8d=a zylJp-J3iGG-ots9SsdM>2CatNgX&LC(ca8l4dz_X466Y=!rpI8eRJEM+$Sz|N4ixL zgoaP$q&yzETG1nd3{Cl&QvUIU?~_-IeDP#`^)QGIy~%sVJ9@e3cP(ZW+X$ME`nv;I z0;T6rn$hpZ^q`Mes>l29|Bd9}^i*7H|79x<{yo(HA~}2@_XZ+BJX#+1U%nyOpt1S! z2O6J09A~=|2E$f45p-bwdmTbk(R5HuY_E4xk z#7DIv?U0~t!?e*zv^GTh0$2t}sEc5k#R%!6t3y zWu?{fGf(I*4*zSE*33mW0tyJoA2JXSs((h|0b@5{fHxaZfFeyeAJwBIK}uGj_sQ|G zFi~%5uYayIw3v7xd>9l85eG~>l8D%xv@|>J-^Ais;bJaPaB0L_P0yo4+rvh$qQjj~VD!EL*#FikdOms&V3TBjixZf) zgo?J3b5%8iqCb&7P+Bdkhl|Wa45^eVu>NZoIqe36?zpxG%gd=QCKwDD}x7hb!uk+5@Tz zXze*GSBMM*+?%Ns(J>_JCymRZ>6g!0|JG^MkadZu%%ou}DeIKmTR_*Zc8(sWHGPDS zUcQyF^1-RuU!ut=yTJ*bNtj#1VRx#Mi0)M1bHmA^wZ&~yIQk9m*)@rmv<(%^Y26r& zYl{5`;DYuQCGqT1FfPwT&sotaeT2akFynS_Zl8o|tK259x?1koA<@+-pB@7y5ZfZ_ z(%p|~iFT+`NR8f)FXEWjk4gP^Wi$aH#j#{qZ?medkAL1aZV!q$2&YRfyZ!C4$u3%l zq0+{3tG><1ZX-EFehRaB(SB`Ib=|WLkkZ2gI7NI^Z;_}HD)m5D+2dhF3x5-xtNJpW zRBDTrzU25JBD}CO)mS>$_`BlM2%wRpymh@}7F7O&4!~urx#T8IGJwKh1Zb?`Kw*C4 z{Sz{zD)88yEGJ_-Wq=P2nQxP-Enuz^QfqRgTbDG}HvN|)H3Ao$xPW_k$4XP@LlaE} zkgE5!tKNei=j1$(eF-O)ilIQCCoG39cUtA96(VT82uY$`+#n$F{4|K^eg*R|Ob1{y z3{h7j^Fd~+SoskMwMzZjA>s_e6!R210~chLT}G8MJ%{h_3)jKY#;gXAxviDvL~8-d zV#aRK>T4{GL$0#l*aS%cD`l%)gU$#Cm;oGn1<}f6N1%+89|lczpc6b;$JEh|0*EG$D1#HI&;xy!LQ|Ht=p}1K{Mp=I5&Y?#} zw9|(y5r&D0QF~ISWRNK#rTxK+7VDV8+V7+j?f<=S{w!JG&T=TdKdEqSfO~PqOjqFD z5I-2&=}5WYg#EH$oTev1R?mR}fTp10nq>1O38=)fYI~AdkJEJ7$g7|G`y<-^c_r=h z^9u>D1~=JETYh)%pZm4xZH)IL&E0zP=S8wY3__w++EUgJu$<;3o$@m}y5a~7Ic#PR z*AglfGuF$;PZafZ0pDC(3I%FH@v-^7i)E^va>`X}T6%ztWTp%_<*(fXcwVWbVDZML4a z7u}UZe)B&(s*J*a%+u_Nhe9&*pxH5(KeWyf+heNc(Y1j!$geG$C5(frGM_wWN!U#u zUMT7pF5$- z^WiqgyFbA`zXEMNv@X9-@=2ODIIPIirsyWIEkEjA{UHCXd}4D75D%_N0yh|8&Vp<)0# z&*XP-xqwx!M5O!UWwjLGerIs_-7S+%4lMoDb z*dXg3s1K34laQwae8l+04idJ!A8S(KoN~@{PrCMz{owObJ~VY`u@dVfW<4L$!wh!l z`kI|>oh{ma>vQZkLt6YJ_Js52tJ>0W)Y}>gU6+NyN9ANFb@{c!r((M0_L7HR#3}3f z9$)T6u}I?AZwO;K2SD*psW_8m<2TQUMeSsO)UMVE?<+$V;2LA&=RH497g4t|4|tyS zX6NW~*)Ge4Qn*w|O2^xq{BE|%(A^QwPUNcpKu^iNuMfy<$^G+D;|EP~3*HA1Wb z$Tq>kU7r&xG>@l-qZ-BkW(!wZEqR{g>FVwk3(}IbbfS35gwaKw~?Gr+{vCj|GVpM1T zBro#9e#-D4X|nr;B>`hRf&(*PscwETITqSCV`hxwS&Nxuu$>;m-%YkA+IM9#>YEsA zLkJNsx8WhBx^l%y=nB}(DxLf-G1(l%ZS}f|PAg`^MpOgctP~yLm%qR`J)LThrv&V! zy~OPU09k26qVc5xTd%93I-zHUcj0PcL#Bva}hnCy`5q4_eN0-Xk`Q?AFCf zrV_7(BFFM)6%q|C8ejw1(2uE1d#3qDh#HH7!90Di(G~SILlWGIr5jkAi>#20x|vr} zm8=PiEtQ={zk+4K;@2~uWt6RH9<{m8R*h4v04F7YtxrLH)*|ja6OBBpj%dl+AWb`q zLHOZ(iMyk)vdGAL<+V-o|ZCfF%k_7s_J|>RC>~>Fa{$*hahn)ivach*xKTzj++NZ zj6(_2J3&m#1KFqC`$#(icJlsR1ozZwPDta4>8VKs1rW9C%V|SYYawyclAhNapfyZT z>LGb8jHD!7_Y|UjZbd)YI6s!uKL@n{iYsU>C3=gIFs!442QXrY89&$3Y!`}x=yg#@ zUr~Zopgu5eT7~BOS&(A_v&gYiA`i(<@7A>!deY43!blLw=?L2CXkU`5rv4n+8LyEOFt>dyrt`-gvh56>CO^rQ-Mlm0 z?t#2LWb`T=tJ#}`3h~qCjK>E+JnRHMh=Fn|8F_GMOEV=XCUc)qQsyh2x#+vdB6Agk zJTC*cUuYr|tFlK-Qy!t>lqut*fcTZ95UFC7S^S<^z*a!oCTuA?G3%Kbu1Ct&07GKF z#5Ffv?WFeQk9X?j^Gc080^{bF856qzVb|ZH}Gq{CVaL z%qS8x5Mz*%=AAovYCUMI5~>t(* zlCwArCn0V8HR>BSqXT@Xa6V%lB@}bzx-4yv$H>jC$4i!Ze7q~N!z7(nJEd_SQX#UD!KQ9y4-bc z593s#d@qZ9FU{~s=;Qo_cwL~st?29H&ma-JGt)x`G$@vR!H-y1{zM;qcGi|LkbvbT zHpAA7<>vI9D#4vyAP-Stj@{Ncvk7y->}tSyfah|yS0<2V`s&Bijeu>K5r>Fcse+i#>?bFX>L9C zN$f`Lnj+#6+xN>pI0U_&lDV&PwhPu5vFru32_OYGt8v<0P)Ost>#O|=YDa(9AGQx$ z{GRs!{$NNVf5!PjLt>byPU=3LsGA-+J76JypFnAy8G{4RNUNA^%juLI*DZOyBTtxF zkBoahBrI;YFa4CkM2!8cv)){Au?rC`1j~&uN^=&PrxuDxI?aK^LaERQY|bp66V4Ra z5io#Nv$l)eod)aDBx5v-Kb*u*MUKQ%jA3SbZ6-c!h2HH}?GHPCIxpxzpsDrl@G{dOw9a7o6jTf)_rv@GaV z&cyLyh^19H`CH&s#`i8q@;Jh3le$ek39)i>zH%MY zXIhK_;jA_CI}X7XAnP`SZI`ulWP652O(&F*6;ZAG+p;J^J1#qiD>@{`(z zqkeCTz5;#jc;Ul2jy%=BDt>=q;psIH(v}A3J`)+#6mhc!YOeI&I`agnl%w^v5fmv0 z?Xu_##m*gs0SE~d6=#tR$GlPj3E2tWDbIy<=7^uO(?Mr=#e{h&p$);OBOJ>_;GP&$ zzefDS&d_>ywqQTS@=C&oPsQdb7^ohiL}q9n@U-&_*j9#tS~*g%L0-*<;OWsXf=~d~ z^PF1Zt}$+?p{26Y@ad@|T{iYAy$RDhH}iRvDz#HDGl64+Tuk7S0-=Q03xUSDpjZ~7 zvPNb*E@lc275&{6S<1ctfxn(;G^PL|F&E+R;{)_m2<}iBD=J<>%$$?a$6|F0M2PBs z0h>J&G^=%2`rVQTcS38!6| zP!MV<%$SNs5HRT5e4<~jgX8dGV2MecOIztP@_Q<7vMmvJytu}!0j>!Oi z%DEc5xKI|WC_SSc+i-BSgagsKR|l_YZ^Qn(3a9#@2BJ=gfM&bI-@F*HN(KOu0q`l= zp9d`B5|t7bC5x1O5FAg}MOx0SG}u9oom^=kjRq%^US>Gx1Qh+!ww(~ER&J(q(MqO4 z`5gKRF7qZdaSR5tjLXU@j;u+Zs)^WURD>P~v7h9)v_B~N#slao7aRU%mV~O1aA8O4 zoO=sS43BonG`UlQlf>6Fxv2oQk#%{Vc(gzG#U(=of6M&kaz#RNBDCKR1+~!tam<$X z1Aw-4%GJ!;U zy%w;$&BB2}c@O$cpw&T~A{i@=u+bTLGd;wqzv$z~kpB-D>(p1vu{HRF9HwVv0fl)l@uVlMweC(HE56(wOvQr7=^UVd{8XXZ{ zk@mwHq|#iR)zn|S|9h}Bi2J>Q^RJwy3LGdbN(WF;R$Nd*`?}&-u68x~847!zdAeHs z3;hUk{|^Le0zwok>E6)hk`1-{W#@&&2lW>`lkfq!pg*A*UrPnN+hB^z)$8=xbJlwk z|NH9!S}&|Rg4}^S6qF41rtn&?9^H9s$zFF%gz#)a0F5=yISv7n<>eG7qlb0|ylpIT z*A?K+{w0uDtEvh67jB<-AJc-PZyo=sdyvlrF9C6|grQ5#R8hq_mR#_=eNNscbfL*D zLCbUS(vj$%PH4jOZxQY2UZ)`40_Bx&Bqp?qXmEkU)`pvEcT*|zfbt&cZxvb z4cNBNx-st_am2O<><71vNDWTyKB4vfqzb_L0_m99kSR$hHY!Cu4newSkQqX9_(-Zs z#{_8f3WHu(S^1Xo+#!Q>`qb0YRmZ9Ts^X36Kt#BO=d{vWEF}Ev?Up;wkN%(E{@OY3 zd8Y};ef~H@@yPauT@;uicOo|oUd+6p#hmLZNs_q5_{gw;QKhuQdoquEfC)snA~@jc zu?0^s&iK#s5P6LqqFJc}qG75A#R9ds#a*UxHccc;0iW78l)G3cM75HfE`GWdEEtl$jw6&L_PI3qQp|ogJ493Mnbi{1q(ois%F8=M$UHq&&bI>m%Xv;I!MHw~I2a^oTxp zytR|7*gjzEuC{%jw_2{geLbEJZY>CWuzJ<&7J|()osC$x88SRZkF)B%QUU=B3}^?5 zsMpD#-lq5ZnA@Sx9XFspN_Re^!4-}Yep?zM>z@pK{)n_MVSz!YK!!vUnLf#*k3S4_ zeT{JTK5~7c40J#q!rlSc>GoQb5;VU3ersvn@YsnO#nEG+^9wa(j`~e0YHV9AXpYlf zgQu>auL4I-$`oeiOFpWB^B!R0B?3?7OhfMlr~9g(^F|)CJJ_M)2H!`c?-|W!CwSrp z9Mdn1ko(r8?U+*GL$z<_@MPxb5Y_n(^Vck@!pASzx1>M=-dkME^_!r;9hn-%v11Q~ zP4ah2^pEXu!PecB$nP*g>X!yM{+GzW9-doH>W6EE57FUEY059^cK{%XiRRmVUr>RM zoT;az<6cP7!6UZDL$RYqvG-E2P~LJo4g>q~DQ(Wsv{5>@aVcz2j^6mEWnL>oZR1o+ zMbS>riIByFf6avuAgAWJ_v%U^r#AvmM&@ZY;O7n!=CQ(iJJet7CYM~Bn_mAK4-1c+ zneacV*2-iy8nTqq1Jr{@Tdz*^`svJ;8* zjFo7*b>ct2Oe_%go-KnUg^wkj)Hjq~+Ft8xkekgfK+_f&Y4iusQomT!k6+eu2ZnfP zFcrGEe|awM7Gf`&B#`8aAq?2U$!s6?gYx6R;VkwLx$~Ky?`1#0rkhSgX7t5zik58F z9~$p4^CNL0L{yAj-|fojTQy#53K4RaCCjMC*vzGFrxf^TEJC+v`qgBxGH4~cSsx^7 zp)ir4>Q*eIE`I=qAw+~7s;kvW@s>#joFjEqM5vsMh(xdBIey(0-^>x;^XqPp1Au_;|m_-=#W<9Jd9$^W10qyf2Z=|s5#ZZ z_YrH4xWPf5-&b#piJ-A^#|e`$n9i5=(~m=He_aFqqFZ{pdzD9s8`se!hZU8VA|;h; zQY53Iv7!J=#N7puf|GYcV$1o#gb^s#iL2A)s!jE(dTkuYgWl>Klr?;YU#kowmk>oLmnRr z9}EGk4ZqNJ3ddrQdCDWI_KgGZtF+0CQ?re-K!372XA4P14h^?`XCsrIOKV^3NgrYx zJw8ErIuk4!w_6;%tqwzl&=xem?-KJHmhYoDl`U!(Mobj)awi_ zltoC)6-Hd+muwcjp{T(?T#&=cflu zw6&Mzi?da5`TOz_H@x6&hukEq7L$W!)?1p}<$zLkG_s5oawBg)o>$xvG&b1O@vX~| zlAE|~i#^~L6sViQOGv zSq@J99jFe~W)0O_3fAwp1a)y|dR_#yTxcs!yAe-JV9<7=&_*3MwBFiflB&A=h#kKt z{B^caMlHAy1wMvScA8B5K*zQ6N!wHUFy=*&-8RiEThSR810h-Ey|aAJ#s1u-EJIad ze_#nXbPV$ID7l)@DW67t^+}l}xk#9T<$Z>H=)9vN9?<$ltth?S47vUlYSRGFuqes% zMN--oe`QXAjFIL#zrewWC6%&uiok32_SP>4u)NZr2gkOdye zM4ulJ%j^FvU{8EiMqgZ{`WT zJgV&iGU~irPlP_xm8EHoSBwHUM<(FOUl(Qq9}4;yw!VtfiZ&I=(nHkdUAT@=^GSGr zpNWnsP_#vEx?$fNe@f}X4LP4Xphz#R#0M17S32=B;BoGNmwe38~Aq-_T z(UIHwZ3<>ni#-LBsTp!nhY0r0P1CEOI_{FblhjHaxjj>t%uaClVz|uJd+WHYdE!ZC z!#94bxy%KP+4CA_j7u^!pmp3{iqoGjdjy6MUR z5vUg8t`G(7F?g zG4C8wGa_Z*Eb#{5EIU2L7Cf_ZNO4^x))u-H^~J_9n%d5(kZ%pUv>8NJM-iDAe&Zv% z*TlBZqsk16Eu^Yb2a0}+pRMXDjUs=4s&U77kP=;nTQ4@*Ai^NNnT|1+aHwOwmMBCI zaJ%~LAquuFZ99%$ViB&Bj)6I1C+&pjoC3Gn(!ohtOCA8Ig3-#EtA@P^VUTAwN&_clG@oCH z12KVIx%*RXF3KE=vdO{hqYJj?xHOZf1HUG(5WQ4!UVp-X8rB=V^NKo=s&!!Cl0OEu znUF*{hIsmZX`0({vo+xTpebl-eMhJwWW1m<& z2%+r4U;UN!j+9OS%%W|1q^*H zK|w(LfC|4P0spG2nmV$Tq8o{g0xF-`YEf(e++o3e{^!~i#{&Hq zm;izAqk)jI$^L)hP4P}vyD)JA9Kz%2PoC$@wzSBJof8m!V=q|LR)e6>AH&|3lca=^ z0@+9(A?L^5<)W$8SCQbz6?A?jD6iI<>&of7M*#XIJul%>Ro1O2amhs;7W+u>wBen` zQ`f>6!N|_X=8dFFZ4&l^t`!=!SKR*hI^hB^iGn7*z>X|-GNa=1U$1p5)zY78OmRr+ z4ee6y!RizQ6ndoTO3h99ei7mA?wcsQg z8^B77)}g?5LpawL?ON1JA{pk>0PIXvd zNB$Jsdx#ir7`t|NWwOMIp_tr(cCYyZ*aUHRoLPrlMo^d1^_q0Z7yRFluv+{FkJ1ki zko%uN1ywe{830!Uo!?{vM~i?m#+bM60%B;IM7CMn3Y@qM{B~Y!s9wdP%7h4C*2D|X zN+J#0D?o&r&1`2}+foZIaVuCImfcFT=Y|tha5^L2Oe^VK_9eIEeS6d6y6uF4_51BQ z!vWM2`Wt?qN<9O4AeyLt6p|X-n0Y86#YqKE$Jhig;TQ;Qtd@xu)QHjB{;~rtGF;5{ zm8vPgaBxQS^8i)Y=NDh(UK)r1`N0~IK=cg6jV@BlP3NkQx>OGE*6a2=m?-8T()cwY zigDsa2E+g%AJG7A_d?_qvd%|z^`khhoBUt{)JHOG2Vr*zq#JYa`8L7-&KX1ydN*|c zZUP1HQ$CfNows-+ric+8Z;OqL3T9xoa<0;PBb`2v)yvAy=k9HD^5x-?R%Pt=g0*2G zd~56UE(+}Xjyro7Jtd{c*#~6=(v0SuxN5n(2%54#qB1~dTcw@ zZhRaRXd%vd5PPl_jqwqC8giwZIE!_bld=oIWnWO`<;ufdHzjT<)M_~YrH*<9`QWuQ zKh*7W>Z0yy93z*iPEmclv>1Wmfj_)L&z`eV`J%R@)iyZlyx4MjrDVzovUhJN;qv6{ ze1K0Uu=mM&W5%yitLk(h^36}e_1X*pjiR#DOg4DE&=%C2U~K~|C*q1Lc2cyhlLG<* zw6+y65L;Q)gEMjvSg<4aw6x|OAG}2Xd1dSbisS9-a z5bJZ}D>6imrF}u7So>T`M*l#op_;9w+moV?h!4z`w@D7nfyv4_z$7ED-co?h+V-`*PY?n8W9uppai5mZ3 zY<9Rc*Hxyh8`wymO5E2#)TeQPwbZH~uv2MuI0t>RPY3o2R{sjxqvSdoGue0wN&N=% zBWX!ByZY}P80EQ=c8lqUeBX{ZPv|Y;a!YB!z0tC@X3GHNL5NW`uJ`{_)>(i>)qIbC z0qIWZ?hue}>F)0C29;(30qI(5N$F6!yFo%yq`N^Gt6|*kCfNj^Ek*uV|j%9;{Dl0ZbN+a-q@5gRP$1HpA`)+|Bes#n8cL* z3QJV>OL$HQY*;n&hTYk)Uhi^H^u*TD+)g+3)4NP+AooH@L1xYpf$Y~`OdMfuqP9H9 zcHhdY8pKcP+R7?z1@uO#PD?Fcu8eLAzuI;UT5*!T%A5^*(Tcv)`N?f20P1K=`|$nc zMrQ%>D!~rx40_{AN(S<8=ZIwTw(U~?IQzJ}PJ&B}E*iOrqF~IZGh=*wCL+(oG%+4} z6bWsB45Gf_LQwO3Ez`vNF)g0Cpw)az)ufI`Ej2q`4$#@~XTPyqry1 z6k5OBN%k*CaU+aaXc|suszwztWDm&MjT{(*W?zE{ULCQ8t3r|`ai7 z_s??;6%GGj%{MTvohJyyZCRap$F-7D^ssl60WAT_aS5o^jAE_pffd1?$SGd^XIEr(Y2;0(H=24(Q3e;$p)yRjl z4{VQyPoS=_b~C9AGhg6sU!_X+NWySJe(q|<)D+zwGA_Hl|J88j4AJeIybrW8&j!@S zDaR0A|4jd9@4X`QsTb|<39`wA7Qc)Gk-^|T;^Pa|EV>TLv>c>s3cSc&H$vW-nxkF#BrnYNx0JckRo~Z2lKi7Y>WQs zw;1%6Wee?%ymO6<8|T`yA4D^X5Ui->uVMF}xr}&xZ4yeRGgft~y&-l<$ z!6i2qe)da?V#bDSnXGSSLTJuW1NESjd==iYItYj?nCP2C*%Lt+ltJeGt;X2n6=(%~ z=4xJr!NGM&2|Y10QHhI;+SI~5L6URn*xC{d-ym@@#De9G-a=s?|JEjdP1C; z_RJMjQtgU$pm{5#1tlD+K%?60_Tk-__9ErBn~BRTcE=wXkHaY6NW1(0i$Ow z$y{&P&7~{zcEgHFWnsR^Z=s<3+rmfZb! z{4S_F?tUCN1Kw^l2XRNaE6^8rHU@3*cAd6DH&|q8bYdo>7i}KG#!L|dLB!TL4xNq9 z)z1W(1|t&`m{eRxBU5l%qqOtWw4wTI!%&*(}`J2z$A z3`|Z?_CuY}*)^^glsOvF(rSWoX!D88C^J(rzcDz{DrH>95lpNXamlBQeN;#xnNmk- zqnL_-tIfv?4}T@rLLb!$3@V@jbt46*sMX74R4RB^zKQ40C8%*Vg(cvY3^8Q1oZUzN zV*9)!O4SpU?`rlmzAsE> zzS%bJlbaFqU=*>f0Y@&B+Eg@sxTjbR12U8K;;BP;u@3cJj7e`gO10DL;Ueo;%o>!JqbQ=|GugVz_I+&3 zU+1#*Q3qd{*^I*bzjU1S7Q;bEm#ZOEIylwkb6JpL9rB37>qG{5S*4eFE9~E|J1V$C)UTz+dvUnZMOi+b=#h{_ ztFsRqe2%f6f{{uyYHqcN;!Sf*(2s4uuAZP3koRLH;cZ&7FeIqolnjvU~ozDwSW-puEpzS0jGDjn_(UpKY2&Ezf+f5L7n7f zjxxUf08+^x`4fO_w0>J16j8EJjPk}}^_ui(RG-NOyN9D4T39l<4cl;uKx3lA4SPR8 z-pIGSg=YfDUj_Zf4weX^t*V{&o!(2;6j8rljt! zc&VL*&6-;Lj!@D#JRLeWeprmVku3O;YQx2%yO52oh7;NBo}a!5pO@>jtkp6*+rAaZ zY*5*wo)t$tH%W279*>36P}i$Qu%3{4O;@lhjapy`eE&l1naszOMxSDo+x$BCG04Uy z(MexC(Q5@Wgq=#V6c>OtThvG1V0-*7)Tnj5n00GncO(JDJ_m6a-NQniAR7vMsAfZP zj=mq9w>m9iMm~G+S??Ww#%BxL!6c>oUQF%v#m>qL?;#V4#Qh?#+aexSp}zS%G;ViL zU3~l6M?Qwv@8nMie+J%2)i<%iIydk2(x8QPkgMf$FUDVDGd&N#HA>2Awrcps3Lc@2;$+njN8=-3-G& zx5vjofS?pr3`%=S6-mzzUZYo$=I|{%Y$3iVuujH9mlUDezRh$SZ%}T0^)`V$P-Jqx z^uxt6GWLC;7lremk{IWY{A*N7omFg|e>~**OXjk?^^NIU=C^X}MWN!l%Gc$l;M(JCtNn64 zfyF$KTHcMo$b@(~lKU9-=MF-k5D+xxYkUqiB|NGR-uuqqCGoaQeO?(4Rh{)`3th8c zuM$81-K&p%{BNv?d`Wnzj=*a&Dv`-cS_G%rdv+6kHfZ{NeCpfMZ=C|Qxt}g&jShnJz)X_ZwW2TY z)vn&?+!LfzqW$a|k3eVvnZUdeWwb4kF?a=5o&YGj8* z8v^@%YMaSBBrXmXjpN+Fdyw;o10yuKO;LiW18(3;8Y_2jlRR~+*JOIppOZ;{u?z`rvK&taDGk>e!Wygdhh_ z1=aJg1_tj4>78VRpGZK4Bd_eZ?UIzWWHMZfRSqK_|C3M*YC^aDclki{K%8K5#`Z?IYS-}B_?uj|7jyw9M7`+#!K|?4HKuXZ7@O?vSb-y< zqA@b+>456*hHt{1A`z%D;k>Axc~Qd228;SrD!M~|mIIt=AS6hkysHf+UkMXUFpcAw z#K(T61rz5SLSDiqqm6KuiBF9SS0%fl0MJE#RWJCZ2K{MIR{w^9>4XRXG~<8*EV+Q% zS3n$Vf;*+^^f_ki7*r@|+jO_YNoG^FU}crm4yF8J;) zwFwzym_5>cC&Bo_wD}@0LX{Dc>BK$dMwBB#*1h|47{UzO%HeBM6vPnUB<#Ml!DA6u z?q;4!eS;XntPaAg79AK;D69w-?eto#5z{GRp0b{T@*{aTcxCCUPjJ^E7+Y&no`K%vk3$IiLy+dz8|I2Tl7s5BK3-WIkV z;8aAQqC7gdnbFEfupg?>FGKf}Vo)c(a>%>3G)ibTNVz@pAv zV6n;2ZQEgqy^K@x<9n8Lr$a8RQK_kIo4NNm=iDRb1+{CM+O^+Y$7MEw#R;L%hgu1u zqkAu>q&%D)K3Cp^V7Ufri77kIII4ed6Nk##0R>5(PpHr82kUAsPGH~E?-3}MufOGR zKWOk6zmq~Ry{(`Q?3hszKMW~lOwpW^qglN&KdKzN`GNC4Rn0}o$@@uDHh}7 zJ{I0y!d|IX|6drYH3H_B>@`??!tN!dCFS%<%njGgwxjE8l?7IeC3}~zMn|?&v`n>!IFWqJ2q`^AQzb4TVCjSZnbGAi4h9nvCJI+8kCC1?{N% ziF)0#8I~9~QMObI+q$OLXLxUrALNF>s*X={PEK3+7KGO zJ6?&H&gCFl6p9&THybTP=pR5fX)&pt;OPBr{DkVaPS369s~(_o@B{&ITeJ9SHd0JB zV(!}xa5%PI5AJOf`EN70uB6KX^51e8rShB#(9=#^YO;u-yHY>luurF-YZfI*jpDQu_GsKD;*xh~G% zushbC%OZCA@V!9s4{H^d>7kq##g{Fiz}0NVKLu+mm$5;pOImFsm)9_b9C{sNyqiWo z+~(9Hrc*NC()SVqmFQ%KU!&o*2_q$6iieZQ30#YkrB2iESKZYP3bn%(4A+!iMFE>j5@VQ#{_uSiAU9C1#1QNN? z)+!`GN8xu@(dS39#7++Uk!icO33OE^(8yaat7R0hi!*!I5t&`b_7`jHH|Oe(=H49X zwh6W@3+eA?v4E_Hm2=Cv$SE4TLO!UzQXxw19da+)Jw+0XlICmfYA}5L zpYO6E%kiOJZc9+Hboh@iC@rAVBeULLrUF|YK-HcF7Zd^4jInCKcUnpp6lB>YQN!M# zb5X=4M8sT5ZA$Z@O}S3p7i*s+=U_{bi)TyLNpXLbYE%?^-cVMbec9PHg1G&7LFa&K z*y}cJUz`;Fns6FB>@0YOF!j}xr}>%_)g+iYlOr`QPhlbP*gwTb2@ZV3AKH3@D(VFz z57eZlhaX}}WWh#n*cprygh`%oqn;EDO#YF|6N0ba?1kkF?%j87(yI|?cuOr$=QgtT z?$faNB<2^*Exz@F8MExI%F9bv7A7WH4cR%a5F+^S9>s;kqy9p~#l_d89z5C7s51>2 zy@q9h+j^9)3$kjPvhwyHxW^5NcxMQy4}e^--(>71-5o-z$ z`s|#IK`uUqY%=JeiV9`Ja2v?-kKiNvq*Np_J%|Fo@)0lHqX?M3X8Edsz zNHtbEOYTBP!xe%|vWHsCNb|eXc^$Toq3g6q$ai#ySXJD?@}TFCjbZ&{BJQoiRlv}i zR|1>ghUeE~exx2ti7iLdSH_)gnrHc{e148BvWAVe9dc~G+^h?tM97tuNHaJnYt5H( zl|NA0;%ds=wOzjANPTbpBZOwsx;cYVfl^v8oGs}>{uLE(XCh;fL6~hFI7b<#GU&Cx zv^Ufzs@PTSylA9!Nmqmczk-}?)KZ{l(f1p%37D*0=|=1;W)EgX=3{=d#A+etJI|@f(s+a#r=`RUGkGAUp13>8hbhDwT{-yw0r5%$qD2BzK(?k#iv0)5%$l zx3db&gTvTSH)`02*oDU@sE1gg7Z~c^8SVRymOs*v*IiI3001Y%87)(dkB{Laz8C=g z09mlr^%z5**@_{16lEdMOOVwXVU0kL?PCtbA*heBrm*+V9&(U~9)*60;l0{tb?^5JS&ih3S1Juk6`zE{iWI&1irL0FW>~l%Kukq{0F7!CaFr5d1^z*Ju7mbGb%#A8nx+-Fv7VHfOe?gL}u%M=$Jc)XFI+cVNjsunn zU_4=d4|ohsO{12GOJ-;6z)bdbrQOhEZMBD1el1+C?^(xp)HYFc`dEn(Pq(?2bmOLD zA2O*J?BAQsqg;{n+MIAKuPW%H+_BawRG5FJ$slRx0$155b`h7OdOkJ;$TNz%>?0t8 zU&&B6COfFwaOM{Xkca1U<{2=dljncE&KlhYDI1#%s_pkGB&D;Rr|scFrv}x<#a2p) zP{)7~<zS?Ixd83{ZYRvLRY?=CM?00|rN3p{QsIl9O^{5*QbtNpk$J|=$Fmft4raF;DvHyO`Z<U<-Nk@^6BxVhp+&St#bwPv2~a>SRIQ?>i+@wa%F zEa`h?=H+hbD-HxXV`rt^g7R zO6_f4AEBaVd)ua7`Y?_nt~eIK4a!PM^T5IUqJeA2>eX$5>eY};*pk|Rfo9gqt|q!J zJWE($JI#^5N*_>Kw%v#URzWR@T*72ad8Qihy^gQr5MXH{7z6tYx6txYw1)%?W0NaXNDeu)5X?RpE0i zTANvkB(I9${uV>LZ}V3E;aEO4kccC z5g*RI7;goC-nRd(L*@UcNMo^e^VE^G?F{OKwLMR-(L771+ts8uhp$3f<_+8Ql@mDT z>L+j&-{)F#5AKg@QxJ{mp3E@xN3%P@;-MN`HtUk97pNP5qAtIPt5s-tk<6FYgnT<= z7k2vt^K?{NyAT!xX-`MLaDf7-$U{Nn!2HJvJY>N|9x?_%r2mHeKmbVg8rx`)4vyb_R%o0Ky{gv@D{kP82r6GRhAc>J7b%y(| z5&$4Suo~1pOHKASquSc_P)BqCz=#v-fMp1UGxd8LHY<|f)3`f?%^j6Y@WbO%=a+w0`Wcg#3{@Zkdoyd zeDD$Tp!I(TeE&JD$LkqW5szBIUga|8D4lOtgfbfX|ig zK_@jD=KnT;|7{Zj03e_5zac-6OXV>UD#&W-!S4SqZT>^&2aajq!+m-rpz);#yZ?Pp z59wzd|B#StexQ=!J)CU`4tttyK!R%mF+&Vfe^XBJ4DV1dg1vTw7l{tKZ3|#yt$Vzd!hg3?+tk} zoqb}+@LLGX{r^?qfJ5SLH3Wo$^q{}Xz5j&#Knq{c#Hz%-)+h7de+bAmKhVw(sN^Q{JgBrQfzw03y`ysI06L1i84+f+Xfsl6|Yj1yp z5PB#1UjBFLEVTL11pD4e1rI@#m_U?BK2d_2_6R?KPv+`RK>o~swK8mxJXDI@79q51 z_P=tpd=ya0*2CxZzj^$B%V(GS|0I9|u@qr|_SPQ~VPbJsV?xY)38}qTPjdGyxK9M! ze$4s9HX-yu5k#g8iraoHJJAjyH2+74j16>B0S9vYr%wDJ^4-?^78u?295nWid<7y0 z_CCrnK}@^&_Z9A)eR38GX*67r?ke-dh_-=yIB1vWq4;gPgwQ2}_cEnX#($gYlgEZ9 w3X+E*U-p8ah&^pYiiN7iT4~3Z~R{#J2 diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83ae4..25a1876bb8 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From c0219488cced566deb45e2f2b274a01698fb7edb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:21:45 +0000 Subject: [PATCH 068/441] Bump mrm-maven-plugin from 1.3.0 to 1.4.1 Bumps [mrm-maven-plugin](https://github.com/mojohaus/mrm) from 1.3.0 to 1.4.1. - [Release notes](https://github.com/mojohaus/mrm/releases) - [Commits](https://github.com/mojohaus/mrm/compare/mrm-1.3.0...mrm-1.4.1) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mrm-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index afaaa94ed3..414af24bff 100644 --- a/pom.xml +++ b/pom.xml @@ -358,7 +358,7 @@ org.codehaus.mojo mrm-maven-plugin - 1.3.0 + 1.4.1 From a5d2ca8473adbfc1ddb1fa837e7ccb91757250e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:21:50 +0000 Subject: [PATCH 069/441] Bump woodstox-core from 6.2.8 to 6.3.0 Bumps [woodstox-core](https://github.com/FasterXML/woodstox) from 6.2.8 to 6.3.0. - [Release notes](https://github.com/FasterXML/woodstox/releases) - [Commits](https://github.com/FasterXML/woodstox/compare/woodstox-core-6.2.8...woodstox-core-6.3.0) --- updated-dependencies: - dependency-name: com.fasterxml.woodstox:woodstox-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 414af24bff..48796c40ec 100644 --- a/pom.xml +++ b/pom.xml @@ -229,7 +229,7 @@ com.fasterxml.woodstox woodstox-core - 6.2.8 + 6.3.0 org.apache.commons From 20019d538930da2417611ecf22c84cc9aec1b260 Mon Sep 17 00:00:00 2001 From: bzamfir Date: Mon, 25 Jul 2022 23:06:22 +0300 Subject: [PATCH 070/441] update-properties does not work across parent-child pom Fixes #582 o Updated PomHelper to validate version properties also across parents. --- src/it-repo/dummy-parent-issue-582-1.0.pom | 23 ++++++ .../invoker.properties | 1 + src/it/it-update-properties-issue-582/pom.xml | 20 +++++ .../verify.groovy | 3 + .../codehaus/mojo/versions/api/PomHelper.java | 82 +++++++++++-------- 5 files changed, 93 insertions(+), 36 deletions(-) create mode 100644 src/it-repo/dummy-parent-issue-582-1.0.pom create mode 100644 src/it/it-update-properties-issue-582/invoker.properties create mode 100644 src/it/it-update-properties-issue-582/pom.xml create mode 100644 src/it/it-update-properties-issue-582/verify.groovy diff --git a/src/it-repo/dummy-parent-issue-582-1.0.pom b/src/it-repo/dummy-parent-issue-582-1.0.pom new file mode 100644 index 0000000000..65fc001b6d --- /dev/null +++ b/src/it-repo/dummy-parent-issue-582-1.0.pom @@ -0,0 +1,23 @@ + + 4.0.0 + + localhost + dummy-parent-issue-582 + 1.0 + pom + + + 1.0 + + + + + localhost + dummy-api + ${api} + + + + + diff --git a/src/it/it-update-properties-issue-582/invoker.properties b/src/it/it-update-properties-issue-582/invoker.properties new file mode 100644 index 0000000000..9b9e55e13f --- /dev/null +++ b/src/it/it-update-properties-issue-582/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:update-properties \ No newline at end of file diff --git a/src/it/it-update-properties-issue-582/pom.xml b/src/it/it-update-properties-issue-582/pom.xml new file mode 100644 index 0000000000..68203983f2 --- /dev/null +++ b/src/it/it-update-properties-issue-582/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + + localhost + dummy-parent-issue-582 + 1.0 + + + localhost + it-update-properties-issue-582 + 1.0 + pom + update-properties with one property, with dependency in parent + + + 1.0 + + + diff --git a/src/it/it-update-properties-issue-582/verify.groovy b/src/it/it-update-properties-issue-582/verify.groovy new file mode 100644 index 0000000000..ab001bf4cc --- /dev/null +++ b/src/it/it-update-properties-issue-582/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text; + +assert pom =~ /3.0<\/api>/ diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index ab727488a6..2f9ea4e084 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -875,7 +875,7 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel throws ExpressionEvaluationException, IOException { ExpressionEvaluator expressionEvaluator = helper.getExpressionEvaluator( project ); - Model model = getRawModel( project ); + Model projectModel = getRawModel( project ); Map result = new TreeMap<>(); Set activeProfiles = new TreeSet<>(); @@ -885,7 +885,7 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel } // add any properties from profiles first (as they override properties from the project - for ( Profile profile : model.getProfiles() ) + for ( Profile profile : projectModel.getProfiles() ) { if ( !activeProfiles.contains( profile.getId() ) ) { @@ -914,52 +914,62 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel } // second, we add all the properties in the pom - addProperties( helper, result, null, model.getProperties() ); - if ( model.getDependencyManagement() != null ) + addProperties( helper, result, null, projectModel.getProperties() ); + Model model = projectModel; + MavenProject currentPrj = project; + while ( currentPrj != null ) { - addDependencyAssocations( helper, expressionEvaluator, result, - model.getDependencyManagement().getDependencies(), false ); - } - addDependencyAssocations( helper, expressionEvaluator, result, model.getDependencies(), false ); - if ( model.getBuild() != null ) - { - if ( model.getBuild().getPluginManagement() != null ) + if ( model.getDependencyManagement() != null ) { - addPluginAssociations( helper, expressionEvaluator, result, - model.getBuild().getPluginManagement().getPlugins() ); + addDependencyAssocations( helper, expressionEvaluator, result, + model.getDependencyManagement().getDependencies(), false ); } - addPluginAssociations( helper, expressionEvaluator, result, model.getBuild().getPlugins() ); - } - if ( model.getReporting() != null ) - { - addReportPluginAssociations( helper, expressionEvaluator, result, model.getReporting().getPlugins() ); - } - - // third, we add any associations from the active profiles - for ( Profile profile : model.getProfiles() ) - { - if ( !activeProfiles.contains( profile.getId() ) ) + addDependencyAssocations( helper, expressionEvaluator, result, model.getDependencies(), false ); + if ( model.getBuild() != null ) { - continue; + if ( model.getBuild().getPluginManagement() != null ) + { + addPluginAssociations( helper, expressionEvaluator, result, + model.getBuild().getPluginManagement().getPlugins() ); + } + addPluginAssociations( helper, expressionEvaluator, result, model.getBuild().getPlugins() ); } - if ( profile.getDependencyManagement() != null ) + if ( model.getReporting() != null ) { - addDependencyAssocations( helper, expressionEvaluator, result, - profile.getDependencyManagement().getDependencies(), false ); + addReportPluginAssociations( helper, expressionEvaluator, result, model.getReporting().getPlugins() ); } - addDependencyAssocations( helper, expressionEvaluator, result, profile.getDependencies(), false ); - if ( profile.getBuild() != null ) + + // third, we add any associations from the active profiles + for ( Profile profile : model.getProfiles() ) { - if ( profile.getBuild().getPluginManagement() != null ) + if ( !activeProfiles.contains( profile.getId() ) ) { - addPluginAssociations( helper, expressionEvaluator, result, - profile.getBuild().getPluginManagement().getPlugins() ); + continue; + } + if ( profile.getDependencyManagement() != null ) + { + addDependencyAssocations( helper, expressionEvaluator, result, + profile.getDependencyManagement().getDependencies(), false ); + } + addDependencyAssocations( helper, expressionEvaluator, result, profile.getDependencies(), false ); + if ( profile.getBuild() != null ) + { + if ( profile.getBuild().getPluginManagement() != null ) + { + addPluginAssociations( helper, expressionEvaluator, result, + profile.getBuild().getPluginManagement().getPlugins() ); + } + addPluginAssociations( helper, expressionEvaluator, result, profile.getBuild().getPlugins() ); + } + if ( profile.getReporting() != null ) + { + addReportPluginAssociations( helper, expressionEvaluator, result, profile.getReporting().getPlugins() ); } - addPluginAssociations( helper, expressionEvaluator, result, profile.getBuild().getPlugins() ); } - if ( profile.getReporting() != null ) + currentPrj = currentPrj.getParent(); + if ( currentPrj != null ) { - addReportPluginAssociations( helper, expressionEvaluator, result, profile.getReporting().getPlugins() ); + model = currentPrj.getOriginalModel(); } } From 78b8dabbf65b495ae11cd290dd9f0d9e5810c136 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Jul 2022 13:25:54 +0000 Subject: [PATCH 071/441] Bump junit-bom from 5.8.2 to 5.9.0 Bumps [junit-bom](https://github.com/junit-team/junit5) from 5.8.2 to 5.9.0. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.2...r5.9.0) --- updated-dependencies: - dependency-name: org.junit:junit-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 48796c40ec..ae02d5b379 100644 --- a/pom.xml +++ b/pom.xml @@ -98,7 +98,7 @@ 1.8 ${mojo.java.target} - 5.8.2 + 5.9.0 3.0.5 3.4.3 1.11.1 From 72a6e16bddafa6b70132a6c228be991697253ec7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Jul 2022 13:24:27 +0000 Subject: [PATCH 072/441] Bump maven-common-artifact-filters from 3.3.0 to 3.3.1 Bumps [maven-common-artifact-filters](https://github.com/apache/maven-common-artifact-filters) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-common-artifact-filters/releases) - [Commits](https://github.com/apache/maven-common-artifact-filters/compare/maven-common-artifact-filters-3.3.0...maven-common-artifact-filters-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-common-artifact-filters dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae02d5b379..0066818728 100644 --- a/pom.xml +++ b/pom.xml @@ -177,7 +177,7 @@ org.apache.maven.shared maven-common-artifact-filters - 3.3.0 + 3.3.1 org.apache.maven.wagon From 908c182102a4a85a8ce9c93296dcf5c5e51405e3 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 15 Jul 2022 12:57:39 +0200 Subject: [PATCH 073/441] Cleanup project pom file - use configuration and plugins version from parent - execute mrm in run-its profile - remove plexus-container-default from dependencies - add breadcrumbs for site --- pom.xml | 104 +++++++++++++++------------------------------- src/site/site.xml | 8 +++- 2 files changed, 41 insertions(+), 71 deletions(-) diff --git a/pom.xml b/pom.xml index 0066818728..0f07aa82aa 100644 --- a/pom.xml +++ b/pom.xml @@ -12,11 +12,13 @@ maven-plugin Versions Maven Plugin - http://www.mojohaus.org/versions-maven-plugin/ + https://www.mojohaus.org/versions-maven-plugin/ + Versions Plugin for Maven. The Versions Plugin updates the versions of components in the POM. 2008 + Apache License, Version 2.0 @@ -50,6 +52,7 @@ +1 + Benoit Lafontaine @@ -87,13 +90,9 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git - https://github.com/mojohaus/versions-maven-plugin/tree/${project.scm.tag} - versions-maven-plugin-2.11.0 + https://github.com/mojohaus/versions-maven-plugin/tree/master + HEAD - - github - https://github.com/mojohaus/versions-maven-plugin/issues/ - 1.8 @@ -124,7 +123,6 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.4 provided @@ -215,12 +213,6 @@ plexus-utils 3.4.2 - - org.codehaus.plexus - plexus-container-default - 2.1.1 - provided - org.codehaus.plexus plexus-interactivity-api @@ -276,23 +268,8 @@ + - - org.apache.maven.plugins - maven-plugin-plugin - 3.6.4 - - true - - - - - helpmojo - descriptor - - - - org.codehaus.mojo animal-sniffer-maven-plugin @@ -352,29 +329,6 @@ src/main/mdo/rule.mdo 2.0.0 - true - - - - org.codehaus.mojo - mrm-maven-plugin - 1.4.1 - - - - start - stop - - - - - repository.proxy.url - - - src/it-repo - - - @@ -437,7 +391,6 @@ org.codehaus.mojo versions-maven-plugin - 2.7 @@ -460,7 +413,32 @@ run-its verify + + + org.codehaus.mojo + mrm-maven-plugin + + + + start + stop + + + + + repository.proxy.url + + + src/it-repo + + + ${project.build.directory}/local-repo + + + + + org.apache.maven.plugins maven-invoker-plugin @@ -469,7 +447,8 @@ integration-test install - run + integration-test + verify false @@ -480,21 +459,6 @@ - - - - org.apache.maven.plugins - maven-invoker-plugin - - - - report - - - - - - diff --git a/src/site/site.xml b/src/site/site.xml index 508a8dd450..9da0008a59 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,5 +1,11 @@ - + + + + + +

From 939a4227f9194cc0e9a489df6ca1730e14c07733 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:21:35 +0000 Subject: [PATCH 074/441] Bump wagonVersion from 3.4.3 to 3.5.2 Bumps `wagonVersion` from 3.4.3 to 3.5.2. Updates `wagon-provider-api` from 3.4.3 to 3.5.2 - [Release notes](https://github.com/apache/maven-wagon/releases) - [Commits](https://github.com/apache/maven-wagon/compare/wagon-3.4.3...wagon-3.5.2) Updates `wagon-file` from 3.4.3 to 3.5.2 --- updated-dependencies: - dependency-name: org.apache.maven.wagon:wagon-provider-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: org.apache.maven.wagon:wagon-file dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0f07aa82aa..6966da644a 100644 --- a/pom.xml +++ b/pom.xml @@ -99,7 +99,7 @@ ${mojo.java.target} 5.9.0 3.0.5 - 3.4.3 + 3.5.2 1.11.1 1.11.1 ${project.version} From 466c4c5c01235158b62c1eba98f367fc0dd02615 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 31 Jul 2022 17:36:19 +0200 Subject: [PATCH 075/441] Upgrade modello xmlns to 2.0.0 in rule.mdo --- src/main/mdo/rule.mdo | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/mdo/rule.mdo b/src/main/mdo/rule.mdo index b0614de4ac..0c9a9c68a7 100644 --- a/src/main/mdo/rule.mdo +++ b/src/main/mdo/rule.mdo @@ -19,8 +19,8 @@ specific language governing permissions and limitations under the License. --> - rule @@ -45,7 +45,7 @@ under the License. 1.0+ - + ignoreVersions 2.0+ false @@ -131,7 +131,7 @@ under the License. 1.0+ - + ignoreVersions 2.0+ false @@ -146,7 +146,7 @@ under the License. rules true 1.0+ - + Rule * @@ -200,7 +200,8 @@ under the License. version 2.0+ String - A version number or a regular expression for version numbers that should be ignored. + A version number or a regular expression for version numbers that should be ignored. + type @@ -226,4 +227,4 @@ under the License. - \ No newline at end of file + From 926388a1ac38f163d23c05d0de59754c0aa89155 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 13:29:19 +0000 Subject: [PATCH 076/441] Bump maven-reporting-api from 3.1.0 to 3.1.1 Bumps [maven-reporting-api](https://github.com/apache/maven-reporting-api) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/apache/maven-reporting-api/releases) - [Commits](https://github.com/apache/maven-reporting-api/compare/maven-reporting-api-3.1.0...maven-reporting-api-3.1.1) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6966da644a..6849d042cf 100644 --- a/pom.xml +++ b/pom.xml @@ -165,7 +165,7 @@ org.apache.maven.reporting maven-reporting-api - 3.1.0 + 3.1.1 org.apache.maven.reporting From 6e6efcbb285d972cd0aa2119a94f683c06164448 Mon Sep 17 00:00:00 2001 From: ajarmoniuk Date: Thu, 4 Aug 2022 13:05:02 +0200 Subject: [PATCH 077/441] Reordering the checks in shouldApplyUpdate + a simple unit test --- .../versions/AbstractVersionsUpdaterMojo.java | 12 ++--- .../mojo/versions/UpdateParentMojoTest.java | 45 +++++++++++++++++++ 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index cdfe1a708f..9166a3c895 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -457,18 +457,18 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A { getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion ); - if ( forceUpdate ) - { - getLog().info( "Force update enabled. LATEST or RELEASE versions will be overwritten with real version" ); - return true; - } - if ( updateVersion == null ) { getLog().warn( "Not updating version: could not resolve any versions" ); return false; } + if ( forceUpdate ) + { + getLog().info( "Force update enabled. LATEST or RELEASE versions will be overwritten with real version" ); + return true; + } + artifact.setVersion( updateVersion.toString() ); try { diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java new file mode 100644 index 0000000000..8ba1f990f7 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -0,0 +1,45 @@ +package org.codehaus.mojo.versions; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.artifact.ProjectArtifact; +import org.junit.Test; + +import javax.xml.stream.XMLStreamException; +import java.util.Collections; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class UpdateParentMojoTest { + + @Test + public void testArtifactIdDoesNotExist() throws MojoExecutionException, XMLStreamException, MojoFailureException { + UpdateParentMojo mojo = new UpdateParentMojo() { + { + project = new MavenProject(); + project.setParent(new MavenProject()); + reactorProjects = Collections.emptyList(); + forceUpdate = true; + + artifactFactory = mock(ArtifactFactory.class); + when(artifactFactory.createDependencyArtifact(anyString(), anyString(), any(VersionRange.class), + anyString(), anyString(), anyString())) + .thenReturn(new ProjectArtifact(project)); + } + + protected ArtifactVersion findLatestVersion(Artifact artifact, VersionRange versionRange, + Boolean allowingSnapshots, boolean usePluginRepositories) { + return null; + } + }; + mojo.update(null); + } +} From 0dbc61937df64d1c804566e451638661a4ad1f28 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk <1554729+ajarmoniuk@users.noreply.github.com> Date: Mon, 15 Aug 2022 11:05:55 +0200 Subject: [PATCH 078/441] New property: updateBuildOutputTimestampPolicy = (onchange | always | never) (#595) (#630) Co-authored-by: Andrzej Jarmoniuk --- .../invoker.properties | 1 + .../pom.xml | 14 +++++++++ .../verify.groovy | 3 ++ .../invoker.properties | 1 + .../pom.xml | 14 +++++++++ .../verify.groovy | 3 ++ .../invoker.properties | 1 + .../pom.xml | 14 +++++++++ .../verify.groovy | 3 ++ .../org/codehaus/mojo/versions/SetMojo.java | 29 ++++++++++++++++--- 10 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 src/it/it-set-021-outputTimestampPolicy-always/invoker.properties create mode 100644 src/it/it-set-021-outputTimestampPolicy-always/pom.xml create mode 100644 src/it/it-set-021-outputTimestampPolicy-always/verify.groovy create mode 100644 src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties create mode 100644 src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml create mode 100644 src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy create mode 100644 src/it/it-set-023-outputTimestampPolicy-never/invoker.properties create mode 100644 src/it/it-set-023-outputTimestampPolicy-never/pom.xml create mode 100644 src/it/it-set-023-outputTimestampPolicy-never/verify.groovy diff --git a/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties b/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties new file mode 100644 index 0000000000..244cd7e9f3 --- /dev/null +++ b/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=1.0 -DupdateBuildOutputTimestampPolicy=always \ No newline at end of file diff --git a/src/it/it-set-021-outputTimestampPolicy-always/pom.xml b/src/it/it-set-021-outputTimestampPolicy-always/pom.xml new file mode 100644 index 0000000000..d354e672ec --- /dev/null +++ b/src/it/it-set-021-outputTimestampPolicy-always/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + localhost + it-set-021-outputTimestampPolicy-always + 1.0 + pom + set + + + 10 + + diff --git a/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy b/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy new file mode 100644 index 0000000000..9c85ced4f4 --- /dev/null +++ b/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text + +assert pom =~ /\d\d\d\d+<.project.build.outputTimestamp>/ diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties b/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties new file mode 100644 index 0000000000..944314bca1 --- /dev/null +++ b/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=1.0 -DupdateBuildOutputTimestampPolicy=onchange \ No newline at end of file diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml b/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml new file mode 100644 index 0000000000..41082c619b --- /dev/null +++ b/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + localhost + it-set-022-outputTimestampPolicy-onchange + 1.0 + pom + set + + + 10 + + diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy b/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy new file mode 100644 index 0000000000..29f438915b --- /dev/null +++ b/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text + +assert pom =~ /10<.project.build.outputTimestamp>/ diff --git a/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties b/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties new file mode 100644 index 0000000000..7d71944e24 --- /dev/null +++ b/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=2.0 -DupdateBuildOutputTimestampPolicy=never \ No newline at end of file diff --git a/src/it/it-set-023-outputTimestampPolicy-never/pom.xml b/src/it/it-set-023-outputTimestampPolicy-never/pom.xml new file mode 100644 index 0000000000..2127220239 --- /dev/null +++ b/src/it/it-set-023-outputTimestampPolicy-never/pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + localhost + it-set-023-outputTimestampPolicy-never + 1.0 + pom + set + + + 10 + + diff --git a/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy b/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy new file mode 100644 index 0000000000..29f438915b --- /dev/null +++ b/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text + +assert pom =~ /10<.project.build.outputTimestamp>/ diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index a94632fd50..a268fb4a26 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -84,7 +84,7 @@ public class SetMojo /** * The groupId of the dependency/module to update. - * If you like to update modules of a aggregator you + * If you like to update modules of a aggregator you * should set -DgroupId='*' to ignore the * group of the current project. On Windows you can omit * the single quotes on Linux they are necessary to prevent @@ -97,7 +97,7 @@ public class SetMojo /** * The artifactId of the dependency/module to update. - * If you like to update modules of a aggregator you + * If you like to update modules of a aggregator you * should set -DartifactId='*' to ignore the * artifactId of the current project. On Windows you can omit * the single quotes on Linux they are necessary to prevent @@ -205,11 +205,22 @@ public class SetMojo /** * Whether to update the project.build.outputTimestamp property in the POM when setting version. * + * @deprecated please use {@link #updateBuildOutputTimestampPolicy} instead * @since 2.10 */ @Parameter( property = "updateBuildOutputTimestamp", defaultValue = "true" ) private boolean updateBuildOutputTimestamp; + /** + * Whether to update the project.build.outputTimestamp property in the POM when setting version. + * Valid values are: onchange, which will only change outputTimestamp for changed POMs, + * always, never. + * + * @since 2.12 + */ + @Parameter( property = "updateBuildOutputTimestampPolicy", defaultValue = "onchange" ) + private String updateBuildOutputTimestampPolicy; + /** * The changes to module coordinates. Guarded by this. */ @@ -301,6 +312,14 @@ public void execute() + "property (that is -DnewVersion=... on the command line) or run in interactive mode" ); } + if ( !"onchange".equals( updateBuildOutputTimestampPolicy ) + && !"always".equals( updateBuildOutputTimestampPolicy ) + && !"never".equals( updateBuildOutputTimestampPolicy ) ) + { + throw new MojoExecutionException( "updateBuildOutputTimestampPolicy should be one of: " + + "\"onchange\", \"always\", \"never\"." ); + } + try { final MavenProject project; @@ -513,10 +532,12 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) for ( VersionChange versionChange : sourceChanges ) { changer.apply( versionChange ); + } - if (updateBuildOutputTimestamp) { + if ( updateBuildOutputTimestamp && !"never".equals( updateBuildOutputTimestampPolicy ) ) { + if ( "always".equals( updateBuildOutputTimestampPolicy) || !sourceChanges.isEmpty() ) { // also update project.build.outputTimestamp - updateBuildOutputTimestamp( pom, model ); + updateBuildOutputTimestamp(pom, model); } } } From cb4bdceaa613e14fa2c0d58098fe0b2a8088300e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 31 Jul 2022 23:55:19 +0200 Subject: [PATCH 079/441] Replace deprecated ArtifactFactory by RepositorySystem --- ...AbstractVersionsDependencyUpdaterMojo.java | 10 +- .../mojo/versions/AbstractVersionsReport.java | 10 +- .../versions/AbstractVersionsUpdaterMojo.java | 9 +- .../versions/DependencyUpdatesReport.java | 5 +- .../DisplayDependencyUpdatesMojo.java | 4 +- .../versions/DisplayParentUpdatesMojo.java | 11 +- .../versions/DisplayPluginUpdatesMojo.java | 45 +++-- .../mojo/versions/LockSnapshotsMojo.java | 6 +- .../mojo/versions/PluginUpdatesReport.java | 5 +- .../mojo/versions/UpdateParentMojo.java | 9 +- .../mojo/versions/UseReleasesMojo.java | 23 +-- .../versions/api/DefaultVersionsHelper.java | 165 ++++++------------ .../codehaus/mojo/versions/api/PomHelper.java | 28 ++- .../mojo/versions/api/VersionsHelper.java | 41 ++--- .../api/DefaultVersionsHelperTest.java | 4 +- 15 files changed, 143 insertions(+), 232 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 8decb68817..4179854b3d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; @@ -231,14 +230,7 @@ protected Artifact toArtifact( Dependency dependency ) Artifact artifact = findArtifact( dependency ); if ( artifact == null ) { - try - { - return getHelper().createDependencyArtifact( dependency ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } + return getHelper().createDependencyArtifact( dependency ); } return artifact; } diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 4be880877e..8f9f32cc38 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -38,6 +37,7 @@ import org.apache.maven.project.path.PathTranslator; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; @@ -82,14 +82,10 @@ public abstract class AbstractVersionsReport @Parameter( defaultValue = "${project}", required = true, readonly = true ) private MavenProject project; - /** - * @since 1.0-alpha-3 - */ @Component - protected ArtifactFactory artifactFactory; + protected RepositorySystem repositorySystem; /** - * @component * @since 1.0-alpha-3 */ @Component @@ -215,7 +211,7 @@ public VersionsHelper getHelper() { try { - helper = new DefaultVersionsHelper( artifactFactory, artifactResolver, artifactMetadataSource, + helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, remoteArtifactRepositories, remotePluginRepositories, localRepository, wagonManager, settings, serverId, rulesUri, getLog(), session, pathTranslator ); diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 9166a3c895..177e5bec38 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -38,6 +38,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.path.PathTranslator; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; @@ -80,11 +81,8 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; - /** - * @since 1.0-alpha-1 - */ @Component - protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory; + protected RepositorySystem repositorySystem; /** * @since 1.0-alpha-1 @@ -131,7 +129,6 @@ public abstract class AbstractVersionsUpdaterMojo protected ArtifactRepository localRepository; /** - * @component * @since 1.0-alpha-3 */ @Component @@ -223,7 +220,7 @@ public VersionsHelper getHelper() { if ( helper == null ) { - helper = new DefaultVersionsHelper( artifactFactory, artifactResolver, artifactMetadataSource, + helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, remoteArtifactRepositories, remotePluginRepositories, localRepository, wagonManager, settings, serverId, rulesUri, getLog(), session, pathTranslator ); diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index e783901681..6a5c14c7af 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -28,7 +28,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; @@ -178,7 +177,7 @@ else if ( "xml".equals( format ) ) } } } - catch ( InvalidVersionSpecificationException| ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException e ) { throw new MavenReportException( e.getMessage(), e ); } @@ -231,4 +230,4 @@ public String getOutputName() return "dependency-updates-report"; } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index c5ca6344c4..6094d7cae3 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -22,7 +22,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -153,6 +152,7 @@ public class DisplayDependencyUpdatesMojo * @deprecated This will be removed with version 3.0.0 * @since 2.5 */ + @Deprecated @Parameter(property = "allowAnyUpdates", defaultValue = "true") private boolean allowAnyUpdates; @@ -388,7 +388,7 @@ public void execute() logUpdates( getHelper().lookupDependenciesUpdates( pluginDependencies, false ), "Plugin Dependencies" ); } } - catch ( InvalidVersionSpecificationException | ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 1ad6289d77..a9e5abc246 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -72,9 +73,13 @@ public void execute() throw new MojoExecutionException( "Invalid version range specification: " + version, e ); } - Artifact artifact = artifactFactory.createDependencyArtifact( getProject().getParent().getGroupId(), - getProject().getParent().getArtifactId(), - versionRange, "pom", null, null ); + Dependency dependency = new Dependency(); + dependency.setGroupId( getProject().getParent().getGroupId() ); + dependency.setArtifactId( getProject().getParent().getArtifactId() ); + dependency.setVersion( version ); + dependency.setType( "pom" ); + + Artifact artifact = getHelper().createDependencyArtifact( dependency ); ArtifactVersion artifactVersion; try diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 18804e7f23..ef57ca3011 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -29,13 +29,13 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.RuntimeInformation; import org.apache.maven.lifecycle.Lifecycle; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.mapping.LifecycleMapping; +import org.apache.maven.model.Dependency; import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; @@ -148,7 +148,6 @@ public class DisplayPluginUpdatesMojo /** * The plugin manager. * - * @component * @since 1.0-alpha-1 */ @Component @@ -414,18 +413,8 @@ public void execute() getLog().debug( "Checking " + coords + " for updates newer than " + version ); String effectiveVersion = version; - Artifact artifactRange; - try - { - boolean unspecified = ( version == null ); - VersionRange versionRange = unspecified ? VersionRange.createFromVersionSpec( "[0,)" ) - : VersionRange.createFromVersionSpec( version ); - artifactRange = artifactFactory.createPluginArtifact( groupId, artifactId, versionRange ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( "Invalid version range specification: " + version, e ); - } + Artifact artifactRange = getHelper().createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), + version ); ArtifactVersion artifactVersion = null; try @@ -436,10 +425,15 @@ public void execute() ArtifactVersion minRequires = null; for ( int j = newerVersions.length - 1; j >= 0; j-- ) { - Artifact probe = - artifactFactory.createDependencyArtifact( groupId, artifactId, - VersionRange.createFromVersion( newerVersions[j].toString() ), - "pom", null, "runtime" ); + + Dependency dependency = new Dependency(); + dependency.setGroupId( groupId ); + dependency.setArtifactId( artifactId ); + dependency.setVersion( newerVersions[j].toString() ); + dependency.setType( "pom" ); + dependency.setScope( "runtime" ); + + Artifact probe = getHelper().createDependencyArtifact( dependency ); try { getHelper().resolveArtifact( probe, true ); @@ -495,9 +489,14 @@ public void execute() } if ( effectiveVersion != null ) { - VersionRange currentVersionRange = VersionRange.createFromVersion( effectiveVersion ); - Artifact probe = artifactFactory.createDependencyArtifact( groupId, artifactId, currentVersionRange, - "pom", null, "runtime" ); + Dependency dependency = new Dependency(); + dependency.setGroupId( groupId ); + dependency.setArtifactId( artifactId ); + dependency.setVersion( effectiveVersion ); + dependency.setType( "pom" ); + dependency.setScope( "runtime" ); + + Artifact probe = getHelper().createDependencyArtifact( dependency ); try { getHelper().resolveArtifact( probe, true ); @@ -769,7 +768,7 @@ private Map getParentsPlugins( List parents ) map.keySet().retainAll( withVersionSpecified ); parentPlugins.putAll( map ); } - catch ( IOException | XMLStreamException e ) + catch ( XMLStreamException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -851,7 +850,7 @@ private Set findPluginsWithVersionsSpecified( MavenProject project ) * @return a set of Strings which correspond to the plugin coordinates where there is a version specified. */ private Set findPluginsWithVersionsSpecified( StringBuilder pomContents, String path ) - throws IOException, XMLStreamException + throws XMLStreamException { Set result = new HashSet<>(); ModifiedPomXMLEventReader pom = newModifiedPomXER( pomContents, path ); diff --git a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 7ea75925bd..0051c56426 100644 --- a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -26,7 +26,6 @@ import javax.xml.stream.XMLStreamException; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -193,10 +192,7 @@ private String resolveSnapshotVersion( Dependency dep ) try { - Artifact depArtifact = - artifactFactory.createDependencyArtifact( dep.getGroupId(), dep.getArtifactId(), - VersionRange.createFromVersionSpec( dep.getVersion() ), - dep.getType(), dep.getClassifier(), dep.getScope() ); + Artifact depArtifact = getHelper().createDependencyArtifact( dep ); resolver.resolve( depArtifact, getProject().getRemoteArtifactRepositories(), localRepository ); lockedVersion = depArtifact.getVersion(); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java index ccf730e49d..516d7bb73b 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; @@ -136,7 +135,7 @@ else if ( "xml".equals( format ) ) } } } - catch ( InvalidVersionSpecificationException | ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException e ) { throw new MavenReportException( e.getMessage(), e ); } @@ -183,4 +182,4 @@ public String getOutputName() return "plugin-updates-report"; } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 84d3222695..d2e7d2a1ac 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -106,8 +107,12 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep throw new MojoExecutionException( "Invalid version range specification: " + version, e ); } - Artifact artifact = artifactFactory.createDependencyArtifact( getProject().getParent().getGroupId(), - getProject().getParent().getArtifactId(), versionRange, "pom", null, null ); + Dependency dependency = new Dependency(); + dependency.setGroupId( getProject().getParent().getGroupId() ); + dependency.setArtifactId( getProject().getParent().getArtifactId() ); + dependency.setVersion( version ); + dependency.setType( "pom" ); + Artifact artifact = getHelper().createDependencyArtifact( dependency ); ArtifactVersion artifactVersion; try diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 811723d46c..790181392d 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -22,8 +22,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -119,20 +117,15 @@ private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project ) { String releaseVersion = versionMatcher.group( 1 ); - VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( releaseVersion ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( "Invalid version range specification: " + version, e ); - } - final MavenProject parent = getProject().getParent(); - Artifact artifact = artifactFactory.createDependencyArtifact( parent.getGroupId(), - parent.getArtifactId(), - versionRange, "pom", null, null ); + + Dependency dependency = new Dependency(); + dependency.setGroupId( parent.getGroupId() ); + dependency.setArtifactId( parent.getArtifactId() ); + dependency.setVersion( releaseVersion ); + dependency.setType( "pom" ); + + Artifact artifact = getHelper().createDependencyArtifact( dependency ); if ( !isIncluded( artifact ) ) { return; diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 51da867a37..f62d22a6ad 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -21,7 +21,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -31,8 +30,6 @@ import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; @@ -40,6 +37,7 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.project.path.PathTranslator; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.apache.maven.wagon.ConnectionException; import org.apache.maven.wagon.ResourceDoesNotExistException; @@ -141,12 +139,7 @@ public class DefaultVersionsHelper */ private final List remotePluginRepositories; - /** - * The artifact factory. - * - * @since 1.0-alpha-3 - */ - private final ArtifactFactory artifactFactory; + private final RepositorySystem repositorySystem; /** * The {@link Log} to send log messages to. @@ -179,7 +172,7 @@ public class DefaultVersionsHelper /** * Constructs a new {@link DefaultVersionsHelper}. * - * @param artifactFactory The artifact factory. + * @param repositorySystem The repositorySystem. * @param artifactResolver Artifact resolver * @param artifactMetadataSource The artifact metadata source to use. * @param remoteArtifactRepositories The remote artifact repositories to consult. @@ -196,14 +189,14 @@ public class DefaultVersionsHelper * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-3 */ - public DefaultVersionsHelper( ArtifactFactory artifactFactory, ArtifactResolver artifactResolver, + public DefaultVersionsHelper( RepositorySystem repositorySystem, ArtifactResolver artifactResolver, ArtifactMetadataSource artifactMetadataSource, List remoteArtifactRepositories, List remotePluginRepositories, ArtifactRepository localRepository, WagonManager wagonManager, Settings settings, String serverId, String rulesUri, Log log, MavenSession mavenSession, PathTranslator pathTranslator ) throws MojoExecutionException { - this.artifactFactory = artifactFactory; + this.repositorySystem = repositorySystem; this.artifactResolver = artifactResolver; this.mavenSession = mavenSession; this.pathTranslator = pathTranslator; @@ -376,25 +369,13 @@ static boolean isClasspathUri(String uri) { return (uri != null && uri.startsWith(CLASSPATH_PROTOCOL + ":")); } - /** - * {@inheritDoc} - */ - public ArtifactFactory getArtifactFactory() - { - return artifactFactory; - } - - /** - * {@inheritDoc} - */ + @Override public Log getLog() { return log; } - /** - * {@inheritDoc} - */ + @Override public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException { @@ -517,6 +498,7 @@ private String showIgnoredVersions( List ignoredVersions ) return buf.toString(); } + @Override public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException { @@ -524,17 +506,13 @@ public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) artifactResolver.resolve( artifact, remoteRepositories, localRepository ); } - /** - * {@inheritDoc} - */ + @Override public VersionComparator getVersionComparator( Artifact artifact ) { return getVersionComparator( artifact.getGroupId(), artifact.getArtifactId() ); } - /** - * {@inheritDoc} - */ + @Override public VersionComparator getVersionComparator( String groupId, String artifactId ) { Rule rule = getBestFitRule( groupId, artifactId ); @@ -603,49 +581,51 @@ protected Rule getBestFitRule( String groupId, String artifactId ) return bestFit; } - /** - * {@inheritDoc} - */ - public Artifact createPluginArtifact( String groupId, String artifactId, VersionRange versionRange ) + @Override + public Artifact createPluginArtifact( String groupId, String artifactId, String version ) { - return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange ); + Plugin plugin = new Plugin(); + plugin.setGroupId( groupId ); + plugin.setArtifactId( artifactId ); + plugin.setVersion( StringUtils.isNotBlank( version) ? version : "[0,]" ); + return repositorySystem.createPluginArtifact( plugin ); } - /** - * {@inheritDoc} - */ - public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, + @Override + public Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional ) { - return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope, - optional ); - } - - /** - * {@inheritDoc} - */ - public Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, + Dependency dependency = new Dependency(); + dependency.setGroupId( groupId ); + dependency.setArtifactId( artifactId ); + dependency.setType( type ); + dependency.setClassifier( classifier ); + dependency.setScope( scope ); + dependency.setOptional( optional ); + dependency.setVersion( StringUtils.isNotBlank( version) ? version : "[0,]" ); + return repositorySystem.createDependencyArtifact( dependency ); + } + + @Override + public Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope ) { - return artifactFactory.createDependencyArtifact( groupId, artifactId, versionRange, type, classifier, scope ); + return createDependencyArtifact( groupId, artifactId, version, type, classifier, scope, false ); } - /** - * {@inheritDoc} - */ + @Override public Artifact createDependencyArtifact( Dependency dependency ) - throws InvalidVersionSpecificationException { - return createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion() == null ? VersionRange.createFromVersionSpec( "[0,]" ) - : VersionRange.createFromVersionSpec( dependency.getVersion() ), - dependency.getType(), dependency.getClassifier(), dependency.getScope(), - dependency.isOptional() ); + if ( StringUtils.isBlank( dependency.getVersion() ) ) + { + dependency = dependency.clone(); + dependency.setVersion( "[,0]" ); + } + + return repositorySystem.createDependencyArtifact( dependency ); } - /** - * {@inheritDoc} - */ + @Override public Set extractArtifacts( Collection mavenProjects ) { Set result = new HashSet<>(); @@ -657,17 +637,13 @@ public Set extractArtifacts( Collection mavenProjects ) return result; } - /** - * {@inheritDoc} - */ + @Override public ArtifactVersion createArtifactVersion( String version ) { return new DefaultArtifactVersion( version ); } - /** - * {@inheritDoc} - */ + @Override public ArtifactVersions lookupArtifactUpdates( Artifact artifact, boolean allowSnapshots, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException @@ -679,12 +655,10 @@ public ArtifactVersions lookupArtifactUpdates( Artifact artifact, boolean allowS return artifactVersions; } - /** - * {@inheritDoc} - */ + @Override public Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException + throws ArtifactMetadataRetrievalException { // Create the request for details collection for parallel lookup... final List> requestsForDetails = @@ -722,28 +696,20 @@ public Map lookupDependenciesUpdates( Set lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException + throws ArtifactMetadataRetrievalException { // Create the request for details collection for parallel lookup... List> requestsForDetails = new ArrayList<>( plugins.size() ); @@ -780,23 +746,19 @@ public Map lookupPluginsUpdates( Set plugi return pluginUpdates; } - /** - * {@inheritDoc} - */ + @Override public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException + throws ArtifactMetadataRetrievalException { String version = plugin.getVersion(); version = version == null ? "LATEST" : version; getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) + " for updates newer than " + version ); - VersionRange versionRange = VersionRange.createFromVersion( version ); - boolean includeSnapshots = allowSnapshots; final ArtifactVersions pluginArtifactVersions = - lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange ), + lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), version ), true ); Set pluginDependencies = new TreeSet<>( new DependencyComparator() ); @@ -810,17 +772,13 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, includeSnapshots ); } - /** - * {@inheritDoc} - */ + @Override public ExpressionEvaluator getExpressionEvaluator( MavenProject project ) { return new VersionsExpressionEvaluator( mavenSession, pathTranslator, project ); } - /** - * {@inheritDoc} - */ + @Override public Map getVersionPropertiesMap( MavenProject project, Property[] propertyDefinitions, String includeProperties, String excludeProperties, @@ -908,15 +866,8 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr { for ( Dependency dependency : dependencies ) { - try - { - getLog().debug( "Property ${" + property.getName() + "}: Adding association to " + dependency ); - builder.addAssociation( this.createDependencyArtifact( dependency ), false ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } + getLog().debug( "Property ${" + property.getName() + "}: Adding association to " + dependency ); + builder.addAssociation( this.createDependencyArtifact( dependency ), false ); } } try diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 2f9ea4e084..03baccf7a4 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -441,8 +441,8 @@ else if ( "version".equals( elementName ) ) { return null; } - return helper.createDependencyArtifact( groupId, artifactId, VersionRange.createFromVersion( version ), "pom", - null, null, false ); + return helper.createDependencyArtifact( groupId, artifactId, version , "pom", + null, null ); } /** @@ -1030,13 +1030,12 @@ private static void addPluginAssociations( VersionsHelper helper, ExpressionEval artifactId = (String) expressionEvaluator.evaluate( artifactId ); } // might as well capture the current value - VersionRange versionRange = - VersionRange.createFromVersion( (String) expressionEvaluator.evaluate( plugin.getVersion() ) ); - property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionRange ), + String evaluatedVersion = (String) expressionEvaluator.evaluate( plugin.getVersion() ); + property.addAssociation( helper.createPluginArtifact( groupId, artifactId, evaluatedVersion ), true ); if ( !propertyRef.equals( version ) ) { - addBounds( property, version, propertyRef, versionRange.toString() ); + addBounds( property, version, propertyRef ); } } } @@ -1087,13 +1086,12 @@ private static void addReportPluginAssociations( VersionsHelper helper, Expressi artifactId = (String) expressionEvaluator.evaluate( artifactId ); } // might as well capture the current value - VersionRange versionRange = - VersionRange.createFromVersion( (String) expressionEvaluator.evaluate( plugin.getVersion() ) ); - property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionRange ), + String versionEvaluated = (String) expressionEvaluator.evaluate( plugin.getVersion() ); + property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionEvaluated ), true ); if ( !propertyRef.equals( version ) ) { - addBounds( property, version, propertyRef, versionRange.toString() ); + addBounds( property, version, propertyRef ); } } } @@ -1143,9 +1141,8 @@ private static void addDependencyAssocations( VersionsHelper helper, ExpressionE artifactId = (String) expressionEvaluator.evaluate( artifactId ); } // might as well capture the current value - VersionRange versionRange = - VersionRange.createFromVersion( (String) expressionEvaluator.evaluate( dependency.getVersion() ) ); - property.addAssociation( helper.createDependencyArtifact( groupId, artifactId, versionRange, + String versionEvaluated = (String) expressionEvaluator.evaluate( dependency.getVersion() ); + property.addAssociation( helper.createDependencyArtifact( groupId, artifactId, versionEvaluated, dependency.getType(), dependency.getClassifier(), dependency.getScope(), @@ -1153,7 +1150,7 @@ private static void addDependencyAssocations( VersionsHelper helper, ExpressionE usePluginRepositories ); if ( !propertyRef.equals( version ) ) { - addBounds( property, version, propertyRef, versionRange.toString() ); + addBounds( property, version, propertyRef ); } } } @@ -1161,8 +1158,7 @@ private static void addDependencyAssocations( VersionsHelper helper, ExpressionE } } - private static void addBounds( PropertyVersionsBuilder builder, String rawVersionRange, String propertyRef, - String evaluatedVersionRange ) + private static void addBounds( PropertyVersionsBuilder builder, String rawVersionRange, String propertyRef ) { Pattern lowerBound = Pattern.compile( "([(\\[])([^,]*)," + RegexUtils.quote( propertyRef ) + "([)\\]])" ); Pattern upperBound = Pattern.compile( "([(\\[])" + RegexUtils.quote( propertyRef ) + ",([^,]*)([)\\]])" ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index a72c395dd0..9cd8fa8269 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -25,13 +25,10 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; @@ -77,15 +74,7 @@ public interface VersionsHelper VersionComparator getVersionComparator( String groupId, String artifactId ); /** - * Returns the artifact factory to use. - * - * @return the artifact factory to use. - * @since 1.0-alpha-3 - */ - ArtifactFactory getArtifactFactory(); - - /** - * Shorthand method for getArtifactFactory().createPluginArtifact(...). + * Shorthand method for repositorySystem.createPluginArtifact(...). * * @param groupId The group Id. * @param artifactId The artifact Id. @@ -93,10 +82,10 @@ public interface VersionsHelper * @return the corresponding plugin artifact. * @since 1.0-alpha-3 */ - Artifact createPluginArtifact( String groupId, String artifactId, VersionRange version ); + Artifact createPluginArtifact( String groupId, String artifactId, String version ); /** - * Shorthand method for getArtifactFactory().createDependencyArtifact(...). + * Shorthand method for repositorySystem.createDependencyArtifact(...). * * @param groupId The group id. * @param artifactId The artifact id. @@ -108,7 +97,7 @@ public interface VersionsHelper * @return The corresponding dependency artifact. * @since 1.0-alpha-3 */ - Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange version, String type, + Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional ); /** @@ -116,27 +105,25 @@ Artifact createDependencyArtifact( String groupId, String artifactId, VersionRan * * @param groupId The group id. * @param artifactId The artifact id. - * @param versionRange The version range. + * @param version The version. * @param type The type. * @param classifier The classifier. * @param scope The scope. * @return The corresponding dependency artifact. * @since 1.0-beta-1 */ - Artifact createDependencyArtifact( String groupId, String artifactId, VersionRange versionRange, String type, + Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope ); /** - * Shorthand method for getArtifactFactory().createDependencyArtifact(...) which extracts the + * Shorthand method for repositorySystem.createDependencyArtifact(...) which extracts the * parameters from the Dependency instance. * * @param dependency The dependency to create the artifact for. * @return The corresponding dependency artifact. - * @throws InvalidVersionSpecificationException if the version specified in the dependency is invalid. * @since 1.0-alpha-3 */ - Artifact createDependencyArtifact( Dependency dependency ) - throws InvalidVersionSpecificationException; + Artifact createDependencyArtifact( Dependency dependency ); /** * Takes a {@link List} of {@link org.apache.maven.project.MavenProject} instances and converts it into a @@ -190,12 +177,11 @@ ArtifactVersions lookupArtifactUpdates( Artifact artifact, boolean allowSnapshot * @param usePluginRepositories Search the plugin repositories. * @return A map, keyed by dependency, with values of type {@link org.codehaus.mojo.versions.api.ArtifactVersions}. * @throws ArtifactMetadataRetrievalException When things go wrong. - * @throws InvalidVersionSpecificationException if something goes wrong. * @since 1.0-beta-1 */ Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException; + throws ArtifactMetadataRetrievalException; /** * Creates an {@link org.codehaus.mojo.versions.api.ArtifactVersions} instance from a dependency. @@ -204,11 +190,10 @@ Map lookupDependenciesUpdates( Set dep * @param usePluginRepositories Search the plugin repositories. * @return The details of updates to the dependency. * @throws ArtifactMetadataRetrievalException When things go wrong. - * @throws InvalidVersionSpecificationException if something goes wrong. * @since 1.0-beta-1 */ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException; + throws ArtifactMetadataRetrievalException; /** * Looks up the updates for a set of plugins. @@ -217,11 +202,10 @@ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePlug * @param allowSnapshots Include snapshots in the list of updates. * @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.PluginUpdatesDetails}. * @throws ArtifactMetadataRetrievalException When things go wrong. - * @throws InvalidVersionSpecificationException if something goes wrong. * @since 1.0-beta-1 */ Map lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException; + throws ArtifactMetadataRetrievalException; /** * Looks up the updates for a plugin. @@ -230,11 +214,10 @@ Map lookupPluginsUpdates( Set plugins, boo * @param allowSnapshots Include snapshots in the list of updates. * @return The plugin update details. * @throws ArtifactMetadataRetrievalException When things go wrong. - * @throws InvalidVersionSpecificationException if a version is invalid. * @since 1.0-beta-1 */ PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException, InvalidVersionSpecificationException; + throws ArtifactMetadataRetrievalException; /** * Returns an {@link ExpressionEvaluator} for the specified project. diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 9a3c6a13ca..f55ad9fee1 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.DefaultArtifactFactory; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; @@ -33,6 +32,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.project.path.DefaultPathTranslator; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.apache.maven.execution.MavenSession; import org.codehaus.mojo.versions.Property; @@ -220,7 +220,7 @@ private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSou // }; DefaultVersionsHelper helper = - new DefaultVersionsHelper( new DefaultArtifactFactory(), new DefaultArtifactResolver(), metadataSource, new ArrayList(), + new DefaultVersionsHelper( lookup( RepositorySystem.class ), new DefaultArtifactResolver(), metadataSource, new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ), From ea9f98d3af6cc5e599a46c46f7c781d6c96cd4b7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 15 Aug 2022 12:26:19 +0200 Subject: [PATCH 080/441] Fix test after #624 --- .../mojo/versions/UpdateParentMojoTest.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 8ba1f990f7..e5a25b1d38 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -1,45 +1,48 @@ package org.codehaus.mojo.versions; +import javax.xml.stream.XMLStreamException; + +import java.util.Collections; + import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; +import org.apache.maven.repository.RepositorySystem; import org.junit.Test; -import javax.xml.stream.XMLStreamException; -import java.util.Collections; - import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class UpdateParentMojoTest { +public class UpdateParentMojoTest +{ @Test - public void testArtifactIdDoesNotExist() throws MojoExecutionException, XMLStreamException, MojoFailureException { - UpdateParentMojo mojo = new UpdateParentMojo() { + public void testArtifactIdDoesNotExist() throws MojoExecutionException, XMLStreamException, MojoFailureException + { + UpdateParentMojo mojo = new UpdateParentMojo() + { { project = new MavenProject(); - project.setParent(new MavenProject()); + project.setParent( new MavenProject() ); reactorProjects = Collections.emptyList(); forceUpdate = true; - artifactFactory = mock(ArtifactFactory.class); - when(artifactFactory.createDependencyArtifact(anyString(), anyString(), any(VersionRange.class), - anyString(), anyString(), anyString())) - .thenReturn(new ProjectArtifact(project)); + repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createDependencyArtifact( any() ) ) + .thenReturn( new ProjectArtifact( project ) ); } - protected ArtifactVersion findLatestVersion(Artifact artifact, VersionRange versionRange, - Boolean allowingSnapshots, boolean usePluginRepositories) { + protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, + Boolean allowingSnapshots, boolean usePluginRepositories ) + { return null; } }; - mojo.update(null); + mojo.update( null ); } } From f47481966c143363572c8f6226a06ff541441f1e Mon Sep 17 00:00:00 2001 From: Christoph Linder Date: Mon, 27 Jun 2022 23:41:14 +0200 Subject: [PATCH 081/441] fixes #318 implement includes/excludes for dependencies fixes #318 implement includes/excludes for dependencies apply maven codestyle fixes #318 implement includes/excludes for dependencies bump @since 2.12.0 fixes #318 implement includes/excludes for dependencies make ITs work on windows fixes #318 implement includes/excludes for dependencies switch to List instead of splitting a list-style string myself fixes #318 implement includes/excludes for dependencies migrate ITs to test.properties since maven runner does some magic with "," in invoker.goals with no other workaround fix some descriptions fixes #318 implement includes/excludes for dependencies add IT for multiple comma-separated inclusion filters --- .../invoker.properties | 1 + .../pom.xml | 31 ++ .../test.properties | 1 + .../verify.groovy | 10 + .../invoker.properties | 1 + .../pom.xml | 31 ++ .../test.properties | 1 + .../verify.groovy | 11 + .../invoker.properties | 1 + .../pom.xml | 31 ++ .../test.properties | 1 + .../verify.groovy | 11 + .../invoker.properties | 1 + .../pom.xml | 31 ++ .../test.properties | 2 + .../verify.groovy | 10 + .../invoker.properties | 1 + .../pom.xml | 57 ++++ .../test.properties | 2 + .../verify.groovy | 11 + .../invoker.properties | 1 + .../pom.xml | 50 ++++ .../test.properties | 2 + .../verify.groovy | 11 + .../DisplayDependencyUpdatesMojo.java | 157 ++++++++-- .../versions/filtering/DependencyFilter.java | 67 +++++ .../filtering/NullAwareWildcardMatcher.java | 22 ++ .../versions/filtering/TokenizedMatcher.java | 107 +++++++ .../versions/filtering/WildcardMatcher.java | 95 +++++++ .../mojo/versions/DependencyBuilder.java | 133 +++++++++ .../codehaus/mojo/versions/HasGAVMatcher.java | 50 ++++ .../filtering/DependencyFilterTest.java | 205 ++++++++++++++ .../filtering/TokenizedMatcherTest.java | 167 +++++++++++ .../filtering/WildcardMatcherTest.java | 267 ++++++++++++++++++ 34 files changed, 1563 insertions(+), 17 deletions(-) create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties create mode 100644 src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy create mode 100644 src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java create mode 100644 src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java create mode 100644 src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java create mode 100644 src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java create mode 100644 src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java create mode 100644 src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java create mode 100644 src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java create mode 100644 src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java create mode 100644 src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml new file mode 100644 index 0000000000..bb408cf5db --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyExcludes + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyExcludes + exclude a set of dependencies + http://localhost/ + + + localhost + dummy-api + 1.0 + provided + + + localhost + dummy-impl + 1.0 + + + localhost + latest-versions-api + 2.0.8 + test + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties new file mode 100644 index 0000000000..a60d6f77e9 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties @@ -0,0 +1 @@ +dependencyExcludes=*:*:*:*:*:compile,*:*:*:*:*:test diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy new file mode 100644 index 0000000000..aadb8bd46a --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy @@ -0,0 +1,10 @@ +def buildLog = new File( basedir, "build.log" ) + +assert buildLog.text.contains( """ +[INFO] The following dependencies in Dependencies have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml new file mode 100644 index 0000000000..e0dd9d9543 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyIncludes-multi + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyIncludes-multi + include a set of dependencies using multiple filters + http://localhost/ + + + localhost + dummy-api + 1.0 + + + localhost + dummy-impl + 1.0 + test + + + localhost + latest-versions-api + 2.0.8 + provided + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties new file mode 100644 index 0000000000..e09c93220e --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties @@ -0,0 +1 @@ +dependencyIncludes=*:dummy-api,*:dummy-impl diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy new file mode 100644 index 0000000000..4845c5558e --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy @@ -0,0 +1,11 @@ +def buildLog = new File(basedir, "build.log") + +assert buildLog.text.contains(""" +[INFO] The following dependencies in Dependencies have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml new file mode 100644 index 0000000000..6b893ec38b --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyIncludes + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyIncludes + include a set of dependencies + http://localhost/ + + + localhost + dummy-api + 1.0 + + + localhost + dummy-impl + 1.0 + test + + + localhost + latest-versions-api + 2.0.8 + provided + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties new file mode 100644 index 0000000000..7c76baa2cd --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties @@ -0,0 +1 @@ +dependencyIncludes=localhost:dummy-*:*:*:*:* diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy new file mode 100644 index 0000000000..4845c5558e --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy @@ -0,0 +1,11 @@ +def buildLog = new File(basedir, "build.log") + +assert buildLog.text.contains(""" +[INFO] The following dependencies in Dependencies have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml new file mode 100644 index 0000000000..24b3d0d189 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes + combine dependency inclusion and exclusion + http://localhost/ + + + localhost + dummy-api + 1.0 + + + localhost + dummy-impl + 1.0 + test + + + localhost + latest-versions-api + 2.0.8 + provided + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties new file mode 100644 index 0000000000..4337c8a82e --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties @@ -0,0 +1,2 @@ +dependencyIncludes=localhost:dummy-*:*:*:*:* +dependencyExcludes=*:dummy-impl:*:*:* diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy new file mode 100644 index 0000000000..347f310aee --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy @@ -0,0 +1,10 @@ +def buildLog = new File(basedir, "build.log") + +assert buildLog.text.contains(""" +[INFO] The following dependencies in Dependencies have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml new file mode 100644 index 0000000000..78561b399d --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyManagementExcludes + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyManagementExcludes + exclude dependencies from dependencyManagement + http://localhost/ + + + localhost + dummy-api + 2.0 + + + localhost + dummy-impl + 2.0 + + + localhost + latest-versions-api + 2.0.11 + + + + + + localhost + dummy-api + 1.0 + + + localhost + dummy-impl + 1.0 + test + + + localhost + latest-versions-api + 2.0.8 + provided + + + localhost + dummy-api-impl-bom-pom + 1.0 + pom + import + + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties new file mode 100644 index 0000000000..6093047d14 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties @@ -0,0 +1,2 @@ +processDependencies=false +dependencyManagementExcludes=*:*:*:*:*:provided,*:*:*:*:*:import diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy new file mode 100644 index 0000000000..df3e5a07e1 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy @@ -0,0 +1,11 @@ +def buildLog = new File(basedir, "build.log") + +assert buildLog.text.contains(""" +[INFO] The following dependencies in Dependency Management have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties new file mode 100644 index 0000000000..d065873965 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml new file mode 100644 index 0000000000..50bd3430cf --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml @@ -0,0 +1,50 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-318-dependencyManagementIncludes + 1.0 + pom + it-display-dependency-updates-issue-318-dependencyManagementIncludes + include dependencies from dependencyManagement + http://localhost/ + + + localhost + dummy-api + 2.0 + + + localhost + dummy-impl + 2.0 + + + localhost + latest-versions-api + 2.0.11 + + + + + + localhost + dummy-api + 1.0 + + + localhost + dummy-impl + 1.0 + test + + + localhost + latest-versions-api + 2.0.8 + provided + + + + diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties new file mode 100644 index 0000000000..04de1a1950 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties @@ -0,0 +1,2 @@ +processDependencies=false +dependencyManagementIncludes=*:*:*:*:*:null,*:*:*:*:*:test diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy new file mode 100644 index 0000000000..df3e5a07e1 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy @@ -0,0 +1,11 @@ +def buildLog = new File(basedir, "build.log") + +assert buildLog.text.contains(""" +[INFO] The following dependencies in Dependency Management have newer versions: +[INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 +[INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 +[INFO] +[INFO] ------------------------------------------------------------------------ +""".replaceAll( "\n", System.lineSeparator() ) ) + +return true diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 6094d7cae3..93358dde98 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -19,6 +19,16 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeSet; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -33,20 +43,12 @@ import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.UpdateScope; +import org.codehaus.mojo.versions.filtering.DependencyFilter; +import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.util.StringUtils; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeSet; - -import javax.xml.stream.XMLStreamException; - /** * Displays all dependencies that have newer versions available. * It will also display dependencies which are used by a plugin or @@ -90,6 +92,50 @@ public class DisplayDependencyUpdatesMojo @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) private boolean processDependencyManagementTransitive; + /** + * Only take these artifacts into consideration. + *

+ * Comma-separated list of extended GAV patterns. + * + *

+ * Extended GAV: groupId:artifactId:version:type:classifier:scope + *

+ *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: "mygroup:artifact:*,*:*:*:*:*:compile" + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "dependencyManagementIncludes", defaultValue = WildcardMatcher.WILDCARD ) + private List dependencyManagementIncludes; + + /** + * Exclude these artifacts from consideration. + *

+ * Comma-separated list of extended GAV patterns. + * + *

+ * Extended GAV: groupId:artifactId:version:type:classifier:scope + *

+ *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system" + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "dependencyManagementExcludes" ) + private List dependencyManagementExcludes; + /** * Whether to process the dependencies section of the project. * @@ -98,6 +144,50 @@ public class DisplayDependencyUpdatesMojo @Parameter( property = "processDependencies", defaultValue = "true" ) private boolean processDependencies; + /** + * Only take these artifacts into consideration. + *

+ * Comma-separated list of extended GAV patterns. + * + *

+ * Extended GAV: groupId:artifactId:version:type:classifier:scope + *

+ *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: "mygroup:artifact:*,*:*:*:*:*:compile" + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "dependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + private List dependencyIncludes; + + /** + * Exclude these artifacts from consideration. + *

+ * Comma-separated list of extended GAV patterns. + * + *

+ * Extended GAV: groupId:artifactId:version:type:classifier:scope + *

+ *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system" + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "dependencyExcludes" ) + private List dependencyExcludes; + /** * Whether to process the dependencies sections of plugins. * @@ -117,7 +207,7 @@ public class DisplayDependencyUpdatesMojo /** * Whether to allow the major version number to be changed. * You need to set {@link #allowAnyUpdates} to false to - * get this configuration gets control. + * get this configuration gets control. * @since 2.5 */ @Parameter(property = "allowMajorUpdates", defaultValue = "true") @@ -126,7 +216,7 @@ public class DisplayDependencyUpdatesMojo /** * Whether to allow the minor version number to be changed. * You need to set {@link #allowMajorUpdates} to false to - * get this configuration gets control. + * get this configuration gets control. * * @since 2.5 */ @@ -136,7 +226,7 @@ public class DisplayDependencyUpdatesMojo /** * Whether to allow the incremental version number to be changed. * You need to set {@link #allowMinorUpdates} to false to - * get this configuration gets control. + * get this configuration gets control. * * @since 2.5 */ @@ -292,6 +382,7 @@ public boolean isVerbose() * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#execute() * @since 1.0-alpha-1 */ + @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -306,7 +397,7 @@ public void execute() for ( Dependency dependency : dependenciesFromPom ) { getLog().debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() - + ":" + dependency.getVersion() ); + + ":" + dependency.getVersion() + ":" + dependency.getScope() ); if ( dependency.getVersion() == null ) { // get parent and get the information from there. @@ -371,11 +462,15 @@ public void execute() { if ( isProcessingDependencyManagement() ) { + dependencyManagement = filterDependencyManagementIncludes( dependencyManagement ); + logUpdates( getHelper().lookupDependenciesUpdates( dependencyManagement, false ), "Dependency Management" ); } if ( isProcessingDependencies() ) { + dependencies = filterDependencyIncludes( dependencies ); + logUpdates( getHelper().lookupDependenciesUpdates( dependencies, false ), "Dependencies" ); } if ( isProcessPluginDependenciesInDependencyManagement() ) @@ -394,6 +489,33 @@ public void execute() } } + private Set filterDependencyIncludes(Set dependencies) { + return filterDependencies(dependencies, dependencyIncludes, dependencyExcludes, "dependencies"); + } + + private Set filterDependencyManagementIncludes(Set dependencyManagement) { + return filterDependencies(dependencyManagement, + dependencyManagementIncludes, dependencyManagementExcludes, "dependecyManagement"); + } + + private Set filterDependencies( + Set dependencies, + List includes, + List excludes, + String section + ) { + DependencyFilter includeDeps = DependencyFilter.parseFrom(includes); + DependencyFilter excludeDeps = DependencyFilter.parseFrom(excludes); + + getLog().debug(String.format("parsed includes in %s: %s -> %s", section, includes, includeDeps )); + getLog().debug(String.format("parsed excludes in %s: %s -> %s", section, excludes, excludeDeps )); + + Set onlyIncludes = includeDeps.retainingIn(dependencies); + Set filtered = excludeDeps.removingFrom(onlyIncludes); + + return filtered; + } + private DependencyManagement getProjectDependencyManagement(MavenProject project) { if (processDependencyManagementTransitive) { return project.getDependencyManagement(); @@ -493,9 +615,9 @@ private void logUpdates( Map updates, String secti } logLine( false, "" ); } - } - - + } + + if ( withUpdates.isEmpty() ) { if ( !usingCurrent.isEmpty() ) @@ -524,6 +646,7 @@ private void logUpdates( Map updates, String secti * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ + @Override protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java new file mode 100644 index 0000000000..af021add5f --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java @@ -0,0 +1,67 @@ +package org.codehaus.mojo.versions.filtering; + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.utils.DependencyComparator; + +public class DependencyFilter +{ + + private final String pattern; + private final List matchers; + + DependencyFilter( String pattern, List matchers ) + { + this.pattern = pattern; + this.matchers = matchers; + } + + public static DependencyFilter parseFrom( List dependencies ) + { + List matchers = dependencies.stream() + .map( TokenizedMatcher::parse ) + .collect( Collectors.toList() ); + + String debugPattern = String.join( ",", dependencies ); + + return new DependencyFilter( debugPattern, matchers ); + } + + private static Predicate not( Predicate predicate ) + { + return x -> !predicate.test( x ); + } + + @Override + public String toString() + { + return String.format( "%s{%s}", getClass().getSimpleName(), pattern ); + } + + public Set retainingIn( Set dependencies ) + { + return filterBy( dependencies, this::matchersMatch ); + } + + public Set removingFrom( Set dependencies ) + { + return filterBy( dependencies, not( this::matchersMatch ) ); + } + + private boolean matchersMatch( Dependency dependency ) + { + return matchers.stream().anyMatch( m -> m.test( dependency ) ); + } + + private TreeSet filterBy( Set dependencies, Predicate predicate ) + { + return dependencies.stream() + .filter( predicate ) + .collect( Collectors.toCollection( () -> new TreeSet<>( new DependencyComparator() ) ) ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java b/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java new file mode 100644 index 0000000000..dfa8fef64c --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java @@ -0,0 +1,22 @@ +package org.codehaus.mojo.versions.filtering; + +public class NullAwareWildcardMatcher extends WildcardMatcher +{ + public static final String NULL_KEYWORD = "null"; + + public NullAwareWildcardMatcher( String pattern ) + { + super( pattern ); + } + + @Override + public boolean test( String token ) + { + if ( NULL_KEYWORD.equals( getPattern() ) ) + { + return token == null; + } + + return super.test( token ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java b/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java new file mode 100644 index 0000000000..336c9f7e82 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java @@ -0,0 +1,107 @@ +package org.codehaus.mojo.versions.filtering; + +import java.util.Collections; +import java.util.EnumMap; +import java.util.Map; +import java.util.function.Function; +import java.util.function.Predicate; + +import org.apache.maven.model.Dependency; + +public class TokenizedMatcher implements Predicate +{ + public enum Tokens + { + GROUP_ID( Dependency::getGroupId ), + ARTIFACT_ID( Dependency::getArtifactId ), + VERSION( Dependency::getVersion ), + TYPE( Dependency::getType ), + CLASSIFIER( Dependency::getClassifier ), + SCOPE( Dependency::getScope ); + + private final Function tokenExtractor; + + Tokens( Function tokenExtractor ) + { + this.tokenExtractor = tokenExtractor; + } + + public Function getTokenExtractor() + { + return tokenExtractor; + } + } + + private final Map> matchers; + + private TokenizedMatcher( Map> matchers ) + { + this.matchers = matchers; + } + + @Override + public boolean test( Dependency dependency ) + { + for ( Tokens token : Tokens.values() ) + { + String tokenValue = token.getTokenExtractor().apply( dependency ); + + Predicate matcher = matchers.get( token ); + boolean matches = matcher.test( tokenValue ); + + if ( !matches ) + { + return false; + } + } + + return true; + } + + public static TokenizedMatcher parse( String pattern ) + { + EnumMap> matchers = new EnumMap<>( Tokens.class ); + + String[] split = pattern == null + ? new String[0] + : pattern.split( ":" ); + + String groupIdPattern = split.length >= 1 + ? split[0] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.GROUP_ID, WildcardMatcher.parse( groupIdPattern ) ); + + String artifactIdPattern = split.length >= 2 + ? split[1] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.ARTIFACT_ID, WildcardMatcher.parse( artifactIdPattern ) ); + + String versionPattern = split.length >= 3 + ? split[2] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.VERSION, WildcardMatcher.parse( versionPattern ) ); + + String typePattern = split.length >= 4 + ? split[3] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.TYPE, WildcardMatcher.parse( typePattern ) ); + + String classifierPattern = split.length >= 5 + ? split[4] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.CLASSIFIER, new NullAwareWildcardMatcher( classifierPattern ) ); + + String scopePattern = split.length >= 6 + ? split[5] + : WildcardMatcher.WILDCARD; + matchers.put( Tokens.SCOPE, new NullAwareWildcardMatcher( scopePattern ) ); + + return new TokenizedMatcher( Collections.unmodifiableMap( matchers ) ); + } + + @Override + public String toString() + { + return String.format( "%s{%s}", getClass().getSimpleName(), matchers ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java b/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java new file mode 100644 index 0000000000..f63f5e88bc --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java @@ -0,0 +1,95 @@ +package org.codehaus.mojo.versions.filtering; + +import java.util.function.Predicate; + +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; + +public class WildcardMatcher implements Predicate +{ + public static final String WILDCARD = "*"; + + private final String pattern; + + protected WildcardMatcher( String pattern ) + { + this.pattern = pattern; + } + + public static WildcardMatcher parse( String pattern ) + { + return new WildcardMatcher( pattern ); + } + + @Override + public boolean test( String token ) + { + if ( token == null ) + { + return WILDCARD.equals( pattern ); + } + + boolean matches; + + // support full wildcard and implied wildcard + if ( WILDCARD.equals( pattern ) || pattern.isEmpty() ) + { + matches = true; + } + // support contains wildcard + else if ( pattern.startsWith( WILDCARD ) && pattern.endsWith( WILDCARD ) ) + { + String contains = pattern.substring( 1, pattern.length() - 1 ); + + matches = token.contains( contains ); + } + // support leading wildcard + else if ( pattern.startsWith( WILDCARD ) ) + { + matches = token.endsWith( pattern.substring( 1 ) ); + } + // support trailing wildcard + else if ( pattern.endsWith( WILDCARD ) ) + { + String prefix = pattern.substring( 0, pattern.length() - 1 ); + + matches = token.startsWith( prefix ); + } + // support versions range + else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" ) ) + { + matches = isVersionIncludedInRange( token, pattern ); + } + // support exact match + else + { + matches = token.equals( pattern ); + } + + return matches; + } + + private boolean isVersionIncludedInRange( final String version, final String range ) + { + try + { + return VersionRange.createFromVersionSpec( range ).containsVersion( new DefaultArtifactVersion( version ) ); + } + catch ( InvalidVersionSpecificationException e ) + { + return false; + } + } + + public String getPattern() + { + return pattern; + } + + @Override + public String toString() + { + return String.format( "%s{%s}", getClass().getSimpleName(), pattern ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java b/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java new file mode 100644 index 0000000000..05bf3817b1 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java @@ -0,0 +1,133 @@ +package org.codehaus.mojo.versions; + +import org.apache.maven.model.Dependency; + +public class DependencyBuilder +{ + + public String getGroupId() + { + return groupId; + } + + public DependencyBuilder withGroupId( String groupId ) + { + this.groupId = groupId; + return this; + } + + public String getArtifactId() + { + return artifactId; + } + + public DependencyBuilder withArtifactId( String artifactId ) + { + this.artifactId = artifactId; + return this; + } + + public String getVersion() + { + return version; + } + + public DependencyBuilder withVersion( String version ) + { + this.version = version; + return this; + } + + public String getType() + { + return type; + } + + public DependencyBuilder withType( String type ) + { + this.type = type; + return this; + } + + public String getClassifier() + { + return classifier; + } + + public DependencyBuilder withClassifier( String classifier ) + { + this.classifier = classifier; + return this; + } + + public String getScope() + { + return scope; + } + + public DependencyBuilder withScope( String scope ) + { + this.scope = scope; + return this; + } + + private String groupId = null; + private String artifactId = null; + private String version = null; + private String type = null; + private String classifier = null; + private String scope = null; + + public static DependencyBuilder newBuilder() + { + return new DependencyBuilder(); + } + + public static DependencyBuilder newBuilder( String groupId, String artifactId, String version, String type, + String classifier, String scope ) + { + return newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ) + .withType( type ) + .withClassifier( classifier ) + .withScope( scope ); + } + + public static DependencyBuilder newBuilder( String groupId, String artifactId, String version ) + { + return newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ); + } + + public static Dependency dependencyWith( String groupId, String artifactId, String version ) + { + return newBuilder( groupId, artifactId, version ) + .build(); + } + + public static Dependency dependencyWith( String groupId, String artifactId, String version, String type, + String classifier, String scope ) + { + return newBuilder( groupId, artifactId, version, type, classifier, scope ) + .build(); + } + + + public Dependency build() + { + Dependency dep = new Dependency(); + dep.setGroupId( groupId ); + dep.setArtifactId( artifactId ); + dep.setVersion( version ); + dep.setType( type ); + dep.setClassifier( classifier ); + dep.setScope( scope ); + + return dep; + } + +} diff --git a/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java b/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java new file mode 100644 index 0000000000..dda261a64f --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java @@ -0,0 +1,50 @@ +package org.codehaus.mojo.versions; + +import java.util.Objects; + +import org.apache.maven.model.Dependency; +import org.hamcrest.Description; +import org.hamcrest.TypeSafeMatcher; + +/** + * Hamcrest-Matcher that matches a {@link Dependency} GAV + */ +public class HasGAVMatcher extends TypeSafeMatcher +{ + private final String groupId; + private final String artifactId; + private final String version; + + public HasGAVMatcher( String groupId, String artifactId, String version ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + } + + public static HasGAVMatcher hasGAVOf( Dependency dependency ) + { + return hasGAV( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ); + } + + public static HasGAVMatcher hasGAV( String groupId, String artifactId, String version ) + { + return new HasGAVMatcher( groupId, artifactId, version ); + } + + @Override + protected boolean matchesSafely( Dependency item ) + { + boolean result = Objects.equals( groupId, item.getGroupId() ) + && Objects.equals( artifactId, item.getArtifactId() ) + && Objects.equals( version, item.getVersion() ); + + return result; + } + + @Override + public void describeTo( Description description ) + { + description.appendText( String.format( "has GAV %s:%s:%s", groupId, artifactId, version ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java new file mode 100644 index 0000000000..5f3a6c69e1 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -0,0 +1,205 @@ +package org.codehaus.mojo.versions.filtering; + +import java.util.HashSet; +import java.util.Set; + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.DependencyBuilder; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static java.util.Arrays.asList; +import static org.codehaus.mojo.versions.HasGAVMatcher.hasGAV; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; + +@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) +class DependencyFilterTest +{ + + @Nested + class RemoveFromTest + { + private final Set input = new HashSet<>( asList( + DependencyBuilder.dependencyWith( "foo", "bar", "1" ), + DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), + DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) + ) ); + + @Test + void removes_excluded_deps_with_exact_match() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); + + Set actual = exclusions.removingFrom( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ) + ) + ); + } + + @Test + void removes_excluded_deps_with_wildcard_in_version() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:*" ) ); + + Set actual = exclusions.removingFrom( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ) + ) + ); + } + + @Test + void removes_excluded_deps_with_wildcard_in_groupId() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:*:*" ) ); + + Set actual = exclusions.removingFrom( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ) + ) + ); + } + + @Test + void removes_excluded_deps_with_all_wildcards() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); + + Set actual = exclusions.removingFrom( input ); + + assertThat( + actual, + empty() + ); + } + + @Test + void removes_multiple_patterns() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( + "*:my-api", + "*:my-impl" + ) ); + + Set actual = exclusions.removingFrom( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ) + ) + ); + } + + } + + @Nested + class RetainingInTest + { + private final Set input = new HashSet<>( asList( + DependencyBuilder.dependencyWith( "foo", "bar", "1" ), + DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), + DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) + ) ); + + @Test + void retains_only_deps_with_exact_match() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); + + Set actual = exclusions.retainingIn( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-impl", "3" ) + ) + ); + } + + @Test + void retains_only_deps_matching_wildcard_in_version() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-api:*" ) ); + + Set actual = exclusions.retainingIn( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ) + ) + ); + } + + @Test + void retains_only_deps_with_multiple_wildcards() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-*:*" ) ); + + Set actual = exclusions.retainingIn( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) + ); + } + + @Test + void retains_all_on_all_wildcards() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); + + Set actual = exclusions.retainingIn( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) + ); + } + + + @Test + void retains_multiple_patterns() + { + DependencyFilter exclusions = DependencyFilter.parseFrom( asList( + "*:my-api", + "*:my-impl" + ) ); + + Set actual = exclusions.retainingIn( input ); + + assertThat( + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) + ); + } + } + +} diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java new file mode 100644 index 0000000000..02102d6703 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java @@ -0,0 +1,167 @@ +package org.codehaus.mojo.versions.filtering; + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.DependencyBuilder; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) +class TokenizedMatcherTest +{ + + @Nested + class ExactMatchPattern + { + + private final TokenizedMatcher matcher = TokenizedMatcher + .parse( "group:artifact:1.0:jar:tests:compile" ); + + + @Test + void accepts_exact_match() + { + Dependency input = DependencyBuilder.dependencyWith( + "group", + "artifact", + "1.0", + "jar", + "tests", + "compile" ); + + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + + @ParameterizedTest + @CsvSource( { + "xxxxx, artifact, 1.0, jar, tests, compile", + "group, xxxxxxxx, 1.0, jar, tests, compile", + "group, artifact, xxx, jar, tests, compile", + "group, artifact, 1.0, xxx, tests, compile", + "group, artifact, 1.0, jar, xxxxx, compile", + "group, artifact, 1.0, jar, tests, xxxxxxx", + } ) + void rejects_differing_fields( + String group, String artifact, String version, String type, String classifier, String scope + ) + { + + Dependency input = DependencyBuilder.dependencyWith( + group, + artifact, + version, + type, + classifier, + scope ); + + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + } + + @Nested + class WildcardPattern + { + + @Test + void accepts_wildcards() + { + Dependency input = DependencyBuilder.dependencyWith( + "foo", + "my-api", + "foo", + "foo", + "foo", + "foo" ); + + TokenizedMatcher matcher = TokenizedMatcher + .parse( "*:my-api" ); + + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @Nested + class NullClassifier + { + private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( + "foo", + "foo", + "foo", + "foo", + "foo", + "foo" ); + + private final TokenizedMatcher matcher = TokenizedMatcher + .parse( "*:*:*:*:null:*" ); + + @Test + void accepts_null_scope() + { + Dependency input = depBuilder.withClassifier( null ).build(); + + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @Test + void rejects_nonnull_scope() + { + Dependency input = depBuilder.withClassifier( "tests" ).build(); + + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + } + + @Nested + class NullScope + { + private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( + "foo", + "foo", + "foo", + "foo", + "foo", + "foo" ); + + private final TokenizedMatcher matcher = TokenizedMatcher + .parse( "*:*:*:*:*:null" ); + + @Test + void accepts_null_scope() + { + Dependency input = depBuilder.withScope( null ).build(); + + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @Test + void rejects_nonnull_scope() + { + Dependency input = depBuilder.withScope( "compile" ).build(); + + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + } + + } + +} diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java new file mode 100644 index 0000000000..655316b731 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java @@ -0,0 +1,267 @@ +package org.codehaus.mojo.versions.filtering; + +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) +class WildcardMatcherTest +{ + @Nested + class ExactValueTest + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf" ); + + @Test + void matches_the_exact_input() + { + boolean actual = matcher.test( "asdf" ); + + assertTrue( actual ); + } + + @Test + void rejects_null() + { + boolean actual = matcher.test( null ); + + assertFalse( actual ); + } + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + "a", + "as", + "asf", + "asXf", + "asdfx", + } ) + void rejects_different_input( String input ) + { + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + } + + @Nested + class WildcardOnlyPattern + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "*" ); + + @Test + void accepts_null() + { + boolean actual = matcher.test( null ); + + assertTrue( actual ); + } + + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + "a", + "asdfx", + } ) + void accepts( String input ) + { + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + } + + + @Nested + class PatternWithWildcardAtStartAndEnd + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf*" ); + + @Test + void rejects_null() + { + boolean actual = matcher.test( null ); + + assertFalse( actual ); + } + + + @ParameterizedTest + @ValueSource( strings = { + "asdf", + "fooasdf", + "asdfbar", + "fooasdfbar", + " asdf", + "asdf ", + " asdf ", + } ) + void accepts( String input ) + { + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + "foo", + } ) + void rejects( String input ) + { + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + + } + + @Nested + class PatternStartingWithWildcard + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf" ); + + @Test + void rejects_null() + { + boolean actual = matcher.test( null ); + + assertFalse( actual ); + } + + + @ParameterizedTest + @ValueSource( strings = { + "asdf", + "asdfasdf", + " asdf", + "Xasdf", + "99999999asdf", + } ) + void accepts( String input ) + { + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + "asdf ", + "asdfx", + "asdfbanana", + } ) + void rejects( String input ) + { + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + + } + + @Nested + class PatternEndingWithWildcard + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf*" ); + + @Test + void rejects_null() + { + boolean actual = matcher.test( null ); + + assertFalse( actual ); + } + + + @ParameterizedTest + @ValueSource( strings = { + "asdf", + "asdfasdf", + "asdf ", + "asdfx", + "asdfbanana", + } ) + void accepts( String input ) + { + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + " asdf", + "Xasdf", + "99999999asdf", + } ) + void rejects( String input ) + { + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + + } + + @Nested + class PatternWithVersionRange + { + private final WildcardMatcher matcher = WildcardMatcher.parse( "[2.0,3.0]" ); + + @Test + void rejects_null() + { + boolean actual = matcher.test( null ); + + assertFalse( actual ); + } + + + @ParameterizedTest + @ValueSource( strings = { + "2.0", + "2.1", + "3.0", + } ) + void accepts( String input ) + { + boolean actual = matcher.test( input ); + + assertTrue( actual ); + } + + @ParameterizedTest + @ValueSource( strings = { + "", + " ", + "1.0", + "2.0-SNAPSHOT", + "4.0", + } ) + void rejects( String input ) + { + boolean actual = matcher.test( input ); + + assertFalse( actual ); + } + + } + +} From 07042efab7aae8de46c9d61e7319fe62a06a0b51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 13:18:13 +0000 Subject: [PATCH 082/441] Bump maven-reporting-impl from 3.1.0 to 3.2.0 Bumps [maven-reporting-impl](https://github.com/apache/maven-reporting-impl) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/apache/maven-reporting-impl/releases) - [Commits](https://github.com/apache/maven-reporting-impl/compare/maven-reporting-impl-3.1.0...maven-reporting-impl-3.2.0) --- updated-dependencies: - dependency-name: org.apache.maven.reporting:maven-reporting-impl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6849d042cf..c5f88dc191 100644 --- a/pom.xml +++ b/pom.xml @@ -170,7 +170,7 @@ org.apache.maven.reporting maven-reporting-impl - 3.1.0 + 3.2.0 org.apache.maven.shared From 9e07dda4ef27f16973959a719ae5b640a5d383b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 14 Aug 2022 22:36:36 +0000 Subject: [PATCH 083/441] Bump woodstox-core from 6.3.0 to 6.3.1 Bumps [woodstox-core](https://github.com/FasterXML/woodstox) from 6.3.0 to 6.3.1. - [Release notes](https://github.com/FasterXML/woodstox/releases) - [Commits](https://github.com/FasterXML/woodstox/compare/woodstox-core-6.3.0...woodstox-core-6.3.1) --- updated-dependencies: - dependency-name: com.fasterxml.woodstox:woodstox-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c5f88dc191..bb5821b676 100644 --- a/pom.xml +++ b/pom.xml @@ -221,7 +221,7 @@ com.fasterxml.woodstox woodstox-core - 6.3.0 + 6.3.1 org.apache.commons From feea169fae1ee6d824ba1ca5699b1f016c866deb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 14 Aug 2022 22:36:46 +0000 Subject: [PATCH 084/441] Bump mockito-core from 4.6.1 to 4.7.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.6.1 to 4.7.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.6.1...v4.7.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bb5821b676..70ce63ae4c 100644 --- a/pom.xml +++ b/pom.xml @@ -247,7 +247,7 @@ org.mockito mockito-core - 4.6.1 + 4.7.0 test From f69438e775fabab1ee8bc82bafa997e4a1933411 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Aug 2022 13:31:47 +0000 Subject: [PATCH 085/441] Bump mojo-parent from 69 to 70 Bumps [mojo-parent](https://github.com/mojohaus/mojo-parent) from 69 to 70. - [Release notes](https://github.com/mojohaus/mojo-parent/releases) - [Commits](https://github.com/mojohaus/mojo-parent/commits) --- updated-dependencies: - dependency-name: org.codehaus.mojo:mojo-parent dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70ce63ae4c..72d20776e1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codehaus.mojo mojo-parent - 69 + 70 versions-maven-plugin From b6c13ccffc66699acc5df747d2d418dc2d2d519e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 19 Aug 2022 21:04:06 +0200 Subject: [PATCH 086/441] Get rid of deprecated PathTranslator --- .../mojo/versions/AbstractVersionsReport.java | 8 ++++---- .../versions/AbstractVersionsUpdaterMojo.java | 9 +++++---- .../versions/api/DefaultVersionsHelper.java | 19 ++++++------------- .../utils/VersionsExpressionEvaluator.java | 9 ++------- .../api/DefaultVersionsHelperTest.java | 5 +++-- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 8f9f32cc38..6abc4a1d73 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -30,11 +30,11 @@ import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.path.PathTranslator; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; @@ -196,8 +196,8 @@ public abstract class AbstractVersionsReport @Parameter( defaultValue = "${session}", required = true, readonly = true ) protected MavenSession session; - @Component - protected PathTranslator pathTranslator; + @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) + private MojoExecution mojoExecution; @Component protected ArtifactResolver artifactResolver; @@ -214,7 +214,7 @@ public VersionsHelper getHelper() helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, remoteArtifactRepositories, remotePluginRepositories, localRepository, wagonManager, settings, serverId, rulesUri, - getLog(), session, pathTranslator ); + getLog(), session, mojoExecution ); } catch ( MojoExecutionException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 177e5bec38..6f8d0a7792 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; @@ -187,8 +188,8 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${session}", required = true, readonly = true ) protected MavenSession session; - @Component - protected PathTranslator pathTranslator; + @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) + private MojoExecution mojoExecution; @Component protected ArtifactResolver artifactResolver; @@ -222,8 +223,8 @@ public VersionsHelper getHelper() { helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, remoteArtifactRepositories, remotePluginRepositories, localRepository, - wagonManager, settings, serverId, rulesUri, getLog(), session, - pathTranslator ); + wagonManager, settings, serverId, rulesUri, getLog(), + session, mojoExecution ); } return helper; } diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index f62d22a6ad..19c71253c0 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -33,10 +33,10 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.path.PathTranslator; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.apache.maven.wagon.ConnectionException; @@ -148,13 +148,6 @@ public class DefaultVersionsHelper */ private final Log log; - /** - * The path translator. - * - * @since 1.0-beta-1 - */ - private final PathTranslator pathTranslator; - /** * The maven session. * @@ -169,6 +162,8 @@ public class DefaultVersionsHelper */ private final ArtifactResolver artifactResolver; + private final MojoExecution mojoExecution; + /** * Constructs a new {@link DefaultVersionsHelper}. * @@ -184,8 +179,6 @@ public class DefaultVersionsHelper * @param rulesUri The URL to retrieve the versioning rules from. * @param log The {@link org.apache.maven.plugin.logging.Log} to send log messages to. * @param mavenSession The maven session information. - * @param pathTranslator The path translator component. @throws org.apache.maven.plugin.MojoExecutionException If - * things go wrong. * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-3 */ @@ -193,13 +186,13 @@ public DefaultVersionsHelper( RepositorySystem repositorySystem, ArtifactResolve ArtifactMetadataSource artifactMetadataSource, List remoteArtifactRepositories, List remotePluginRepositories, ArtifactRepository localRepository, WagonManager wagonManager, Settings settings, String serverId, String rulesUri, - Log log, MavenSession mavenSession, PathTranslator pathTranslator ) + Log log, MavenSession mavenSession, MojoExecution mojoExecution ) throws MojoExecutionException { this.repositorySystem = repositorySystem; this.artifactResolver = artifactResolver; this.mavenSession = mavenSession; - this.pathTranslator = pathTranslator; + this.mojoExecution = mojoExecution; this.ruleSet = loadRuleSet( serverId, settings, wagonManager, rulesUri, log ); this.artifactMetadataSource = artifactMetadataSource; this.localRepository = localRepository; @@ -775,7 +768,7 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna @Override public ExpressionEvaluator getExpressionEvaluator( MavenProject project ) { - return new VersionsExpressionEvaluator( mavenSession, pathTranslator, project ); + return new VersionsExpressionEvaluator( mavenSession, mojoExecution ); } @Override diff --git a/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java b/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java index 899821c2c1..7ab86be342 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java @@ -22,9 +22,6 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.PluginParameterExpressionEvaluator; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.path.PathTranslator; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; /** @@ -37,10 +34,8 @@ public class VersionsExpressionEvaluator extends PluginParameterExpressionEvaluator implements ExpressionEvaluator { - public VersionsExpressionEvaluator( MavenSession mavenSession, PathTranslator pathTranslator, - MavenProject mavenProject ) + public VersionsExpressionEvaluator( MavenSession mavenSession, MojoExecution mojoExecution ) { - super( mavenSession, new MojoExecution( new MojoDescriptor() ), pathTranslator, null, mavenProject, - mavenSession.getExecutionProperties() ); + super( mavenSession, mojoExecution ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index f55ad9fee1..dd753bfde3 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -28,6 +28,7 @@ import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.MavenMetadataSource; @@ -223,8 +224,8 @@ private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSou new DefaultVersionsHelper( lookup( RepositorySystem.class ), new DefaultArtifactResolver(), metadataSource, new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), - wagonManager, new Settings(), "", rulesUri, mock( Log.class ), mock( MavenSession.class ), - new DefaultPathTranslator()); + wagonManager, new Settings(), "", rulesUri, mock( Log.class ), + mock( MavenSession.class ), mock( MojoExecution.class ) ); return helper; } From fbe667fa3b856b14449a189769e9231d75206bab Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 20 Aug 2022 12:10:07 +0200 Subject: [PATCH 087/441] Require Maven 3.2.5 --- pom.xml | 11 +++++++++-- .../mojo/versions/DisplayPluginUpdatesMojo.java | 7 ++++--- .../mojo/versions/api/DefaultVersionsHelperTest.java | 5 ++--- .../versions/ordering/VersionComparatorsTest.java | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 72d20776e1..486b4eb6bb 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ - 3.0 + ${mavenVersion} @@ -98,7 +98,7 @@ 1.8 ${mojo.java.target} 5.9.0 - 3.0.5 + 3.2.5 3.5.2 1.11.1 1.11.1 @@ -228,6 +228,13 @@ commons-lang3 3.12.0 + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 3.3.0 + test + org.junit.jupiter junit-jupiter diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index ef57ca3011..91229b2f4d 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -36,7 +36,6 @@ import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.mapping.LifecycleMapping; import org.apache.maven.model.Dependency; -import org.apache.maven.model.InputLocation; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Prerequisites; @@ -44,8 +43,8 @@ import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.building.DefaultModelBuildingRequest; import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblemCollector; +import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.model.interpolation.ModelInterpolator; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.plugin.InvalidPluginException; @@ -1799,8 +1798,10 @@ private static int compare( ArtifactVersion a, ArtifactVersion b ) } private static class IgnoringModelProblemCollector implements ModelProblemCollector { + @Override - public void add(Severity severity, String message, InputLocation location, Exception cause) { + public void add( ModelProblemCollectorRequest req ) + { // ignore } } diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index dd753bfde3..44d9a23013 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -30,15 +30,14 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.MavenMetadataSource; -import org.apache.maven.project.path.DefaultPathTranslator; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.apache.maven.execution.MavenSession; import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.ordering.VersionComparators; -import org.codehaus.plexus.PlexusTestCase; import org.hamcrest.CoreMatchers; import org.junit.Test; @@ -58,7 +57,7 @@ /** * Test {@link DefaultVersionsHelper} */ -public class DefaultVersionsHelperTest extends PlexusTestCase +public class DefaultVersionsHelperTest extends AbstractMojoTestCase { @Test diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java index be51e5bfc5..07b244d078 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java @@ -32,7 +32,7 @@ public class VersionComparatorsTest "1.0", "1.0.0", "1.0.0-1", - "1.0.0.sp1", + "1.0.0-sp1", "foobar", "1-alpha-1", }; From cd941512e4468aed5e624ac8a7e7a2859543f385 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 19 Aug 2022 21:53:36 +0200 Subject: [PATCH 088/441] Limit to only artifacts that have updates and are in the dependency graph (#589) Added `onlyUpgradable`, which will restrict the reports to only show upgradable artifacts, and `onlyProjectDependencies`, `onlyProjectPlugins`, which will restrict the graph of demendencyManagement/pluginManagement artifacts to the graph used in the project. Additionally, some refactoring and improvements. --- .../mojo/versions/AbstractVersionsReport.java | 29 +- .../versions/DependencyUpdatesReport.java | 181 ++++++------ .../mojo/versions/PluginUpdatesReport.java | 126 +++++---- .../mojo/versions/utils/MiscUtils.java | 28 ++ .../versions/DependencyUpdatesReportTest.java | 263 ++++++++++++++++++ .../versions/PluginUpdatesReportTest.java | 225 +++++++++++++++ 6 files changed, 679 insertions(+), 173 deletions(-) create mode 100644 src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java create mode 100644 src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java create mode 100644 src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 6abc4a1d73..bb3b81e90c 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -57,30 +57,13 @@ public abstract class AbstractVersionsReport extends AbstractMavenReport { - - /** - * Doxia Site Renderer component. - * - * @since 1.0-alpha-3 - */ - @Component - private Renderer siteRenderer; - /** * Internationalization component. * * @since 1.0-alpha-3 */ @Component - private I18N i18n; - - /** - * The Maven Project. - * - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) - private MavenProject project; + protected I18N i18n; @Component protected RepositorySystem repositorySystem; @@ -91,16 +74,6 @@ public abstract class AbstractVersionsReport @Component private ArtifactResolver resolver; - /** - * The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from - * the command line. If the goal is run indirectly as part of a site generation, the output directory configured in - * the Maven Site Plugin is used instead. - * - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project.reporting.outputDirectory}", required = true ) - private File outputDirectory; - /** * Skip entire check. * diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index 6a5c14c7af..791ef57abf 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -20,8 +20,6 @@ */ import java.io.File; -import java.util.Collections; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -36,7 +34,9 @@ import org.apache.maven.reporting.MavenReportException; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.utils.DependencyComparator; -import org.codehaus.plexus.util.StringUtils; + +import static java.util.Collections.EMPTY_MAP; +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; /** * Generates a report of available updates for the dependencies of a project. @@ -44,38 +44,54 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "dependency-updates-report", requiresProject = true, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) -public class DependencyUpdatesReport - extends AbstractVersionsReport +@Mojo( name = "dependency-updates-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +public class DependencyUpdatesReport extends AbstractVersionsReport { /** * Whether to process the dependencyManagement in pom or not. - * + * * @since 2.5 */ @Parameter( property = "processDependencyManagement", defaultValue = "true" ) - private boolean processDependencyManagement; + protected boolean processDependencyManagement; /** * Whether to process the depdendencyManagement part transitive or not. * In case of <type>pom</type>and * <scope>import</scope> this means - * by default to report also the imported dependencies. + * by default to report also the imported dependencies. * If processTransitive is set to false the report will only show - * updates of the imported pom it self. - * + * updates of the imported pom itself. + * * @since 2.5 Note: Currently in experimental state. */ @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) - private boolean processDependencyManagementTransitive; + protected boolean processDependencyManagementTransitive; /** * Report formats (html and/or xml). HTML by default. - * */ @Parameter( property = "dependencyUpdatesReportFormats", defaultValue = "html" ) - private String[] formats = new String[] { "html" }; + protected String[] formats = new String[] {"html"}; + + /** + * If true, only shows the subsection of the dependencyManagement artifacts that + * are actually used in the project's dependency graph. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyProjectDependencies", defaultValue = "false" ) + protected boolean onlyProjectDependencies; + + /** + * If true, only shows upgradable dependencies in the report. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + protected boolean onlyUpgradable; /** * {@inheritDoc} @@ -97,82 +113,101 @@ public boolean canGenerateReport() * generates an empty report in case there are no sources to generate a report with * * @param locale the locale to generate the report for. - * @param sink the report formatting tool + * @param sink the report formatting tool */ - protected void doGenerateReport( Locale locale, Sink sink ) - throws MavenReportException + @SuppressWarnings( "deprecation" ) + protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { Set dependencies = new TreeSet<>( new DependencyComparator() ); dependencies.addAll( getProject().getDependencies() ); Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); - if ( processDependencyManagementTransitive ) + if ( processDependencyManagement ) { - if ( getProject().getDependencyManagement() != null - && getProject().getDependencyManagement().getDependencies() != null ) + if ( processDependencyManagementTransitive ) { - for ( Dependency dep : getProject().getDependencyManagement().getDependencies() ) + if ( getProject().getDependencyManagement() != null + && getProject().getDependencyManagement().getDependencies() != null ) { - getLog().debug( "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() - + ":" + dep.getType() + ":" + dep.getScope() ); + for ( Dependency dep : getProject().getDependencyManagement().getDependencies() ) + { + getLog().debug( + "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" + + dep.getType() + ":" + dep.getScope() ); + } + dependencyManagement.addAll( getProject().getDependencyManagement().getDependencies() ); } - dependencyManagement.addAll( getProject().getDependencyManagement().getDependencies() ); } - } - else - { - if ( getProject().getOriginalModel().getDependencyManagement() != null - && getProject().getOriginalModel().getDependencyManagement().getDependencies() != null ) + else { - // Using the original model to get the original dependencyManagement entries and - // not the interpolated model. - // TODO: I'm not 100% sure if this will work correctly in all cases. - for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) + if ( getProject().getOriginalModel().getDependencyManagement() != null + && getProject().getOriginalModel().getDependencyManagement().getDependencies() != null ) { - getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" - + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + // Using the original model to get the original dependencyManagement entries and + // not the interpolated model. + // TODO: I'm not 100% sure if this will work correctly in all cases. + for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) + { + getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + } + dependencyManagement.addAll( + getProject().getOriginalModel().getDependencyManagement().getDependencies() ); } - dependencyManagement.addAll( getProject().getOriginalModel().getDependencyManagement().getDependencies() ); } - } - if ( processDependencyManagement ) - { - dependencies = removeDependencyManagment( dependencies, dependencyManagement ); + if ( !onlyProjectDependencies ) + { + // Retains only dependencies not present in dependencyManagement + dependencies.removeIf( dep -> dependencyManagement.stream().anyMatch( dmDep -> match( dep, dmDep ) ) ); + } + else + { + // Retain only dependencies in dependencyManagement that are also present in dependencies + dependencyManagement.removeIf( dep -> dependencies.stream().noneMatch( dmDep -> match( dep, dmDep ) ) ); + } } try { Map dependencyUpdates = - getHelper().lookupDependenciesUpdates( dependencies, false ); + getHelper().lookupDependenciesUpdates( dependencies, false ); - Map dependencyManagementUpdates = Collections.emptyMap(); - if ( processDependencyManagement ) + Map dependencyManagementUpdates = + processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) : + EMPTY_MAP; + + if ( onlyUpgradable ) { - dependencyManagementUpdates = getHelper().lookupDependenciesUpdates( dependencyManagement, false ); + dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 1 ); + dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 1 ); } + for ( String format : formats ) { if ( "html".equals( format ) ) { DependencyUpdatesRenderer renderer = - new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, dependencyUpdates, - dependencyManagementUpdates ); + new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, dependencyUpdates, + dependencyManagementUpdates ); renderer.render(); } else if ( "xml".equals( format ) ) { - File outputDir = new File(getProject().getBuild().getDirectory()); - if (!outputDir.exists()) + File outputDir = new File( getProject().getBuild().getDirectory() ); + if ( !outputDir.exists() ) { - outputDir.mkdirs(); + if ( !outputDir.mkdirs() ) + { + throw new MavenReportException( "Could not create output directory" ); + } } - String outputFile = - outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; + String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; DependencyUpdatesXmlRenderer xmlGenerator = - new DependencyUpdatesXmlRenderer( dependencyUpdates, dependencyManagementUpdates, outputFile ); + new DependencyUpdatesXmlRenderer( dependencyUpdates, dependencyManagementUpdates, + outputFile ); xmlGenerator.render(); } } @@ -184,42 +219,18 @@ else if ( "xml".equals( format ) ) } /** - * Returns a set of dependencies where the dependencies which are defined in the dependency management section have - * been filtered out. + * Compares two dependencies with each other * - * @param dependencies The set of dependencies. - * @param dependencyManagement The set of dependencies from the dependency management section. - * @return A new set of dependencies which are from the set of dependencies but not from the set of dependency - * management dependencies. - * @since 1.0-beta-1 + * @return true if the two dependencies match */ - private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement ) + private boolean match( Dependency dep, Dependency dmDep ) { - Set result = new TreeSet<>( new DependencyComparator() ); - for ( Dependency c : dependencies ) - { - boolean matched = false; - Iterator j = dependencyManagement.iterator(); - while ( !matched && j.hasNext() ) - { - Dependency t = j.next(); - if ( StringUtils.equals( t.getGroupId(), c.getGroupId() ) - && StringUtils.equals( t.getArtifactId(), c.getArtifactId() ) - && ( t.getScope() == null || StringUtils.equals( t.getScope(), c.getScope() ) ) - && ( t.getClassifier() == null || StringUtils.equals( t.getClassifier(), c.getClassifier() ) ) - && ( c.getVersion() == null || t.getVersion() == null - || StringUtils.equals( t.getVersion(), c.getVersion() ) ) ) - { - matched = true; - break; - } - } - if ( !matched ) - { - result.add( c ); - } - } - return result; + return dmDep.getGroupId().equals( dep.getGroupId() ) + && dmDep.getArtifactId().equals( dep.getArtifactId() ) + && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) + && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) + && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() + .equals( dep.getVersion() ) ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java index 516d7bb73b..5ced4f1903 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java @@ -19,6 +19,12 @@ * under the License. */ +import java.io.File; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; @@ -27,13 +33,8 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.codehaus.mojo.versions.utils.PluginComparator; -import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; /** * Generates a report of available updates for the plugins of a project. @@ -41,18 +42,34 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "plugin-updates-report", requiresProject = true, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class PluginUpdatesReport - extends AbstractVersionsReport +@Mojo( name = "plugin-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true ) +public class PluginUpdatesReport extends AbstractVersionsReport { /** * Report formats (html and/or xml). HTML by default. - * */ @Parameter( property = "pluginUpdatesReportFormats", defaultValue = "html" ) private String[] formats = new String[] { "html" }; + /** + * If true, only shows the subsection of the pluginManagement artifacts that + * are actually used in the project's plugin graph. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyProjectPlugins", defaultValue = "false" ) + protected boolean onlyProjectPlugins; + + /** + * If true, only shows upgradable plugins in the report. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + protected boolean onlyUpgradable; + /** * {@inheritDoc} */ @@ -72,24 +89,23 @@ public boolean canGenerateReport() private boolean haveBuildPluginManagementPlugins() { return getProject().getBuild() != null && getProject().getBuild().getPluginManagement() != null - && getProject().getBuild().getPluginManagement().getPlugins() != null - && !getProject().getBuild().getPluginManagement().getPlugins().isEmpty(); + && getProject().getBuild().getPluginManagement().getPlugins() != null && !getProject().getBuild() + .getPluginManagement().getPlugins().isEmpty(); } private boolean haveBuildPlugins() { return getProject().getBuild() != null && getProject().getBuild().getPlugins() != null - && !getProject().getBuild().getPlugins().isEmpty(); + && !getProject().getBuild().getPlugins().isEmpty(); } /** * generates an empty report in case there are no sources to generate a report with * * @param locale the locale to generate the report for. - * @param sink the report formatting tool + * @param sink the report formatting tool */ - protected void doGenerateReport( Locale locale, Sink sink ) - throws MavenReportException + protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { Set pluginManagement = new TreeSet<>( new PluginComparator() ); if ( haveBuildPluginManagementPlugins() ) @@ -103,34 +119,57 @@ protected void doGenerateReport( Locale locale, Sink sink ) plugins.addAll( getProject().getBuild().getPlugins() ); } - plugins = removePluginManagment( plugins, pluginManagement ); + PluginComparator comparator = new PluginComparator(); + if ( !onlyProjectPlugins ) + { + // Retains only plugins not present in pluginManagement + plugins.removeIf( plugin -> pluginManagement.stream() + .anyMatch( pmPlugin -> comparator.compare( plugin, pmPlugin ) == 0 ) ); + } + else + { + // Retain only plugins in pluginManagement that are also present in plugins + pluginManagement.removeIf( + pmPlugin -> plugins.stream().noneMatch( plugin -> comparator.compare( plugin, pmPlugin ) == 0 ) ); + } try { Map pluginUpdates = - getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); + getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); Map pluginManagementUpdates = - getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); + getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); + + if ( onlyUpgradable ) + { + pluginUpdates = + filter( pluginUpdates, plugin -> plugin.getArtifactVersions().getVersions().length > 1 ); + pluginManagementUpdates = filter( pluginManagementUpdates, + plugin -> plugin.getArtifactVersions().getVersions().length > 1 ); + } + for ( String format : formats ) { if ( "html".equals( format ) ) { PluginUpdatesRenderer renderer = - new PluginUpdatesRenderer( sink, getI18n(), getOutputName(), locale, pluginUpdates, - pluginManagementUpdates ); + new PluginUpdatesRenderer( sink, getI18n(), getOutputName(), locale, pluginUpdates, + pluginManagementUpdates ); renderer.render(); } else if ( "xml".equals( format ) ) { - File outputDir = new File(getProject().getBuild().getDirectory()); - if (!outputDir.exists()) + File outputDir = new File( getProject().getBuild().getDirectory() ); + if ( !outputDir.exists() ) { - outputDir.mkdirs(); + if ( !outputDir.mkdirs() ) + { + throw new MavenReportException( "Could not create output directory" ); + } } - String outputFile = - outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; + String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; PluginUpdatesXmlRenderer xmlGenerator = - new PluginUpdatesXmlRenderer( pluginUpdates, pluginManagementUpdates, outputFile ); + new PluginUpdatesXmlRenderer( pluginUpdates, pluginManagementUpdates, outputFile ); xmlGenerator.render(); } } @@ -141,39 +180,6 @@ else if ( "xml".equals( format ) ) } } - /** - * Returns a set of dependencies where the dependencies which are defined in the dependency management section have - * been filtered out. - * - * @param plugins The set of dependencies. - * @param pluginManagement The set of dependencies from the dependency management section. - * @return A new set of dependencies which are from the set of dependencies but not from the set of dependency - * management dependencies. - * @since 1.0-beta-1 - */ - private static Set removePluginManagment( Set plugins, Set pluginManagement ) - { - Set result = new TreeSet<>( new PluginComparator() ); - for ( Plugin c : plugins ) - { - boolean matched = false; - for ( Plugin t : pluginManagement ) - { - if ( StringUtils.equals( t.getGroupId(), c.getGroupId() ) - && StringUtils.equals( t.getArtifactId(), c.getArtifactId() ) ) - { - matched = true; - break; - } - } - if ( !matched ) - { - result.add( c ); - } - } - return result; - } - /** * {@inheritDoc} */ diff --git a/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java new file mode 100644 index 0000000000..215ae598a9 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java @@ -0,0 +1,28 @@ +package org.codehaus.mojo.versions.utils; + +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * Miscellaneous utility class. + */ +public class MiscUtils +{ + /** + * Filters a given map leaving only elements fulfilling a predicate. Does not change the input map, + * the filtered map is returned as output. + * + * @param map input map to be filtered + * @param predicate predicate for element comparison + * @param key type + * @param value type + * @return map such that every element comforms with the predicate + */ + public static Map filter( Map map, + Function predicate ) + { + return map.entrySet().stream().filter( e -> predicate.apply( e.getValue() ) ) + .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java new file mode 100644 index 0000000000..a5bf0765cd --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -0,0 +1,263 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; +import org.apache.maven.doxia.sink.SinkFactory; +import org.apache.maven.doxia.tools.SiteTool; +import org.apache.maven.doxia.tools.SiteToolException; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.plexus.i18n.I18N; +import org.junit.Test; + +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * Basic tests for {@linkplain DependencyUpdatesReport}. + * + * @author Andrzej Jarmoniuk + */ +public class DependencyUpdatesReportTest +{ + private static class TestDependencyUpdatesReport extends DependencyUpdatesReport + { + @SuppressWarnings( "deprecation" ) + public TestDependencyUpdatesReport() + { + mockPlexusComponents(); + + project = new MavenProject(); + project.setOriginalModel( new Model() ); + project.getOriginalModel().setDependencyManagement( new DependencyManagement() ); + project.getModel().setDependencyManagement( new DependencyManagement() ); + + artifactMetadataSource = mock( ArtifactMetadataSource.class ); + try + { + when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + invocation -> { + Artifact artifact = invocation.getArgument( 0 ); + if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "2.0.0" ) ); + } + if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "1.1.0" ) ); + } + return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); + } ); + } + catch ( ArtifactMetadataRetrievalException e ) + { + throw new RuntimeException( e ); + } + } + + public TestDependencyUpdatesReport withDependencies( Dependency... dependencies ) + { + project.setDependencies( Arrays.asList( dependencies ) ); + return this; + } + + public TestDependencyUpdatesReport withOriginalDependencyManagement( + Dependency... originalDependencyManagement ) + { + project.getOriginalModel().getDependencyManagement() + .setDependencies( Arrays.asList( originalDependencyManagement ) ); + return this; + } + + public TestDependencyUpdatesReport withDependencyManagement( Dependency... dependencyManagement ) + { + project.getModel().getDependencyManagement().setDependencies( Arrays.asList( dependencyManagement ) ); + return this; + } + + public TestDependencyUpdatesReport withOnlyUpgradable( boolean onlyUpgradable ) + { + this.onlyUpgradable = onlyUpgradable; + return this; + } + + public TestDependencyUpdatesReport withProcessDependencyManagement( boolean processDependencyManagement ) + { + this.processDependencyManagement = processDependencyManagement; + return this; + } + + public TestDependencyUpdatesReport withProcessDependencyManagementTransitive( + boolean processDependencyManagementTransitive ) + { + this.processDependencyManagementTransitive = processDependencyManagementTransitive; + return this; + } + + public TestDependencyUpdatesReport withOnlyProjectDependencies( + boolean onlyProjectDependencies ) + { + this.onlyProjectDependencies = onlyProjectDependencies; + return this; + } + + /** + *

Mocks some Plexus components to speed up test execution.

+ *

Note: these components could just as well be injected using + * org.codehaus.plexus.PlexusTestCase.lookup, + * but that method greatly slows down test execution.

+ * + * @see Testing + * Plexus Components + */ + private void mockPlexusComponents() + { + i18n = mock( I18N.class ); + when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( + invocation -> invocation.getArgument( 2 ) ); + + repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion(), dependency.getScope(), dependency.getType(), + dependency.getClassifier(), null ); + } ); + + Artifact skinArtifact = mock( Artifact.class ); + when( skinArtifact.getId() ).thenReturn( "" ); + siteTool = mock( SiteTool.class ); + try + { + when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); + } + catch ( SiteToolException e ) + { + throw new RuntimeException( e ); + } + } + } + + private static Dependency dependencyOf( String artifactId ) + { + return DependencyBuilder.dependencyWith( "groupA", artifactId, "1.0.0", "default", "pom", SCOPE_COMPILE ); + } + + @Test + public void testOnlyUpgradableDependencies() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withOnlyUpgradable( true ) + .withDependencies( + dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, not( containsString( "artifactC" ) ) ); + } + + @Test + public void testOnlyUpgradableWithOriginalDependencyManagement() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withOriginalDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, not( containsString( "artifactC" ) ) ); + } + + @Test + public void testOnlyUpgradableWithTransitiveDependencyManagement() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withDependencyManagement( + dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withProcessDependencyManagementTransitive( true ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, not( containsString( "artifactC" ) ) ); + } + + @Test + public void testOnlyProjectDependencies() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withDependencies( dependencyOf( "artifactA" ) ) + .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withOnlyProjectDependencies( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, containsString( "artifactA" ) ); + assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); + } +} \ No newline at end of file diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java new file mode 100644 index 0000000000..b893d557d1 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java @@ -0,0 +1,225 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; +import org.apache.maven.doxia.sink.SinkFactory; +import org.apache.maven.doxia.tools.SiteTool; +import org.apache.maven.doxia.tools.SiteToolException; +import org.apache.maven.model.Build; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.plexus.i18n.I18N; +import org.junit.Test; + +import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * Basic tests for {@linkplain PluginUpdatesReport}. + * + * @author Andrzej Jarmoniuk + */ +public class PluginUpdatesReportTest +{ + private static class TestPluginUpdatesReport extends PluginUpdatesReport + { + @SuppressWarnings( "deprecation" ) + public TestPluginUpdatesReport() + { + mockPlexusComponents(); + + project = new MavenProject(); + project.setBuild( new Build() ); + project.getBuild().setPluginManagement( new PluginManagement() ); + + artifactMetadataSource = mock( ArtifactMetadataSource.class ); + try + { + when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + invocation -> { + Artifact artifact = invocation.getArgument( 0 ); + if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "2.0.0" ) ); + } + if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "1.1.0" ) ); + } + return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); + } ); + } + catch ( ArtifactMetadataRetrievalException e ) + { + throw new RuntimeException( e ); + } + } + + public TestPluginUpdatesReport withPlugins( Plugin... plugins ) + { + project.getBuild().setPlugins( Arrays.asList( plugins ) ); + return this; + } + + public TestPluginUpdatesReport withPluginManagement( Plugin... pluginManagement ) + { + project.getBuild().getPluginManagement().setPlugins( Arrays.asList( pluginManagement ) ); + return this; + } + + public TestPluginUpdatesReport withOnlyUpgradable( boolean onlyUpgradable ) + { + this.onlyUpgradable = onlyUpgradable; + return this; + } + + public TestPluginUpdatesReport withOnlyProjectPlugins( boolean onlyProjectPlugins ) + { + this.onlyProjectPlugins = onlyProjectPlugins; + return this; + } + + /** + *

Mocks some Plexus components to speed up test execution.

+ *

Note: these components could just as well be injected using + * org.codehaus.plexus.PlexusTestCase.lookup, + * but that method greatly slows down test execution.

+ * + * @see Testing + * Plexus Components + */ + private void mockPlexusComponents() + { + i18n = mock( I18N.class ); + when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( + invocation -> invocation.getArgument( 2 ) ); + + repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createPluginArtifact( any( Plugin.class ) ) ).thenAnswer( invocation -> { + Plugin plugin = invocation.getArgument( 0 ); + return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), + SCOPE_RUNTIME, "maven-plugin", "jar", null ); + } ); + + Artifact skinArtifact = mock( Artifact.class ); + when( skinArtifact.getId() ).thenReturn( "" ); + siteTool = mock( SiteTool.class ); + try + { + when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); + } + catch ( SiteToolException e ) + { + throw new RuntimeException( e ); + } + } + } + + private static Plugin pluginOf( String artifactId ) + { + return new Plugin() + { + { + setGroupId( "defaultGroup" ); + setArtifactId( artifactId ); + setVersion( "1.0.0" ); + } + }; + } + + @Test + public void testOnlyUpgradablePlugins() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestPluginUpdatesReport() + .withPlugins( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, not( containsString( "artifactC" ) ) ); + } + + @Test + public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestPluginUpdatesReport() + .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, not( containsString( "artifactC" ) ) ); + } + + @Test + public void testOnlyProjectPlugins() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestPluginUpdatesReport() + .withPlugins( pluginOf( "artifactA" ) ) + .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .withOnlyProjectPlugins( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, containsString( "artifactA" ) ); + assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); + } +} \ No newline at end of file From 540785721e8cb21be5e15dabf031b06eb1ee0125 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 20 Aug 2022 09:13:22 +0200 Subject: [PATCH 089/441] support to increase x or y in version of x.y.z, not only z #539 --- .../org/codehaus/mojo/versions/SetMojo.java | 217 +++++++++++------- .../codehaus/mojo/versions/SetMojoTest.java | 95 ++++++++ 2 files changed, 223 insertions(+), 89 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/SetMojoTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index a268fb4a26..1938aacdc4 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -19,12 +19,14 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.io.File; import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.Date; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -36,8 +38,6 @@ import java.util.TreeMap; import java.util.regex.Pattern; -import javax.xml.stream.XMLStreamException; - import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; @@ -68,8 +68,7 @@ * @since 1.0-beta-1 */ @Mojo( name = "set", requiresProject = true, requiresDirectInvocation = true, aggregator = true, threadSafe = true ) -public class SetMojo - extends AbstractVersionsUpdaterMojo +public class SetMojo extends AbstractVersionsUpdaterMojo { private static final String SNAPSHOT = "-SNAPSHOT"; @@ -115,6 +114,7 @@ public class SetMojo * version of the current project. On Windows you can omit * the single quotes on Linux they are necessary to prevent * expansion through the shell. + * * @since 1.2 */ @Parameter( property = "oldVersion", defaultValue = "${project.version}" ) @@ -178,11 +178,25 @@ public class SetMojo /** * Whether to add next version number and -SNAPSHOT to the existing version. + * Unless specified by nextSnapshotIndexToIncrement, will increment + * the last minor index of the snapshot version, e.g. the z in x.y.z-SNAPSHOT * * @since 2.10 */ @Parameter( property = "nextSnapshot", defaultValue = "false" ) - private boolean nextSnapshot; + protected boolean nextSnapshot; + + /** + *

Specifies the version index to increment when using nextSnapshot. + * Will increment the (1-based, counting from the left, or the most major component) index + * of the snapshot version, e.g. for -DnextSnapshotIndexToIncrement=1 + * and the version being 1.2.3-SNAPSHOT, the new version will become 2.2.3-SNAPSHOT.

+ *

Only valid with nextSnapshot.

+ * + * @since 2.12 + */ + @Parameter( property = "nextSnapshotIndexToIncrement" ) + protected Integer nextSnapshotIndexToIncrement; /** * Whether to process all modules whereas they have parent/child or not. @@ -205,8 +219,8 @@ public class SetMojo /** * Whether to update the project.build.outputTimestamp property in the POM when setting version. * - * @deprecated please use {@link #updateBuildOutputTimestampPolicy} instead * @since 2.10 + * @deprecated please use {@link #updateBuildOutputTimestampPolicy} instead */ @Parameter( property = "updateBuildOutputTimestamp", defaultValue = "true" ) private boolean updateBuildOutputTimestamp; @@ -238,10 +252,9 @@ private synchronized void addChange( String groupId, String artifactId, String o * Called when this mojo is executed. * * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. */ - public void execute() - throws MojoExecutionException, MojoFailureException + public void execute() throws MojoExecutionException, MojoFailureException { if ( getProject().getOriginalModel().getVersion() == null ) { @@ -259,30 +272,15 @@ public void execute() } } + if ( !nextSnapshot && nextSnapshotIndexToIncrement != null ) + { + throw new MojoExecutionException( "nextSnapshotIndexToIncrement is not valid when nextSnapshot is false" ); + } + if ( !removeSnapshot && nextSnapshot ) { String version = getVersion(); - String versionWithoutSnapshot = version; - if ( version.endsWith( SNAPSHOT ) ) - { - versionWithoutSnapshot = version.substring( 0, version.indexOf( SNAPSHOT ) ); - } - LinkedList numbers = new LinkedList(); - if ( versionWithoutSnapshot.contains( "." ) ) - { - // Chop the version into numbers by splitting on the dot (.) - Collections.addAll( numbers, versionWithoutSnapshot.split( "\\." ) ); - } - else - { - // The version contains no dots, assume that it is only 1 number - numbers.add( versionWithoutSnapshot ); - } - - int lastNumber = Integer.parseInt( numbers.removeLast() ); - numbers.addLast( String.valueOf( lastNumber + 1 ) ); - String nextVersion = StringUtils.join( numbers.toArray( new String[0] ), "." ); - newVersion = nextVersion + "-SNAPSHOT"; + newVersion = getIncrementedVersion( version, nextSnapshotIndexToIncrement ); getLog().info( "SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion ); } @@ -292,8 +290,8 @@ public void execute() { try { - newVersion = - prompter.prompt( "Enter the new version to set", getProject().getOriginalModel().getVersion() ); + newVersion = prompter.prompt( "Enter the new version to set", + getProject().getOriginalModel().getVersion() ); } catch ( PrompterException e ) { @@ -303,68 +301,70 @@ public void execute() else { throw new MojoExecutionException( "You must specify the new version, either by using the newVersion " - + "property (that is -DnewVersion=... on the command line) or run in interactive mode" ); + + "property (that is -DnewVersion=... on the command line) or run in interactive mode" ); } } if ( StringUtils.isEmpty( newVersion ) ) { throw new MojoExecutionException( "You must specify the new version, either by using the newVersion " - + "property (that is -DnewVersion=... on the command line) or run in interactive mode" ); + + "property (that is -DnewVersion=... on the command line) or run in interactive mode" ); } - if ( !"onchange".equals( updateBuildOutputTimestampPolicy ) - && !"always".equals( updateBuildOutputTimestampPolicy ) - && !"never".equals( updateBuildOutputTimestampPolicy ) ) + if ( !"onchange".equals( updateBuildOutputTimestampPolicy ) && !"always".equals( + updateBuildOutputTimestampPolicy ) && !"never".equals( updateBuildOutputTimestampPolicy ) ) { - throw new MojoExecutionException( "updateBuildOutputTimestampPolicy should be one of: " - + "\"onchange\", \"always\", \"never\"." ); + throw new MojoExecutionException( + "updateBuildOutputTimestampPolicy should be one of: " + "\"onchange\", \"always\", \"never\"." ); } try { final MavenProject project; - if ( processFromLocalAggregationRoot ) { + if ( processFromLocalAggregationRoot ) + { project = PomHelper.getLocalRoot( projectBuilder, getProject(), localRepository, null, getLog() ); } - else { + else + { project = getProject(); } getLog().info( "Local aggregation root: " + project.getBasedir() ); Map reactorModels = PomHelper.getReactorModels( project, getLog() ); final SortedMap reactor = - new TreeMap( new ReactorDepthComparator( reactorModels ) ); + new TreeMap( new ReactorDepthComparator( reactorModels ) ); reactor.putAll( reactorModels ); // set of files to update final Set files = new LinkedHashSet(); - getLog().info( "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " - + newVersion ); + getLog().info( + "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); Pattern groupIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( groupId, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( groupId, "*" ), true ) ); Pattern artifactIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); Pattern oldVersionIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); boolean found = false; for ( Model m : reactor.values() ) { final String mGroupId = PomHelper.getGroupId( m ); final String mArtifactId = PomHelper.getArtifactId( m ); final String mVersion = PomHelper.getVersion( m ); - if (( ( groupIdRegex.matcher( mGroupId ).matches() && artifactIdRegex.matcher( mArtifactId ).matches() ) // - || (processAllModules) ) // - && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) + if ( ( ( groupIdRegex.matcher( mGroupId ).matches() && artifactIdRegex.matcher( mArtifactId ) + .matches() ) // + || ( processAllModules ) ) // + && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) { found = true; // if the change is not one we have swept up already applyChange( project, reactor, files, mGroupId, m.getArtifactId(), - StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() ); + StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() ); } } if ( !found && RegexUtils.getWildcardScore( groupId ) == 0 && RegexUtils.getWildcardScore( artifactId ) == 0 - && RegexUtils.getWildcardScore( oldVersion ) == 0 ) + && RegexUtils.getWildcardScore( oldVersion ) == 0 ) { applyChange( project, reactor, files, groupId, artifactId, oldVersion ); } @@ -382,6 +382,40 @@ public void execute() } } + /** + * Returns the incremented version, with the nextSnapshotIndexToIncrement indicating the 1-based index, + * conunting from the left, or the most major version component, of the version string. + * + * @param version input version + * @return version with the incremented index specified by nextSnapshotIndexToIncrement or last index + * @throws MojoExecutionException thrown if the input parameters are invalid + */ + protected String getIncrementedVersion( String version, Integer nextSnapshotIndexToIncrement ) + throws MojoExecutionException + { + String versionWithoutSnapshot = + version.endsWith( SNAPSHOT ) ? version.substring( 0, version.indexOf( SNAPSHOT ) ) : version; + List numbers = new LinkedList<>( Arrays.asList( versionWithoutSnapshot.split( "\\." ) ) ); + + if ( nextSnapshotIndexToIncrement == null ) + { + nextSnapshotIndexToIncrement = numbers.size(); + } + else if ( nextSnapshotIndexToIncrement < 1 ) + { + throw new MojoExecutionException( "nextSnapshotIndexToIncrement cannot be less than 1" ); + } + else if ( nextSnapshotIndexToIncrement > numbers.size() ) + { + throw new MojoExecutionException( + "nextSnapshotIndexToIncrement cannot be greater than the last version index" ); + } + int snapshotVersionToIncrement = Integer.parseInt( numbers.remove( nextSnapshotIndexToIncrement - 1 ) ); + numbers.add( nextSnapshotIndexToIncrement - 1, String.valueOf( snapshotVersionToIncrement + 1 ) ); + + return StringUtils.join( numbers.toArray( new String[0] ), "." ) + "-SNAPSHOT"; + } + private static String fixNullOrEmpty( String value, String defaultValue ) { return StringUtils.isBlank( value ) ? defaultValue : value; @@ -406,8 +440,8 @@ private void applyChange( MavenProject project, SortedMap reactor final String sourcePath = sourceEntry.getKey(); final Model sourceModel = sourceEntry.getValue(); - getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" - : "Processing " + sourcePath + " as a parent." ); + getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" : + "Processing " + sourcePath + " as a parent." ); final String sourceGroupId = PomHelper.getGroupId( sourceModel ); if ( sourceGroupId == null ) @@ -430,50 +464,53 @@ private void applyChange( MavenProject project, SortedMap reactor addFile( files, project, sourcePath ); - getLog().debug( "Looking for modules which use " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + " as their parent" ); + getLog().debug( + "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + + " as their parent" ); for ( Map.Entry stringModelEntry : processAllModules ? reactor.entrySet() : // - PomHelper.getChildModels( reactor, sourceGroupId, - sourceArtifactId ).entrySet() ) + PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) { final Model targetModel = stringModelEntry.getValue(); final Parent parent = targetModel.getParent(); getLog().debug( "Module: " + stringModelEntry.getKey() ); if ( parent != null && sourceVersion.equals( parent.getVersion() ) ) { - getLog().debug( " parent already is " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + sourceVersion ); + getLog().debug( + " parent already is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + + ":" + sourceVersion ); } else { - getLog().debug( " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + ":" + ( parent == null ? "" : parent.getVersion() )); - getLog().debug( " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + ":" + sourceVersion ); + getLog().debug( + " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + ( + parent == null ? "" : parent.getVersion() ) ); + getLog().debug( + " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + sourceVersion ); } final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); if ( ( updateMatchingVersions || !targetExplicit ) // - && ( parent != null && StringUtils.equals( parent.getVersion(), PomHelper.getVersion( targetModel ) ) ) ) + && ( parent != null && StringUtils.equals( parent.getVersion(), + PomHelper.getVersion( targetModel ) ) ) ) { - getLog().debug( " module is " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) - + ":" + PomHelper.getVersion( targetModel ) ); - getLog().debug( " will become " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) - + ":" + sourceVersion ); + getLog().debug( + " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + PomHelper.getVersion( + targetModel ) ); + getLog().debug( + " will become " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + sourceVersion ); addChange( PomHelper.getGroupId( targetModel ), PomHelper.getArtifactId( targetModel ), - PomHelper.getVersion( targetModel ), sourceVersion ); + PomHelper.getVersion( targetModel ), sourceVersion ); targetModel.setVersion( sourceVersion ); } else { - getLog().debug( " module is " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) - + ":" + PomHelper.getVersion( targetModel ) ); + getLog().debug( + " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + PomHelper.getVersion( + targetModel ) ); } } } @@ -509,11 +546,11 @@ else if ( moduleDir.isDirectory() ) * * @param pom The pom file to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. - * @throws javax.xml.stream.XMLStreamException when things go wrong. + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. + * @throws javax.xml.stream.XMLStreamException when things go wrong. */ protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { ContextualLog log = new DelegatingContextualLog( getLog() ); try @@ -526,18 +563,21 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) versionChangerFactory.setLog( log ); versionChangerFactory.setModel( model ); - VersionChanger changer = versionChangerFactory.newVersionChanger( processParent, processProject, - processDependencies, processPlugins ); + VersionChanger changer = + versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, + processPlugins ); for ( VersionChange versionChange : sourceChanges ) { changer.apply( versionChange ); } - if ( updateBuildOutputTimestamp && !"never".equals( updateBuildOutputTimestampPolicy ) ) { - if ( "always".equals( updateBuildOutputTimestampPolicy) || !sourceChanges.isEmpty() ) { + if ( updateBuildOutputTimestamp && !"never".equals( updateBuildOutputTimestampPolicy ) ) + { + if ( "always".equals( updateBuildOutputTimestampPolicy ) || !sourceChanges.isEmpty() ) + { // also update project.build.outputTimestamp - updateBuildOutputTimestamp(pom, model); + updateBuildOutputTimestamp( pom, model ); } } } @@ -548,8 +588,7 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) log.clearContext(); } - private void updateBuildOutputTimestamp( ModifiedPomXMLEventReader pom, Model model ) - throws XMLStreamException + private void updateBuildOutputTimestamp( ModifiedPomXMLEventReader pom, Model model ) throws XMLStreamException { String buildOutputTimestamp = model.getProperties().getProperty( "project.build.outputTimestamp" ); diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java new file mode 100644 index 0000000000..b078dbeccb --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -0,0 +1,95 @@ +package org.codehaus.mojo.versions; + +import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.fail; + +public class SetMojoTest +{ + @Test + public void testGetIncrementedVersion() throws MojoExecutionException + { + new SetMojo() + { + { + assertThat( getIncrementedVersion( "1.0.0", null ), is( "1.0.1-SNAPSHOT" ) ); + assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", null ), is( "1.0.1-SNAPSHOT" ) ); + assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 1 ), is( "2.0.0-SNAPSHOT" ) ); + assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 2 ), is( "1.1.0-SNAPSHOT" ) ); + assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 3 ), is( "1.0.1-SNAPSHOT" ) ); + } + }; + } + + @Test + public void testNextSnapshotIndexLowerBound() + { + new SetMojo() + { + { + try + { + getIncrementedVersion( "1.0.0", 0 ); + fail(); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), + containsString( "nextSnapshotIndexToIncrement cannot be less than 1" ) ); + } + } + }; + } + + @Test + public void testNextSnapshotIndexUpperBound() + { + new SetMojo() + { + { + try + { + getIncrementedVersion( "1.0.0", 4 ); + fail(); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), containsString( + "nextSnapshotIndexToIncrement cannot be greater than the last version index" ) ); + } + } + }; + } + + @Test + public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureException + { + try + { + new SetMojo() + { + { + project = new MavenProject(); + project.setParent( new MavenProject() ); + project.setOriginalModel( new Model() ); + project.getOriginalModel().setVersion( "1.2.3-SNAPSHOT" ); + + nextSnapshotIndexToIncrement = 4; + } + }.execute(); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), + containsString( "nextSnapshotIndexToIncrement is not valid when nextSnapshot is false" ) ); + } + } + +} From 6c6688b6ae6cbd7edadaa34417870a0216e48637 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Tue, 23 Aug 2022 13:07:56 +0200 Subject: [PATCH 090/441] Cache result of getBestFitRule (fixes #575) This was identified as a performance hotspot and the result is static for each run, adding a cache dramatically speeds up some executions. The included IT shows the problem: Without this optimization, it runs over a minute, with the fix it finishes instantly. --- src/it/it-property-updates-report-001/pom.xml | 14 +- .../invoker.properties | 2 + .../maven-version-rules.xml | 117 +++++++++++ .../pom.xml | 183 ++++++++++++++++++ .../versions/api/DefaultVersionsHelper.java | 15 ++ 5 files changed, 319 insertions(+), 12 deletions(-) create mode 100644 src/it/it-property-updates-report-002-slow/invoker.properties create mode 100644 src/it/it-property-updates-report-002-slow/maven-version-rules.xml create mode 100644 src/it/it-property-updates-report-002-slow/pom.xml diff --git a/src/it/it-property-updates-report-001/pom.xml b/src/it/it-property-updates-report-001/pom.xml index 5fb0beb858..59a117f3c1 100644 --- a/src/it/it-property-updates-report-001/pom.xml +++ b/src/it/it-property-updates-report-001/pom.xml @@ -55,25 +55,15 @@
maven-site-plugin - @sitePluginVersion@ - - - maven-project-info-reports-plugin - 2.1 + @maven-site-plugin.version@ + true - - maven-project-info-reports-plugin - 2.1 - - - - @project.groupId@ @project.artifactId@ diff --git a/src/it/it-property-updates-report-002-slow/invoker.properties b/src/it/it-property-updates-report-002-slow/invoker.properties new file mode 100644 index 0000000000..b0549c1189 --- /dev/null +++ b/src/it/it-property-updates-report-002-slow/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals=site +invoker.timeoutInSeconds=30 diff --git a/src/it/it-property-updates-report-002-slow/maven-version-rules.xml b/src/it/it-property-updates-report-002-slow/maven-version-rules.xml new file mode 100644 index 0000000000..2178a24370 --- /dev/null +++ b/src/it/it-property-updates-report-002-slow/maven-version-rules.xml @@ -0,0 +1,117 @@ + + + + + 200[34].* + + + + + .*[.-](rc|pr)\d+ + + + + + 2\.9\.\d+ + .*[.-](rc|pr)\d+ + + + + + .*[.-](rc|pr)\d+ + + + + + .*-RC\d+ + .*-EA\d* + .*-BETA-\d* + + + + + .*\.(Alpha|Beta|CR)\d+ + + + + + .*-alpha\d+ + + + + + .*-(alpha|beta|rc)-\d+ + + + + + .*\.(Alpha|Beta|CR)\d+ + + + + + .*-CR\d+ + + + + + 1.11.1 + 1.11.1-PUBLISHED-BY-MISTAKE + + + + + .*-(beta-|RC)\d* + + + + + .*\.jre[67] + + + + + .*-alpha\d+ + .*-beta\d+ + + + + + .*-atlassian-.* + + + + + .*-beta(\.\d+)? + .*-RC\.\d+ + + + + + .*\.(ALPHA|BETA)\d+ + + + + + .*RC\d+ + .*-beta\.\d+ + + + + + .*-b\d+\.\d+ + + + + + .*-b[\d.]+ + + + + + .*-beta-\d+ + .*-rc-\d+ + + + + diff --git a/src/it/it-property-updates-report-002-slow/pom.xml b/src/it/it-property-updates-report-002-slow/pom.xml new file mode 100644 index 0000000000..2db31ed03b --- /dev/null +++ b/src/it/it-property-updates-report-002-slow/pom.xml @@ -0,0 +1,183 @@ + + 4.0.0 + localhost + it-property-updates-report-002-slow + 1.0 + pom + property-updates-report + Validate performance of property-updates-report + + + 3.2.17.RELEASE + 4.3.2.Final + 1.7.10 + 2.2.11 + 0.11.1 + 3.17 + 4.5.2 + 2.6.7.3 + 2.4.3 + 42.2.6 + 2.0.0 + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + org.slf4j + slf4j-simple + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + jul-to-slf4j + ${slf4j.version} + + + + org.springframework + spring-framework-bom + ${spring.version} + pom + import + + + + org.hibernate + hibernate-validator + ${hibernate-validator.version} + + + + org.postgresql + postgresql + ${postgresql-client.version} + + + + org.mariadb.jdbc + mariadb-java-client + ${mariadb-client.version} + + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + org.apache.httpcomponents + fluent-hc + ${httpclient.version} + + + org.apache.httpcomponents + httpclient-cache + ${httpclient.version} + + + org.apache.httpcomponents + httpmime + ${httpclient.version} + + + + com.fasterxml.jackson + jackson-bom + ${jackson.version} + pom + import + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + org.apache.poi + poi-ooxml-schemas + ${poi.version} + + + stax + stax-api + + + + + + org.glassfish.jaxb + jaxb-bom + ${jaxb.version} + pom + import + + + + org.jvnet.jaxb2_commons + jaxb2-basics-runtime + ${jaxb2-basics.version} + + + org.jvnet.jaxb2_commons + jaxb2-basics-testing + ${jaxb2-basics.version} + + + + org.codehaus.groovy + groovy-all + ${groovy.version} + + + + + + + + + maven-site-plugin + @maven-site-plugin.version@ + + + + + + + true + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + file:${project.basedir}/maven-version-rules.xml + + + + + property-updates-report + + + + + + + diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 19c71253c0..91b4fb7fc0 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -164,6 +164,14 @@ public class DefaultVersionsHelper private final MojoExecution mojoExecution; + /** + * A cache mapping artifacts to their best fitting rule, since looking up + * this information can be quite costly. + * + * @since 2.12 + */ + private final Map artifactBestFitRule = new HashMap<>(); + /** * Constructs a new {@link DefaultVersionsHelper}. * @@ -522,6 +530,11 @@ public VersionComparator getVersionComparator( String groupId, String artifactId */ protected Rule getBestFitRule( String groupId, String artifactId ) { + String groupArtifactId = groupId + ':' + artifactId; + if (artifactBestFitRule.containsKey( groupArtifactId )) { + return artifactBestFitRule.get( groupArtifactId ); + } + Rule bestFit = null; final List rules = ruleSet.getRules(); int bestGroupIdScore = Integer.MAX_VALUE; @@ -571,6 +584,8 @@ protected Rule getBestFitRule( String groupId, String artifactId ) } bestFit = rule; } + + artifactBestFitRule.put( groupArtifactId, bestFit ); return bestFit; } From 9934505f478f69af6c2c81ac4ae415b07723ee60 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 21 Aug 2022 13:57:55 +0200 Subject: [PATCH 091/441] Enable checkstyle during build - checkstyle verification will be done on each build - reformat code according to rules - reorder imports --- pom.xml | 14 +- ...AbstractVersionsDependencyUpdaterMojo.java | 19 +- .../versions/AbstractVersionsDisplayMojo.java | 14 +- .../mojo/versions/AbstractVersionsReport.java | 8 +- .../AbstractVersionsReportRenderer.java | 4 + .../versions/AbstractVersionsUpdaterMojo.java | 72 ++--- .../codehaus/mojo/versions/CommitMojo.java | 6 +- .../versions/CompareDependenciesMojo.java | 25 +- .../versions/DependencyUpdatesRenderer.java | 8 +- .../versions/DependencyUpdatesReport.java | 36 +-- .../DependencyUpdatesXmlRenderer.java | 29 +- .../DisplayDependencyUpdatesMojo.java | 96 +++--- .../versions/DisplayParentUpdatesMojo.java | 15 +- .../versions/DisplayPluginUpdatesMojo.java | 265 +++++++++-------- .../versions/DisplayPropertyUpdatesMojo.java | 11 +- .../mojo/versions/ForceReleasesMojo.java | 17 +- .../mojo/versions/LockSnapshotsMojo.java | 6 +- .../MinimalMavenBuildVersionFinder.java | 203 ++++++++----- .../mojo/versions/PluginUpdatesDetails.java | 9 +- .../mojo/versions/PluginUpdatesRenderer.java | 16 +- .../versions/PluginUpdatesXmlRenderer.java | 16 +- .../versions/PropertyUpdatesRenderer.java | 10 +- .../mojo/versions/PropertyUpdatesReport.java | 7 +- .../mojo/versions/ResolveRangesMojo.java | 18 +- .../org/codehaus/mojo/versions/SetMojo.java | 93 +++--- .../mojo/versions/SetPropertyMojo.java | 83 +++--- .../codehaus/mojo/versions/SetScmTagMojo.java | 33 ++- .../mojo/versions/UnlockSnapshotsMojo.java | 31 +- .../mojo/versions/UpdateChildModulesMojo.java | 71 ++--- .../mojo/versions/UpdateParentMojo.java | 9 +- .../mojo/versions/UpdatePropertiesMojo.java | 31 +- .../mojo/versions/UpdatePropertyMojo.java | 28 +- .../mojo/versions/UseDepVersionMojo.java | 28 +- .../mojo/versions/UseLatestReleasesMojo.java | 38 +-- .../mojo/versions/UseLatestSnapshotsMojo.java | 49 ++-- .../mojo/versions/UseLatestVersionsMojo.java | 33 ++- .../mojo/versions/UseNextReleasesMojo.java | 15 +- .../mojo/versions/UseNextSnapshotsMojo.java | 25 +- .../mojo/versions/UseNextVersionsMojo.java | 16 +- .../mojo/versions/UseReactorMojo.java | 17 +- .../mojo/versions/UseReleasesMojo.java | 35 +-- .../mojo/versions/api/ArtifactVersions.java | 10 +- .../api/DefaultArtifactAssociation.java | 4 +- .../versions/api/DefaultVersionsHelper.java | 277 ++++++++++-------- .../codehaus/mojo/versions/api/PomHelper.java | 175 +++++------ .../mojo/versions/api/PropertyVersions.java | 138 +++++---- .../versions/api/PropertyVersionsBuilder.java | 12 +- .../mojo/versions/api/UpdateScope.java | 6 +- .../change/CompositeVersionChanger.java | 1 + .../change/DependencyVersionChanger.java | 4 +- .../versions/change/ParentVersionChanger.java | 4 +- .../versions/change/PluginVersionChanger.java | 4 +- .../change/ProjectVersionChanger.java | 4 +- .../change/VersionChangerFactory.java | 6 +- .../versions/ordering/ComparableVersion.java | 15 +- .../ordering/MajorMinorIncrementalFilter.java | 11 +- .../ordering/MavenVersionComparator.java | 3 + .../ordering/MercuryVersionComparator.java | 6 +- .../ordering/NumericVersionComparator.java | 7 +- .../ordering/ReactorDepthComparator.java | 6 +- .../versions/ordering/VersionComparator.java | 4 +- .../versions/ordering/VersionComparators.java | 6 +- .../recording/ChangeRecorderNull.java | 3 +- .../versions/recording/ChangeRecorderXML.java | 12 +- .../rewriting/ModifiedPomXMLEventReader.java | 21 +- .../versions/utils/DependencyComparator.java | 4 +- .../mojo/versions/utils/PluginComparator.java | 12 +- .../utils/PropertiesVersionsFileReader.java | 42 +-- .../versions/utils/PropertyComparator.java | 4 +- .../mojo/versions/utils/WagonUtils.java | 2 +- .../versions/DependencyUpdatesReportTest.java | 112 +++---- .../MinimalMavenBuildVersionFinderTest.java | 57 ++-- .../versions/PluginUpdatesReportTest.java | 84 +++--- .../mojo/versions/RewriteWithStAXTest.java | 10 +- ...ratePatternsForIncludesAnExcludesTest.java | 9 +- .../versions/api/ArtifactVersionsTest.java | 43 +-- .../api/DefaultVersionsHelperTest.java | 78 ++--- .../mojo/versions/api/PomHelperTest.java | 44 +-- .../filtering/DependencyFilterTest.java | 131 ++++----- .../filtering/TokenizedMatcherTest.java | 99 +++---- .../filtering/WildcardMatcherTest.java | 120 ++++---- .../MajorMinorIncrementalFilterTest.java | 126 ++++---- .../NumericVersionComparatorTest.java | 3 +- .../ordering/VersionComparatorsTest.java | 29 +- .../recording/ChangeRecorderXMLTest.java | 17 +- .../PropertiesVersionsFileReaderTest.java | 36 ++- 86 files changed, 1827 insertions(+), 1533 deletions(-) diff --git a/pom.xml b/pom.xml index 486b4eb6bb..fd3e86c710 100644 --- a/pom.xml +++ b/pom.xml @@ -266,17 +266,11 @@ - - - - org.codehaus.modello - modello-maven-plugin - 2.0.0 - - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + org.codehaus.mojo animal-sniffer-maven-plugin diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 4179854b3d..f3349023a5 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -172,7 +172,8 @@ public boolean isProcessingParent() /** * Should the artifacts produced in the current reactor be excluded from processing. * - * @return returns true if the artifacts produced in the current reactor should be excluded from processing. + * @return returns true if the artifacts produced in the current reactor + * should be excluded from processing. * @since 1.0-alpha-3 */ public boolean isExcludeReactor() @@ -182,7 +183,7 @@ public boolean isExcludeReactor() /** * Should the dependency be updated itself or is it handled by properties. - * + * * @param dependency Dependency * @return true if the version starts with '${' * @since 2.8 @@ -220,8 +221,8 @@ protected Artifact findArtifact( Dependency dependency ) * Try to find the dependency artifact that matches the given dependency. * * @param dependency Dependency - * @throws MojoExecutionException Mojo execution exception * @return Artifact + * @throws MojoExecutionException Mojo execution exception * @since 1.0-alpha-3 */ protected Artifact toArtifact( Dependency dependency ) @@ -301,9 +302,11 @@ protected String toString( Dependency d ) */ protected boolean isProducedByReactor( Dependency dependency ) { - for ( Object reactorProject : reactorProjects ) { + for ( Object reactorProject : reactorProjects ) + { MavenProject project = (MavenProject) reactorProject; - if ( compare(project, dependency) ) { + if ( compare( project, dependency ) ) + { return true; } } @@ -315,7 +318,7 @@ protected boolean isProducedByReactor( Dependency dependency ) * Compare a project to a dependency. Returns true only if the groupId and artifactId are all equal. * * @param project the project - * @param dep the dependency + * @param dep the dependency * @return true if project and dep refer to the same artifact */ private boolean compare( MavenProject project, Dependency dep ) @@ -332,7 +335,7 @@ private boolean compare( MavenProject project, Dependency dep ) * equal. * * @param artifact Artifact - * @param dep Dependency + * @param dep Dependency * @return true if artifact and dep refer to the same artifact */ private boolean compare( Artifact artifact, Dependency dep ) @@ -381,7 +384,7 @@ protected boolean isIncluded( Artifact artifact ) /** * Indicates whether any includes were specified via the 'includes' or 'includesList' options. - * + * * @return true if includes were specified, false otherwise. */ protected boolean hasIncludes() diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index d912f25e2d..c7db3a478b 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -37,7 +37,7 @@ public abstract class AbstractVersionsDisplayMojo extends AbstractVersionsUpdaterMojo { - String NL = System.getProperty( "line.separator" ); + static final String NL = System.getProperty( "line.separator" ); private static final int DEFAULT_OUTPUT_LINE_WIDTH = 80; @@ -70,7 +70,8 @@ public abstract class AbstractVersionsDisplayMojo * * @since 2.10.0 */ - @Parameter( property = "versions.outputLineWidth", defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "" ) + @Parameter( property = "versions.outputLineWidth", + defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "" ) private int outputLineWidth; private boolean outputFileError = false; @@ -129,7 +130,7 @@ else if ( !outputFile.getParentFile().isDirectory() ) { outputEncoding = System.getProperty( "file.encoding" ); getLog().warn( "File encoding has not been set, using platform encoding " + outputEncoding - + ", i.e. build is platform dependent!" ); + + ", i.e. build is platform dependent!" ); } } } @@ -152,8 +153,8 @@ protected void logLine( boolean error, String line ) try { Files.write( outputFile.toPath(), - ( error ? "> " + line + NL : line + NL ).getBytes( outputEncoding ), - StandardOpenOption.APPEND, StandardOpenOption.CREATE ); + ( error ? "> " + line + NL : line + NL ).getBytes( outputEncoding ), + StandardOpenOption.APPEND, StandardOpenOption.CREATE ); } catch ( IOException e ) { @@ -166,7 +167,8 @@ protected void logLine( boolean error, String line ) /** * @return Offset of the configured output line width compared to the default with of 80. */ - protected int getOutputLineWidthOffset() { + protected int getOutputLineWidthOffset() + { return this.outputLineWidth - DEFAULT_OUTPUT_LINE_WIDTH; } diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index bb3b81e90c..c60bfe56cc 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -19,6 +19,10 @@ * under the License. */ +import java.io.File; +import java.util.List; +import java.util.Locale; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -44,10 +48,6 @@ import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.plexus.i18n.I18N; -import java.io.File; -import java.util.List; -import java.util.Locale; - /** * Base class for all versions reports. * diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index b7bca23459..470f9c4a1f 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -211,6 +211,7 @@ protected void safeBold() } } + @SuppressWarnings( "checkstyle:MethodName" ) protected void safeBold_() { try @@ -235,6 +236,7 @@ protected void safeItalic() } } + @SuppressWarnings( "checkstyle:MethodName" ) protected void safeItalic_() { try @@ -306,6 +308,7 @@ protected void renderDependencyDetailTable( Dependency dependency, ArtifactVersi renderDependencyDetailTable( dependency, details, true, true, true ); } + @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderDependencyDetailTable( Dependency dependency, ArtifactVersions details, boolean includeScope, boolean includeClassifier, boolean includeType ) { @@ -601,6 +604,7 @@ protected void renderPropertySummaryTableHeader() sink.tableRow_(); } + @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderPropertyDetailTable( Property property, PropertyVersions versions ) { final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 6f8d0a7792..83121bda23 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -19,6 +19,15 @@ * under the License. */ +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.Writer; +import java.util.List; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -38,7 +47,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.path.PathTranslator; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; @@ -55,14 +63,6 @@ import org.codehaus.plexus.util.WriterFactory; import org.codehaus.stax2.XMLInputFactory2; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.Writer; -import java.util.List; - /** * Abstract base class for Versions Mojos. * @@ -277,14 +277,14 @@ public void execute() /** * Finds the latest version of the specified artifact that matches the version range. * - * @param artifact The artifact. - * @param versionRange The version range. - * @param allowingSnapshots null for no override, otherwise the local override to apply. + * @param artifact The artifact. + * @param versionRange The version range. + * @param allowingSnapshots null for no override, otherwise the local override to apply. * @param usePluginRepositories Use plugin repositories * @return The latest version of the specified artifact that matches the specified version range or - * null if no matching version could be found. + * null if no matching version could be found. * @throws ArtifactMetadataRetrievalException If the artifact metadata could not be found. - * @throws MojoExecutionException if something goes wrong. + * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-1 */ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, @@ -308,7 +308,7 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver * Gets the property value that is defined in the pom. This is an extension point to allow updating a file external * to the reactor. * - * @param pom The pom. + * @param pom The pom. * @param property The property. * @return The value as defined in the pom or null if not defined. * @since 1.0-alpha-1 @@ -323,7 +323,7 @@ protected String getPropertyValue( StringBuilder pom, String property ) * * @param outFile The file to process. * @throws MojoExecutionException If things go wrong. - * @throws MojoFailureException If things go wrong. + * @throws MojoFailureException If things go wrong. * @since 1.0-alpha-1 */ protected void process( File outFile ) @@ -375,7 +375,7 @@ protected void process( File outFile ) * Creates a {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader} from a StringBuilder. * * @param input The XML to read and modify. - * @param path Path pointing to the source of the XML + * @param path Path pointing to the source of the XML * @return The {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader}. */ protected final ModifiedPomXMLEventReader newModifiedPomXER( StringBuilder input, String path ) @@ -398,13 +398,13 @@ protected final ModifiedPomXMLEventReader newModifiedPomXER( StringBuilder input * Writes a StringBuilder into a file. * * @param outFile The file to read. - * @param input The contents of the file. + * @param input The contents of the file. * @throws IOException when things go wrong. */ protected final void writeFile( File outFile, StringBuilder input ) throws IOException { - try (Writer writer = WriterFactory.newXmlWriter( outFile ) ) + try ( Writer writer = WriterFactory.newXmlWriter( outFile ) ) { IOUtil.copy( input.toString(), writer ); } @@ -414,44 +414,44 @@ protected final void writeFile( File outFile, StringBuilder input ) * Updates the pom. * * @param pom The pom to update. - * @throws MojoExecutionException If things go wrong. - * @throws MojoFailureException If things go wrong. + * @throws MojoExecutionException If things go wrong. + * @throws MojoFailureException If things go wrong. * @throws javax.xml.stream.XMLStreamException If things go wrong. - * @throws ArtifactMetadataRetrievalException if something goes wrong. + * @throws ArtifactMetadataRetrievalException if something goes wrong. * @since 1.0-alpha-1 */ protected abstract void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException; /** - * @deprecated - * This method no longer supported. - * use shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, Boolean forceUpdate ) - * - * Returns true if the update should be applied. - * - * @param artifact The artifact. + * @param artifact The artifact. * @param currentVersion The current version of the artifact. - * @param updateVersion The proposed new version of the artifact. + * @param updateVersion The proposed new version of the artifact. * @return true if the update should be applied. * @since 1.0-alpha-1 + * @deprecated This method no longer supported. + * use shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, Boolean + * forceUpdate ) + *

+ * Returns true if the update should be applied. */ @Deprecated protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion ) { - return shouldApplyUpdate(artifact,currentVersion,updateVersion,false); + return shouldApplyUpdate( artifact, currentVersion, updateVersion, false ); } /** * Returns true if the update should be applied. * - * @param artifact The artifact. + * @param artifact The artifact. * @param currentVersion The current version of the artifact. - * @param updateVersion The proposed new version of the artifact. + * @param updateVersion The proposed new version of the artifact. * @return true if the update should be applied to the pom. * @since 2.9 */ - protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, boolean forceUpdate ) + protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, + boolean forceUpdate ) { getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion ); @@ -495,8 +495,8 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * Based on the passed flags, determines which segment is unchangable. This can be used when determining an upper * bound for the "latest" version. * - * @param allowMajorUpdates Allow major updates - * @param allowMinorUpdates Allow minor updates + * @param allowMajorUpdates Allow major updates + * @param allowMinorUpdates Allow minor updates * @param allowIncrementalUpdates Allow incremental updates * @return Returns the segment that is unchangable. If any segment can change, returns -1. */ diff --git a/src/main/java/org/codehaus/mojo/versions/CommitMojo.java b/src/main/java/org/codehaus/mojo/versions/CommitMojo.java index 8ad1746444..3a715cff70 100644 --- a/src/main/java/org/codehaus/mojo/versions/CommitMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CommitMojo.java @@ -19,6 +19,9 @@ * under the License. */ +import java.io.File; +import java.io.IOException; + import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -27,9 +30,6 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; - /** * Removes the initial backup of the pom, thereby accepting the changes. * diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index c74116c0c5..ad0a716887 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -28,8 +30,6 @@ import java.util.List; import java.util.Map; -import javax.xml.stream.XMLStreamException; - import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -119,8 +119,8 @@ public class CompareDependenciesMojo /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException Something wrong with the plugin itself - * @throws org.apache.maven.plugin.MojoFailureException The plugin detected an error in the build - * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming + * @throws org.apache.maven.plugin.MojoFailureException The plugin detected an error in the build + * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) @@ -129,7 +129,7 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( this.ignoreRemoteDependencies && this.ignoreRemoteDependencyManagement ) { throw new MojoFailureException( " ignoreRemoteDependencies and ignoreRemoteDependencyManagement" - + "are both set to true. At least one of these needs to be false " ); + + "are both set to true. At least one of these needs to be false " ); } if ( updateDependencies ) @@ -167,7 +167,7 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( !ignoreRemoteDependencyManagement ) { List remoteProjectDepMgmtDeps = ( remoteMavenProject.getDependencyManagement() == null ) ? null - : remoteMavenProject.getDependencyManagement().getDependencies(); + : remoteMavenProject.getDependencyManagement().getDependencies(); mapDependencies( remoteDepsMap, remoteProjectDepMgmtDeps ); } if ( !ignoreRemoteDependencies ) @@ -303,7 +303,7 @@ private List updatePropertyVersions( ModifiedPomXMLEventReader pom, && PomHelper.setPropertyVersion( pom, null, property.getName(), candidateVersion ) ) { getLog().info( "Updated ${" + property.getName() + "} from " + originalVersion + " to " - + candidateVersion ); + + candidateVersion ); } } } @@ -319,8 +319,8 @@ private List updatePropertyVersions( ModifiedPomXMLEventReader pom, * indicating that there is no candidate. * * @param remoteDependencies the remote dependencies - * @param property the property to update - * @param propertyVersions the association + * @param property the property to update + * @param propertyVersions the association * @return the candidate version or null if there isn't any */ private String computeCandidateVersion( Map remoteDependencies, Property property, @@ -360,8 +360,8 @@ private void writeReportFile( List dependenciesUpdate, List prop reportOutputFile.getParentFile().mkdirs(); } - try( FileWriter fw = new FileWriter( reportOutputFile ); // - PrintWriter pw = new PrintWriter( fw ) ) + try ( FileWriter fw = new FileWriter( reportOutputFile ); // + PrintWriter pw = new PrintWriter( fw ) ) { pw.println( "The following differences were found:" ); pw.println(); @@ -450,7 +450,8 @@ private void mapDependencies( Map map, List deps private static String generateId( Artifact artifact ) { StringBuilder sb = new StringBuilder(); - sb.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" ).append( artifact.getType() ); + sb.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" ) + .append( artifact.getType() ); if ( artifact.getClassifier() != null ) { sb.append( ":" ).append( artifact.getClassifier() ); diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java index 81eff8626a..3295b1a8c8 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java @@ -19,6 +19,10 @@ * under the License. */ +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; @@ -27,10 +31,6 @@ import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.i18n.I18N; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - /** * @since 1.0-beta-1 */ diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index 791ef57abf..c3ed203827 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -128,13 +128,13 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx if ( processDependencyManagementTransitive ) { if ( getProject().getDependencyManagement() != null - && getProject().getDependencyManagement().getDependencies() != null ) + && getProject().getDependencyManagement().getDependencies() != null ) { for ( Dependency dep : getProject().getDependencyManagement().getDependencies() ) { getLog().debug( - "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" - + dep.getType() + ":" + dep.getScope() ); + "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" + + dep.getType() + ":" + dep.getScope() ); } dependencyManagement.addAll( getProject().getDependencyManagement().getDependencies() ); } @@ -142,7 +142,7 @@ && getProject().getDependencyManagement().getDependencies() != null ) else { if ( getProject().getOriginalModel().getDependencyManagement() != null - && getProject().getOriginalModel().getDependencyManagement().getDependencies() != null ) + && getProject().getOriginalModel().getDependencyManagement().getDependencies() != null ) { // Using the original model to get the original dependencyManagement entries and // not the interpolated model. @@ -150,10 +150,10 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) { getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" - + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); } dependencyManagement.addAll( - getProject().getOriginalModel().getDependencyManagement().getDependencies() ); + getProject().getOriginalModel().getDependencyManagement().getDependencies() ); } } @@ -172,11 +172,11 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! try { Map dependencyUpdates = - getHelper().lookupDependenciesUpdates( dependencies, false ); + getHelper().lookupDependenciesUpdates( dependencies, false ); Map dependencyManagementUpdates = - processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) : - EMPTY_MAP; + processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) + : EMPTY_MAP; if ( onlyUpgradable ) { @@ -189,8 +189,8 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! if ( "html".equals( format ) ) { DependencyUpdatesRenderer renderer = - new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, dependencyUpdates, - dependencyManagementUpdates ); + new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, dependencyUpdates, + dependencyManagementUpdates ); renderer.render(); } @@ -206,8 +206,8 @@ else if ( "xml".equals( format ) ) } String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; DependencyUpdatesXmlRenderer xmlGenerator = - new DependencyUpdatesXmlRenderer( dependencyUpdates, dependencyManagementUpdates, - outputFile ); + new DependencyUpdatesXmlRenderer( dependencyUpdates, dependencyManagementUpdates, + outputFile ); xmlGenerator.render(); } } @@ -226,11 +226,11 @@ else if ( "xml".equals( format ) ) private boolean match( Dependency dep, Dependency dmDep ) { return dmDep.getGroupId().equals( dep.getGroupId() ) - && dmDep.getArtifactId().equals( dep.getArtifactId() ) - && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) - && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) - && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() - .equals( dep.getVersion() ) ); + && dmDep.getArtifactId().equals( dep.getArtifactId() ) + && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) + && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) + && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() + .equals( dep.getVersion() ) ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java index d5ca9983e5..6c98285bc1 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java @@ -36,7 +36,7 @@ /** * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available * dependency/dependency management updates. - * + * * @author Illia Dubinin * @since 2.4 */ @@ -86,7 +86,7 @@ public DependencyUpdatesXmlRenderer( Map dependenc /** * Makes report file with given name in target directory. - * + * * @throws MavenReportException if something went wrong */ public void render() @@ -118,9 +118,9 @@ public void render() /** * Method wraps value in xml tag. In ex: to wrap foo in tag bar you have to pass foo as value and bar as tag. As a * result you will get: <bar>foo</bar> - * + * * @param value - string to wrap - * @param tag - name of tag + * @param tag - name of tag * @return value wrapped in xml tag */ @@ -132,7 +132,7 @@ public static String wrapElement( String value, String tag ) /** * Returns summary of dependency analysis result in xml format: current version, next available, next incremental, * next minor and next major versions. - * + * * @param allUpdates all dependencies versions * @return summary in xml format */ @@ -180,7 +180,7 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) * Returns xml report for current dependency state with following info: current version, next available version, * next incremental/minor/major if available and status ('incremental available', 'minor available', 'major * available' or 'no new available') - * + * * @param versions version info for dependency * @return xml reports about current possible updates. */ @@ -234,7 +234,8 @@ private static String getDependencyInfoBlock( Map sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); for ( Entry entry : dependencyUpdates.entrySet() ) { - sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) + .append( NL ); Dependency dep = entry.getKey(); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getGroupId(), @@ -250,7 +251,8 @@ private static String getDependencyInfoBlock( Map sBuilder.append( getVersionsBlocks( entry.getValue() ) ); - sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) + .append( NL ); } sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); return sBuilder.toString(); @@ -264,14 +266,17 @@ private static String getVersionsInScopeBlock( ArtifactVersions av, UpdateScope ArtifactVersion nextVersion = av.getOldestUpdate( scope ); if ( nextVersion != null ) { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_TAG ).append( versionsTag ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_TAG ).append( versionsTag ) + .append( CLOSE_TAG ).append( NL ); ArtifactVersion[] versions = av.getAllUpdates( scope ); for ( ArtifactVersion version : versions ) { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( TAB ).append( wrapElement( version.toString(), - scope.toString().toLowerCase() ) ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( TAB ).append( TAB ) + .append( wrapElement( version.toString(), + scope.toString().toLowerCase() ) ).append( NL ); } - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( versionsTag ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( versionsTag ) + .append( CLOSE_TAG ).append( NL ); } return sBuilder.toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 93358dde98..f4cf8274bb 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -57,7 +57,8 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "display-dependency-updates", requiresProject = true, requiresDirectInvocation = false, threadSafe = true ) +@Mojo( name = "display-dependency-updates", requiresProject = true, requiresDirectInvocation = false, + threadSafe = true ) public class DisplayDependencyUpdatesMojo extends AbstractVersionsDisplayMojo { @@ -208,9 +209,10 @@ public class DisplayDependencyUpdatesMojo * Whether to allow the major version number to be changed. * You need to set {@link #allowAnyUpdates} to false to * get this configuration gets control. + * * @since 2.5 */ - @Parameter(property = "allowMajorUpdates", defaultValue = "true") + @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) private boolean allowMajorUpdates; /** @@ -220,7 +222,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter(property = "allowMinorUpdates", defaultValue = "true") + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) private boolean allowMinorUpdates; /** @@ -230,7 +232,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") + @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) private boolean allowIncrementalUpdates; /** @@ -239,11 +241,12 @@ public class DisplayDependencyUpdatesMojo * If you set this to false you can control changes in version * number by {@link #allowMajorUpdates}, {@link #allowMinorUpdates} or * {@link #allowIncrementalUpdates}. - * @deprecated This will be removed with version 3.0.0 + * * @since 2.5 + * @deprecated This will be removed with version 3.0.0 */ @Deprecated - @Parameter(property = "allowAnyUpdates", defaultValue = "true") + @Parameter( property = "allowAnyUpdates", defaultValue = "true" ) private boolean allowAnyUpdates; /** @@ -289,13 +292,14 @@ private static Set extractDependenciesFromPlugins( List plug * Returns a set of dependencies where the dependencies which are defined in the dependency management section have * been filtered out. * - * @param dependencies The set of dependencies. + * @param dependencies The set of dependencies. * @param dependencyManagement The set of dependencies from the dependency management section. * @return A new set of dependencies which are from the set of dependencies but not from the set of dependency - * management dependencies. + * management dependencies. * @since 1.0-beta-1 */ - private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement ) + private static Set removeDependencyManagment( Set dependencies, + Set dependencyManagement ) { Set result = new TreeSet<>( new DependencyComparator() ); for ( Dependency dependency : dependencies ) @@ -320,31 +324,31 @@ private static Set removeDependencyManagment( Set depend // open for tests protected static boolean dependenciesMatch( Dependency dependency, Dependency managedDependency ) { - if ( ! managedDependency.getGroupId().equals( dependency.getGroupId() ) ) + if ( !managedDependency.getGroupId().equals( dependency.getGroupId() ) ) { return false; } - if ( ! managedDependency.getArtifactId().equals( dependency.getArtifactId() ) ) + if ( !managedDependency.getArtifactId().equals( dependency.getArtifactId() ) ) { return false; } if ( managedDependency.getScope() == null - || Objects.equals( managedDependency.getScope(), dependency.getScope() ) ) + || Objects.equals( managedDependency.getScope(), dependency.getScope() ) ) { return false; } if ( managedDependency.getClassifier() == null - || Objects.equals( managedDependency.getClassifier(), dependency.getClassifier() ) ) + || Objects.equals( managedDependency.getClassifier(), dependency.getClassifier() ) ) { return false; } return dependency.getVersion() == null - || managedDependency.getVersion() == null - || Objects.equals( managedDependency.getVersion(), dependency.getVersion() ); + || managedDependency.getVersion() == null + || Objects.equals( managedDependency.getVersion(), dependency.getVersion() ); } public boolean isProcessingDependencyManagement() @@ -378,7 +382,7 @@ public boolean isVerbose() /** * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#execute() * @since 1.0-alpha-1 */ @@ -389,7 +393,7 @@ public void execute() logInit(); Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); - DependencyManagement projectDependencyManagement = getProjectDependencyManagement(getProject()); + DependencyManagement projectDependencyManagement = getProjectDependencyManagement( getProject() ); if ( projectDependencyManagement != null ) { @@ -397,14 +401,15 @@ public void execute() for ( Dependency dependency : dependenciesFromPom ) { getLog().debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() - + ":" + dependency.getVersion() + ":" + dependency.getScope() ); + + ":" + dependency.getVersion() + ":" + dependency.getScope() ); if ( dependency.getVersion() == null ) { // get parent and get the information from there. if ( getProject().hasParent() ) { getLog().debug( "Reading parent dependencyManagement information" ); - DependencyManagement parentProjectDependencyManagement = getProjectDependencyManagement(getProject().getParent()); + DependencyManagement parentProjectDependencyManagement = + getProjectDependencyManagement( getProject().getParent() ); if ( parentProjectDependencyManagement != null ) { List parentDeps = parentProjectDependencyManagement.getDependencies(); @@ -489,38 +494,44 @@ public void execute() } } - private Set filterDependencyIncludes(Set dependencies) { - return filterDependencies(dependencies, dependencyIncludes, dependencyExcludes, "dependencies"); + private Set filterDependencyIncludes( Set dependencies ) + { + return filterDependencies( dependencies, dependencyIncludes, dependencyExcludes, "dependencies" ); } - private Set filterDependencyManagementIncludes(Set dependencyManagement) { - return filterDependencies(dependencyManagement, - dependencyManagementIncludes, dependencyManagementExcludes, "dependecyManagement"); + private Set filterDependencyManagementIncludes( Set dependencyManagement ) + { + return filterDependencies( dependencyManagement, + dependencyManagementIncludes, dependencyManagementExcludes, "dependecyManagement" ); } private Set filterDependencies( - Set dependencies, - List includes, - List excludes, - String section - ) { - DependencyFilter includeDeps = DependencyFilter.parseFrom(includes); - DependencyFilter excludeDeps = DependencyFilter.parseFrom(excludes); + Set dependencies, + List includes, + List excludes, + String section + ) + { + DependencyFilter includeDeps = DependencyFilter.parseFrom( includes ); + DependencyFilter excludeDeps = DependencyFilter.parseFrom( excludes ); - getLog().debug(String.format("parsed includes in %s: %s -> %s", section, includes, includeDeps )); - getLog().debug(String.format("parsed excludes in %s: %s -> %s", section, excludes, excludeDeps )); + getLog().debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); + getLog().debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); - Set onlyIncludes = includeDeps.retainingIn(dependencies); - Set filtered = excludeDeps.removingFrom(onlyIncludes); + Set onlyIncludes = includeDeps.retainingIn( dependencies ); + Set filtered = excludeDeps.removingFrom( onlyIncludes ); return filtered; } - private DependencyManagement getProjectDependencyManagement(MavenProject project) { - if (processDependencyManagementTransitive) { + private DependencyManagement getProjectDependencyManagement( MavenProject project ) + { + if ( processDependencyManagementTransitive ) + { return project.getDependencyManagement(); } - else { + else + { return project.getOriginalModel().getDependencyManagement(); } } @@ -574,7 +585,7 @@ private void logUpdates( Map updates, String secti versions.getNewestVersion( versions.getArtifact().getVersionRange(), allowSnapshots ); current = versions.getArtifact().getVersionRange().toString(); latest = newestVersion == null ? null - : versions.getNewestUpdate( newestVersion, calculateUpdateScope(), allowSnapshots ); + : versions.getNewestUpdate( newestVersion, calculateUpdateScope(), allowSnapshots ); if ( latest != null && ArtifactVersions.isVersionInRange( latest, versions.getArtifact().getVersionRange() ) ) { @@ -591,7 +602,8 @@ private void logUpdates( Map updates, String secti } else { - t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), "." ) + right ); + t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), "." ) + + right ); } } @@ -641,8 +653,8 @@ private void logUpdates( Map updates, String secti /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way - * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way + * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index a9e5abc246..dca737c981 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -30,8 +32,6 @@ import org.apache.maven.plugins.annotations.Mojo; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * Displays any updates of the project's parent project * @@ -43,6 +43,8 @@ public class DisplayParentUpdatesMojo extends AbstractVersionsDisplayMojo { + public static final int MESSAGE_LENGTH = 68; + @Override public void execute() throws MojoExecutionException, MojoFailureException @@ -94,13 +96,13 @@ public void execute() if ( artifactVersion == null || currentVersion.equals( artifactVersion.toString() ) ) { logLine( false, "The parent project is the latest version:" ); - StringBuilder buf = new StringBuilder( 68 ); + StringBuilder buf = new StringBuilder( MESSAGE_LENGTH ); buf.append( " " ); buf.append( getProject().getParent().getGroupId() ); buf.append( ':' ); buf.append( getProject().getParent().getArtifactId() ); buf.append( ' ' ); - int padding = 68 - currentVersion.length(); + int padding = MESSAGE_LENGTH - currentVersion.length(); while ( buf.length() < padding ) { buf.append( '.' ); @@ -112,13 +114,14 @@ public void execute() else { logLine( false, "The parent project has a newer version:" ); - StringBuilder buf = new StringBuilder( 68 ); + StringBuilder buf = new StringBuilder( MESSAGE_LENGTH ); buf.append( " " ); buf.append( getProject().getParent().getGroupId() ); buf.append( ':' ); buf.append( getProject().getParent().getArtifactId() ); buf.append( ' ' ); - int padding = 68 - currentVersion.length() - artifactVersion.toString().length() - " -> ".length(); + int padding = MESSAGE_LENGTH - currentVersion.length() + - artifactVersion.toString().length() - " -> ".length(); while ( buf.length() < padding ) { buf.append( '.' ); diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 91229b2f4d..67f62ca5ed 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -19,6 +19,32 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; +import java.io.StringWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.regex.Pattern; + import org.apache.maven.BuildFailureException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -72,32 +98,6 @@ import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.StringUtils; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.XMLEvent; - -import java.io.File; -import java.io.IOException; -import java.io.Reader; -import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.regex.Pattern; - /** * Displays all plugins that have newer versions available, taking care of Maven version prerequisites. * @@ -176,10 +176,10 @@ private Map getSuperPomPluginManagement() { Method getPluginsBoundByDefaultToAllLifecycles = LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - new Class[] { String.class } ); + new Class[] {String.class} ); Set plugins = (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { - getProject().getPackaging() } ); + getProject().getPackaging()} ); // we need to provide a copy with the version blanked out so that inferring from super-pom // works as for 2.x as 3.x fills in the version on us! Map result = new LinkedHashMap<>( plugins.size() ); @@ -192,13 +192,14 @@ private Map getSuperPomPluginManagement() { try { - try( Reader reader = ReaderFactory.newXmlReader( superPom ) ) + try ( Reader reader = ReaderFactory.newXmlReader( superPom ) ) { StringBuilder buf = new StringBuilder( IOUtil.toString( reader ) ); ModifiedPomXMLEventReader pom = newModifiedPomXER( buf, superPom.toString() ); Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); + + "((/build(/pluginManagement)?)|(/reporting))" + + "/plugins/plugin" ); Stack pathStack = new Stack<>(); StackState curState = null; while ( pom.hasNext() ) @@ -244,8 +245,8 @@ else if ( event.isEndElement() ) Plugin plugin = new Plugin(); plugin.setArtifactId( curState.artifactId ); plugin.setGroupId( curState.groupId == null - ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID - : curState.groupId ); + ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID + : curState.groupId ); plugin.setVersion( curState.version ); if ( !result.containsKey( plugin.getKey() ) ) { @@ -349,10 +350,11 @@ private Map getPluginManagement( Model model ) /** * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way + * @throws MojoFailureException when things go wrong in a very bad way * @see AbstractVersionsUpdaterMojo#execute() * @since 1.0-alpha-1 */ + @SuppressWarnings( "checkstyle:MethodLength" ) public void execute() throws MojoExecutionException, MojoFailureException { @@ -404,7 +406,8 @@ public void execute() } boolean versionSpecifiedInCurrentPom = pluginsWithVersionsSpecified.contains( coords ); - if ( !versionSpecifiedInCurrentPom && parentPlugins.containsKey( coords ) ) { + if ( !versionSpecifiedInCurrentPom && parentPlugins.containsKey( coords ) ) + { getLog().debug( "Skip " + coords + ", version " + version + " is defined in parent POM." ); continue; } @@ -469,12 +472,14 @@ public void execute() { // plugin version configured that require a Maven version higher than spec upgradePlugins.put( upgradePluginKey, - pad( upgradePluginKey, INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); + pad( upgradePluginKey, + INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); } else { // plugin that can be upgraded - upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE + getOutputLineWidthOffset(), + upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE + + getOutputLineWidthOffset(), effectiveVersion, " -> ", newer ) ); } } @@ -542,15 +547,15 @@ public void execute() getLog().debug( "[" + coords + "].superPom.version=" + version ); newVersion = artifactVersion != null ? artifactVersion.toString() - : ( version != null ? version - : ( effectiveVersion != null ? effectiveVersion : "(unknown)" ) ); + : ( version != null ? version + : ( effectiveVersion != null ? effectiveVersion : "(unknown)" ) ); if ( version != null ) { superPomDrivingMinVersion = true; } pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getOutputLineWidthOffset(), - superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); + superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); } else if ( artifactVersion != null ) { @@ -561,10 +566,11 @@ else if ( artifactVersion != null ) newVersion = null; } if ( version != null && artifactVersion != null && newVersion != null && effectiveVersion != null - && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) < 0 ) + && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) + < 0 ) { pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getOutputLineWidthOffset(), - effectiveVersion, " -> ", newVersion ) ); + effectiveVersion, " -> ", newVersion ) ); } } @@ -580,7 +586,7 @@ && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifact else { logLine( false, "The following plugin updates are available:" ); - for ( String update : new TreeSet<>(pluginUpdates) ) + for ( String update : new TreeSet<>( pluginUpdates ) ) { logLine( false, update ); } @@ -595,7 +601,7 @@ && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifact else { getLog().warn( "The following plugins do not have their version specified:" ); - for ( String lockdown : new TreeSet<>(pluginLockdowns) ) + for ( String lockdown : new TreeSet<>( pluginLockdowns ) ) { getLog().warn( lockdown ); } @@ -690,7 +696,7 @@ else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion logLine( false, "" ); } - private static String pad( String start, int len, String...ends ) + private static String pad( String start, int len, String... ends ) { StringBuilder buf = new StringBuilder( len ); buf.append( " " ); @@ -720,7 +726,7 @@ private Map getParentsPlugins( List parents ) for ( MavenProject parentProject : parents ) { getLog().debug( "Processing parent: " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() - + ":" + parentProject.getVersion() + " -> " + parentProject.getFile() ); + + ":" + parentProject.getVersion() + " -> " + parentProject.getFile() ); StringWriter writer = new StringWriter(); boolean havePom = false; @@ -730,8 +736,8 @@ private Map getParentsPlugins( List parents ) if ( originalModel == null ) { getLog().warn( "project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" - + parentProject.getArtifactId() + ":" + parentProject.getVersion() - + " is null, substituting project.getModel()" ); + + parentProject.getArtifactId() + ":" + parentProject.getVersion() + + " is null, substituting project.getModel()" ); originalModel = parentProject.getModel(); } try @@ -745,15 +751,17 @@ private Map getParentsPlugins( List parents ) // ignore } ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); - modelBuildingRequest.setUserProperties(getProject().getProperties()); + modelBuildingRequest.setUserProperties( getProject().getProperties() ); interpolatedModel = modelInterpolator.interpolateModel( originalModel, null, - modelBuildingRequest, new IgnoringModelProblemCollector() ); + modelBuildingRequest, + new IgnoringModelProblemCollector() ); if ( havePom ) { try { Set withVersionSpecified = - findPluginsWithVersionsSpecified( new StringBuilder( writer.toString() ), getSafeProjectPathInfo(parentProject) ); + findPluginsWithVersionsSpecified( new StringBuilder( writer.toString() ), + getSafeProjectPathInfo( parentProject ) ); Map map = getPluginManagement( interpolatedModel ); map.keySet().retainAll( withVersionSpecified ); @@ -781,13 +789,16 @@ private Map getParentsPlugins( List parents ) } return parentPlugins; } - - private String getSafeProjectPathInfo(MavenProject project) { + + private String getSafeProjectPathInfo( MavenProject project ) + { File file = project.getFile(); - if (file != null) { + if ( file != null ) + { return file.getAbsolutePath(); } - else { + else + { // path is used only as information in error message, we can fallback to project artifact info here return project.toString(); } @@ -818,7 +829,7 @@ private static final class StackState private String version; - public StackState( String path ) + StackState( String path ) { this.path = path; } @@ -838,14 +849,15 @@ public String toString() private Set findPluginsWithVersionsSpecified( MavenProject project ) throws IOException, XMLStreamException { - return findPluginsWithVersionsSpecified( PomHelper.readXmlFile( project.getFile() ), getSafeProjectPathInfo(project) ); + return findPluginsWithVersionsSpecified( PomHelper.readXmlFile( project.getFile() ), + getSafeProjectPathInfo( project ) ); } /** * Returns a set of Strings which correspond to the plugin coordinates where there is a version specified. * * @param pomContents The project to get the plugins with versions specified. - * @param path Path that points to the source of the XML + * @param path Path that points to the source of the XML * @return a set of Strings which correspond to the plugin coordinates where there is a version specified. */ private Set findPluginsWithVersionsSpecified( StringBuilder pomContents, String path ) @@ -855,7 +867,7 @@ private Set findPluginsWithVersionsSpecified( StringBuilder pomContents, ModifiedPomXMLEventReader pom = newModifiedPomXER( pomContents, path ); Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); + + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); Stack pathStack = new Stack<>(); StackState curState = null; while ( pom.hasNext() ) @@ -917,30 +929,35 @@ else if ( event.isEndElement() ) /** * Get the minimum required Maven version of the given plugin - * Same logic as in https://github.com/apache/maven-plugin-tools/blob/c8ddcdcb10d342a5a5e2f38245bb569af5730c7c/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java#L711 + * Same logic as in + * @see PluginReport + * * @param pluginProject the plugin for which to retrieve the minimum Maven version which is required * @return The minimally required Maven version (never {@code null}) */ - private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject ) { + private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject ) + { Prerequisites prerequisites = pluginProject.getPrerequisites(); - if (null == prerequisites) { - return new DefaultArtifactVersion("2.0"); + if ( null == prerequisites ) + { + return new DefaultArtifactVersion( "2.0" ); } String prerequisitesMavenValue = prerequisites.getMaven(); - if (null == prerequisitesMavenValue) { - return new DefaultArtifactVersion("2.0"); + if ( null == prerequisitesMavenValue ) + { + return new DefaultArtifactVersion( "2.0" ); } - return new DefaultArtifactVersion(prerequisitesMavenValue); + return new DefaultArtifactVersion( prerequisitesMavenValue ); } - + /** * Gets the build plugins of a specific project. * - * @param model the model to get the build plugins from. + * @param model the model to get the build plugins from. * @param onlyIncludeInherited true to only return the plugins definitions that will be inherited by - * child projects. + * child projects. * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ @@ -1002,7 +1019,7 @@ private Map getBuildPlugins( Model model, boolean onlyIncludeInh private static boolean getPluginInherited( Object plugin ) { return "true".equalsIgnoreCase( plugin instanceof ReportPlugin ? ( (ReportPlugin) plugin ).getInherited() - : ( (Plugin) plugin ).getInherited() ); + : ( (Plugin) plugin ).getInherited() ); } /** @@ -1049,12 +1066,12 @@ private Map getLifecyclePlugins( MavenProject project ) * Gets the plugins that are bound to the defined phases. This does not find plugins bound in the pom to a phase * later than the plugin is executing. * - * @param project the project + * @param project the project * @param thePhases the the phases * @return the bound plugins * @throws org.apache.maven.plugin.PluginNotFoundException the plugin not found exception - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws IllegalAccessException the illegal access exception + * @throws LifecycleExecutionException the lifecycle execution exception + * @throws IllegalAccessException the illegal access exception */ // pilfered this from enforcer-rules // TODO coordinate with Brian Fox to remove the duplicate code @@ -1068,10 +1085,10 @@ private Set getBoundPlugins( MavenProject project, String thePhases ) { Method getPluginsBoundByDefaultToAllLifecycles = LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - new Class[] { String.class } ); + new Class[] {String.class} ); Set plugins = (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { - project.getPackaging() == null ? "jar" : project.getPackaging() } ); + project.getPackaging() == null ? "jar" : project.getPackaging()} ); // we need to provide a copy with the version blanked out so that inferring from super-pom // works as for 2.x as 3.x fills in the version on us! Set result = new LinkedHashSet<>( plugins.size() ); @@ -1128,9 +1145,9 @@ private Set getBoundPlugins( MavenProject project, String thePhases ) * Gets the lifecycle for phase. * * @param lifecycles The list of lifecycles. - * @param phase the phase + * @param phase the phase * @return the lifecycle for phase - * @throws BuildFailureException the build failure exception + * @throws BuildFailureException the build failure exception * @throws LifecycleExecutionException the lifecycle execution exception */ private Lifecycle getLifecycleForPhase( List lifecycles, String phase ) @@ -1152,10 +1169,10 @@ private Lifecycle getLifecycleForPhase( List lifecycles, String phase /** * Gets the all plugins. * - * @param project the project + * @param project the project * @param lifecycle the lifecycle * @return the all plugins - * @throws PluginNotFoundException the plugin not found exception + * @throws PluginNotFoundException the plugin not found exception * @throws LifecycleExecutionException the lifecycle execution exception */ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) @@ -1164,9 +1181,9 @@ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) { Set plugins = new HashSet<>(); // first, bind those associated with the packaging - Map mappings = findMappingsForLifecycle( project, lifecycle ); + Map mappings = findMappingsForLifecycle( project, lifecycle ); - for ( Map.Entry entry : mappings.entrySet() ) + for ( Map.Entry entry : mappings.entrySet() ) { String value = (String) entry.getValue(); String[] tokens = value.split( ":" ); @@ -1195,17 +1212,17 @@ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) /** * Find mappings for lifecycle. * - * @param project the project + * @param project the project * @param lifecycle the lifecycle * @return the map * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception + * @throws PluginNotFoundException the plugin not found exception */ - private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifecycle ) + private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException { String packaging = project.getPackaging(); - Map mappings = null; + Map mappings = null; LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, session.getSettings(), session.getLocalRepository() ); @@ -1214,7 +1231,7 @@ private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifec mappings = m.getPhases( lifecycle.getId() ); } - Map defaultMappings = lifecycle.getDefaultPhases(); + Map defaultMappings = lifecycle.getDefaultPhases(); if ( mappings == null ) { @@ -1228,7 +1245,7 @@ private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifec if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging - + "\'.", e ); + + "\'.", e ); } } } @@ -1238,7 +1255,7 @@ private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifec if ( defaultMappings == null ) { throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging - + "\', and there is no default" ); + + "\', and there is no default" ); } else { @@ -1252,11 +1269,11 @@ private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifec /** * Find optional mojos for lifecycle. * - * @param project the project + * @param project the project * @param lifecycle the lifecycle * @return the list * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception + * @throws PluginNotFoundException the plugin not found exception */ private List findOptionalMojosForLifecycle( MavenProject project, Lifecycle lifecycle ) throws LifecycleExecutionException, PluginNotFoundException @@ -1282,7 +1299,7 @@ private List findOptionalMojosForLifecycle( MavenProject project, Lifecy catch ( ComponentLookupException e ) { getLog().debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " - + lifecycle.getId() + ". Error: " + e.getMessage(), e ); + + lifecycle.getId() + ". Error: " + e.getMessage(), e ); } } @@ -1297,14 +1314,14 @@ private List findOptionalMojosForLifecycle( MavenProject project, Lifecy /** * Find extension. * - * @param project the project - * @param role the role - * @param roleHint the role hint - * @param settings the settings + * @param project the project + * @param role the role + * @param roleHint the role hint + * @param settings the settings * @param localRepository the local repository * @return the object * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception + * @throws PluginNotFoundException the plugin not found exception */ private Object findExtension( MavenProject project, String role, String roleHint, Settings settings, ArtifactRepository localRepository ) @@ -1335,7 +1352,7 @@ private Object findExtension( MavenProject project, String role, String roleHint catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Error getting extensions from the plugin '" - + plugin.getKey() + "': " + e.getMessage(), e ); + + plugin.getKey() + "': " + e.getMessage(), e ); } } } @@ -1345,12 +1362,12 @@ private Object findExtension( MavenProject project, String role, String roleHint /** * Verify plugin. * - * @param plugin the plugin + * @param plugin the plugin * @param project the project * @param session the session * @return the plugin descriptor * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception + * @throws PluginNotFoundException the plugin not found exception */ private PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws LifecycleExecutionException, PluginNotFoundException @@ -1363,10 +1380,10 @@ private PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject proje catch ( PluginManagerException e ) { throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" - + plugin.getKey() + "': " + e.getMessage(), e ); + + plugin.getKey() + "': " + e.getMessage(), e ); } catch ( PluginVersionResolutionException | InvalidVersionSpecificationException | InvalidPluginException // - | ArtifactNotFoundException | ArtifactResolutionException | PluginVersionNotFoundException e ) + | ArtifactNotFoundException | ArtifactResolutionException | PluginVersionNotFoundException e ) { throw new LifecycleExecutionException( e.getMessage(), e ); } @@ -1418,8 +1435,9 @@ public Map getPhaseToLifecycleMap( List lifecycles { Lifecycle prevLifecycle = phaseToLifecycleMap.get( phase ); throw new LifecycleExecutionException( "Phase '" + phase - + "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" - + prevLifecycle.getId() + "'" ); + + "' is defined in more than one lifecycle: '" + + lifecycle.getId() + "' and '" + + prevLifecycle.getId() + "'" ); } else { @@ -1433,14 +1451,15 @@ public Map getPhaseToLifecycleMap( List lifecycles /** * Returns the set of all plugins used by the project. * - * @param superPomPluginManagement the super pom's pluginManagement plugins. - * @param parentPluginManagement the parent pom's pluginManagement plugins. - * @param parentBuildPlugins the parent pom's build plugins. - * @param parentReportPlugins the parent pom's report plugins. + * @param superPomPluginManagement the super pom's pluginManagement plugins. + * @param parentPluginManagement the parent pom's pluginManagement plugins. + * @param parentBuildPlugins the parent pom's build plugins. + * @param parentReportPlugins the parent pom's report plugins. * @param pluginsWithVersionsSpecified the plugin coords that have a version defined in the project. * @return the set of plugins used by the project. * @throws org.apache.maven.plugin.MojoExecutionException if things go wrong. */ + @SuppressWarnings( "checkstyle:MethodLength" ) private Set getProjectPlugins( Map superPomPluginManagement, Map parentPluginManagement, Map parentBuildPlugins, @@ -1481,9 +1500,10 @@ private Set getProjectPlugins( Map superPomPluginManagem debugVersionMap( "final aggregate version map", excludePluginManagement ); ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); - modelBuildingRequest.setUserProperties(getProject().getProperties()); - Model originalModel = modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), - modelBuildingRequest, new IgnoringModelProblemCollector() ); + modelBuildingRequest.setUserProperties( getProject().getProperties() ); + Model originalModel = + modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), + modelBuildingRequest, new IgnoringModelProblemCollector() ); try { @@ -1616,8 +1636,8 @@ private Set getProjectPlugins( Map superPomPluginManagem /** * Adds those project plugins which are not inherited from the parent definitions to the list of plugins. * - * @param plugins The list of plugins. - * @param projectPlugins The project's plugins. + * @param plugins The list of plugins. + * @param projectPlugins The project's plugins. * @param parentDefinitions The parent plugin definitions. * @since 1.0-alpha-1 */ @@ -1657,8 +1677,9 @@ else if ( parentVersion == null || !parentVersion.equals( version ) ) * Logs at debug level a map of plugins keyed by versionless key. * * @param description log description - * @param plugins a map with keys being the {@link String} corresponding to the versionless artifact key and values - * being {@link Plugin} or {@link ReportPlugin}. + * @param plugins a map with keys being the {@link String} corresponding to the versionless artifact key and + * values + * being {@link Plugin} or {@link ReportPlugin}. */ private void debugPluginMap( String description, Map plugins ) { @@ -1681,9 +1702,10 @@ private void debugPluginMap( String description, Map plugins ) /** * Logs at debug level a map of plugin versions keyed by versionless key. * - * @param description log description - * @param pluginVersions a map with keys being the {@link String} corresponding to the versionless artifact key and values - * being {@link String} plugin version. + * @param description log description + * @param pluginVersions a map with keys being the {@link String} corresponding to the versionless artifact key and + * values + * being {@link String} plugin version. */ private void debugVersionMap( String description, Map pluginVersions ) { @@ -1723,9 +1745,9 @@ private static List toPlugins( List reportPlugins ) /** * Gets the report plugins of a specific project. * - * @param model the model to get the report plugins from. + * @param model the model to get the report plugins from. * @param onlyIncludeInherited true to only return the plugins definitions that will be inherited by - * child projects. + * child projects. * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ @@ -1780,8 +1802,8 @@ private Map getReportPlugins( Model model, boolean onlyIncludeIn /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ @@ -1797,7 +1819,8 @@ private static int compare( ArtifactVersion a, ArtifactVersion b ) return a.compareTo( b ); } - private static class IgnoringModelProblemCollector implements ModelProblemCollector { + private static class IgnoringModelProblemCollector implements ModelProblemCollector + { @Override public void add( ModelProblemCollectorRequest req ) diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 2ac1607ea4..57dcb4a557 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeSet; -import javax.xml.stream.XMLStreamException; - import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.plugin.MojoExecutionException; @@ -148,7 +148,8 @@ public void execute() buf.append( property.getName() ); buf.append( "} " ); final String newVersion = winner.toString(); - int padding = INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getOutputLineWidthOffset(); + int padding = + INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getOutputLineWidthOffset(); while ( buf.length() < padding ) { buf.append( '.' ); @@ -181,7 +182,7 @@ public void execute() if ( !current.isEmpty() ) { logLine( false, "The following version properties are referencing the newest available version:" ); - for ( String s : new TreeSet<>(current) ) + for ( String s : new TreeSet<>( current ) ) { logLine( false, " " + s ); } @@ -198,7 +199,7 @@ else if ( updates.isEmpty() ) if ( !updates.isEmpty() ) { logLine( false, "The following version property updates are available:" ); - for ( String update : new TreeSet<>(updates) ) + for ( String update : new TreeSet<>( updates ) ) { logLine( false, " " + update ); } diff --git a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index b50796e9e6..0edc0bfa51 100644 --- a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -19,6 +19,12 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.Collection; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -30,11 +36,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.Collection; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Replaces any -SNAPSHOT versions with a release version, older if necessary (if there has been a release). * @@ -51,15 +52,15 @@ public class ForceReleasesMojo /** * Pattern to match a snapshot version. */ - public final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); // ------------------------------ METHODS -------------------------- /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way - * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way + * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) diff --git a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 0051c56426..42830207af 100644 --- a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -19,12 +19,12 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.util.Collection; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.xml.stream.XMLStreamException; - import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -53,7 +53,7 @@ public class LockSnapshotsMojo /** * Pattern to match a timestamped snapshot version. For example 1.0-20090128.202731-1 */ - public final Pattern matchSnapshotRegex = Pattern.compile( "-" + Artifact.SNAPSHOT_VERSION ); + private final Pattern matchSnapshotRegex = Pattern.compile( "-" + Artifact.SNAPSHOT_VERSION ); // ------------------------------ METHODS -------------------------- diff --git a/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java b/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java index a8d8b211bd..4f606ab0a7 100644 --- a/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java +++ b/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java @@ -13,106 +13,134 @@ /** * Finds the minimal Maven version required to build a Maven project. - * Evaluates the {@code maven-enforcer-plugin:enforce} goal and + * Evaluates the {@code maven-enforcer-plugin:enforce} goal and * its {@code requireMavenVersion} rule. - * + * * @see Require Maven Version Rule */ -class MinimalMavenBuildVersionFinder { +class MinimalMavenBuildVersionFinder +{ - private MinimalMavenBuildVersionFinder() { + private MinimalMavenBuildVersionFinder() + { // not supposed to be created, static methods only } - static ArtifactVersion find(MavenProject mavenProject, String defaultVersion, Log log) { - ArtifactVersion version = getEnforcerMavenVersion(mavenProject, log); - if (version == null && defaultVersion != null) { - version = new DefaultArtifactVersion(defaultVersion); + static ArtifactVersion find( MavenProject mavenProject, String defaultVersion, Log log ) + { + ArtifactVersion version = getEnforcerMavenVersion( mavenProject, log ); + if ( version == null && defaultVersion != null ) + { + version = new DefaultArtifactVersion( defaultVersion ); } return version; } - private static ArtifactVersion getEnforcerMavenVersion(MavenProject mavenProject, Log log) { + private static ArtifactVersion getEnforcerMavenVersion( MavenProject mavenProject, Log log ) + { List buildPlugins = mavenProject.getBuildPlugins(); - if (null == buildPlugins) { - log.debug("MinimalMavenBuildVersionFinder: No build plugins found"); + if ( null == buildPlugins ) + { + log.debug( "MinimalMavenBuildVersionFinder: No build plugins found" ); return null; } - Plugin mavenEnforcerPlugin = getMavenEnforcerPlugin(buildPlugins); - if (null == mavenEnforcerPlugin) { - log.debug("MinimalMavenBuildVersionFinder: No maven-enforcer-plugin used"); + Plugin mavenEnforcerPlugin = getMavenEnforcerPlugin( buildPlugins ); + if ( null == mavenEnforcerPlugin ) + { + log.debug( "MinimalMavenBuildVersionFinder: No maven-enforcer-plugin used" ); return null; } List pluginExecutions = mavenEnforcerPlugin.getExecutions(); - if (null == pluginExecutions) { - log.debug("MinimalMavenBuildVersionFinder: No executions of maven-enforcer-plugin found"); + if ( null == pluginExecutions ) + { + log.debug( "MinimalMavenBuildVersionFinder: No executions of maven-enforcer-plugin found" ); return null; } - List pluginExecutionsWithEnforceGoal = getPluginExecutionsWithEnforceGoal(pluginExecutions); - if (pluginExecutionsWithEnforceGoal.isEmpty()) { - log.debug("MinimalMavenBuildVersionFinder: No 'enforce' execution of maven-enforcer-plugin found"); + List pluginExecutionsWithEnforceGoal = getPluginExecutionsWithEnforceGoal( pluginExecutions ); + if ( pluginExecutionsWithEnforceGoal.isEmpty() ) + { + log.debug( "MinimalMavenBuildVersionFinder: No 'enforce' execution of maven-enforcer-plugin found" ); return null; } - - Xpp3Dom requireMavenVersionTag = getRequireMavenVersionTag(pluginExecutionsWithEnforceGoal); - if (null == requireMavenVersionTag) { - log.debug("MinimalMavenBuildVersionFinder: No 'requireMavenVersion' rule of maven-enforcer-plugin found"); + + Xpp3Dom requireMavenVersionTag = getRequireMavenVersionTag( pluginExecutionsWithEnforceGoal ); + if ( null == requireMavenVersionTag ) + { + log.debug( "MinimalMavenBuildVersionFinder: " + + "No 'requireMavenVersion' rule of maven-enforcer-plugin found" ); return null; } - Xpp3Dom versionTag = requireMavenVersionTag.getChild("version"); - if (null == versionTag) { - log.debug("MinimalMavenBuildVersionFinder: No version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); + Xpp3Dom versionTag = requireMavenVersionTag.getChild( "version" ); + if ( null == versionTag ) + { + log.debug( "MinimalMavenBuildVersionFinder: " + + "No version specified in 'requireMavenVersion' rule of maven-enforcer-plugin" ); return null; } String versionTagValue = versionTag.getValue(); - if (null == versionTagValue || "".equals(versionTagValue)) { - log.debug("MinimalMavenBuildVersionFinder: Empty version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); + if ( null == versionTagValue || "".equals( versionTagValue ) ) + { + log.debug( "MinimalMavenBuildVersionFinder: " + + "Empty version specified in 'requireMavenVersion' rule of maven-enforcer-plugin" ); return null; } - ArtifactVersion minimumVersion = getMinimumVersionFromRange(versionTagValue); - log.debug("Calculated minimum version " + minimumVersion + " from version parameter value '" + versionTagValue + "'"); + ArtifactVersion minimumVersion = getMinimumVersionFromRange( versionTagValue ); + log.debug( "Calculated minimum version " + minimumVersion + " from version parameter value '" + versionTagValue + + "'" ); return minimumVersion; } - - private static Plugin getMavenEnforcerPlugin(List buildPlugins) { - for (Plugin plugin : buildPlugins) { - if ("maven-enforcer-plugin".equals(plugin.getArtifactId()) && "org.apache.maven.plugins".equals(plugin.getGroupId())) { + + private static Plugin getMavenEnforcerPlugin( List buildPlugins ) + { + for ( Plugin plugin : buildPlugins ) + { + if ( "maven-enforcer-plugin".equals( plugin.getArtifactId() ) && "org.apache.maven.plugins".equals( + plugin.getGroupId() ) ) + { return plugin; } } return null; } - private static List getPluginExecutionsWithEnforceGoal(List executions) { + private static List getPluginExecutionsWithEnforceGoal( List executions ) + { List pluginExecutions = new ArrayList<>(); - for (PluginExecution pluginExecution : executions) { + for ( PluginExecution pluginExecution : executions ) + { List goals = pluginExecution.getGoals(); - if (goals != null && goals.contains("enforce")) { - pluginExecutions.add(pluginExecution); + if ( goals != null && goals.contains( "enforce" ) ) + { + pluginExecutions.add( pluginExecution ); } } return pluginExecutions; } - private static Xpp3Dom getRequireMavenVersionTag(List executions) { - for (PluginExecution pluginExecution : executions) { + private static Xpp3Dom getRequireMavenVersionTag( List executions ) + { + for ( PluginExecution pluginExecution : executions ) + { Xpp3Dom configurationTag = (Xpp3Dom) pluginExecution.getConfiguration(); - if (null == configurationTag) { + if ( null == configurationTag ) + { continue; } - Xpp3Dom rulesTag = configurationTag.getChild("rules"); - if (null == rulesTag) { + Xpp3Dom rulesTag = configurationTag.getChild( "rules" ); + if ( null == rulesTag ) + { continue; } - Xpp3Dom requireMavenVersionTag = rulesTag.getChild("requireMavenVersion"); - if (null == requireMavenVersionTag) { + Xpp3Dom requireMavenVersionTag = rulesTag.getChild( "requireMavenVersion" ); + if ( null == requireMavenVersionTag ) + { continue; } @@ -122,80 +150,103 @@ private static Xpp3Dom getRequireMavenVersionTag(List execution } /** - * The below method implements the specification found at https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html + * The below method implements the specification found at + * https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html */ - static ArtifactVersion getMinimumVersionFromRange(String versionRange) { + static ArtifactVersion getMinimumVersionFromRange( String versionRange ) + { int openIndicesCount = 0; int closeIndicesCount = 0; - for (int i = 0; i < versionRange.length(); i++) { - char character = versionRange.charAt(i); + for ( int i = 0; i < versionRange.length(); i++ ) + { + char character = versionRange.charAt( i ); - if ('(' == character || '[' == character) { + if ( '(' == character || '[' == character ) + { openIndicesCount++; - } else if (')' == character || ']' == character) { + } + else if ( ')' == character || ']' == character ) + { closeIndicesCount++; } } - if (openIndicesCount != closeIndicesCount) { + if ( openIndicesCount != closeIndicesCount ) + { return null; } - if (openIndicesCount == 0) { - return new DefaultArtifactVersion(versionRange); + if ( openIndicesCount == 0 ) + { + return new DefaultArtifactVersion( versionRange ); } - if (!((versionRange.charAt(0) == '[' || versionRange.charAt(0) == '(') && (versionRange.charAt(versionRange.length() - 1) == ']' || versionRange.charAt(versionRange.length() - 1) == ')'))) { + if ( !( ( versionRange.charAt( 0 ) == '[' || versionRange.charAt( 0 ) == '(' ) && ( + versionRange.charAt( versionRange.length() - 1 ) == ']' + || versionRange.charAt( versionRange.length() - 1 ) == ')' ) ) ) + { return null; } - if (openIndicesCount != 1) { + if ( openIndicesCount != 1 ) + { return null; } - String innerString = versionRange.substring(1, versionRange.length() - 1); + String innerString = versionRange.substring( 1, versionRange.length() - 1 ); - int commaIndex = innerString.indexOf(','); + int commaIndex = innerString.indexOf( ',' ); - if (commaIndex == -1) { - if (versionRange.charAt(0) == '[' && versionRange.charAt(versionRange.length() - 1) == ']') { - return new DefaultArtifactVersion(innerString); + if ( commaIndex == -1 ) + { + if ( versionRange.charAt( 0 ) == '[' && versionRange.charAt( versionRange.length() - 1 ) == ']' ) + { + return new DefaultArtifactVersion( innerString ); } - else { + else + { return null; } } - if (commaIndex == 0) { + if ( commaIndex == 0 ) + { return null; } - if (commaIndex == innerString.length() - 1) { - String minimumVersion = innerString.substring(0, innerString.length() - 1); + if ( commaIndex == innerString.length() - 1 ) + { + String minimumVersion = innerString.substring( 0, innerString.length() - 1 ); - if (versionRange.charAt(0) == '[' && versionRange.charAt(versionRange.length() - 1) == ')') { - return new DefaultArtifactVersion(minimumVersion); + if ( versionRange.charAt( 0 ) == '[' && versionRange.charAt( versionRange.length() - 1 ) == ')' ) + { + return new DefaultArtifactVersion( minimumVersion ); } - if (versionRange.charAt(0) == '(' && versionRange.charAt(versionRange.length() - 1) == ')') { - // this is actually wrong - the Maven version should be higher than this, the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this - return new DefaultArtifactVersion(minimumVersion); + if ( versionRange.charAt( 0 ) == '(' && versionRange.charAt( versionRange.length() - 1 ) == ')' ) + { + // this is actually wrong - the Maven version should be higher than this, + // the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this + return new DefaultArtifactVersion( minimumVersion ); } return null; } - String minimumVersion = innerString.substring(0, commaIndex); + String minimumVersion = innerString.substring( 0, commaIndex ); - if (versionRange.charAt(0) == '[') { - return new DefaultArtifactVersion(minimumVersion); + if ( versionRange.charAt( 0 ) == '[' ) + { + return new DefaultArtifactVersion( minimumVersion ); } - if (versionRange.charAt(0) == '(') { - // this is actually wrong - the Maven version should be higher than this, the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this - return new DefaultArtifactVersion(minimumVersion); + if ( versionRange.charAt( 0 ) == '(' ) + { + // this is actually wrong - the Maven version should be higher than this, + // the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this + return new DefaultArtifactVersion( minimumVersion ); } return null; diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java index 1ea7c67b6d..5ab759516d 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java @@ -19,14 +19,14 @@ * under the License. */ +import java.util.Map; +import java.util.Objects; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.UpdateScope; -import java.util.Map; -import java.util.Objects; - /** * Details of a plugin's updates. */ @@ -38,7 +38,8 @@ public class PluginUpdatesDetails private final boolean includeSnapshots; - public PluginUpdatesDetails( ArtifactVersions artifactVersions, Map dependencyVersions, boolean includeSnapshots ) + public PluginUpdatesDetails( ArtifactVersions artifactVersions, + Map dependencyVersions, boolean includeSnapshots ) { Objects.requireNonNull( artifactVersions ); Objects.requireNonNull( dependencyVersions ); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index e3141771a8..2154e53bf6 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -341,6 +341,7 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) sink.tableRow_(); } + @SuppressWarnings( "checkstyle:MethodLength" ) private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) { final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); @@ -350,10 +351,10 @@ private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) sink.section2(); sink.sectionTitle2(); sink.text( MessageFormat.format( getText( "report.plugin" ), new Object[] { - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) } ) ); + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() )} ) ); sink.sectionTitle2_(); sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); + sink.tableRows( new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false ); sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.status" ) ); @@ -429,9 +430,10 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != { sink.lineBreak(); } - boolean bold = equals( versions[i], - details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) + boolean bold = equals( + versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) + || equals( versions[i], + details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) ) || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) ) @@ -503,7 +505,7 @@ else if ( equals( versions[i], sink.section3(); sink.sectionTitle3(); sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), new Object[] { - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) } ) ); + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() )} ) ); sink.sectionTitle3_(); renderDependencySummaryTable( details.getDependencyVersions(), false, true, true ); @@ -521,7 +523,7 @@ private void renderDependencyDetail( Dependency dependency, ArtifactVersions det sink.section3(); sink.sectionTitle3(); sink.text( MessageFormat.format( getText( "report.pluginDependency" ), new Object[] { - ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) } ) ); + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() )} ) ); sink.sectionTitle3_(); renderDependencyDetailTable( dependency, details, false, true, true ); sink.section3_(); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java index 05877cbc60..e19a98e3e6 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java @@ -19,9 +19,6 @@ * under the License. */ -import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.getVersionsBlocks; -import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.wrapElement; - import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; @@ -35,10 +32,13 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.utils.PluginComparator; +import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.getVersionsBlocks; +import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.wrapElement; + /** * XML renderer for PluginUpdatesReport creates an xml file in target directory and writes report about available * plugin/plugin management updates. - * + * * @author Illia Dubinin * @since 2.4 */ @@ -75,7 +75,7 @@ public PluginUpdatesXmlRenderer( Map pluginUpdates /** * Makes report file with given name in target directory. - * + * * @throws MavenReportException if something went wrong */ public void render() @@ -118,7 +118,8 @@ private static String getPluginsInfoBlock( Map plu sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); for ( Entry entry : pluginUpdates.entrySet() ) { - sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) + .append( NL ); Plugin plugin = entry.getKey(); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( plugin.getGroupId(), @@ -128,7 +129,8 @@ private static String getPluginsInfoBlock( Map plu sBuilder.append( getVersionsBlocks( entry.getValue().getArtifactVersions() ) ); - sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) + .append( NL ); } sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); return sBuilder.toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java index 3d3df836cd..e46530d2fb 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java @@ -19,16 +19,16 @@ * under the License. */ +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; + import org.apache.maven.doxia.sink.Sink; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.mojo.versions.utils.PropertyComparator; import org.codehaus.plexus.i18n.I18N; -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - /** * @since 1.0-beta-1 */ @@ -198,4 +198,4 @@ private void renderPropertyDetail( Property property, PropertyVersions versions sink.section2_(); } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java index dd9cda92ea..5668ae9ffa 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java @@ -39,7 +39,8 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "property-updates-report", requiresProject = true, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +@Mojo( name = "property-updates-report", requiresProject = true, requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true ) public class PropertyUpdatesReport extends AbstractVersionsReport { @@ -104,7 +105,7 @@ protected void doGenerateReport( Locale locale, Sink sink ) try { updateSet.putAll( getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, - excludeProperties, autoLinkItems )); + excludeProperties, autoLinkItems ) ); } catch ( MojoExecutionException e ) { @@ -122,4 +123,4 @@ public String getOutputName() { return "property-updates-report"; } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 5ff16462aa..193fbc347f 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import java.util.Collection; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.xml.stream.XMLStreamException; - import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -104,15 +104,15 @@ public class ResolveRangesMojo /** * Pattern to match a version range. For example 1.0-20090128.202731-1 */ - public final Pattern matchRangeRegex = Pattern.compile( "," ); + private final Pattern matchRangeRegex = Pattern.compile( "," ); // ------------------------------ METHODS -------------------------- /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) @@ -196,7 +196,7 @@ private void resolveRangesInParent( ModifiedPomXMLEventReader pom ) else { getLog().warn( "Could not find the version tag for parent " + artifact + " in project " - + getProject().getId() + " so unable to set version to " + artifactVersion ); + + getProject().getId() + " so unable to set version to " + artifactVersion ); } } } @@ -217,7 +217,8 @@ private void resolveRanges( ModifiedPomXMLEventReader pom, Collection reactorModels = PomHelper.getReactorModels( project, getLog() ); final SortedMap reactor = - new TreeMap( new ReactorDepthComparator( reactorModels ) ); + new TreeMap( new ReactorDepthComparator( reactorModels ) ); reactor.putAll( reactorModels ); // set of files to update final Set files = new LinkedHashSet(); getLog().info( - "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); + "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); Pattern groupIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( groupId, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( groupId, "*" ), true ) ); Pattern artifactIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); Pattern oldVersionIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); + Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); boolean found = false; for ( Model m : reactor.values() ) { @@ -353,18 +355,18 @@ public void execute() throws MojoExecutionException, MojoFailureException final String mArtifactId = PomHelper.getArtifactId( m ); final String mVersion = PomHelper.getVersion( m ); if ( ( ( groupIdRegex.matcher( mGroupId ).matches() && artifactIdRegex.matcher( mArtifactId ) - .matches() ) // - || ( processAllModules ) ) // - && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) + .matches() ) // + || ( processAllModules ) ) // + && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) { found = true; // if the change is not one we have swept up already applyChange( project, reactor, files, mGroupId, m.getArtifactId(), - StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() ); + StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() ); } } if ( !found && RegexUtils.getWildcardScore( groupId ) == 0 && RegexUtils.getWildcardScore( artifactId ) == 0 - && RegexUtils.getWildcardScore( oldVersion ) == 0 ) + && RegexUtils.getWildcardScore( oldVersion ) == 0 ) { applyChange( project, reactor, files, groupId, artifactId, oldVersion ); } @@ -391,10 +393,10 @@ public void execute() throws MojoExecutionException, MojoFailureException * @throws MojoExecutionException thrown if the input parameters are invalid */ protected String getIncrementedVersion( String version, Integer nextSnapshotIndexToIncrement ) - throws MojoExecutionException + throws MojoExecutionException { String versionWithoutSnapshot = - version.endsWith( SNAPSHOT ) ? version.substring( 0, version.indexOf( SNAPSHOT ) ) : version; + version.endsWith( SNAPSHOT ) ? version.substring( 0, version.indexOf( SNAPSHOT ) ) : version; List numbers = new LinkedList<>( Arrays.asList( versionWithoutSnapshot.split( "\\." ) ) ); if ( nextSnapshotIndexToIncrement == null ) @@ -408,7 +410,7 @@ else if ( nextSnapshotIndexToIncrement < 1 ) else if ( nextSnapshotIndexToIncrement > numbers.size() ) { throw new MojoExecutionException( - "nextSnapshotIndexToIncrement cannot be greater than the last version index" ); + "nextSnapshotIndexToIncrement cannot be greater than the last version index" ); } int snapshotVersionToIncrement = Integer.parseInt( numbers.remove( nextSnapshotIndexToIncrement - 1 ) ); numbers.add( nextSnapshotIndexToIncrement - 1, String.valueOf( snapshotVersionToIncrement + 1 ) ); @@ -440,8 +442,8 @@ private void applyChange( MavenProject project, SortedMap reactor final String sourcePath = sourceEntry.getKey(); final Model sourceModel = sourceEntry.getValue(); - getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" : - "Processing " + sourcePath + " as a parent." ); + getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" + : "Processing " + sourcePath + " as a parent." ); final String sourceGroupId = PomHelper.getGroupId( sourceModel ); if ( sourceGroupId == null ) @@ -465,11 +467,11 @@ private void applyChange( MavenProject project, SortedMap reactor addFile( files, project, sourcePath ); getLog().debug( - "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + " as their parent" ); + "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + + " as their parent" ); - for ( Map.Entry stringModelEntry : processAllModules ? reactor.entrySet() : // - PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) + for ( Map.Entry stringModelEntry : processAllModules ? reactor.entrySet() + : PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) { final Model targetModel = stringModelEntry.getValue(); final Parent parent = targetModel.getParent(); @@ -477,40 +479,43 @@ private void applyChange( MavenProject project, SortedMap reactor if ( parent != null && sourceVersion.equals( parent.getVersion() ) ) { getLog().debug( - " parent already is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + ":" + sourceVersion ); + " parent already is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + + ":" + sourceVersion ); } else { getLog().debug( - " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + ( - parent == null ? "" : parent.getVersion() ) ); + " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + ( + parent == null ? "" : parent.getVersion() ) ); getLog().debug( - " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); + " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + sourceVersion ); } final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); if ( ( updateMatchingVersions || !targetExplicit ) // - && ( parent != null && StringUtils.equals( parent.getVersion(), - PomHelper.getVersion( targetModel ) ) ) ) + && ( parent != null && StringUtils.equals( parent.getVersion(), + PomHelper.getVersion( targetModel ) ) ) ) { getLog().debug( - " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" + PomHelper.getVersion( - targetModel ) ); + " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + + PomHelper.getVersion( + targetModel ) ); getLog().debug( - " will become " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" + sourceVersion ); + " will become " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + + ":" + sourceVersion ); addChange( PomHelper.getGroupId( targetModel ), PomHelper.getArtifactId( targetModel ), - PomHelper.getVersion( targetModel ), sourceVersion ); + PomHelper.getVersion( targetModel ), sourceVersion ); targetModel.setVersion( sourceVersion ); } else { getLog().debug( - " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" + PomHelper.getVersion( - targetModel ) ); + " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + + PomHelper.getVersion( + targetModel ) ); } } } @@ -550,7 +555,7 @@ else if ( moduleDir.isDirectory() ) * @throws javax.xml.stream.XMLStreamException when things go wrong. */ protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { ContextualLog log = new DelegatingContextualLog( getLog() ); try @@ -564,8 +569,8 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) versionChangerFactory.setModel( model ); VersionChanger changer = - versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, - processPlugins ); + versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, + processPlugins ); for ( VersionChange versionChange : sourceChanges ) { diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 0ef7c64fba..13acc9414f 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -19,6 +19,12 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Map; + import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -29,17 +35,12 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; -import javax.xml.stream.XMLStreamException; -import java.io.IOException; -import java.util.Arrays; -import java.util.Map; - /** * Set a property to a given version without any sanity checks. Please be careful this can lead to changes which might * not build anymore. The sanity checks are done by other goals like update-properties or * update-property etc. they are not done here. So use this goal with care. * - * @author Karl Heinz Marbaise + * @author Karl Heinz Marbaise * @since 2.5 */ @Mojo( name = "set-property", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) @@ -71,6 +72,7 @@ public class SetPropertyMojo /** * A property file name containing: property=value, to update several properties at the same time. * If 'property' and 'newVersion' are also used, they will be ignored. + * * @since 2.9 */ @@ -80,8 +82,8 @@ public class SetPropertyMojo /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) @@ -89,37 +91,49 @@ protected void update( ModifiedPomXMLEventReader pom ) { Property[] propertiesConfig = null; String properties = ""; - if (!StringUtils.isEmpty(propertiesVersionsFile) ) { + if ( !StringUtils.isEmpty( propertiesVersionsFile ) ) + { logWrongConfigWarning(); getLog().debug( "Reading properties and versions to update from file: " + propertiesVersionsFile ); - PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader(propertiesVersionsFile); - try { + PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader( propertiesVersionsFile ); + try + { reader.read(); - } catch (IOException e) { - getLog().error("Unable to read property file " + propertiesVersionsFile - + ". re-run with -X option for more details."); - getLog().debug("Error while reading property file " + propertiesVersionsFile, e); - throw new MojoFailureException("Unable to read property file " + propertiesVersionsFile); + } + catch ( IOException e ) + { + getLog().error( "Unable to read property file " + propertiesVersionsFile + + ". re-run with -X option for more details." ); + getLog().debug( "Error while reading property file " + propertiesVersionsFile, e ); + throw new MojoFailureException( "Unable to read property file " + propertiesVersionsFile ); } propertiesConfig = reader.getPropertiesConfig(); properties = reader.getProperties(); - } else if (!StringUtils.isEmpty(property)) { + } + else if ( !StringUtils.isEmpty( property ) ) + { getLog().debug( "Reading properties and versions to update from property and newVersion " ); - propertiesConfig = Arrays.stream(StringUtils.split(property, ",")) - .map(prp -> { - Property propertyConfig = new Property(prp); - propertyConfig.setVersion(newVersion); + propertiesConfig = Arrays.stream( StringUtils.split( property, "," ) ).map( + prp -> + { + Property propertyConfig = new Property( prp ); + propertyConfig.setVersion( newVersion ); return propertyConfig; - }) - .toArray(size -> new Property[size]); + } ) + .toArray( size -> new Property[size] ); properties = property; - } else { - throw new MojoExecutionException("Please provide either 'property' or 'propertiesVersionsFile' parameter."); } - update(pom, propertiesConfig, properties); + else + { + throw new MojoExecutionException( + "Please provide either 'property' or 'propertiesVersionsFile' parameter." ); + } + update( pom, propertiesConfig, properties ); } - private void update(ModifiedPomXMLEventReader pom, Property[] propertiesConfig, String properties) throws MojoExecutionException, XMLStreamException { + private void update( ModifiedPomXMLEventReader pom, Property[] propertiesConfig, String properties ) + throws MojoExecutionException, XMLStreamException + { Map propertyVersions = this.getHelper().getVersionPropertiesMap( getProject(), propertiesConfig, properties, "", autoLinkItems ); @@ -134,16 +148,19 @@ private void update(ModifiedPomXMLEventReader pom, Property[] propertiesConfig, { continue; } - PomHelper.setPropertyVersion(pom, version.getProfileId(), currentProperty.getName(), newVersionGiven ); + PomHelper.setPropertyVersion( pom, version.getProfileId(), currentProperty.getName(), newVersionGiven ); } } - private void logWrongConfigWarning() { - if (!StringUtils.isEmpty(property)) { - getLog().warn("-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used"); + private void logWrongConfigWarning() + { + if ( !StringUtils.isEmpty( property ) ) + { + getLog().warn( "-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used" ); } - if (!StringUtils.isEmpty(newVersion)) { - getLog().warn("-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used"); + if ( !StringUtils.isEmpty( newVersion ) ) + { + getLog().warn( "-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used" ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index d7649cc475..8c7300331a 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -1,11 +1,9 @@ package org.codehaus.mojo.versions; -import static org.apache.commons.lang3.StringUtils.isBlank; +import javax.xml.stream.XMLStreamException; import java.io.IOException; -import javax.xml.stream.XMLStreamException; - import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.model.Model; import org.apache.maven.model.Scm; @@ -16,6 +14,8 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static org.apache.commons.lang3.StringUtils.isBlank; + /** * Updates the current project's SCM tag. * @@ -39,34 +39,35 @@ public class SetScmTagMojo * Called when this mojo is executed. * * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. */ - @Override + @Override public void execute() - throws MojoExecutionException, MojoFailureException - { - if ( isBlank(newTag) ) - { - throw new MojoFailureException("'newTag' cannot be empty"); - } + throws MojoExecutionException, MojoFailureException + { + if ( isBlank( newTag ) ) + { + throw new MojoFailureException( "'newTag' cannot be empty" ); + } - super.execute(); - } + super.execute(); + } @Override - protected void update(ModifiedPomXMLEventReader pom) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { try { Model model = PomHelper.getRawModel( pom ); Scm scm = model.getScm(); - if (scm == null) + if ( scm == null ) { throw new MojoFailureException( "No was present" ); } getLog().info( "Updating from tag " + scm.getTag() + " > " + newTag ); - boolean success = PomHelper.setProjectValue(pom, "/project/scm/tag", newTag ); + boolean success = PomHelper.setProjectValue( pom, "/project/scm/tag", newTag ); if ( !success ) { throw new MojoFailureException( "Could not update the SCM tag" ); diff --git a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 5190760ebb..1a21bb176c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -19,6 +19,12 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -28,11 +34,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Attempts to resolve unlocked snapshot dependency versions to the locked timestamp versions used in the build. For * example, an unlocked snapshot version like "1.0-SNAPSHOT" could be resolved to "1.0-20090128.202731-1". If a @@ -54,7 +55,7 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo /** * Pattern to match a timestamped snapshot version. For example 1.0-20090128.202731-1 */ - public final Pattern matchSnapshotRegex = Pattern.compile( "-(\\d{8}\\.\\d{6})-(\\d+)$" ); + private final Pattern matchSnapshotRegex = Pattern.compile( "-(\\d{8}\\.\\d{6})-(\\d+)$" ); // ------------------------------ METHODS -------------------------- @@ -65,7 +66,8 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) @@ -82,7 +84,8 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep } } - private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) throws XMLStreamException, MojoExecutionException + private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) + throws XMLStreamException, MojoExecutionException { for ( Dependency dep : dependencies ) { @@ -109,17 +112,18 @@ private void unlockSnapshots( ModifiedPomXMLEventReader pom, List de { String unlockedVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - unlockedVersion, getProject().getModel() ) ) + unlockedVersion, getProject().getModel() ) ) { getChangeRecorder().recordUpdate( "unlockSnapshot", dep.getGroupId(), dep.getArtifactId(), - dep.getVersion(), unlockedVersion ); + dep.getVersion(), unlockedVersion ); getLog().info( "Unlocked " + toString( dep ) + " to version " + unlockedVersion ); } } } } - private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) throws XMLStreamException, MojoExecutionException + private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) + throws XMLStreamException, MojoExecutionException { if ( parent == null ) { @@ -143,9 +147,10 @@ private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject p if ( PomHelper.setProjectParentVersion( pom, unlockedParentVersion ) ) { getLog().info( "Unlocked parent " + parentArtifact + " to version " - + unlockedParentVersion ); + + unlockedParentVersion ); getChangeRecorder().recordUpdate( "unlockParentVersion", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), parentArtifact.getVersion(), unlockedParentVersion ); + parentArtifact.getArtifactId(), parentArtifact.getVersion(), + unlockedParentVersion ); } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index fa72cdabc4..bd0f0e88d5 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -19,6 +19,14 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; @@ -28,13 +36,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * Scans the current projects child modules, updating the versions of any which use the current project to the version * of the current project. @@ -42,7 +43,8 @@ * @author Stephen Connolly * @since 1.0-alpha-2 */ -@Mojo( name = "update-child-modules", requiresProject = true, requiresDirectInvocation = true, aggregator = true, threadSafe = true ) +@Mojo( name = "update-child-modules", requiresProject = true, requiresDirectInvocation = true, aggregator = true, + threadSafe = true ) public class UpdateChildModulesMojo extends AbstractVersionsUpdaterMojo { @@ -65,7 +67,7 @@ public class UpdateChildModulesMojo * Called when this mojo is executed. * * @throws MojoExecutionException when things go wrong. - * @throws MojoFailureException when things go wrong. + * @throws MojoFailureException when things go wrong. */ public void execute() throws MojoExecutionException, MojoFailureException @@ -77,28 +79,30 @@ public void execute() { final Map reactor = PomHelper.getReactorModels( getProject(), getLog() ); List order = new ArrayList<>( reactor.keySet() ); - order.sort( ( o1, o2 ) -> { - Model m1 = reactor.get( o1 ); - Model m2 = reactor.get( o2 ); - int d1 = PomHelper.getReactorParentCount( reactor, m1 ); - int d2 = PomHelper.getReactorParentCount( reactor, m2 ); - if ( d1 < d2 ) - { - return -1; - } - else if ( d1 > d2 ) + order.sort( + ( o1, o2 ) -> { - return 1; - } - return 0; - } ); + Model m1 = reactor.get( o1 ); + Model m2 = reactor.get( o2 ); + int d1 = PomHelper.getReactorParentCount( reactor, m1 ); + int d2 = PomHelper.getReactorParentCount( reactor, m2 ); + if ( d1 < d2 ) + { + return -1; + } + else if ( d1 > d2 ) + { + return 1; + } + return 0; + } ); for ( String sourcePath : order ) { Model sourceModel = reactor.get( sourcePath ); getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" - : "Processing " + sourcePath + " as a parent." ); + : "Processing " + sourcePath + " as a parent." ); synchronized ( this ) { @@ -122,7 +126,8 @@ else if ( d1 > d2 ) } getLog().debug( "Looking for modules which use " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + " as their parent to update it to " + sourceVersion ); + + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + + " as their parent to update it to " + sourceVersion ); for ( Map.Entry target : PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) @@ -149,18 +154,18 @@ else if ( d1 > d2 ) if ( sourceVersion.equals( parent.getVersion() ) ) { getLog().debug( "Module: " + targetPath + " parent is " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); + + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + sourceVersion ); } else { getLog().info( "Module: " + targetPath ); getLog().info( " parent was " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + parent.getVersion() ); + + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + parent.getVersion() ); getLog().info( " updated to " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); + + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + sourceVersion ); process( moduleProjectFile ); didSomething = true; } @@ -184,8 +189,8 @@ else if ( d1 > d2 ) * * @param pom The pom file to update. * @throws MojoExecutionException when things go wrong. - * @throws MojoFailureException when things go wrong. - * @throws XMLStreamException when things go wrong. + * @throws MojoFailureException when things go wrong. + * @throws XMLStreamException when things go wrong. */ protected synchronized void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index d2e7d2a1ac..bfa1253013 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -32,8 +34,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * Sets the parent version to the latest parent version. * @@ -75,7 +75,8 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( getProject().getParent() == null ) { @@ -136,7 +137,7 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep getLog().debug( "Made an update from " + currentVersion + " to " + artifactVersion ); this.getChangeRecorder().recordUpdate( "updateParent", artifact.getGroupId(), artifact.getArtifactId(), - currentVersion, artifactVersion.toString() ); + currentVersion, artifactVersion.toString() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 033f6623f5..cb1c8fcee1 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.Map; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -28,9 +32,6 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.Map; - /** * Sets properties to the latest versions of specific artifacts. * @@ -128,10 +129,14 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException { Map propertyVersions = this.getHelper().getVersionPropertiesMap( getProject(), - properties, includeProperties, excludeProperties, autoLinkItems ); + properties, + includeProperties, + excludeProperties, + autoLinkItems ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); @@ -148,7 +153,10 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep if ( !( isIncluded( association.getArtifact() ) ) ) { getLog().info( - "Not updating the property ${" + property.getName() + "} because it is used by artifact " + association.getArtifact().toString() + " and that artifact is not included in the list of " + " allowed artifacts to be updated." ); + "Not updating the property ${" + property.getName() + "} because it is used by artifact " + + association.getArtifact().toString() + + " and that artifact is not included in the list of " + + " allowed artifacts to be updated." ); canUpdateProperty = false; break; } @@ -157,18 +165,19 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep if ( canUpdateProperty ) { int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + allowIncrementalUpdates ); ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); + allowDowngrade, segment ); - if (targetVersion != null) + if ( targetVersion != null ) { for ( final ArtifactAssociation association : version.getAssociations() ) { if ( ( isIncluded( association.getArtifact() ) ) ) { this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, targetVersion.toString() ); + association.getArtifactId(), currentVersion, + targetVersion.toString() ); } } } @@ -177,4 +186,4 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep } } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 1e3127aa28..6390c29a59 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.Map; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -28,9 +32,6 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.Map; - /** * Sets a property to the latest version in a given range of associated artifacts. * @@ -46,7 +47,7 @@ public class UpdatePropertyMojo /** * A property to update. - * + * * @since 1.3 */ @Parameter( property = "property" ) @@ -65,7 +66,7 @@ public class UpdatePropertyMojo * -DnewVersion=[19.0] otherwise a newer existing version will be used. If you need to downgrade a * version you have to define -DallowDowngrade=true as well otherwise * the version will be kept. - * + * * @since 1.3 */ @Parameter( property = "newVersion" ) @@ -83,7 +84,7 @@ public class UpdatePropertyMojo * If a property points to a version like 1.2.3 and your repository contains versions like * 1.2.3 and 1.1.0 without settings this to true the property will never * being changed back to 1.1.0 by using -DnewVersion=[1.1.0]. - * + * * @since 3.0.0 */ @Parameter( property = "allowDowngrade", defaultValue = "false" ) @@ -120,8 +121,8 @@ public class UpdatePropertyMojo /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming + * @throws MojoFailureException when things go wrong in a very bad way + * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ @@ -131,7 +132,7 @@ protected void update( ModifiedPomXMLEventReader pom ) Property propertyConfig = new Property( property ); propertyConfig.setVersion( newVersion ); Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), new Property[] { propertyConfig }, property, "", + this.getHelper().getVersionPropertiesMap( getProject(), new Property[] {propertyConfig}, property, "", autoLinkItems ); for ( Map.Entry entry : propertyVersions.entrySet() ) { @@ -146,17 +147,18 @@ protected void update( ModifiedPomXMLEventReader pom ) int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); + allowDowngrade, segment ); - if (targetVersion != null) + if ( targetVersion != null ) { for ( final ArtifactAssociation association : version.getAssociations() ) { this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, targetVersion.toString() ); + association.getArtifactId(), currentVersion, + targetVersion.toString() ); } } } } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index df965e464c..0a9169c0c7 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -19,10 +19,10 @@ * under the License. */ -import java.util.Collection; - import javax.xml.stream.XMLStreamException; +import java.util.Collection; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.model.Dependency; @@ -36,7 +36,9 @@ /** * Updates a dependency to a specific version. - * This can be useful if you have to manage versions for a very large (100+ module) projects where you can’t always use the most up-to-date version of a particular third party component. + * This can be useful if you have to manage versions for a very large (100+ module) projects where you can’t always use + * the most up-to-date version of a particular third party component. + * * @author Dan Arcari * @since 2.3 */ @@ -62,19 +64,22 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo protected boolean forceVersion; @Override - protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { if ( depVersion == null || depVersion.equals( "" ) ) { throw new IllegalArgumentException( - "depVersion must be supplied with use-specific-version, and cannot be blank." ); + "depVersion must be supplied with use-specific-version, and cannot be blank." ); } if ( !forceVersion && !hasIncludes() ) { throw new IllegalArgumentException( - "The use-specific-version goal is intended to be used with a single artifact. Please specify a value for the 'includes' parameter, or use -DforceVersion=true to override this check." ); + "The use-specific-version goal is intended to be used with a single artifact. " + + "Please specify a value for the 'includes' parameter, " + + "or use -DforceVersion=true to override this check." ); } try @@ -95,7 +100,8 @@ protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionExcep } } - private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException + private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) + throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException { for ( Dependency dep : dependencies ) { @@ -122,20 +128,20 @@ private void useDepVersion( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; - getLog().info( "Upper bound: " + (upperBound == null ? "none" : upperBound.toString() ) ); + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); String latestVersion; - ArrayList snapshotsOnly = new ArrayList(); + ArrayList snapshotsOnly = new ArrayList<>(); for ( ArtifactVersion artifactVersion : newer ) { @@ -185,9 +186,8 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment(lowerBound, segment) : null; - getLog().info( "Upper bound: " + (upperBound == null ? "none" : upperBound.toString() ) ); + segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); for ( ArtifactVersion artifactVersion : newer ) @@ -164,7 +165,7 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - for ( Dependency dep : dependencies ) { + for ( Dependency dep : dependencies ) + { if ( isExcludeReactor() && isProducedByReactor( dep ) ) { getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); @@ -108,7 +110,7 @@ private void useNextVersions( ModifiedPomXMLEventReader pom, Collection d } private void useReactor( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, ArtifactMetadataRetrievalException { for ( Object reactorProject : reactorProjects ) { MavenProject project = (MavenProject) reactorProject; if ( StringUtils.equals( project.getGroupId(), parent.getGroupId() ) - && StringUtils.equals( project.getArtifactId(), parent.getArtifactId() ) - && !StringUtils.equals( project.getVersion(), parent.getVersion() ) ) + && StringUtils.equals( project.getArtifactId(), parent.getArtifactId() ) + && !StringUtils.equals( project.getVersion(), parent.getVersion() ) ) { if ( PomHelper.setProjectParentVersion( pom, project.getVersion() ) ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 790181392d..bd25c628f8 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -19,6 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.Collection; +import java.util.NoSuchElementException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -32,13 +39,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import java.util.Collection; -import java.util.NoSuchElementException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.xml.stream.XMLStreamException; - /** * Replaces any -SNAPSHOT versions with the corresponding release version (if it has been released). * @@ -71,15 +71,15 @@ public class UseReleasesMojo /** * Pattern to match a snapshot version. */ - public final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); // ------------------------------ METHODS -------------------------- /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way - * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way + * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) @@ -148,7 +148,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project ) else if ( failIfNotReplaced ) { throw new NoSuchElementException( "No matching release of " + toString( project ) - + " found for update." ); + + " found for update." ); } } else @@ -159,7 +159,7 @@ else if ( failIfNotReplaced ) if ( proposedVersion.toString().startsWith( releaseVersion ) ) { getLog().debug( "Found matching version for " + toString( project ) + " to version " - + releaseVersion ); + + releaseVersion ); finalVersion = proposedVersion; } } @@ -171,7 +171,8 @@ else if ( failIfNotReplaced ) getLog().info( "Updated " + toString( project ) + " to version " + finalVersion ); this.getChangeRecorder().recordUpdate( "useReleases", parent.getGroupId(), - parent.getArtifactId(), version, finalVersion.toString() ); + parent.getArtifactId(), version, + finalVersion.toString() ); } } else @@ -180,7 +181,7 @@ else if ( failIfNotReplaced ) if ( failIfNotReplaced ) { throw new NoSuchElementException( "No matching release of " + toString( project ) - + " found for update via rangeMatching." ); + + " found for update via rangeMatching." ); } } @@ -259,7 +260,7 @@ private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Strin getLog().info( "Updated " + toString( dep ) + " to version " + finalVersion ); this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), - dep.getArtifactId(), version, finalVersion.toString() ); + dep.getArtifactId(), version, finalVersion.toString() ); } } else @@ -268,7 +269,7 @@ private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Strin if ( failIfNotReplaced ) { throw new NoSuchElementException( "No matching release of " + toString( dep ) - + " found for update via rangeMatching." ); + + " found for update via rangeMatching." ); } } } @@ -284,7 +285,7 @@ private void noRangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, Str getLog().info( "Updated " + toString( dep ) + " to version " + releaseVersion ); this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), - dep.getArtifactId(), version, releaseVersion ); + dep.getArtifactId(), version, releaseVersion ); } } else if ( failIfNotReplaced ) diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index 1fbc5b0069..bb15f2ec10 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -19,6 +19,11 @@ * under the License. */ +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -26,11 +31,6 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.VersionComparator; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - /** * Holds the results of a search for versions of an artifact. * diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java index 694f2faa78..3b85131ff7 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java @@ -19,11 +19,11 @@ * under the License. */ +import java.util.Objects; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import java.util.Objects; - /** * Created by IntelliJ IDEA. * diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 91b4fb7fc0..3ee5c04fa9 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -19,6 +19,32 @@ * under the License. */ +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.regex.Pattern; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; @@ -64,28 +90,6 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.*; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.regex.Pattern; - /** * Helper class that provides common functionality required by both the mojos and the reports. * @@ -106,8 +110,8 @@ public class DefaultVersionsHelper /** * The artifact comparison rules to use. * - * @deprecated * @since 1.0-alpha-3 + * @deprecated */ private final RuleSet ruleSet; @@ -175,23 +179,25 @@ public class DefaultVersionsHelper /** * Constructs a new {@link DefaultVersionsHelper}. * - * @param repositorySystem The repositorySystem. - * @param artifactResolver Artifact resolver - * @param artifactMetadataSource The artifact metadata source to use. + * @param repositorySystem The repositorySystem. + * @param artifactResolver Artifact resolver + * @param artifactMetadataSource The artifact metadata source to use. * @param remoteArtifactRepositories The remote artifact repositories to consult. - * @param remotePluginRepositories The remote plugin repositories to consult. - * @param localRepository The local repository to consult. - * @param wagonManager The wagon manager (used if rules need to be retrieved). - * @param settings The settings (used to provide proxy information to the wagon manager). - * @param serverId The serverId hint for the wagon manager. - * @param rulesUri The URL to retrieve the versioning rules from. - * @param log The {@link org.apache.maven.plugin.logging.Log} to send log messages to. - * @param mavenSession The maven session information. + * @param remotePluginRepositories The remote plugin repositories to consult. + * @param localRepository The local repository to consult. + * @param wagonManager The wagon manager (used if rules need to be retrieved). + * @param settings The settings (used to provide proxy information to the wagon manager). + * @param serverId The serverId hint for the wagon manager. + * @param rulesUri The URL to retrieve the versioning rules from. + * @param log The {@link org.apache.maven.plugin.logging.Log} to send log messages to. + * @param mavenSession The maven session information. * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-3 */ + @SuppressWarnings( "checkstyle:ParameterNumber" ) public DefaultVersionsHelper( RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, List remoteArtifactRepositories, + ArtifactMetadataSource artifactMetadataSource, + List remoteArtifactRepositories, List remotePluginRepositories, ArtifactRepository localRepository, WagonManager wagonManager, Settings settings, String serverId, String rulesUri, Log log, MavenSession mavenSession, MojoExecution mojoExecution ) @@ -217,9 +223,9 @@ private static RuleSet getRuleSet( Wagon wagon, String remoteURI ) try { wagon.get( remoteURI, tempFile ); - try(InputStream is = new FileInputStream(tempFile)) + try ( InputStream is = new FileInputStream( tempFile ) ) { - return readRulesFromStream(is); + return readRulesFromStream( is ); } } finally @@ -232,10 +238,11 @@ private static RuleSet getRuleSet( Wagon wagon, String remoteURI ) } } - private static RuleSet readRulesFromStream(InputStream stream) - throws IOException { + private static RuleSet readRulesFromStream( InputStream stream ) + throws IOException + { RuleXpp3Reader reader = new RuleXpp3Reader(); - try (BufferedInputStream bis = new BufferedInputStream( stream )) + try ( BufferedInputStream bis = new BufferedInputStream( stream ) ) { return reader.read( bis ); } @@ -259,115 +266,141 @@ static boolean match( String wildcardRule, String value ) private static RuleSet loadRuleSet( String serverId, Settings settings, WagonManager wagonManager, String rulesUri, Log logger ) - throws MojoExecutionException { + throws MojoExecutionException + { RuleSet ruleSet = new RuleSet(); - boolean rulesUriGiven = isRulesUriNotBlank(rulesUri); + boolean rulesUriGiven = isRulesUriNotBlank( rulesUri ); - if (rulesUriGiven) { + if ( rulesUriGiven ) + { RuleSet loadedRules; - if (isClasspathUri(rulesUri)) { - loadedRules = getRulesFromClasspath(rulesUri, logger); - } else { - loadedRules = getRulesViaWagon(rulesUri, logger, serverId, serverId, wagonManager, - settings); + if ( isClasspathUri( rulesUri ) ) + { + loadedRules = getRulesFromClasspath( rulesUri, logger ); + } + else + { + loadedRules = getRulesViaWagon( rulesUri, logger, serverId, serverId, wagonManager, + settings ); } - ruleSet.setIgnoreVersions(loadedRules.getIgnoreVersions()); - ruleSet.setRules(loadedRules.getRules()); + ruleSet.setIgnoreVersions( loadedRules.getIgnoreVersions() ); + ruleSet.setRules( loadedRules.getRules() ); } return ruleSet; } - private static RuleSet getRulesFromClasspath(String uri, Log logger) - throws MojoExecutionException { - logger.debug("Going to load rules from \"" + uri + "\""); + private static RuleSet getRulesFromClasspath( String uri, Log logger ) + throws MojoExecutionException + { + logger.debug( "Going to load rules from \"" + uri + "\"" ); - String choppedUrl = uri.substring(CLASSPATH_PROTOCOL.length() + 3); + String choppedUrl = uri.substring( CLASSPATH_PROTOCOL.length() + 3 ); - URL url = DefaultVersionsHelper.class.getResource(choppedUrl); + URL url = DefaultVersionsHelper.class.getResource( choppedUrl ); - if (null == url) { + if ( null == url ) + { String message = "Resource \"" + uri + "\" not found in classpath."; - throw new MojoExecutionException(message); + throw new MojoExecutionException( message ); } - try { - RuleSet rules = readRulesFromStream(url.openStream()); - logger.debug("Loaded rules from \"" + uri + "\" successfully"); + try + { + RuleSet rules = readRulesFromStream( url.openStream() ); + logger.debug( "Loaded rules from \"" + uri + "\" successfully" ); return rules; } - catch (IOException e) { - throw new MojoExecutionException("Could not load specified rules from " + uri, e); + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not load specified rules from " + uri, e ); } } - private static boolean isRulesUriNotBlank(String rulesUri) { + private static boolean isRulesUriNotBlank( String rulesUri ) + { return rulesUri != null && rulesUri.trim().length() != 0; } - private static RuleSet getRulesViaWagon(String rulesUri, Log logger, String serverId, String id, - WagonManager wagonManager, Settings settings) - throws MojoExecutionException { + private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String serverId, String id, + WagonManager wagonManager, Settings settings ) + throws MojoExecutionException + { RuleSet loadedRules = new RuleSet(); - int split = rulesUri.lastIndexOf('/'); + int split = rulesUri.lastIndexOf( '/' ); String baseUri = rulesUri; String fileUri = ""; - if (split != -1) { - baseUri = rulesUri.substring(0, split) + '/'; - fileUri = split + 1 < rulesUri.length() ? rulesUri.substring(split + 1) : ""; + if ( split != -1 ) + { + baseUri = rulesUri.substring( 0, split ) + '/'; + fileUri = split + 1 < rulesUri.length() ? rulesUri.substring( split + 1 ) : ""; } - try { - Wagon wagon = WagonUtils.createWagon(serverId, baseUri, wagonManager, settings, logger); - try { - logger.debug("Trying to load ruleset from file \"" + fileUri + "\" in " + baseUri); - loadedRules = getRuleSet(wagon, fileUri); + try + { + Wagon wagon = WagonUtils.createWagon( serverId, baseUri, wagonManager, settings, logger ); + try + { + logger.debug( "Trying to load ruleset from file \"" + fileUri + "\" in " + baseUri ); + loadedRules = getRuleSet( wagon, fileUri ); } - finally { - logger.debug("Rule set loaded"); + finally + { + logger.debug( "Rule set loaded" ); - if (wagon != null) { - try { + if ( wagon != null ) + { + try + { wagon.disconnect(); } - catch (ConnectionException e) { - logger.warn("Could not disconnect wagon!", e); + catch ( ConnectionException e ) + { + logger.warn( "Could not disconnect wagon!", e ); } } } } - catch (TransferFailedException e) { - throw new MojoExecutionException("Could not transfer rules from " + rulesUri, e); + catch ( TransferFailedException e ) + { + throw new MojoExecutionException( "Could not transfer rules from " + rulesUri, e ); } - catch (AuthorizationException e) { - throw new MojoExecutionException("Authorization failure trying to load rules from " + rulesUri, e); + catch ( AuthorizationException e ) + { + throw new MojoExecutionException( "Authorization failure trying to load rules from " + rulesUri, e ); } - catch (ResourceDoesNotExistException e) { - throw new MojoExecutionException("Could not load specified rules from " + rulesUri, e); + catch ( ResourceDoesNotExistException e ) + { + throw new MojoExecutionException( "Could not load specified rules from " + rulesUri, e ); } - catch (AuthenticationException e) { - throw new MojoExecutionException("Authentication failure trying to load rules from " + rulesUri, e); + catch ( AuthenticationException e ) + { + throw new MojoExecutionException( "Authentication failure trying to load rules from " + rulesUri, e ); } - catch (UnsupportedProtocolException e) { - throw new MojoExecutionException("Unsupported protocol for " + rulesUri, e); + catch ( UnsupportedProtocolException e ) + { + throw new MojoExecutionException( "Unsupported protocol for " + rulesUri, e ); } - catch (ConnectionException e) { - throw new MojoExecutionException("Could not establish connection to " + rulesUri, e); + catch ( ConnectionException e ) + { + throw new MojoExecutionException( "Could not establish connection to " + rulesUri, e ); } - catch (IOException e) { - throw new MojoExecutionException("Could not load specified rules from " + rulesUri, e); + catch ( IOException e ) + { + throw new MojoExecutionException( "Could not load specified rules from " + rulesUri, e ); } return loadedRules; } - static boolean isClasspathUri(String uri) { - return (uri != null && uri.startsWith(CLASSPATH_PROTOCOL + ":")); + static boolean isClasspathUri( String uri ) + { + return ( uri != null && uri.startsWith( CLASSPATH_PROTOCOL + ":" ) ); } @Override @@ -405,8 +438,9 @@ public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePl if ( getLog().isDebugEnabled() ) { getLog().debug( "Version " + version + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) + " found on ignore list: " - + ignoreVersion ); + + ArtifactUtils.versionlessKey( artifact ) + + " found on ignore list: " + + ignoreVersion ); } i.remove(); break; @@ -419,8 +453,9 @@ else if ( TYPE_EXACT.equals( ignoreVersion.getType() ) ) if ( getLog().isDebugEnabled() ) { getLog().debug( "Version " + version + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) + " found on ignore list: " - + ignoreVersion ); + + ArtifactUtils.versionlessKey( artifact ) + + " found on ignore list: " + + ignoreVersion ); } i.remove(); break; @@ -447,8 +482,9 @@ private List getIgnoredVersions( Artifact artifact ) if ( !TYPE_EXACT.equals( ignoreVersion.getType() ) && !TYPE_REGEX.equals( ignoreVersion.getType() ) ) { getLog().warn( "The type attribute '" + ignoreVersion.getType() + "' for global ignoreVersion[" - + ignoreVersion + "] is not valid." + " Please use either '" + TYPE_EXACT + "' or '" + TYPE_REGEX - + "'." ); + + ignoreVersion + "] is not valid." + " Please use either '" + TYPE_EXACT + "' or '" + + TYPE_REGEX + + "'." ); } else { @@ -465,7 +501,7 @@ private List getIgnoredVersions( Artifact artifact ) if ( !TYPE_EXACT.equals( ignoreVersion.getType() ) && !TYPE_REGEX.equals( ignoreVersion.getType() ) ) { getLog().warn( "The type attribute '" + ignoreVersion.getType() + "' for " + rule + " is not valid." - + " Please use either '" + TYPE_EXACT + "' or '" + TYPE_REGEX + "'." ); + + " Please use either '" + TYPE_EXACT + "' or '" + TYPE_REGEX + "'." ); } else { @@ -503,7 +539,8 @@ private String showIgnoredVersions( List ignoredVersions ) public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException { - List remoteRepositories = usePluginRepositories ? remotePluginRepositories : remoteArtifactRepositories; + List remoteRepositories = + usePluginRepositories ? remotePluginRepositories : remoteArtifactRepositories; artifactResolver.resolve( artifact, remoteRepositories, localRepository ); } @@ -524,7 +561,7 @@ public VersionComparator getVersionComparator( String groupId, String artifactId /** * Find the rule, if any, which best fits the artifact details given. * - * @param groupId Group id of the artifact + * @param groupId Group id of the artifact * @param artifactId Artifact id of the artifact * @return Rule which best describes the given artifact */ @@ -595,7 +632,7 @@ public Artifact createPluginArtifact( String groupId, String artifactId, String Plugin plugin = new Plugin(); plugin.setGroupId( groupId ); plugin.setArtifactId( artifactId ); - plugin.setVersion( StringUtils.isNotBlank( version) ? version : "[0,]" ); + plugin.setVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ); return repositorySystem.createPluginArtifact( plugin ); } @@ -610,7 +647,7 @@ public Artifact createDependencyArtifact( String groupId, String artifactId, Str dependency.setClassifier( classifier ); dependency.setScope( scope ); dependency.setOptional( optional ); - dependency.setVersion( StringUtils.isNotBlank( version) ? version : "[0,]" ); + dependency.setVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ); return repositorySystem.createDependencyArtifact( dependency ); } @@ -695,7 +732,7 @@ public Map lookupDependenciesUpdates( Set lookupPluginsUpdates( Set plugi catch ( ExecutionException | InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " - + ie.getMessage(), ie, null ); + + ie.getMessage(), ie, null ); } finally { @@ -761,7 +798,7 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna String version = plugin.getVersion(); version = version == null ? "LATEST" : version; getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) - + " for updates newer than " + version ); + + " for updates newer than " + version ); boolean includeSnapshots = allowSnapshots; @@ -822,7 +859,7 @@ public Map getVersionPropertiesMap( MavenProject pro { final Property value = new Property( name ); getLog().debug( "Property ${" + name + "}: Adding inferred version range of " - + propertyVersionsBuilder.getVersionRange() ); + + propertyVersionsBuilder.getVersionRange() ); value.setVersion( propertyVersionsBuilder.getVersionRange() ); properties.put( name, value ); } @@ -861,7 +898,7 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr if ( builder == null || !builder.isAssociated() ) { getLog().debug( "Property ${" + property.getName() + "}: Looks like this property is not " - + "associated with any dependency..." ); + + "associated with any dependency..." ); builder = new PropertyVersionsBuilder( null, property.getName(), this ); } if ( !property.isAutoLinkDependencies() ) @@ -885,7 +922,7 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr && !StringUtils.isEmpty( builder.getVersionRange() ) ) { getLog().debug( "Property ${" + property.getName() + "}: Adding inferred version range of " - + builder.getVersionRange() ); + + builder.getVersionRange() ); property.setVersion( builder.getVersionRange() ); } versions.setCurrentVersion( project.getProperties().getProperty( property.getName() ) ); @@ -917,7 +954,7 @@ private static class DependencyArtifactVersions private final ArtifactVersions artifactVersions; - public DependencyArtifactVersions( final Dependency dependency, final ArtifactVersions artifactVersions ) + DependencyArtifactVersions( final Dependency dependency, final ArtifactVersions artifactVersions ) { this.dependency = dependency; this.artifactVersions = artifactVersions; @@ -941,7 +978,7 @@ private static class PluginPluginUpdatesDetails private final PluginUpdatesDetails pluginUpdatesDetails; - public PluginPluginUpdatesDetails( final Plugin plugin, final PluginUpdatesDetails pluginUpdatesDetails ) + PluginPluginUpdatesDetails( final Plugin plugin, final PluginUpdatesDetails pluginUpdatesDetails ) { this.plugin = plugin; this.pluginUpdatesDetails = pluginUpdatesDetails; @@ -966,7 +1003,7 @@ private class DependencyLookup private final boolean usePluginRepositories; - public DependencyLookup( final Dependency dependency, final boolean usePluginRepositories ) + DependencyLookup( final Dependency dependency, final boolean usePluginRepositories ) { this.dependency = dependency; this.usePluginRepositories = usePluginRepositories; @@ -988,7 +1025,7 @@ private class PluginLookup private final boolean allowSnapshots; - public PluginLookup( final Plugin plugin, final Boolean allowSnapshots ) + PluginLookup( final Plugin plugin, final Boolean allowSnapshots ) { this.plugin = plugin; this.allowSnapshots = allowSnapshots; diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 03baccf7a4..e855bf1733 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -19,33 +19,9 @@ * under the License. */ -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.Profile; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.profiles.ProfileManager; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.RegexUtils; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -69,6 +45,31 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.Profile; +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.profiles.ProfileManager; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.RegexUtils; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.util.IOUtil; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + /** * Helper class for modifying pom files. * @@ -102,7 +103,7 @@ public static Model getRawModel( MavenProject project ) public static Model getRawModel( File moduleProjectFile ) throws IOException { - try (FileInputStream input = new FileInputStream( moduleProjectFile )) + try ( FileInputStream input = new FileInputStream( moduleProjectFile ) ) { return new MavenXpp3Reader().read( input ); } @@ -122,7 +123,7 @@ public static Model getRawModel( File moduleProjectFile ) public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventReader ) throws IOException { - try (StringReader stringReader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() )) + try ( StringReader stringReader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() ) ) { return new MavenXpp3Reader().read( stringReader ); } @@ -135,10 +136,10 @@ public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventRe /** * Searches the pom re-defining the specified property to the specified version. * - * @param pom The pom to modify. + * @param pom The pom to modify. * @param profileId The profile in which to modify the property. - * @param property The property to modify. - * @param value The new value of the property. + * @param property The property to modify. + * @param value The new value of the property. * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. */ @@ -222,7 +223,7 @@ else if ( matchScopeRegex.matcher( path ).matches() ) /** * Searches the pom re-defining the project version to the specified version. * - * @param pom The pom to modify. + * @param pom The pom to modify. * @param value The new value of the property. * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. @@ -236,9 +237,9 @@ public static boolean setProjectVersion( final ModifiedPomXMLEventReader pom, fi /** * Searches the pom re-defining a project value using the given pattern. * - * @param pom The pom to modify. + * @param pom The pom to modify. * @param pattern The pattern to look for. - * @param value The new value of the property. + * @param value The new value of the property. * @return true if a replacement was made. * @throws XMLStreamException if something went wrong. */ @@ -290,7 +291,7 @@ public static boolean setProjectValue( final ModifiedPomXMLEventReader pom, Stri * * @param pom The pom. * @return the project version or null if the project version is not defined (i.e. inherited from - * parent version). + * parent version). * @throws XMLStreamException if something went wrong. */ public static String getProjectVersion( final ModifiedPomXMLEventReader pom ) @@ -336,7 +337,7 @@ public static String getProjectVersion( final ModifiedPomXMLEventReader pom ) /** * Searches the pom re-defining the project version to the specified version. * - * @param pom The pom to modify. + * @param pom The pom to modify. * @param value The new value of the property. * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. @@ -387,7 +388,7 @@ public static boolean setProjectParentVersion( final ModifiedPomXMLEventReader p /** * Gets the parent artifact from the pom. * - * @param pom The pom. + * @param pom The pom. * @param helper The helper (used to create the artifact). * @return The parent artifact or null if no parent is specified. * @throws XMLStreamException if something went wrong. @@ -441,22 +442,23 @@ else if ( "version".equals( elementName ) ) { return null; } - return helper.createDependencyArtifact( groupId, artifactId, version , "pom", + return helper.createDependencyArtifact( groupId, artifactId, version, "pom", null, null ); } /** * Searches the pom re-defining the specified dependency to the specified version. * - * @param pom The pom to modify. - * @param groupId The groupId of the dependency. + * @param pom The pom to modify. + * @param groupId The groupId of the dependency. * @param artifactId The artifactId of the dependency. * @param oldVersion The old version of the dependency. * @param newVersion The new version of the dependency. - * @param model The model to get the project properties from. + * @param model The model to get the project properties from. * @return true if a replacement was made. * @throws XMLStreamException if something went wrong. */ + @SuppressWarnings( "checkstyle:MethodLength" ) public static boolean setDependencyVersion( final ModifiedPomXMLEventReader pom, final String groupId, final String artifactId, final String oldVersion, final String newVersion, final Model model ) @@ -467,8 +469,8 @@ public static boolean setDependencyVersion( final ModifiedPomXMLEventReader pom, Set implicitPaths = new HashSet<>( Arrays.asList( "/project/parent/groupId", "/project/parent/artifactId", - "/project/parent/version", "/project/groupId", - "/project/artifactId", "/project/version" ) ); + "/project/parent/version", "/project/groupId", + "/project/artifactId", "/project/version" ) ); Map implicitProperties = new HashMap<>(); for ( Map.Entry entry : model.getProperties().entrySet() ) @@ -530,12 +532,16 @@ public static boolean setDependencyVersion( final ModifiedPomXMLEventReader pom, boolean haveArtifactId = false; boolean haveOldVersion = false; - final Pattern matchScopeRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" + "/dependencies/dependency" ); + final Pattern matchScopeRegex = Pattern.compile( + "/project" + "(/profiles/profile)?" + + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" + + "/dependencies/dependency" ); - final Pattern matchTargetRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" + "/dependencies/dependency" - + "((/groupId)|(/artifactId)|(/version))" ); + final Pattern matchTargetRegex = Pattern.compile( + "/project" + "(/profiles/profile)?" + + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" + + "/dependencies/dependency" + + "((/groupId)|(/artifactId)|(/version))" ); pom.rewind(); @@ -622,7 +628,7 @@ else if ( matchScopeRegex.matcher( path ).matches() ) /** * A lightweight expression evaluation function. * - * @param expr The expression to evaluate. + * @param expr The expression to evaluate. * @param properties The properties to substitute. * @return The evaluated expression. */ @@ -715,7 +721,7 @@ private static String stripTokens( String expr ) /** * Checks if two versions or ranges have an overlap. * - * @param leftVersionOrRange the 1st version number or range to test + * @param leftVersionOrRange the 1st version number or range to test * @param rightVersionOrRange the 2nd version number or range to test * @return true if both versions have an overlap * @throws InvalidVersionSpecificationException if the versions can't be parsed to a range @@ -753,8 +759,8 @@ private static VersionRange createVersionRange( String versionOrRange ) /** * Searches the pom re-defining the specified plugin to the specified version. * - * @param pom The pom to modify. - * @param groupId The groupId of the dependency. + * @param pom The pom to modify. + * @param groupId The groupId of the dependency. * @param artifactId The artifactId of the dependency. * @param oldVersion The old version of the dependency. * @param newVersion The new version of the dependency. @@ -777,10 +783,11 @@ public static boolean setPluginVersion( final ModifiedPomXMLEventReader pom, fin boolean haveOldVersion = false; matchScopeRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" ); + + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" ); matchTargetRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" + "((/groupId)|(/artifactId)|(/version))" ); + + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" + + "((/groupId)|(/artifactId)|(/version))" ); pom.rewind(); @@ -864,11 +871,11 @@ else if ( matchScopeRegex.matcher( path ).matches() ) /** * Examines the project to find any properties which are associated with versions of artifacts in the project. * - * @param helper Our versions helper. + * @param helper Our versions helper. * @param project The project to examine. * @return An array of properties that are associated within the project. * @throws ExpressionEvaluationException if an expression cannot be evaluated. - * @throws IOException if the project's pom file cannot be parsed. + * @throws IOException if the project's pom file cannot be parsed. * @since 1.0-alpha-3 */ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHelper helper, MavenProject project ) @@ -963,7 +970,8 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel } if ( profile.getReporting() != null ) { - addReportPluginAssociations( helper, expressionEvaluator, result, profile.getReporting().getPlugins() ); + addReportPluginAssociations( helper, expressionEvaluator, result, + profile.getReporting().getPlugins() ); } } currentPrj = currentPrj.getParent(); @@ -983,10 +991,11 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel * Takes a list of {@link org.apache.maven.model.Plugin} instances and adds associations to properties used to * define versions of the plugin artifact or any of the plugin dependencies specified in the pom. * - * @param helper Our helper. + * @param helper Our helper. * @param expressionEvaluator Our expression evaluator. - * @param result The map of {@link org.codehaus.mojo.versions.api.PropertyVersionsBuilder} keyed by property name. - * @param plugins The list of {@link org.apache.maven.model.Plugin}. + * @param result The map of {@link org.codehaus.mojo.versions.api.PropertyVersionsBuilder} keyed by + * property name. + * @param plugins The list of {@link org.apache.maven.model.Plugin}. * @throws ExpressionEvaluationException if an expression cannot be evaluated. */ private static void addPluginAssociations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator, @@ -1211,7 +1220,7 @@ private static void purgeProperties( Map result * activation). * * @param project The project. - * @param logger The logger to use. + * @param logger The logger to use. * @return the set of all child modules of the project. */ public static Set getAllChildModules( MavenProject project, Log logger ) @@ -1223,7 +1232,7 @@ public static Set getAllChildModules( MavenProject project, Log logger ) * Returns a set of all child modules for a project, including any defined in profiles (ignoring profile * activation). * - * @param model The project model. + * @param model The project model. * @param logger The logger to use. * @return the set of all child modules of the project. */ @@ -1239,7 +1248,7 @@ public static Set getAllChildModules( Model model, Log logger ) /** * Outputs a debug message with a list of modules. * - * @param logger The logger to log to. + * @param logger The logger to log to. * @param message The message to display. * @param modules The modules to append to the message. */ @@ -1254,7 +1263,7 @@ public static void debugModules( Log logger, String message, Collection } else { - modules.forEach( module -> logger.debug( " " + module )); + modules.forEach( module -> logger.debug( " " + module ) ); } } @@ -1263,8 +1272,8 @@ public static void debugModules( Log logger, String message, Collection /** * Modifies the collection of child modules removing those which cannot be found relative to the parent. * - * @param logger The logger to log to. - * @param project the project. + * @param logger The logger to log to. + * @param project the project. * @param childModules the child modules. */ public static void removeMissingChildModules( Log logger, MavenProject project, Collection childModules ) @@ -1275,8 +1284,8 @@ public static void removeMissingChildModules( Log logger, MavenProject project, /** * Modifies the collection of child modules removing those which cannot be found relative to the parent. * - * @param logger The logger to log to. - * @param basedir the project basedir. + * @param logger The logger to log to. + * @param basedir the project basedir. * @param childModules the child modules. */ public static void removeMissingChildModules( Log logger, File basedir, Collection childModules ) @@ -1368,10 +1377,10 @@ public static String getGroupId( Model model ) /** * Finds the local root of the specified project. * - * @param project The project to find the local root for. - * @param localRepository the local repo. + * @param project The project to find the local root for. + * @param localRepository the local repo. * @param globalProfileManager the global profile manager. - * @param logger The logger to log to. + * @param logger The logger to log to. * @return The local root (note this may be the project passed as an argument). */ public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project, @@ -1418,7 +1427,7 @@ public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProje * Builds a map of raw models keyed by module path. * * @param project The project to build from. - * @param logger The logger for logging. + * @param logger The logger for logging. * @return A map of raw models keyed by path relative to the project's basedir. * @throws IOException if things go wrong. */ @@ -1436,10 +1445,10 @@ public static Map getReactorModels( MavenProject project, Log log /** * Builds a sub-map of raw models keyed by module path. * - * @param path The relative path to base the sub-map on. - * @param model The model at the relative path. + * @param path The relative path to base the sub-map on. + * @param model The model at the relative path. * @param project The project to build from. - * @param logger The logger for logging. + * @param logger The logger for logging. * @return A map of raw models keyed by path relative to the project's basedir. * @throws IOException if things go wrong. */ @@ -1498,8 +1507,8 @@ private static Map getReactorModels( String path, Model model, Ma /** * Returns all the models that have a specified groupId and artifactId as parent. * - * @param reactor The map of models keyed by path. - * @param groupId The groupId of the parent. + * @param reactor The map of models keyed by path. + * @param groupId The groupId of the parent. * @param artifactId The artifactId of the parent. * @return a map of models that have a specified groupId and artifactId as parent keyed by path. */ @@ -1523,8 +1532,8 @@ public static Map getChildModels( Map reactor, Str /** * Returns the model that has the specified groupId and artifactId or null if no such model exists. * - * @param reactor The map of models keyed by path. - * @param groupId The groupId to match. + * @param reactor The map of models keyed by path. + * @param groupId The groupId to match. * @param artifactId The artifactId to match. * @return The model or null if the model was not in the reactor. */ @@ -1537,8 +1546,8 @@ public static Model getModel( Map reactor, String groupId, String /** * Returns the model that has the specified groupId and artifactId or null if no such model exists. * - * @param reactor The map of models keyed by path. - * @param groupId The groupId to match. + * @param reactor The map of models keyed by path. + * @param groupId The groupId to match. * @param artifactId The artifactId to match. * @return The model entry or null if the model was not in the reactor. */ @@ -1560,7 +1569,7 @@ public static Map.Entry getModelEntry( Map reactor * Returns a count of how many parents a model has in the reactor. * * @param reactor The map of models keyed by path. - * @param model The model. + * @param model The model. * @return The number of parents of this model in the reactor. */ public static int getReactorParentCount( Map reactor, Model model ) @@ -1590,7 +1599,7 @@ public static int getReactorParentCount( Map reactor, Model model public static StringBuilder readXmlFile( File outFile ) throws IOException { - try( Reader reader = ReaderFactory.newXmlReader( outFile ) ) + try ( Reader reader = ReaderFactory.newXmlReader( outFile ) ) { return new StringBuilder( IOUtil.toString( reader ) ); } @@ -1629,7 +1638,7 @@ public static List readImportedPOMsFromDependencyManagementSection( String scopeElement = "scope"; Set recognizedElements = new HashSet<>( Arrays.asList( groupIdElement, artifactIdElement, versionElement, typeElement, - scopeElement ) ); + scopeElement ) ); Map depData = new HashMap<>(); pom.rewind(); diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 3d79570520..eb363589ae 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -19,6 +19,17 @@ * under the License. */ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -31,17 +42,6 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - /** * Manages a property that is associated with one or more artifacts. * @@ -158,8 +158,8 @@ private VersionComparator[] lookupComparators() * * @param artifacts The {@link Collection} of {@link Artifact} instances . * @return The versions that can be resolved from the supplied Artifact instances or an empty array if no version - * can be resolved (i.e. the property is not associated with any of the supplied artifacts or the property - * is also associated to an artifact that has not been provided). + * can be resolved (i.e. the property is not associated with any of the supplied artifacts or the property + * is also associated to an artifact that has not been provided). * @throws org.apache.maven.plugin.MojoExecutionException When things go wrong. * @since 1.0-alpha-3 */ @@ -192,10 +192,12 @@ public ArtifactVersion[] getVersions( Collection artifacts ) } // we now have a list of all the versions that partially satisfy the association requirements Iterator k = result.iterator(); - versions: while ( k.hasNext() ) + versions: + while ( k.hasNext() ) { ArtifactVersion candidate = k.next(); - associations: for ( ArtifactAssociation association : associations ) + associations: + for ( ArtifactAssociation association : associations ) { for ( Artifact artifact : artifacts ) { @@ -276,10 +278,12 @@ private ArtifactVersion[] asArtifactVersionArray( Collection re Arrays.sort( alt, rules[j] ); if ( !Arrays.equals( alt, answer ) ) { - throw new IllegalStateException( "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the set of versions available to this property.\nFirst rule says: " - + Arrays.asList( answer ) + "\nSecond rule says: " + Arrays.asList( alt ) ); + throw new IllegalStateException( + "Property " + name + " is associated with multiple artifacts" + + " and these artifacts use different version sorting rules and these rules are effectively" + + " incompatible for the set of versions available to this property.\nFirst rule says: " + + Arrays.asList( answer ) + "\nSecond rule says: " + + Arrays.asList( alt ) ); } } return answer; @@ -322,7 +326,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert final boolean includeSnapshots = !property.isBanSnapshots() && allowSnapshots; helper.getLog().debug( "getNewestVersion(): includeSnapshots='" + includeSnapshots + "'" ); helper.getLog().debug( "Property ${" + property.getName() + "}: Set of valid available versions is " - + Arrays.asList( getVersions( includeSnapshots ) ) ); + + Arrays.asList( getVersions( includeSnapshots ) ) ); VersionRange range; try { @@ -347,7 +351,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert { if ( segment != -1 ) { - lowerBoundArtifactVersion = getLowerBound(helper, currentVersion, segment); + lowerBoundArtifactVersion = getLowerBound( helper, currentVersion, segment ); } helper.getLog().debug( "lowerBoundArtifactVersion is null based on allowDowngrade:" + allowDowngrade ); } @@ -374,7 +378,8 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert Collection reactorArtifacts = helper.extractArtifacts( reactorProjects ); ArtifactVersion[] reactorVersions = getVersions( reactorArtifacts ); helper.getLog().debug( "Property ${" + property.getName() - + "}: Set of valid available versions from the reactor is " + Arrays.asList( reactorVersions ) ); + + "}: Set of valid available versions from the reactor is " + Arrays.asList( + reactorVersions ) ); ArtifactVersion fromReactor = null; if ( reactorVersions.length > 0 ) { @@ -384,7 +389,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert { fromReactor = reactorVersions[j]; helper.getLog().debug( "Property ${" + property.getName() + "}: Reactor has version " - + fromReactor ); + + fromReactor ); break; } } @@ -394,7 +399,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert if ( property.isPreferReactor() ) { helper.getLog().debug( "Property ${" + property.getName() - + "}: Reactor has a version and we prefer the reactor" ); + + "}: Reactor has a version and we prefer the reactor" ); result = fromReactor; } else @@ -412,7 +417,7 @@ else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) else { helper.getLog().debug( "Property ${" + property.getName() - + "}: Reactor has the same or older version" ); + + "}: Reactor has the same or older version" ); } } } @@ -454,11 +459,14 @@ private int innerCompare( ArtifactVersion v1, ArtifactVersion v2 ) int alt = comparators[i].compare( v1, v2 ); if ( result != alt && ( result >= 0 && alt < 0 ) || ( result <= 0 && alt > 0 ) ) { - throw new IllegalStateException( "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the two of versions being compared.\nFirst rule says compare(\"" + v1 - + "\", \"" + v2 + "\") = " + result + "\nSecond rule says compare(\"" + v1 + "\", \"" + v2 - + "\") = " + alt ); + throw new IllegalStateException( + "Property " + name + " is associated with multiple artifacts" + + " and these artifacts use different version sorting rules and these rules are effectively" + + " incompatible for the two of versions being compared.\nFirst rule says compare(\"" + + v1 + + "\", \"" + v2 + "\") = " + result + + "\nSecond rule says compare(\"" + v1 + "\", \"" + v2 + + "\") = " + alt ); } } return result; @@ -478,10 +486,14 @@ public int getSegmentCount( ArtifactVersion v ) int alt = comparators[i].getSegmentCount( v ); if ( result != alt ) { - throw new IllegalStateException( "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the two of versions being compared.\nFirst rule says getSegmentCount(\"" - + v + "\") = " + result + "\nSecond rule says getSegmentCount(\"" + v + "\") = " + alt ); + throw new IllegalStateException( + "Property " + name + " is associated with multiple artifacts" + + " and these artifacts use different version sorting rules and these rules are effectively" + + " incompatible for the two of versions being compared.\n" + + "First rule says getSegmentCount(\"" + + v + "\") = " + result + + "\nSecond rule says getSegmentCount(\"" + v + "\") = " + + alt ); } } return result; @@ -501,11 +513,14 @@ public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) ArtifactVersion alt = comparators[i].incrementSegment( v, segment ); if ( !result.toString().equals( alt.toString() ) ) { - throw new IllegalStateException( "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the two of versions being compared.\nFirst rule says incrementSegment(\"" - + v + "\", " + segment + ") = " + result + "\nSecond rule says incrementSegment(\"" + v + "\", " - + segment + ") = " + alt ); + throw new IllegalStateException( + "Property " + name + " is associated with multiple artifacts" + + " and these artifacts use different version sorting rules and these rules are effectively" + + " incompatible for the two of versions being compared.\n" + + "First rule says incrementSegment(\"" + + v + "\", " + segment + ") = " + result + + "\nSecond rule says incrementSegment(\"" + v + "\", " + + segment + ") = " + alt ); } } return result; @@ -514,42 +529,43 @@ public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) } - private ArtifactVersion getLowerBound(VersionsHelper helper, - String currentVersion, int segment) + private ArtifactVersion getLowerBound( VersionsHelper helper, + String currentVersion, int segment ) { - ArtifactVersion version = helper.createArtifactVersion(currentVersion); - int segmentCount = getVersionComparator().getSegmentCount(version); - if (segment < 0 || segment > segmentCount) + ArtifactVersion version = helper.createArtifactVersion( currentVersion ); + int segmentCount = getVersionComparator().getSegmentCount( version ); + if ( segment < 0 || segment > segmentCount ) { - throw new InvalidSegmentException(segment, segmentCount, - currentVersion); + throw new InvalidSegmentException( segment, segmentCount, + currentVersion ); } StringBuilder newVersion = new StringBuilder(); - newVersion.append(segment >= 0 ? version.getMajorVersion() : 0); - if (segmentCount > 0) + newVersion.append( segment >= 0 ? version.getMajorVersion() : 0 ); + if ( segmentCount > 0 ) { - newVersion.append(".") - .append(segment >= 1 ? version.getMinorVersion() : 0); + newVersion.append( "." ) + .append( segment >= 1 ? version.getMinorVersion() : 0 ); } - if (segmentCount > 1) + if ( segmentCount > 1 ) { - newVersion.append(".") - .append(segment >= 2 ? version.getIncrementalVersion() : 0); + newVersion.append( "." ) + .append( segment >= 2 ? version.getIncrementalVersion() : 0 ); } - if (segmentCount > 2) + if ( segmentCount > 2 ) { - if (version.getQualifier() != null) + if ( version.getQualifier() != null ) { - newVersion.append("-") - .append(segment >= 3 ? version.getQualifier() : "0"); - } else + newVersion.append( "-" ) + .append( segment >= 3 ? version.getQualifier() : "0" ); + } + else { - newVersion.append("-") - .append(segment >= 3 ? version.getBuildNumber() : "0"); + newVersion.append( "-" ) + .append( segment >= 3 ? version.getBuildNumber() : "0" ); } } - return helper.createArtifactVersion(newVersion.toString()); + return helper.createArtifactVersion( newVersion.toString() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java index 9d5cf9e222..2e3c7a7312 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java @@ -19,17 +19,17 @@ * under the License. */ -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.codehaus.mojo.versions.ordering.VersionComparator; - import java.util.Comparator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.ordering.VersionComparator; + /** * Builds {@link org.codehaus.mojo.versions.api.PropertyVersions} instances. * @@ -57,7 +57,7 @@ class PropertyVersionsBuilder * @param name The property name. * @param helper The {@link org.codehaus.mojo.versions.api.DefaultVersionsHelper}. */ - public PropertyVersionsBuilder( String profileId, String name, VersionsHelper helper ) + PropertyVersionsBuilder( String profileId, String name, VersionsHelper helper ) { this.profileId = profileId; this.name = name; diff --git a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java index 62406c7b6b..0cefcec07e 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java +++ b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java @@ -406,7 +406,7 @@ public final Class getDeclaringClass() */ public static UpdateScope valueOf( String name ) { - UpdateScope result = levelConstants.get( name ); + UpdateScope result = LEVEL_CONSTANTS.get( name ); if ( result != null ) { return result; @@ -464,7 +464,7 @@ public static UpdateScope classifyUpdate( VersionComparator comparator, Artifact } } - private static final Map levelConstants; + private static final Map LEVEL_CONSTANTS; static { @@ -474,7 +474,7 @@ public static UpdateScope classifyUpdate( VersionComparator comparator, Artifact map.put( MINOR.name(), MINOR ); map.put( MAJOR.name(), MAJOR ); map.put( ANY.name(), ANY ); - levelConstants = map; + LEVEL_CONSTANTS = map; } /** diff --git a/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java index 1d81a3206e..26ee76a7cb 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java +++ b/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java @@ -20,6 +20,7 @@ */ import javax.xml.stream.XMLStreamException; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java index acb85ad1a9..2ae7173224 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java +++ b/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * Created by IntelliJ IDEA. * diff --git a/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java index 307e11ab89..7d39e15a07 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java +++ b/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * */ diff --git a/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java index c327ec43fe..8c2f80ea11 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java +++ b/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * Created by IntelliJ IDEA. * diff --git a/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java index 929bb9cff1..17fc8b9c85 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java +++ b/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java @@ -19,13 +19,13 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; - /** * Created by IntelliJ IDEA. * diff --git a/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java b/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java index b09af29df5..1f1d543d6c 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java +++ b/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java @@ -19,13 +19,13 @@ * under the License. */ +import java.util.ArrayList; +import java.util.List; + import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import java.util.ArrayList; -import java.util.List; - /** * Created by IntelliJ IDEA. * diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java index 1d656c0dd5..6b944ce9af 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java @@ -77,7 +77,7 @@ private IntegerItem() this.value = BIG_INTEGEGER_ZERO; } - public IntegerItem( String str ) + IntegerItem( String str ) { this.value = new BigInteger( str ); } @@ -127,11 +127,11 @@ public String toString() private static class StringItem implements Item { - private final static String[] QUALIFIERS = { "snapshot", "alpha", "beta", "milestone", "rc", "", "sp" }; + private static final String[] QUALIFIERS = {"snapshot", "alpha", "beta", "milestone", "rc", "", "sp"}; - private final static List QUALIFIERS_LIST = Arrays.asList( QUALIFIERS ); + private static final List QUALIFIERS_LIST = Arrays.asList( QUALIFIERS ); - private final static Properties ALIASES = new Properties(); + private static final Properties ALIASES = new Properties(); static { @@ -148,7 +148,7 @@ private static class StringItem private final String value; - public StringItem( String value, boolean followedByDigit ) + StringItem( String value, boolean followedByDigit ) { if ( followedByDigit && value.length() == 1 ) { @@ -164,6 +164,9 @@ public StringItem( String value, boolean followedByDigit ) case 'm': value = "milestone"; break; + default: + // no action + break; } } this.value = ALIASES.getProperty( value, value ); @@ -381,7 +384,9 @@ else if ( c == '-' ) { // new ListItem only if previous were digits and new char is a digit, // ie need to differentiate only 1.1 from 1-1 + // CHECKSTYLE_OFF: InnerAssignment list.add( list = new ListItem() ); + // CHECKSTYLE_ON: InnerAssignment stack.push( list ); } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java b/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java index 1d802f22b3..a88311698a 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java @@ -45,7 +45,7 @@ * versions which will defined 2.1.0-M1 as less than 2.1.0. The method * {@link #filter(ArtifactVersion, ArtifactVersion[])} will filter out those versions which violate the configuration * {@link #allowMajorUpdates}, {@link #allowMinorUpdates} {@link #allowIncrementalUpdates}. - * + * * @author Karl Heinz Marbaise */ public class MajorMinorIncrementalFilter @@ -67,9 +67,9 @@ public MajorMinorIncrementalFilter( boolean allowMajorUpdates, boolean allowMino /** * @param selectedVersion The version which will be checked. - * @param newerVersions The list of identified versions which are greater or equal than the selectedVersion. + * @param newerVersions The list of identified versions which are greater or equal than the selectedVersion. * @return The cleaned up list which obeys usage of {@link #allowMajorUpdates}, {@link #allowMinorUpdates}, - * {@link #allowIncrementalUpdates}. + * {@link #allowIncrementalUpdates}. */ public ArtifactVersion[] filter( ArtifactVersion selectedVersion, ArtifactVersion[] newerVersions ) { @@ -106,11 +106,12 @@ else if ( artifactVersion.getIncrementalVersion() != selectedVersion.getIncremen } } } - else { + else + { // build number or qualifier. Will already be sorted and higher if ( !versionsToUse.contains( artifactVersion ) ) { - versionsToUse.add( artifactVersion ); + versionsToUse.add( artifactVersion ); } } } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index b61ff7bdd8..e13d3da951 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -155,6 +155,9 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment build++; } break; + default: + // no action + break; } StringBuilder result = new StringBuilder(); result.append( major ); diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java index 168febd97f..b26e88517a 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java @@ -19,12 +19,12 @@ * under the License. */ -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; - import java.math.BigInteger; import java.util.StringTokenizer; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + /** * A comparator which uses Mercury's version rules. * diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java index 3cc1a73f02..1468717b9b 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java @@ -19,12 +19,12 @@ * under the License. */ -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; - import java.math.BigInteger; import java.util.StringTokenizer; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + /** * A comparator which will compare all segments of a dot separated version string as numbers if possible, i.e. 1.3.34 * > 1.3.9 and 1.3.4.3.2.34 > 1.3.4.3.2.9 and 1.3.4.3.2.34 > 1.3.4.3.2.34-SNAPSHOT @@ -162,6 +162,7 @@ protected int innerGetSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ + @SuppressWarnings( "checkstyle:MethodLength" ) protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) { final int segmentCount = innerGetSegmentCount( v ); diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java index 02b902742e..b9e0e7199b 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java @@ -19,12 +19,12 @@ * under the License. */ -import org.apache.maven.model.Model; -import org.codehaus.mojo.versions.api.PomHelper; - import java.util.Comparator; import java.util.Map; +import org.apache.maven.model.Model; +import org.codehaus.mojo.versions.api.PomHelper; + /** * Compares project paths relative to the base directory based on their depth in a reactor * diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 6a90938df8..ee2956a7cb 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -19,10 +19,10 @@ * under the License. */ -import org.apache.maven.artifact.versioning.ArtifactVersion; - import java.util.Comparator; +import org.apache.maven.artifact.versioning.ArtifactVersion; + /** * A rule for comparing and manipulating versions. */ diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java index f3db6e99e2..0576b0104f 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java @@ -19,12 +19,12 @@ * under the License. */ -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + /** * Utility. * diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index f023e0df58..e2bf312b54 100644 --- a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -46,7 +46,8 @@ private ChangeRecorderNull() } @Override - public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) + public final void recordUpdate( final String kind, final String groupId, final String artifactId, + final String oldVersion, final String newVersion ) { Objects.requireNonNull( kind, "kind" ); Objects.requireNonNull( groupId, "groupId" ); diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java index 3f88ccc38a..d6b62526df 100644 --- a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -19,10 +19,6 @@ * under the License. */ -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -32,10 +28,15 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; + import java.io.IOException; import java.io.OutputStream; import java.util.Objects; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /** * A recorder of version updates. */ @@ -81,7 +82,8 @@ private ChangeRecorderXML( final Document document, final Element root ) } @Override - public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) + public final void recordUpdate( final String kind, final String groupId, final String artifactId, + final String oldVersion, final String newVersion ) { Objects.requireNonNull( kind, "kind" ); Objects.requireNonNull( groupId, "groupId" ); diff --git a/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java b/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java index f8fdd35299..b65321dece 100644 --- a/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java +++ b/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java @@ -19,18 +19,19 @@ * under the License. */ -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.Characters; import javax.xml.stream.events.XMLEvent; + import java.io.IOException; import java.io.StringReader; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + /** * Represents the modified pom file. Note: implementations of the StAX API (JSR-173) are not good round-trip rewriting * while keeping all unchanged bytes in the file as is. For example, the StAX API specifies that CR @@ -129,9 +130,9 @@ public class ModifiedPomXMLEventReader /** * Constructor ModifiedPomXMLEventReader creates a new ModifiedPomXMLEventReader instance. * - * @param pom of type StringBuilder + * @param pom of type StringBuilder * @param factory of type XMLInputFactory - * @param path Path pointing to source of XML + * @param path Path pointing to source of XML * @throws XMLStreamException when */ public ModifiedPomXMLEventReader( StringBuilder pom, XMLInputFactory factory, String path ) @@ -381,7 +382,7 @@ public boolean hasNext() } catch ( XMLStreamException e ) { - throw new RuntimeException("Error parsing " + path + ": " + e.getMessage(), e); + throw new RuntimeException( "Error parsing " + path + ": " + e.getMessage(), e ); } } @@ -500,8 +501,8 @@ public String getBetween( int index1, int index2 ) /** * Replaces all content between marks index1 and index2 with the replacement text. * - * @param index1 The event mark to replace after. - * @param index2 The event mark to replace before. + * @param index1 The event mark to replace after. + * @param index2 The event mark to replace before. * @param replacement The replacement. */ public void replaceBetween( int index1, int index2, String replacement ) @@ -546,7 +547,7 @@ else if ( markStart[i] > markEnd[index1] || markEnd[i] < markStart[index2] ) /** * Replaces the specified marked element with the replacement text. * - * @param index The mark. + * @param index The mark. * @param replacement The replacement. */ public void replaceMark( int index, String replacement ) diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java index 025b62808d..20be1ad5f3 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java @@ -19,10 +19,10 @@ * under the License. */ -import org.apache.maven.model.Dependency; - import java.util.Comparator; +import org.apache.maven.model.Dependency; + /** * A comparator used to sort dependencies by group id, artifact id and finally version. * diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java index 6f65b7e45e..b62a06ec08 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java @@ -19,11 +19,11 @@ * under the License. */ +import java.util.Comparator; + import org.apache.maven.model.Plugin; import org.apache.maven.model.ReportPlugin; -import java.util.Comparator; - /** * A comparator used to sort plugins and report plugins by group id, artifact id and finally version. * @@ -46,11 +46,13 @@ public int compare( Object o1, Object o2 ) { if ( !( o1 instanceof Plugin || o1 instanceof ReportPlugin ) ) { - throw new IllegalArgumentException( "This comparator can only be used to compare Plugin and ReportPlugin instances" ); + throw new IllegalArgumentException( + "This comparator can only be used to compare Plugin and ReportPlugin instances" ); } if ( !( o2 instanceof Plugin || o2 instanceof ReportPlugin ) ) { - throw new IllegalArgumentException( "This comparator can only be used to compare Plugin and ReportPlugin instances" ); + throw new IllegalArgumentException( + "This comparator can only be used to compare Plugin and ReportPlugin instances" ); } String g1 = o1 instanceof Plugin ? ( (Plugin) o1 ).getGroupId() : ( (ReportPlugin) o1 ).getGroupId(); String g2 = o2 instanceof Plugin ? ( (Plugin) o2 ).getGroupId() : ( (ReportPlugin) o2 ).getGroupId(); @@ -80,4 +82,4 @@ public int compare( Object o1, Object o2 ) return r; } -} \ No newline at end of file +} diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java index de22fd7878..5a4f7f5658 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java @@ -1,7 +1,5 @@ package org.codehaus.mojo.versions.utils; -import org.codehaus.mojo.versions.Property; - import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -10,7 +8,10 @@ import java.util.Properties; import java.util.stream.Collectors; -public class PropertiesVersionsFileReader { +import org.codehaus.mojo.versions.Property; + +public class PropertiesVersionsFileReader +{ /** * Commas-separated list of properties @@ -21,38 +22,45 @@ public class PropertiesVersionsFileReader { private String propertyFilePath; - public PropertiesVersionsFileReader(String filePath) { + public PropertiesVersionsFileReader( String filePath ) + { propertyFilePath = filePath; } - public void read() throws IOException { - try (InputStream input = new FileInputStream(propertyFilePath)) { + public void read() throws IOException + { + try ( InputStream input = new FileInputStream( propertyFilePath ) ) + { Properties prop = new Properties(); // load a properties file - prop.load(input); + prop.load( input ); prop.propertyNames(); - propertiesCsv = prop.keySet().stream().map(Object::toString).collect(Collectors.joining(",")); + propertiesCsv = prop.keySet().stream().map( Object::toString ).collect( Collectors.joining( "," ) ); List propertiesConfigList = new ArrayList<>(); - prop.forEach((name, version) -> { - Property propertyConfig = new Property((String)name); - propertyConfig.setVersion((String)version); - propertiesConfigList.add(propertyConfig); - }); - - propertiesConfig = propertiesConfigList.toArray(new Property[0]); + prop.forEach( + ( name, version ) -> + { + Property propertyConfig = new Property( (String) name ); + propertyConfig.setVersion( (String) version ); + propertiesConfigList.add( propertyConfig ); + } ); + + propertiesConfig = propertiesConfigList.toArray( new Property[0] ); } } - public String getProperties() { + public String getProperties() + { return propertiesCsv; } - public Property[] getPropertiesConfig() { + public Property[] getPropertiesConfig() + { return propertiesConfig; } } diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java index 45b7211ed6..a00af7d2b0 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java @@ -19,10 +19,10 @@ * under the License. */ -import org.codehaus.mojo.versions.Property; - import java.util.Comparator; +import org.codehaus.mojo.versions.Property; + /** * A comparator used to sort {@link Property} instances. * diff --git a/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java index ecb714ff5e..5e02e041b2 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java @@ -19,9 +19,9 @@ * under the License. */ -import org.apache.maven.repository.legacy.WagonConfigurationException; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.repository.legacy.WagonConfigurationException; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Settings; import org.apache.maven.wagon.ConnectionException; diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index a5bf0765cd..9d8b53ddb8 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -65,7 +65,7 @@ public class DependencyUpdatesReportTest private static class TestDependencyUpdatesReport extends DependencyUpdatesReport { @SuppressWarnings( "deprecation" ) - public TestDependencyUpdatesReport() + TestDependencyUpdatesReport() { mockPlexusComponents(); @@ -78,22 +78,23 @@ public TestDependencyUpdatesReport() try { when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> { - Artifact artifact = invocation.getArgument( 0 ); - if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "2.0.0" ) ); - } - if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "1.1.0" ) ); - } - return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); - } ); + invocation -> + { + Artifact artifact = invocation.getArgument( 0 ); + if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "2.0.0" ) ); + } + if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "1.1.0" ) ); + } + return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); + } ); } catch ( ArtifactMetadataRetrievalException e ) { @@ -108,10 +109,10 @@ public TestDependencyUpdatesReport withDependencies( Dependency... dependencies } public TestDependencyUpdatesReport withOriginalDependencyManagement( - Dependency... originalDependencyManagement ) + Dependency... originalDependencyManagement ) { project.getOriginalModel().getDependencyManagement() - .setDependencies( Arrays.asList( originalDependencyManagement ) ); + .setDependencies( Arrays.asList( originalDependencyManagement ) ); return this; } @@ -134,14 +135,14 @@ public TestDependencyUpdatesReport withProcessDependencyManagement( boolean proc } public TestDependencyUpdatesReport withProcessDependencyManagementTransitive( - boolean processDependencyManagementTransitive ) + boolean processDependencyManagementTransitive ) { this.processDependencyManagementTransitive = processDependencyManagementTransitive; return this; } public TestDependencyUpdatesReport withOnlyProjectDependencies( - boolean onlyProjectDependencies ) + boolean onlyProjectDependencies ) { this.onlyProjectDependencies = onlyProjectDependencies; return this; @@ -153,23 +154,24 @@ public TestDependencyUpdatesReport withOnlyProjectDependencies( * org.codehaus.plexus.PlexusTestCase.lookup, * but that method greatly slows down test execution.

* - * @see Testing - * Plexus Components + * @see + * Testing Plexus Components */ private void mockPlexusComponents() { i18n = mock( I18N.class ); when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( - invocation -> invocation.getArgument( 2 ) ); + invocation -> invocation.getArgument( 2 ) ); repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier(), null ); - } ); + when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( + invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion(), dependency.getScope(), dependency.getType(), + dependency.getClassifier(), null ); + } ); Artifact skinArtifact = mock( Artifact.class ); when( skinArtifact.getId() ).thenReturn( "" ); @@ -196,11 +198,11 @@ public void testOnlyUpgradableDependencies() throws IOException, MavenReportExce OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReport() - .withOnlyUpgradable( true ) - .withDependencies( - dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOnlyUpgradable( true ) + .withDependencies( + dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); @@ -213,11 +215,11 @@ public void testOnlyUpgradableWithOriginalDependencyManagement() throws IOExcept OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReport() - .withOriginalDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOriginalDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); @@ -230,13 +232,13 @@ public void testOnlyUpgradableWithTransitiveDependencyManagement() throws IOExce OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReport() - .withDependencyManagement( - dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withProcessDependencyManagementTransitive( true ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withDependencyManagement( + dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withProcessDependencyManagementTransitive( true ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); @@ -249,15 +251,15 @@ public void testOnlyProjectDependencies() throws IOException, MavenReportExcepti OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReport() - .withDependencies( dependencyOf( "artifactA" ) ) - .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withOnlyProjectDependencies( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withDependencies( dependencyOf( "artifactA" ) ) + .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withOnlyProjectDependencies( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, containsString( "artifactA" ) ); assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); } -} \ No newline at end of file +} diff --git a/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java b/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java index 3d5fc064d3..73bb50082d 100644 --- a/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java +++ b/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java @@ -1,41 +1,48 @@ package org.codehaus.mojo.versions; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + /** * Unit tests for MinimalMavenBuildVersionFinder. */ -public class MinimalMavenBuildVersionFinderTest { +public class MinimalMavenBuildVersionFinderTest +{ @Test - public void testValidVersionRanges() { - DefaultArtifactVersion expectedMinimumVersion = new DefaultArtifactVersion("1.0"); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0]")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,)")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,)")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0]")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0)")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0]")); - assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0)")); + public void testValidVersionRanges() + { + DefaultArtifactVersion expectedMinimumVersion = new DefaultArtifactVersion( "1.0" ); + assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0" ) ); + assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0]" ) ); + assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,)" ) ); + assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,)" ) ); + assertEquals( expectedMinimumVersion, + MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,2.0]" ) ); + assertEquals( expectedMinimumVersion, + MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,2.0)" ) ); + assertEquals( expectedMinimumVersion, + MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,2.0]" ) ); + assertEquals( expectedMinimumVersion, + MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,2.0)" ) ); } @Test - public void testInvalidVersionRanges() { - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0]")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0)")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0],[1.2,)")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),(1.1,)")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),[1.1,)")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0)")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0()")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("()1.0")); - assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0]")); + public void testInvalidVersionRanges() + { + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0]" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0)" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0],[1.2,)" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.1),(1.1,)" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.1),[1.1,)" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0)" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0()" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "()1.0" ) ); + assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0]" ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java index b893d557d1..ce0376a64f 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java @@ -65,7 +65,7 @@ public class PluginUpdatesReportTest private static class TestPluginUpdatesReport extends PluginUpdatesReport { @SuppressWarnings( "deprecation" ) - public TestPluginUpdatesReport() + TestPluginUpdatesReport() { mockPlexusComponents(); @@ -77,22 +77,23 @@ public TestPluginUpdatesReport() try { when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> { - Artifact artifact = invocation.getArgument( 0 ); - if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "2.0.0" ) ); - } - if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "1.1.0" ) ); - } - return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); - } ); + invocation -> + { + Artifact artifact = invocation.getArgument( 0 ); + if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "2.0.0" ) ); + } + if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( + artifact.getVersion() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), + new DefaultArtifactVersion( "1.1.0" ) ); + } + return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); + } ); } catch ( ArtifactMetadataRetrievalException e ) { @@ -130,22 +131,23 @@ public TestPluginUpdatesReport withOnlyProjectPlugins( boolean onlyProjectPlugin * org.codehaus.plexus.PlexusTestCase.lookup, * but that method greatly slows down test execution.

* - * @see Testing - * Plexus Components + * @see + * Testing Plexus Components */ private void mockPlexusComponents() { i18n = mock( I18N.class ); when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( - invocation -> invocation.getArgument( 2 ) ); + invocation -> invocation.getArgument( 2 ) ); repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createPluginArtifact( any( Plugin.class ) ) ).thenAnswer( invocation -> { - Plugin plugin = invocation.getArgument( 0 ); - return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), - SCOPE_RUNTIME, "maven-plugin", "jar", null ); - } ); + when( repositorySystem.createPluginArtifact( any( Plugin.class ) ) ).thenAnswer( + invocation -> + { + Plugin plugin = invocation.getArgument( 0 ); + return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), + SCOPE_RUNTIME, "maven-plugin", "jar", null ); + } ); Artifact skinArtifact = mock( Artifact.class ); when( skinArtifact.getId() ).thenReturn( "" ); @@ -179,10 +181,10 @@ public void testOnlyUpgradablePlugins() throws IOException, MavenReportException OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReport() - .withPlugins( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withPlugins( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); @@ -195,10 +197,10 @@ public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenRe OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReport() - .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); @@ -211,15 +213,15 @@ public void testOnlyProjectPlugins() throws IOException, MavenReportException OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReport() - .withPlugins( pluginOf( "artifactA" ) ) - .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .withOnlyProjectPlugins( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withPlugins( pluginOf( "artifactA" ) ) + .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .withOnlyProjectPlugins( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); assertThat( output, containsString( "artifactA" ) ); assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); } -} \ No newline at end of file +} diff --git a/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java b/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java index 8411d8d4bd..f8cd2700ca 100644 --- a/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java +++ b/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java @@ -19,10 +19,6 @@ * under the License. */ -import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.stax2.XMLInputFactory2; -import org.junit.Test; - import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLInputFactory; @@ -30,10 +26,15 @@ import javax.xml.stream.events.EndElement; import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Stack; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.stax2.XMLInputFactory2; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -109,6 +110,7 @@ public void testReplace() assertEquals( expected, output.toString() ); } + @SuppressWarnings( {"checkstyle:MethodLength", "checkstyle:LineLength"} ) @Test public void testReplaceFancy() throws Exception diff --git a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index 4bdce9e6f0..82fa5b718d 100644 --- a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -1,13 +1,12 @@ package org.codehaus.mojo.versions; -import java.util.List; - import javax.xml.stream.XMLStreamException; +import java.util.List; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; - import org.junit.Before; import org.junit.Test; @@ -79,8 +78,8 @@ public void testSeparatePatternsWithTwoCommaSeparatedPatterns() @Test public void testSeparatePatternsWithSeveralCommaSeparatedPatterns() { - List patterns = - mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2,group:artifact:type:version3,group:artifact:type:version4" ); + List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2," + + "group:artifact:type:version3,group:artifact:type:version4" ); assertEquals( 4, patterns.size() ); assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); assertEquals( "group:artifact:type:version2", patterns.get( 1 ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index 8d7c97b436..ac72d98996 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -19,6 +19,8 @@ * under the License. */ +import java.util.Arrays; + import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -29,8 +31,6 @@ import org.hamcrest.Matchers; import org.junit.Test; -import java.util.Arrays; - import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -40,32 +40,33 @@ public class ArtifactVersionsTest { @Test - public void test4DigitVersions() throws Exception { - ArtifactVersion[] versions = versions( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1"); + public void test4DigitVersions() throws Exception + { + ArtifactVersion[] versions = versions( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1" ); final DefaultArtifact artifact = - new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", - "jar", new DefaultArtifactHandler() ); + new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", + "jar", new DefaultArtifactHandler() ); // TODO This should also work for the MavenVersionComparator when using maven 3.x libraries ArtifactVersions instance = - new ArtifactVersions(artifact, Arrays.asList( versions ), new MercuryVersionComparator() ); + new ArtifactVersions( artifact, Arrays.asList( versions ), new MercuryVersionComparator() ); assertEquals( "artifact", instance.getArtifactId() ); assertEquals( "group", instance.getGroupId() ); - assertThat(instance.getVersions(), - Matchers.arrayContaining(versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", - "3.1.0.1" ))); - assertThat(instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ), - Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); + assertThat( instance.getVersions(), + Matchers.arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", + "3.1.0.1" ) ) ); + assertThat( instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ), + Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); - assertThat(instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ), - //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); - Matchers.arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); + assertThat( instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ), + //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); + Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); assertEquals( new DefaultArtifactVersion( "2.121.2.1" ), instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), new DefaultArtifactVersion( "3.0" ) ) ); assertNull( - instance.getNewestVersion( new DefaultArtifactVersion( "1.1.1" ), - new DefaultArtifactVersion( "2.0" ) ) ); + instance.getNewestVersion( new DefaultArtifactVersion( "1.1.1" ), + new DefaultArtifactVersion( "2.0" ) ) ); } @Test @@ -95,11 +96,13 @@ public void testSmokes() instance.getNewestVersion( new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ) ) ); } - private ArtifactVersion[] versions(String... versions) { + private ArtifactVersion[] versions( String... versions ) + { ArtifactVersion[] artifactVersions = new ArtifactVersion[versions.length]; - for ( int i = 0; i < versions.length; i++ ) { + for ( int i = 0; i < versions.length; i++ ) + { artifactVersions[i] = new DefaultArtifactVersion( versions[i] ); } return artifactVersions; } -} \ No newline at end of file +} diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 44d9a23013..0bf4622945 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -19,6 +19,10 @@ * under the License. */ +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -28,6 +32,7 @@ import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.testing.AbstractMojoTestCase; @@ -35,24 +40,19 @@ import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; -import org.apache.maven.execution.MavenSession; import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.ordering.VersionComparators; import org.hamcrest.CoreMatchers; import org.junit.Test; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import static java.util.Arrays.asList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsIterableContaining.hasItems; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyList; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import static org.mockito.Mockito.same; +import static org.mockito.Mockito.when; /** * Test {@link DefaultVersionsHelper} @@ -67,9 +67,9 @@ public void testPerRuleVersionsIgnored() throws Exception final Artifact artifact = mock( Artifact.class ); when( artifact.getGroupId() ).thenReturn( "com.mycompany.maven" ); when( artifact.getArtifactId() ).thenReturn( "artifact-one" ); - + final List artifactVersions = new ArrayList<>(); - + artifactVersions.add( new DefaultArtifactVersion( "one" ) ); artifactVersions.add( new DefaultArtifactVersion( "two" ) ); final ArtifactVersion three = new DefaultArtifactVersion( "three" ); @@ -81,13 +81,13 @@ public void testPerRuleVersionsIgnored() throws Exception when( metadataSource.retrieveAvailableVersions( same( artifact ), any( ArtifactRepository.class ), anyList() ) ) .thenReturn( artifactVersions ); - + VersionsHelper helper = createHelper( metadataSource ); - + final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); - + final List actual = asList( versions.getVersions( true ) ); - + assertEquals( 3, actual.size() ); assertThat( actual, hasItems( three, oneTwoHundred, illegal ) ); } @@ -99,9 +99,9 @@ public void testGlobalRuleVersionsIgnored() throws Exception final Artifact artifact = mock( Artifact.class ); when( artifact.getGroupId() ).thenReturn( "other.company" ); when( artifact.getArtifactId() ).thenReturn( "artifact-two" ); - + final List artifactVersions = new ArrayList<>(); - + final ArtifactVersion one = new DefaultArtifactVersion( "one" ); final ArtifactVersion two = new DefaultArtifactVersion( "two" ); final ArtifactVersion three = new DefaultArtifactVersion( "three" ); @@ -113,15 +113,15 @@ public void testGlobalRuleVersionsIgnored() throws Exception final ArtifactVersion illegal = new DefaultArtifactVersion( "illegalVersion" ); artifactVersions.add( illegal ); - when(metadataSource.retrieveAvailableVersions( same( artifact ), any( ArtifactRepository.class ), anyList() ) ) + when( metadataSource.retrieveAvailableVersions( same( artifact ), any( ArtifactRepository.class ), anyList() ) ) .thenReturn( artifactVersions ); - + VersionsHelper helper = createHelper( metadataSource ); - + final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); - + final List actual = asList( versions.getVersions( true ) ); - + assertEquals( 4, actual.size() ); assertThat( actual, hasItems( one, two, three, illegal ) ); } @@ -160,7 +160,7 @@ public void testRuleSets() @Test - public void testMVERSIONS159_ExcludedAndNotIncluded() + public void testMVERSIONS159ExcludedAndNotIncluded() throws Exception { VersionsHelper helper = createHelper(); @@ -170,24 +170,27 @@ public void testMVERSIONS159_ExcludedAndNotIncluded() new Property( "bar.version" ) }; // should not throw an IllegalStateException - Map result = helper.getVersionPropertiesMap( project, propertyDefinitions, "foo.version", "bar.version", false ); + Map result = + helper.getVersionPropertiesMap( project, propertyDefinitions, "foo.version", "bar.version", false ); assertTrue( result.isEmpty() ); } @Test - public void testIsClasspathUriDetectsClassPathProtocol() throws Exception { + public void testIsClasspathUriDetectsClassPathProtocol() throws Exception + { DefaultVersionsHelper helper = createHelper(); String uri = "classpath:/p/a/c/k/a/g/e/resource.res"; - assertThat(DefaultVersionsHelper.isClasspathUri(uri), CoreMatchers.is(true)); + assertThat( DefaultVersionsHelper.isClasspathUri( uri ), CoreMatchers.is( true ) ); } @Test - public void testIsClasspathUriDetectsThatItIsDifferentProtocol() throws Exception { + public void testIsClasspathUriDetectsThatItIsDifferentProtocol() throws Exception + { DefaultVersionsHelper helper = createHelper(); String uri = "http://10.10.10.10/p/a/c/k/a/g/e/resource.res"; - assertThat(DefaultVersionsHelper.isClasspathUri(uri), CoreMatchers.is(false)); + assertThat( DefaultVersionsHelper.isClasspathUri( uri ), CoreMatchers.is( false ) ); } @@ -196,7 +199,7 @@ private DefaultVersionsHelper createHelper() { return createHelper( new MavenMetadataSource() ); } - + private DefaultVersionsHelper createHelper( ArtifactMetadataSource metadataSource ) throws Exception { final String resourcePath = "/" + getClass().getPackage().getName().replace( '.', '/' ) + "/rules.xml"; @@ -208,19 +211,20 @@ private DefaultVersionsHelper createHelper( ArtifactMetadataSource metadataSourc private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource ) throws Exception { - WagonManager wagonManager = lookup(WagonManager.class); -// new DefaultWagonManager() -// { -// @Override -// public Wagon getWagon( String protocol ) -// throws UnsupportedProtocolException -// { -// return new FileWagon(); -// } -// }; + WagonManager wagonManager = lookup( WagonManager.class ); + // new DefaultWagonManager() + // { + // @Override + // public Wagon getWagon( String protocol ) + // throws UnsupportedProtocolException + // { + // return new FileWagon(); + // } + // }; DefaultVersionsHelper helper = - new DefaultVersionsHelper( lookup( RepositorySystem.class ), new DefaultArtifactResolver(), metadataSource, new ArrayList(), + new DefaultVersionsHelper( lookup( RepositorySystem.class ), new DefaultArtifactResolver(), metadataSource, + new ArrayList(), new ArrayList(), new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), wagonManager, new Settings(), "", rulesUri, mock( Log.class ), diff --git a/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index 0e54877e6f..653dc658d3 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -1,5 +1,12 @@ package org.codehaus.mojo.versions.api; +import javax.xml.stream.XMLInputFactory; + +import java.io.File; +import java.io.StringReader; +import java.net.URL; +import java.util.List; + import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; @@ -7,12 +14,6 @@ import org.codehaus.stax2.XMLInputFactory2; import org.junit.Test; -import javax.xml.stream.XMLInputFactory; -import java.io.File; -import java.io.StringReader; -import java.net.URL; -import java.util.List; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -55,6 +56,7 @@ public void testImportedPOMsRetrievedFromDependencyManagement() assertEquals( "import", dependency.getScope() ); assertEquals( "pom", dependency.getType() ); } + /** * Tests what happens when changing a long property substitution pattern, e.g. * MVERSIONS-44 @@ -87,74 +89,74 @@ public void testLongProperties() @Test public void testGroupIdNotOnChildPom() - throws Exception + throws Exception { URL url = getClass().getResource( "PomHelperTest.noGroupIdOnChild.pom.xml" ); StringBuilder input = PomHelper.readXmlFile( new File( url.getPath() ) ); MavenXpp3Reader reader = new MavenXpp3Reader(); - Model model = reader.read(new StringReader(input.toString())); + Model model = reader.read( new StringReader( input.toString() ) ); - assertEquals("org.myorg", PomHelper.getGroupId(model)); + assertEquals( "org.myorg", PomHelper.getGroupId( model ) ); } @Test - public void test_Version_Version_Equal() + public void testVersionVersionEqual() throws Exception { assertTrue( PomHelper.isVersionOverlap( "1.0.8", "1.0.8" ) ); } @Test - public void test_Version_Version_Differ() + public void testVersionVersionDiffer() throws Exception { assertFalse( PomHelper.isVersionOverlap( "1.0.8", "1.0.0" ) ); } @Test - public void test_Version_Range_Intersect() + public void testVersionRangeIntersect() throws Exception { assertTrue( PomHelper.isVersionOverlap( "1.0.8", "[1.0.3,1.1.0]" ) ); } @Test - public void test_Version_Range_Disjoint() + public void testVersionRangeDisjoint() throws Exception { assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[0.0.1,1.0.0]" ) ); } @Test - public void test_Version_LeftOpenRange_Disjoint() + public void testVersionLeftOpenRangeDisjoint() throws Exception { assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[,1.0.0]" ) ); } @Test - public void test_Version_RightOpenRange_Disjoint() + public void testVersionRightOpenRangeDisjoint() throws Exception { assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[1.1.0,)" ) ); } @Test - public void test_Empty_Range() + public void testEmptyRange() throws Exception { assertTrue( PomHelper.isVersionOverlap( "1.0.8", "" ) ); } @Test - public void test_Range_Empty() + public void testRangeEmpty() throws Exception { assertTrue( PomHelper.isVersionOverlap( "[1.0.5,1.0.8]", "" ) ); } @Test - public void test_Range_Range_Intersect() + public void testRangeRangeIntersect() throws Exception { assertTrue( PomHelper.isVersionOverlap( "[1.0.5,1.0.8]", "[1.0.7,1.1.0]" ) ); @@ -162,7 +164,7 @@ public void test_Range_Range_Intersect() } @Test - public void test_Range_Range_Disjoint() + public void testRangeRangeDisjoint() throws Exception { assertFalse( PomHelper.isVersionOverlap( "[1.0.5,1.0.6]", "[1.0.7,1.1.0]" ) ); @@ -170,7 +172,7 @@ public void test_Range_Range_Disjoint() } @Test - public void test_Range_Version_Disjoint() + public void testRangeVersionDisjoint() throws Exception { assertFalse( PomHelper.isVersionOverlap( "[1.0.5,1.0.6]", "1.0.8" ) ); @@ -178,7 +180,7 @@ public void test_Range_Version_Disjoint() } @Test - public void test_Range_Version_Intersect() + public void testRangeVersionIntersect() throws Exception { assertTrue( PomHelper.isVersionOverlap( "[1.0.0,2.0.0]", "1.0.8" ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java index 5f3a6c69e1..aca6d8697a 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -5,8 +5,6 @@ import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.DependencyBuilder; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -16,7 +14,6 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; -@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) class DependencyFilterTest { @@ -24,86 +21,86 @@ class DependencyFilterTest class RemoveFromTest { private final Set input = new HashSet<>( asList( - DependencyBuilder.dependencyWith( "foo", "bar", "1" ), - DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), - DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) + DependencyBuilder.dependencyWith( "foo", "bar", "1" ), + DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), + DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) ) ); @Test - void removes_excluded_deps_with_exact_match() + void removesExcludedDepsWithExactMatch() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); Set actual = exclusions.removingFrom( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ) - ) + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ) + ) ); } @Test - void removes_excluded_deps_with_wildcard_in_version() + void removesExcludedDepsWithWildcardInVersion() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:*" ) ); Set actual = exclusions.removingFrom( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ) - ) + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ) + ) ); } @Test - void removes_excluded_deps_with_wildcard_in_groupId() + void removesExcludedDepsWithWildcardInGroupId() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:*:*" ) ); Set actual = exclusions.removingFrom( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ) - ) + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ) + ) ); } @Test - void removes_excluded_deps_with_all_wildcards() + void removesExcludedDepsWithAllWildcards() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); Set actual = exclusions.removingFrom( input ); assertThat( - actual, - empty() + actual, + empty() ); } @Test - void removes_multiple_patterns() + void removesMultiplePatterns() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( - "*:my-api", - "*:my-impl" + "*:my-api", + "*:my-impl" ) ); Set actual = exclusions.removingFrom( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ) - ) + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ) + ) ); } @@ -113,91 +110,91 @@ void removes_multiple_patterns() class RetainingInTest { private final Set input = new HashSet<>( asList( - DependencyBuilder.dependencyWith( "foo", "bar", "1" ), - DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), - DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) + DependencyBuilder.dependencyWith( "foo", "bar", "1" ), + DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), + DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) ) ); @Test - void retains_only_deps_with_exact_match() + void retainsOnlyDepsWithExactMatch() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); Set actual = exclusions.retainingIn( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "localhost", "my-impl", "3" ) - ) + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-impl", "3" ) + ) ); } @Test - void retains_only_deps_matching_wildcard_in_version() + void retainsOnlyDepsMatchingWildcardInVersion() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-api:*" ) ); Set actual = exclusions.retainingIn( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ) - ) + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ) + ) ); } @Test - void retains_only_deps_with_multiple_wildcards() + void retainsOnlyDepsWithMultipleWildcards() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-*:*" ) ); Set actual = exclusions.retainingIn( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) - ) + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) ); } @Test - void retains_all_on_all_wildcards() + void retainsAllOnAllWildcards() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); Set actual = exclusions.retainingIn( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) - ) + actual, + containsInAnyOrder( + hasGAV( "foo", "bar", "1" ), + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) ); } @Test - void retains_multiple_patterns() + void retainsMultiplePatterns() { DependencyFilter exclusions = DependencyFilter.parseFrom( asList( - "*:my-api", - "*:my-impl" + "*:my-api", + "*:my-impl" ) ); Set actual = exclusions.retainingIn( input ); assertThat( - actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) - ) + actual, + containsInAnyOrder( + hasGAV( "localhost", "my-api", "2" ), + hasGAV( "localhost", "my-impl", "3" ) + ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java index 02102d6703..e5ad0f2249 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java @@ -2,8 +2,6 @@ import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.DependencyBuilder; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -12,7 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) class TokenizedMatcherTest { @@ -21,19 +18,19 @@ class ExactMatchPattern { private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "group:artifact:1.0:jar:tests:compile" ); + .parse( "group:artifact:1.0:jar:tests:compile" ); @Test - void accepts_exact_match() + void acceptsExactMatch() { Dependency input = DependencyBuilder.dependencyWith( - "group", - "artifact", - "1.0", - "jar", - "tests", - "compile" ); + "group", + "artifact", + "1.0", + "jar", + "tests", + "compile" ); boolean actual = matcher.test( input ); @@ -43,25 +40,25 @@ void accepts_exact_match() @ParameterizedTest @CsvSource( { - "xxxxx, artifact, 1.0, jar, tests, compile", - "group, xxxxxxxx, 1.0, jar, tests, compile", - "group, artifact, xxx, jar, tests, compile", - "group, artifact, 1.0, xxx, tests, compile", - "group, artifact, 1.0, jar, xxxxx, compile", - "group, artifact, 1.0, jar, tests, xxxxxxx", + "xxxxx, artifact, 1.0, jar, tests, compile", + "group, xxxxxxxx, 1.0, jar, tests, compile", + "group, artifact, xxx, jar, tests, compile", + "group, artifact, 1.0, xxx, tests, compile", + "group, artifact, 1.0, jar, xxxxx, compile", + "group, artifact, 1.0, jar, tests, xxxxxxx", } ) - void rejects_differing_fields( - String group, String artifact, String version, String type, String classifier, String scope + void rejectsDifferingFields( + String group, String artifact, String version, String type, String classifier, String scope ) { Dependency input = DependencyBuilder.dependencyWith( - group, - artifact, - version, - type, - classifier, - scope ); + group, + artifact, + version, + type, + classifier, + scope ); boolean actual = matcher.test( input ); @@ -74,18 +71,18 @@ class WildcardPattern { @Test - void accepts_wildcards() + void acceptsWildcards() { Dependency input = DependencyBuilder.dependencyWith( - "foo", - "my-api", - "foo", - "foo", - "foo", - "foo" ); + "foo", + "my-api", + "foo", + "foo", + "foo", + "foo" ); TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:my-api" ); + .parse( "*:my-api" ); boolean actual = matcher.test( input ); @@ -96,18 +93,18 @@ void accepts_wildcards() class NullClassifier { private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( - "foo", - "foo", - "foo", - "foo", - "foo", - "foo" ); + "foo", + "foo", + "foo", + "foo", + "foo", + "foo" ); private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:*:*:*:null:*" ); + .parse( "*:*:*:*:null:*" ); @Test - void accepts_null_scope() + void acceptsNullScope() { Dependency input = depBuilder.withClassifier( null ).build(); @@ -117,7 +114,7 @@ void accepts_null_scope() } @Test - void rejects_nonnull_scope() + void rejectsNonnullScope() { Dependency input = depBuilder.withClassifier( "tests" ).build(); @@ -131,18 +128,18 @@ void rejects_nonnull_scope() class NullScope { private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( - "foo", - "foo", - "foo", - "foo", - "foo", - "foo" ); + "foo", + "foo", + "foo", + "foo", + "foo", + "foo" ); private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:*:*:*:*:null" ); + .parse( "*:*:*:*:*:null" ); @Test - void accepts_null_scope() + void acceptsNullScope() { Dependency input = depBuilder.withScope( null ).build(); @@ -152,7 +149,7 @@ void accepts_null_scope() } @Test - void rejects_nonnull_scope() + void rejectsNonnullScope() { Dependency input = depBuilder.withScope( "compile" ).build(); diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java index 655316b731..c6b4717cba 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java @@ -1,15 +1,13 @@ package org.codehaus.mojo.versions.filtering; -import org.junit.jupiter.api.DisplayNameGeneration; -import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -@DisplayNameGeneration( DisplayNameGenerator.ReplaceUnderscores.class ) class WildcardMatcherTest { @Nested @@ -18,7 +16,7 @@ class ExactValueTest private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf" ); @Test - void matches_the_exact_input() + void matchesTheExactInput() { boolean actual = matcher.test( "asdf" ); @@ -26,7 +24,7 @@ void matches_the_exact_input() } @Test - void rejects_null() + void rejectsNull() { boolean actual = matcher.test( null ); @@ -35,15 +33,15 @@ void rejects_null() @ParameterizedTest @ValueSource( strings = { - "", - " ", - "a", - "as", - "asf", - "asXf", - "asdfx", + "", + " ", + "a", + "as", + "asf", + "asXf", + "asdfx", } ) - void rejects_different_input( String input ) + void rejectsDifferentInput( String input ) { boolean actual = matcher.test( input ); @@ -57,7 +55,7 @@ class WildcardOnlyPattern private final WildcardMatcher matcher = WildcardMatcher.parse( "*" ); @Test - void accepts_null() + void acceptsNull() { boolean actual = matcher.test( null ); @@ -67,10 +65,10 @@ void accepts_null() @ParameterizedTest @ValueSource( strings = { - "", - " ", - "a", - "asdfx", + "", + " ", + "a", + "asdfx", } ) void accepts( String input ) { @@ -88,7 +86,7 @@ class PatternWithWildcardAtStartAndEnd private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf*" ); @Test - void rejects_null() + void rejectsNull() { boolean actual = matcher.test( null ); @@ -98,13 +96,13 @@ void rejects_null() @ParameterizedTest @ValueSource( strings = { - "asdf", - "fooasdf", - "asdfbar", - "fooasdfbar", - " asdf", - "asdf ", - " asdf ", + "asdf", + "fooasdf", + "asdfbar", + "fooasdfbar", + " asdf", + "asdf ", + " asdf ", } ) void accepts( String input ) { @@ -115,9 +113,9 @@ void accepts( String input ) @ParameterizedTest @ValueSource( strings = { - "", - " ", - "foo", + "", + " ", + "foo", } ) void rejects( String input ) { @@ -134,7 +132,7 @@ class PatternStartingWithWildcard private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf" ); @Test - void rejects_null() + void rejectsNull() { boolean actual = matcher.test( null ); @@ -144,11 +142,11 @@ void rejects_null() @ParameterizedTest @ValueSource( strings = { - "asdf", - "asdfasdf", - " asdf", - "Xasdf", - "99999999asdf", + "asdf", + "asdfasdf", + " asdf", + "Xasdf", + "99999999asdf", } ) void accepts( String input ) { @@ -159,11 +157,11 @@ void accepts( String input ) @ParameterizedTest @ValueSource( strings = { - "", - " ", - "asdf ", - "asdfx", - "asdfbanana", + "", + " ", + "asdf ", + "asdfx", + "asdfbanana", } ) void rejects( String input ) { @@ -180,7 +178,7 @@ class PatternEndingWithWildcard private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf*" ); @Test - void rejects_null() + void rejectsNull() { boolean actual = matcher.test( null ); @@ -190,11 +188,11 @@ void rejects_null() @ParameterizedTest @ValueSource( strings = { - "asdf", - "asdfasdf", - "asdf ", - "asdfx", - "asdfbanana", + "asdf", + "asdfasdf", + "asdf ", + "asdfx", + "asdfbanana", } ) void accepts( String input ) { @@ -205,11 +203,11 @@ void accepts( String input ) @ParameterizedTest @ValueSource( strings = { - "", - " ", - " asdf", - "Xasdf", - "99999999asdf", + "", + " ", + " asdf", + "Xasdf", + "99999999asdf", } ) void rejects( String input ) { @@ -226,7 +224,7 @@ class PatternWithVersionRange private final WildcardMatcher matcher = WildcardMatcher.parse( "[2.0,3.0]" ); @Test - void rejects_null() + void rejectsNull() { boolean actual = matcher.test( null ); @@ -236,9 +234,9 @@ void rejects_null() @ParameterizedTest @ValueSource( strings = { - "2.0", - "2.1", - "3.0", + "2.0", + "2.1", + "3.0", } ) void accepts( String input ) { @@ -249,11 +247,11 @@ void accepts( String input ) @ParameterizedTest @ValueSource( strings = { - "", - " ", - "1.0", - "2.0-SNAPSHOT", - "4.0", + "", + " ", + "1.0", + "2.0-SNAPSHOT", + "4.0", } ) void rejects( String input ) { diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java index 37ce954b23..4c5436c926 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java @@ -7,88 +7,96 @@ import static org.hamcrest.Matchers.arrayContaining; import static org.junit.Assert.assertThat; -public class MajorMinorIncrementalFilterTest { +public class MajorMinorIncrementalFilterTest +{ - private ArtifactVersion[] newerVersions = new ArtifactVersion[] { version("1.1.1-sp1"), - version("1.1.1-1"), - version("1.1.2"), - version("1.1.3"), - version("1.2.0"), - version("2.0.0-SNAPSHOT") }; + private ArtifactVersion[] newerVersions = new ArtifactVersion[] {version( "1.1.1-sp1" ), + version( "1.1.1-1" ), + version( "1.1.2" ), + version( "1.1.3" ), + version( "1.2.0" ), + version( "2.0.0-SNAPSHOT" )}; @Test - public void checkFilter() { - ArtifactVersion selectedVersion = version("1.1.1"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(true, true, true); - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, newerVersions); - assertThat(filteredVersions, arrayContaining( - version("1.1.1-sp1"), version("1.1.1-1"), - version("1.1.2"), version("1.1.3"), - version("1.2.0"), version("2.0.0-SNAPSHOT"))); + public void checkFilter() + { + ArtifactVersion selectedVersion = version( "1.1.1" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( true, true, true ); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); + assertThat( filteredVersions, arrayContaining( + version( "1.1.1-sp1" ), version( "1.1.1-1" ), + version( "1.1.2" ), version( "1.1.3" ), + version( "1.2.0" ), version( "2.0.0-SNAPSHOT" ) ) ); } @Test - public void checkFilterWithNoMajorUpdates() { - ArtifactVersion selectedVersion = version("1.1.1"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(false, true, true); - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, newerVersions); - assertThat(filteredVersions, arrayContaining(version("1.1.1-sp1"), version("1.1.1-1"), - version("1.1.2"), version("1.1.3"), version("1.2.0"))); + public void checkFilterWithNoMajorUpdates() + { + ArtifactVersion selectedVersion = version( "1.1.1" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, true, true ); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); + assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ), + version( "1.1.2" ), version( "1.1.3" ), version( "1.2.0" ) ) ); } @Test - public void checkFilterWithNoMajorOrMinorUpdates() { - ArtifactVersion selectedVersion = version("1.1.1"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(false, false, true); - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, newerVersions); - assertThat(filteredVersions, arrayContaining(version("1.1.1-sp1"), version("1.1.1-1"), - version("1.1.2"), version("1.1.3"))); + public void checkFilterWithNoMajorOrMinorUpdates() + { + ArtifactVersion selectedVersion = version( "1.1.1" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, true ); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); + assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ), + version( "1.1.2" ), version( "1.1.3" ) ) ); } @Test - public void checkFilterWithNoMajorOrMinorOrIncrementalUpdates() { - ArtifactVersion selectedVersion = version("1.1.1"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(false, false, false); - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, newerVersions); - assertThat(filteredVersions, arrayContaining(version("1.1.1-sp1"), version("1.1.1-1"))); + public void checkFilterWithNoMajorOrMinorOrIncrementalUpdates() + { + ArtifactVersion selectedVersion = version( "1.1.1" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, false ); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); + assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ) ) ); } @Test - public void checkFilterWithSnapshotAtSameVersion() { - ArtifactVersion selectedVersion = version("1.1.1-SNAPSHOT"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(false, false, false); - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, - new ArtifactVersion[] {version("1.1.1")}); - assertThat(filteredVersions, arrayContaining(version("1.1.1"))); + public void checkFilterWithSnapshotAtSameVersion() + { + ArtifactVersion selectedVersion = version( "1.1.1-SNAPSHOT" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, false ); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, + new ArtifactVersion[] {version( "1.1.1" )} ); + assertThat( filteredVersions, arrayContaining( version( "1.1.1" ) ) ); } @Test - public void checkFilterWithNonStandardVersions() { - ArtifactVersion selectedVersion = version("1.1.1.1"); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter(true, true, true); + public void checkFilterWithNonStandardVersions() + { + ArtifactVersion selectedVersion = version( "1.1.1.1" ); + MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( true, true, true ); - ArtifactVersion[] newerVersions = new ArtifactVersion[] { version("1.1.1.1-sp1"), - version("1.1.1.2"), - version("1.1.2.21"), - version("1.1.3.0"), - version("1.2.0"), - version("1.2.0.1"), - version("2.0.0-SNAPSHOT") }; + ArtifactVersion[] newerVersions = new ArtifactVersion[] {version( "1.1.1.1-sp1" ), + version( "1.1.1.2" ), + version( "1.1.2.21" ), + version( "1.1.3.0" ), + version( "1.2.0" ), + version( "1.2.0.1" ), + version( "2.0.0-SNAPSHOT" )}; - ArtifactVersion[] filteredVersions = filter.filter(selectedVersion, newerVersions); - assertThat(filteredVersions, - arrayContaining(version("1.1.1.1-sp1"), - version("1.1.1.2"), - version("1.1.2.21"), - version("1.1.3.0"), - version("1.2.0"), - version("1.2.0.1"), - version("2.0.0-SNAPSHOT"))); + ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); + assertThat( filteredVersions, + arrayContaining( version( "1.1.1.1-sp1" ), + version( "1.1.1.2" ), + version( "1.1.2.21" ), + version( "1.1.3.0" ), + version( "1.2.0" ), + version( "1.2.0.1" ), + version( "2.0.0-SNAPSHOT" ) ) ); } - private ArtifactVersion version(String versionString) { - return new DefaultArtifactVersion(versionString); + private ArtifactVersion version( String versionString ) + { + return new DefaultArtifactVersion( versionString ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index 0c1b561a28..fc0ac1498d 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -29,7 +29,8 @@ public class NumericVersionComparatorTest { private NumericVersionComparator instance = new NumericVersionComparator(); - private int instanceCompare(String v1, String v2) { + private int instanceCompare( String v1, String v2 ) + { return instance.compare( new DefaultArtifactVersion( v1 ), new DefaultArtifactVersion( v2 ) ); } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java index 07b244d078..d6ec074b96 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java @@ -19,8 +19,8 @@ * under the License. */ -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; import static org.junit.Assert.assertTrue; @@ -38,33 +38,40 @@ public class VersionComparatorsTest }; @Test - public void testMavenVersionComparator() { + public void testMavenVersionComparator() + { assertVersions( new MavenVersionComparator() ); } @Test - public void testMercuryVersionComparator() { - assertVersions( new MercuryVersionComparator()); + public void testMercuryVersionComparator() + { + assertVersions( new MercuryVersionComparator() ); } @Test - public void testNumericVersionComparator() { + public void testNumericVersionComparator() + { assertVersions( new NumericVersionComparator() ); } - public void assertVersions(VersionComparator instance) { - for (int i = 0; i < versionDataset.length; i++) { + public void assertVersions( VersionComparator instance ) + { + for ( int i = 0; i < versionDataset.length; i++ ) + { assertLater( versionDataset[i], instance ); - assertLater( versionDataset[i]+"-SNAPSHOT", instance ); + assertLater( versionDataset[i] + "-SNAPSHOT", instance ); } } - public void assertLater(String version, VersionComparator instance) { + public void assertLater( String version, VersionComparator instance ) + { ArtifactVersion v1 = new DefaultArtifactVersion( version ); int count = instance.getSegmentCount( v1 ); - for (int i = 0; i < count; i++) { + for ( int i = 0; i < count; i++ ) + { ArtifactVersion v2 = instance.incrementSegment( v1, i ); - assertTrue(v1 + " < " + v2, instance.compare(v1, v2 ) < 0); + assertTrue( v1 + " < " + v2, instance.compare( v1, v2 ) < 0 ); } } } diff --git a/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java index fdd2c05fc2..c5cb59a076 100644 --- a/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java +++ b/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -19,22 +19,23 @@ * under the License. */ -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + public final class ChangeRecorderXMLTest { private static void copyResource( final String name, final File output ) throws IOException diff --git a/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java index 673d33880e..7b2e05ce39 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java @@ -1,36 +1,42 @@ package org.codehaus.mojo.versions.utils; -import org.apache.commons.lang3.StringUtils; -import org.junit.Test; - import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import org.apache.commons.lang3.StringUtils; +import org.junit.Test; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class PropertiesVersionsFileReaderTest { +public class PropertiesVersionsFileReaderTest +{ - private static final String TEST_PROPERTIES_FILE = "src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties"; + private static final String TEST_PROPERTIES_FILE = + "src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties"; @Test - public void testRead() throws IOException { - PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader(TEST_PROPERTIES_FILE); + public void testRead() throws IOException + { + PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader( TEST_PROPERTIES_FILE ); reader.read(); - int numberOfPropertiesConfig=3; - assertTrue(equalsCvsUnordered("booking-api.version,booking-lib.version,be-air-impl.version", reader.getProperties())); - assertEquals(numberOfPropertiesConfig, reader.getPropertiesConfig().length); + int numberOfPropertiesConfig = 3; + assertTrue( equalsCvsUnordered( "booking-api.version,booking-lib.version,be-air-impl.version", + reader.getProperties() ) ); + assertEquals( numberOfPropertiesConfig, reader.getPropertiesConfig().length ); } - private boolean equalsCvsUnordered(String csvExpected, String csvActual) { - if (StringUtils.isEmpty(csvExpected)) { + private boolean equalsCvsUnordered( String csvExpected, String csvActual ) + { + if ( StringUtils.isEmpty( csvExpected ) ) + { return false; } - Set listExpected = new HashSet(Arrays.asList(csvExpected.split(","))); - Set listActual = new HashSet(Arrays.asList(csvActual.split(","))); - return listExpected.equals(listActual); + Set listExpected = new HashSet( Arrays.asList( csvExpected.split( "," ) ) ); + Set listActual = new HashSet( Arrays.asList( csvActual.split( "," ) ) ); + return listExpected.equals( listActual ); } } From 7d564aacf5a2f3ca9ee8b2678e13ba8d896fb45f Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 25 Aug 2022 15:11:42 +0200 Subject: [PATCH 092/441] Fix code formatting --- .../codehaus/mojo/versions/api/DefaultVersionsHelper.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 3ee5c04fa9..cb679d3621 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -171,11 +171,11 @@ public class DefaultVersionsHelper /** * A cache mapping artifacts to their best fitting rule, since looking up * this information can be quite costly. - * + * * @since 2.12 */ private final Map artifactBestFitRule = new HashMap<>(); - + /** * Constructs a new {@link DefaultVersionsHelper}. * @@ -568,7 +568,8 @@ public VersionComparator getVersionComparator( String groupId, String artifactId protected Rule getBestFitRule( String groupId, String artifactId ) { String groupArtifactId = groupId + ':' + artifactId; - if (artifactBestFitRule.containsKey( groupArtifactId )) { + if ( artifactBestFitRule.containsKey( groupArtifactId ) ) + { return artifactBestFitRule.get( groupArtifactId ); } From 010595046a923f9be40d8b89f2d80459d1f18c19 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Aug 2022 08:54:07 +0000 Subject: [PATCH 093/441] Bump postgresql in /src/it/it-property-updates-report-002-slow Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.2.6 to 42.4.1. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](https://github.com/pgjdbc/pgjdbc/compare/REL42.2.6...REL42.4.1) --- updated-dependencies: - dependency-name: org.postgresql:postgresql dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/it/it-property-updates-report-002-slow/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/it-property-updates-report-002-slow/pom.xml b/src/it/it-property-updates-report-002-slow/pom.xml index 2db31ed03b..648af1713c 100644 --- a/src/it/it-property-updates-report-002-slow/pom.xml +++ b/src/it/it-property-updates-report-002-slow/pom.xml @@ -18,7 +18,7 @@ 4.5.2 2.6.7.3 2.4.3 - 42.2.6 + 42.4.1 2.0.0 From 751ace7d6fe7c85ef217636745dd97fa2f1ccfb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Aug 2022 08:54:08 +0000 Subject: [PATCH 094/441] Bump httpclient in /src/it/it-property-updates-report-002-slow Bumps httpclient from 4.5.2 to 4.5.13. --- updated-dependencies: - dependency-name: org.apache.httpcomponents:httpclient dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/it/it-property-updates-report-002-slow/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/it/it-property-updates-report-002-slow/pom.xml b/src/it/it-property-updates-report-002-slow/pom.xml index 648af1713c..06e49a050a 100644 --- a/src/it/it-property-updates-report-002-slow/pom.xml +++ b/src/it/it-property-updates-report-002-slow/pom.xml @@ -15,7 +15,7 @@ 2.2.11 0.11.1 3.17 - 4.5.2 + 4.5.13 2.6.7.3 2.4.3 42.4.1 From 214995eb99dc7fdf07d82a6b2ed559d91100c387 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 25 Aug 2022 10:28:00 +0200 Subject: [PATCH 095/441] Fix for issue #648: de-shadowing the localRepository property --- .../invoker.properties | 3 ++ .../it-abstract-versions-report-001/pom.xml | 33 +++++++++++++++++++ .../verify.groovy | 15 +++++++++ .../mojo/versions/AbstractVersionsReport.java | 6 ---- 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 src/it/it-abstract-versions-report-001/invoker.properties create mode 100644 src/it/it-abstract-versions-report-001/pom.xml create mode 100644 src/it/it-abstract-versions-report-001/verify.groovy diff --git a/src/it/it-abstract-versions-report-001/invoker.properties b/src/it/it-abstract-versions-report-001/invoker.properties new file mode 100644 index 0000000000..a60d6037ef --- /dev/null +++ b/src/it/it-abstract-versions-report-001/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report + +invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:plugin-updates-report \ No newline at end of file diff --git a/src/it/it-abstract-versions-report-001/pom.xml b/src/it/it-abstract-versions-report-001/pom.xml new file mode 100644 index 0000000000..06cb3eb644 --- /dev/null +++ b/src/it/it-abstract-versions-report-001/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + localhost + it-abstract-versions-report-001 + 1.0 + pom + abstract-versions-report + http://localhost/ + + + Testing command line invocation of dependency- and plugin-updates-report + + + + + localhost + dummy-api + 1.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + + + diff --git a/src/it/it-abstract-versions-report-001/verify.groovy b/src/it/it-abstract-versions-report-001/verify.groovy new file mode 100644 index 0000000000..da937db0ce --- /dev/null +++ b/src/it/it-abstract-versions-report-001/verify.groovy @@ -0,0 +1,15 @@ +dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ) + +assert dependencyUpdatesReport.exists( ) + +// some basic (=not comprehensive) checks on the contents of the dependency report +assert dependencyUpdatesReport.text =~ /\b1\.1\.0-2\b/ // current version of the dependency +assert dependencyUpdatesReport.text =~ /\b3\.0\b/ // latest major available version + +pluginUpdatesReport = new File( basedir, "target/site/plugin-updates-report.html" ) + +assert pluginUpdatesReport.exists( ) + +// some basic (=not comprehensive) checks on the contents of the plugin report +assert pluginUpdatesReport.text =~ /\b1\.0\b/ // current version of the plugin +assert pluginUpdatesReport.text =~ /\b3\.1\b/ // latest major available version \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index c60bfe56cc..61fb7b63b8 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -102,12 +102,6 @@ public abstract class AbstractVersionsReport @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true ) protected List remotePluginRepositories; - /** - * @since 1.0-alpha-1 - */ - @Parameter( defaultValue = "${localRepository}", readonly = true ) - protected ArtifactRepository localRepository; - /** * @since 1.0-alpha-3 */ From d96c74626bc84e3372f5f7ee49c91d4daebb720e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 26 Aug 2022 08:20:34 +0200 Subject: [PATCH 096/441] Fix for issue #323: using version range if currentVersion is not available --- .../DependencyUpdatesXmlRenderer.java | 5 +- .../DependencyUpdatesXmlRendererTest.java | 66 +++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java index 6c98285bc1..3abfcdc41d 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java @@ -187,8 +187,9 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) public static String getVersionsBlocks( ArtifactVersions versions ) { StringBuilder sBuilder = new StringBuilder(); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( versions.getCurrentVersion().toString(), - CURRENT_VERSION ) ).append( NL ); + sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( versions.isCurrentVersionDefined() + ? versions.getCurrentVersion().toString() : versions.getArtifact().getVersionRange().toString(), + CURRENT_VERSION ) ).append( NL ); ArtifactVersion nextVersion = versions.getOldestUpdate( UpdateScope.ANY ); if ( nextVersion != null ) { diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java new file mode 100644 index 0000000000..6f890a8f7b --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -0,0 +1,66 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.hamcrest.core.Is; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.core.IsNull.nullValue; + +/** + * Basic tests for {@linkplain DependencyUpdatesXmlRenderer}. + * + * @author Andrzej Jarmoniuk + */ +public class DependencyUpdatesXmlRendererTest +{ + @Test + public void testGetVersionsBlocks() throws InvalidVersionSpecificationException + { + List versions = + versionsOf( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1" ); + final Artifact artifact = + new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", + "bar", "jar", null ); + ArtifactVersions artifactVersions = new ArtifactVersions( artifact, versions, null ); + assertThat( artifactVersions.getCurrentVersion(), nullValue() ); + assertThat( artifactVersions.isCurrentVersionDefined(), Is.is( false ) ); + String versionsBlocks = DependencyUpdatesXmlRenderer.getVersionsBlocks( artifactVersions ); + assertThat( versionsBlocks, containsString( "[1.0,3.0]" ) ); + } + + private static List versionsOf( String... versions ) + { + return Arrays.stream( versions ).map( DefaultArtifactVersion::new ).collect( Collectors.toList() ); + } +} From 189cfbf9c99968f24c64834ed9e610ae4a82cf0e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 27 Aug 2022 12:20:19 +0200 Subject: [PATCH 097/441] Fixing #604: npe in DependencyVersionChanger if artifact version is null --- .../child/pom.xml | 13 +++++++++++ .../invoker.properties | 1 + .../it-set-024-versionless-dependency/pom.xml | 22 +++++++++++++++++++ .../org/codehaus/mojo/versions/SetMojo.java | 11 +++++----- 4 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 src/it/it-set-024-versionless-dependency/child/pom.xml create mode 100644 src/it/it-set-024-versionless-dependency/invoker.properties create mode 100644 src/it/it-set-024-versionless-dependency/pom.xml diff --git a/src/it/it-set-024-versionless-dependency/child/pom.xml b/src/it/it-set-024-versionless-dependency/child/pom.xml new file mode 100644 index 0000000000..92fcf1a5d7 --- /dev/null +++ b/src/it/it-set-024-versionless-dependency/child/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + + + localhost + test-artifact + 1.0 + + + child + + \ No newline at end of file diff --git a/src/it/it-set-024-versionless-dependency/invoker.properties b/src/it/it-set-024-versionless-dependency/invoker.properties new file mode 100644 index 0000000000..26c0549d71 --- /dev/null +++ b/src/it/it-set-024-versionless-dependency/invoker.properties @@ -0,0 +1 @@ +invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:set -DprocessDependencies=true, -DartifactId=child -DoldVersion=1.0 -DnewVersion=2.0 \ No newline at end of file diff --git a/src/it/it-set-024-versionless-dependency/pom.xml b/src/it/it-set-024-versionless-dependency/pom.xml new file mode 100644 index 0000000000..a5c323139a --- /dev/null +++ b/src/it/it-set-024-versionless-dependency/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + localhost + test-artifact + 1.0 + pom + + + + + localhost + dummy-api + 1.1 + + + + + + child + + \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index edb7c066c1..421ffa6ea1 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -354,15 +354,16 @@ public void execute() throws MojoExecutionException, MojoFailureException final String mGroupId = PomHelper.getGroupId( m ); final String mArtifactId = PomHelper.getArtifactId( m ); final String mVersion = PomHelper.getVersion( m ); - if ( ( ( groupIdRegex.matcher( mGroupId ).matches() && artifactIdRegex.matcher( mArtifactId ) - .matches() ) // - || ( processAllModules ) ) // - && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) + if ( ( processAllModules + || groupIdRegex.matcher( mGroupId ).matches() + && artifactIdRegex.matcher( mArtifactId ).matches() ) + && oldVersionIdRegex.matcher( mVersion ).matches() + && !newVersion.equals( mVersion ) ) { found = true; // if the change is not one we have swept up already applyChange( project, reactor, files, mGroupId, m.getArtifactId(), - StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : m.getVersion() ); + StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : mVersion ); } } if ( !found && RegexUtils.getWildcardScore( groupId ) == 0 && RegexUtils.getWildcardScore( artifactId ) == 0 From c6ab45d52d5c95f8def61b7481d2988e48eec7b0 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 27 Aug 2022 13:29:46 +0200 Subject: [PATCH 098/441] Bump project version to 2.12.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd3e86c710..27792efd97 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.11.1-SNAPSHOT + 2.12.0-SNAPSHOT maven-plugin Versions Maven Plugin From 44431b85e6474ad59e1a04c05357bfc421b77c1a Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 27 Aug 2022 13:09:07 +0200 Subject: [PATCH 099/441] Extension of AbstractMojoTestCase from maven testing harness, adding a possibility of injecting a project without having to create project stubs. --- .../mojo/versions/utils/BaseMojoTestCase.java | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java new file mode 100644 index 0000000000..5900ff12c0 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java @@ -0,0 +1,113 @@ +package org.codehaus.mojo.versions.utils; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.codehaus.mojo.versions.SetMojo; +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + *

Extension of the {@link AbstractMojoTestCase} class, providing support + * for loading projects specified by POM file path (instead of + * using stubs with implementation hint).

+ * + *

Example usage:

+ * + *
+ *     // provide the path to the POM containing the tested project
+ *     SetMojo myMojo = createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" );
+ *     assertNotNull( myMojo );
+ *     myMojo.execute();
+ * 
+ * @author Andrzej Jarmoniuk + */ +public abstract class BaseMojoTestCase extends AbstractMojoTestCase +{ + /** + * Lookup the mojo leveraging the actual subprojects pom + * and injects the project using the given pom file path. + * + * @param goal to execute on the plugin + * @param pomFilePath path to the pom project to inject + * @return a Mojo instance + * @throws Exception thrown if mojo lookup fails + */ + protected SetMojo createMojo( String goal, String pomFilePath ) throws Exception + { + File pomFile = new File( pomFilePath ); + SetMojo mojo = (SetMojo) lookupMojo( goal, pomFile ); + mojo.setProject( new TestProjectStub( pomFile ) ); + return mojo; + } + + private static class TestProjectStub extends MavenProjectStub + { + private final File pomFile; + + /** + * Default constructor + */ + private TestProjectStub( File pomFile ) throws IOException, XmlPullParserException + { + this.pomFile = pomFile; + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = pomReader.read( ReaderFactory.newXmlReader( pomFile ) ); + model.setPomFile( pomFile ); + + setModel( model ); + setOriginalModel( model.clone() ); + setGroupId( model.getGroupId() ); + setArtifactId( model.getArtifactId() ); + setVersion( model.getVersion() ); + setName( model.getName() ); + setUrl( model.getUrl() ); + setPackaging( model.getPackaging() ); + setFile( model.getPomFile() ); + + setBuild( new Build() + {{ + setFinalName( model.getArtifactId() ); + setDirectory( getBasedir() + "/target" ); + setSourceDirectory( getBasedir() + "/src/main/java" ); + setOutputDirectory( getBasedir() + "/target/classes" ); + setTestSourceDirectory( getBasedir() + "/src/test/java" ); + setTestOutputDirectory( getBasedir() + "/target/test-classes" ); + }} ); + + setCompileSourceRoots( Collections.singletonList( getBasedir() + "/src/main/java" ) ); + setTestCompileSourceRoots( Collections.singletonList( getBasedir() + "/src/test/java" ) ); + } + + @Override + public File getBasedir() + { + return pomFile.getParentFile(); + } + } +} From 22ef02f949b7e16bfe0bb4f37e44cb92c98a0a42 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 27 Aug 2022 16:24:11 +0200 Subject: [PATCH 100/441] Fixing #654: NPE in SetMojo when a dependency version is null --- pom.xml | 3 ++ .../org/codehaus/mojo/versions/SetMojo.java | 10 +++-- .../codehaus/mojo/versions/api/PomHelper.java | 31 ++++++--------- .../mojo/versions/utils/RegexUtils.java | 18 +++++---- .../codehaus/mojo/versions/SetMojoTest.java | 10 ++++- .../codehaus/mojo/set/versionless-01/pom.xml | 38 +++++++++++++++++++ 6 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml diff --git a/pom.xml b/pom.xml index 27792efd97..620ed09ab0 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,9 @@ antoon.johansson@gmail.com +1 + + Andrzej Jarmoniuk + diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 421ffa6ea1..9aae5bd90a 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -433,10 +433,12 @@ private void applyChange( MavenProject project, SortedMap reactor addChange( groupId, artifactId, oldVersion, newVersion ); // now fake out the triggering change - final Map.Entry current = PomHelper.getModelEntry( reactor, groupId, artifactId ); - current.getValue().setVersion( newVersion ); - - addFile( files, project, current.getKey() ); + Map.Entry current = PomHelper.getModelEntry( reactor, groupId, artifactId ); + if ( current != null ) + { + current.getValue().setVersion( newVersion ); + addFile( files, project, current.getKey() ); + } for ( Map.Entry sourceEntry : reactor.entrySet() ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index e855bf1733..e3d625d459 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -816,7 +816,7 @@ else if ( inMatchScope && matchTargetRegex.matcher( path ).matches() ) { if ( "groupId".equals( elementName ) ) { - haveGroupId = groupId.equals( pom.getElementText().trim() ); + haveGroupId = pom.getElementText().trim().equals( groupId ); path = stack.pop(); } else if ( "artifactId".equals( elementName ) ) @@ -1539,12 +1539,14 @@ public static Map getChildModels( Map reactor, Str */ public static Model getModel( Map reactor, String groupId, String artifactId ) { - Map.Entry entry = getModelEntry( reactor, groupId, artifactId ); - return entry == null ? null : entry.getValue(); + return reactor.values().stream().filter( + model -> ( groupId == null || groupId.equals( getGroupId( model ) ) ) && artifactId.equals( + getArtifactId( model ) ) ).findAny().orElse( null ); } /** - * Returns the model that has the specified groupId and artifactId or null if no such model exists. + * Returns the model that has the specified groupId (if specified) + * and artifactId or null if no such model exists. * * @param reactor The map of models keyed by path. * @param groupId The groupId to match. @@ -1554,15 +1556,9 @@ public static Model getModel( Map reactor, String groupId, String public static Map.Entry getModelEntry( Map reactor, String groupId, String artifactId ) { - for ( Map.Entry entry : reactor.entrySet() ) - { - Model model = entry.getValue(); - if ( groupId.equals( getGroupId( model ) ) && artifactId.equals( getArtifactId( model ) ) ) - { - return entry; - } - } - return null; + return reactor.entrySet().stream().filter( + e -> ( groupId == null || groupId.equals( PomHelper.getGroupId( e.getValue() ) ) ) && artifactId.equals( + PomHelper.getArtifactId( e.getValue() ) ) ).findAny().orElse( null ); } /** @@ -1578,15 +1574,12 @@ public static int getReactorParentCount( Map reactor, Model model { return 0; } - else + Model parentModel = getModel( reactor, model.getParent().getGroupId(), model.getParent().getArtifactId() ); + if ( parentModel == null ) { - Model parentModel = getModel( reactor, model.getParent().getGroupId(), model.getParent().getArtifactId() ); - if ( parentModel != null ) - { - return getReactorParentCount( reactor, parentModel ) + 1; - } return 0; } + return getReactorParentCount( reactor, parentModel ) + 1; } /** diff --git a/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java index 7a74967679..a9da7cfb42 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java @@ -97,16 +97,18 @@ public static String quote( String s ) public static int getWildcardScore( String wildcardRule ) { int score = 0; - for ( int i = 0; i < wildcardRule.length(); i++ ) + if ( wildcardRule != null ) { - char c = wildcardRule.charAt( i ); - if ( c == '?' ) - { - score++; - } - else if ( c == '*' ) + for ( char c : wildcardRule.toCharArray() ) { - score += 1000; + if ( c == '?' ) + { + score++; + } + else if ( c == '*' ) + { + score += 1000; + } } } return score; diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index b078dbeccb..fb674768a8 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -4,14 +4,14 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.utils.BaseMojoTestCase; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; -import static org.junit.Assert.fail; -public class SetMojoTest +public class SetMojoTest extends BaseMojoTestCase { @Test public void testGetIncrementedVersion() throws MojoExecutionException @@ -92,4 +92,10 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti } } + @Test + public void testVersionlessDependency() throws Exception + { + SetMojo myMojo = createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" ); + myMojo.execute(); + } } diff --git a/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml b/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml new file mode 100644 index 0000000000..22956c5178 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + + + localhost + dummy-api + 1.1 + + + + + + + localhost + dummy-api + + + + + + + versions-maven-plugin + + onchange + dummy-api + 2.0 + + + + + \ No newline at end of file From 345cb3a9bc57c3cc245723b8bea93c9ec7fb9821 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 28 Aug 2022 08:31:24 +0200 Subject: [PATCH 101/441] Making createMojo generic (was previously restricted to SetMojo) --- .../codehaus/mojo/versions/utils/BaseMojoTestCase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java index 5900ff12c0..c9ed9c714f 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java @@ -7,9 +7,9 @@ import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import org.codehaus.mojo.versions.SetMojo; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; @@ -58,11 +58,11 @@ public abstract class BaseMojoTestCase extends AbstractMojoTestCase * @return a Mojo instance * @throws Exception thrown if mojo lookup fails */ - protected SetMojo createMojo( String goal, String pomFilePath ) throws Exception + protected T createMojo( String goal, String pomFilePath ) throws Exception { File pomFile = new File( pomFilePath ); - SetMojo mojo = (SetMojo) lookupMojo( goal, pomFile ); - mojo.setProject( new TestProjectStub( pomFile ) ); + T mojo = (T) lookupMojo( goal, pomFile ); + setVariableValueToObject( mojo, "project", new TestProjectStub( pomFile ) ); return mojo; } From 869979f9e3fe386f20e5d18b761f0575e80d2cfa Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 28 Aug 2022 13:26:26 +0200 Subject: [PATCH 102/441] Add me as developer --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index 620ed09ab0..186db5f9d3 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,14 @@ +1 + + Slawomir Jaranowski + sjaranowski@apache.org + + Developer + + Europe/Warsaw + From 01dcc600aeb963a1cd19ce5e22de644ab4f88719 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 29 Aug 2022 11:10:33 +0200 Subject: [PATCH 103/441] stale action - set close-issue-reason as not_planned --- .github/workflows/stale.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 52afe49d4d..b0639af2a9 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -13,6 +13,7 @@ jobs: days-before-pr-stale: 365 days-before-pr-close: 30 stale-issue-message: 'This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' + close-issue-reason: 'not_planned' days-before-issue-stale: 365 days-before-issue-close: 30 From a440adc04bc17b910129d365f4c9371980db21e2 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 28 Aug 2022 11:06:31 +0200 Subject: [PATCH 104/441] Implementing #213: new argument: allowDowngrade, only valid if allowSnapshots is false, will optionally downgrade the dependency version if its current version is a snapshot --- pom.xml | 2 +- .../mojo/versions/UseLatestVersionsMojo.java | 35 ++- .../versions/api/AbstractVersionDetails.java | 109 ++++++-- .../mojo/versions/api/PropertyVersions.java | 67 +---- .../versions/UseLatestVersionsMojoTest.java | 244 ++++++++++++++++++ 5 files changed, 366 insertions(+), 91 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java diff --git a/pom.xml b/pom.xml index 186db5f9d3..b515a15d6a 100644 --- a/pom.xml +++ b/pom.xml @@ -264,7 +264,7 @@
org.mockito - mockito-core + mockito-inline 4.7.0 test diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 60301607a0..cbfb7adf9a 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -22,9 +22,8 @@ import javax.xml.stream.XMLStreamException; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.Collections; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -75,8 +74,33 @@ public class UseLatestVersionsMojo @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) private boolean allowIncrementalUpdates; + /** + *

Whether to downgrade a snapshot dependency if allowSnapshots is false + * and there exists a non-snapshot version within the range fulfilling the criteria.

+ *

Only valid if allowSnapshots is false.

+ * + * @since 2.12.0 + */ + @Parameter( property = "allowDowngrade", + defaultValue = "false" ) + private boolean allowDowngrade; + // ------------------------------ METHODS -------------------------- + + /** + * {@inheritDoc} + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException + { + if ( allowDowngrade && allowSnapshots ) + { + throw new MojoExecutionException( "allowDowngrade is only valid with allowSnapshots equal to false" ); + } + super.execute(); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong @@ -109,9 +133,7 @@ protected void update( ModifiedPomXMLEventReader pom ) dependency.setGroupId( getProject().getParent().getGroupId() ); dependency.setVersion( getProject().getParent().getVersion() ); dependency.setType( "pom" ); - List list = new ArrayList(); - list.add( dependency ); - useLatestVersions( pom, list ); + useLatestVersions( pom, Collections.singletonList( dependency ) ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -154,7 +176,8 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection 0 ) diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index a06ba2c4fb..ee2a954df0 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -26,6 +26,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; /** @@ -135,30 +136,6 @@ public final ArtifactVersion[] getVersions( ArtifactVersion currentVersion, Arti return getVersions( currentVersion, upperBound, includeSnapshots, false, false ); } - /** - * Gets newer versions of the specified artifact version. - * - * @param version The current version of the artifact. - * @param upperBoundFixedSegment Indicates the segment in the version number that cannot be changed. For example, a - * value of 0 indicates that the major version number cannot be changed. A value of -1 indicates any - * segment value can be changed. - * @param includeSnapshots Whether to include snapshot versions. - * @return Returns the newer artifact versions. - */ - private ArtifactVersion[] getNewerVersions( ArtifactVersion version, int upperBoundFixedSegment, - boolean includeSnapshots ) - { - ArtifactVersion lowerBound = version; - ArtifactVersion upperBound = null; - - if ( upperBoundFixedSegment != -1 ) - { - upperBound = getVersionComparator().incrementSegment( lowerBound, upperBoundFixedSegment ); - } - - return getVersions( version, upperBound, includeSnapshots, false, false ); - } - private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) { return getVersions( version, null, includeSnapshots, false, true ); @@ -243,9 +220,43 @@ public final ArtifactVersion[] getNewerVersions( String version, boolean include return getNewerVersions( new DefaultArtifactVersion( version ), includeSnapshots ); } + /** + * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots + * should be included. + * + * @param version current version + * @param upperBoundSegment the upper bound segment + * @param includeSnapshots whether snapshot versions should be included + * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, int, boolean, boolean)} instead + * @return array of newer versions fulfilling the criteria + */ + @Deprecated public final ArtifactVersion[] getNewerVersions( String version, int upperBoundSegment, boolean includeSnapshots ) { - return getNewerVersions( new DefaultArtifactVersion( version ), upperBoundSegment, includeSnapshots ); + return getNewerVersions( version, upperBoundSegment, includeSnapshots, false ); + } + + /** + * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots + * should be included. + * + * @param versionString current version + * @param upperBoundSegment the upper bound segment + * @param includeSnapshots whether snapshot versions should be included + * @param allowDowngrade whether to allow downgrading if the current version is a snapshots and snapshots + * are disallowed + * @return array of newer versions fulfilling the criteria + */ + public final ArtifactVersion[] getNewerVersions( String versionString, int upperBoundSegment, + boolean includeSnapshots, boolean allowDowngrade ) + { + ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); + ArtifactVersion lowerBound = + allowDowngrade ? getLowerBoundArtifactVersion( currentVersion, upperBoundSegment ) : currentVersion; + ArtifactVersion upperBound = upperBoundSegment == -1 ? null + : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment ); + + return getVersions( lowerBound, upperBound, includeSnapshots, allowDowngrade, allowDowngrade ); } public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) @@ -483,4 +494,52 @@ public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean inclu { return getVersions( versionRange, getCurrentVersion(), null, includeSnapshots, false, true ); } + + protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, int segment ) + { + String lowerBound = getLowerBound( version, segment ); + return lowerBound != null ? new DefaultArtifactVersion( lowerBound ) : null; + } + + protected String getLowerBound( ArtifactVersion version, int segment ) + { + if ( segment < 0 ) + { + return null; + } + + int segmentCount = getVersionComparator().getSegmentCount( version ); + if ( segment > segmentCount ) + { + throw new InvalidSegmentException( segment, segmentCount, + version.toString() ); + } + + StringBuilder newVersion = new StringBuilder(); + newVersion.append( version.getMajorVersion() ); + if ( segmentCount > 0 ) + { + newVersion.append( "." ) + .append( segment >= 1 ? version.getMinorVersion() : 0 ); + } + if ( segmentCount > 1 ) + { + newVersion.append( "." ) + .append( segment >= 2 ? version.getIncrementalVersion() : 0 ); + } + if ( segmentCount > 2 ) + { + if ( version.getQualifier() != null ) + { + newVersion.append( "-" ) + .append( segment >= 3 ? version.getQualifier() : "0" ); + } + else + { + newVersion.append( "-" ) + .append( segment >= 3 ? version.getBuildNumber() : "0" ); + } + } + return newVersion.toString(); + } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index eb363589ae..4ab81204b5 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -23,7 +23,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -39,7 +38,6 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.mojo.versions.Property; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; /** @@ -145,12 +143,8 @@ public ArtifactAssociation[] getAssociations() private VersionComparator[] lookupComparators() { - Set result = new HashSet(); - for ( ArtifactAssociation association : associations ) - { - result.add( helper.getVersionComparator( association.getArtifact() ) ); - } - return result.toArray( new VersionComparator[0] ); + return associations.stream().map( association -> helper.getVersionComparator( association.getArtifact() ) ) + .distinct().toArray( VersionComparator[]::new ); } /** @@ -346,19 +340,15 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert throw new MojoExecutionException( e.getMessage(), e ); } - ArtifactVersion lowerBoundArtifactVersion = null; + ArtifactVersion lowerBoundArtifactVersion = helper.createArtifactVersion( currentVersion ); if ( allowDowngrade ) { - if ( segment != -1 ) - { - lowerBoundArtifactVersion = getLowerBound( helper, currentVersion, segment ); - } - helper.getLog().debug( "lowerBoundArtifactVersion is null based on allowDowngrade:" + allowDowngrade ); + String updatedVersion = getLowerBound( lowerBoundArtifactVersion, segment ); + lowerBoundArtifactVersion = updatedVersion != null ? helper.createArtifactVersion( updatedVersion ) : null; } - else + if ( helper.getLog().isDebugEnabled() ) { - lowerBoundArtifactVersion = helper.createArtifactVersion( currentVersion ); - helper.getLog().debug( "lowerBoundArtifactVersion: " + lowerBoundArtifactVersion.toString() ); + helper.getLog().debug( "lowerBoundArtifactVersion: " + lowerBoundArtifactVersion ); } ArtifactVersion upperBound = null; @@ -375,7 +365,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert if ( property.isSearchReactor() ) { helper.getLog().debug( "Property ${" + property.getName() + "}: Searching reactor for a valid version..." ); - Collection reactorArtifacts = helper.extractArtifacts( reactorProjects ); + Set reactorArtifacts = helper.extractArtifacts( reactorProjects ); ArtifactVersion[] reactorVersions = getVersions( reactorArtifacts ); helper.getLog().debug( "Property ${" + property.getName() + "}: Set of valid available versions from the reactor is " + Arrays.asList( @@ -527,45 +517,4 @@ public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) } } - - - private ArtifactVersion getLowerBound( VersionsHelper helper, - String currentVersion, int segment ) - { - ArtifactVersion version = helper.createArtifactVersion( currentVersion ); - int segmentCount = getVersionComparator().getSegmentCount( version ); - if ( segment < 0 || segment > segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, - currentVersion ); - } - - StringBuilder newVersion = new StringBuilder(); - newVersion.append( segment >= 0 ? version.getMajorVersion() : 0 ); - if ( segmentCount > 0 ) - { - newVersion.append( "." ) - .append( segment >= 1 ? version.getMinorVersion() : 0 ); - } - if ( segmentCount > 1 ) - { - newVersion.append( "." ) - .append( segment >= 2 ? version.getIncrementalVersion() : 0 ); - } - if ( segmentCount > 2 ) - { - if ( version.getQualifier() != null ) - { - newVersion.append( "-" ) - .append( segment >= 3 ? version.getQualifier() : "0" ); - } - else - { - newVersion.append( "-" ) - .append( segment >= 3 ? version.getBuildNumber() : "0" ); - } - } - return helper.createArtifactVersion( newVersion.toString() ); - } - } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java new file mode 100644 index 0000000000..4d64826b32 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -0,0 +1,244 @@ +package org.codehaus.mojo.versions; + +import javax.xml.stream.XMLStreamException; + +import java.io.OutputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; + +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +@SuppressWarnings( "deprecation" ) +public class UseLatestVersionsMojoTest extends AbstractMojoTestCase +{ + private UseLatestVersionsMojo mojo; + private TestChangeRecorder changeRecorder; + + @Before + public void setUp() throws Exception + { + super.setUp(); + RepositorySystem repositorySystemMock = mock( RepositorySystem.class ); + when( repositorySystemMock.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), + dependency.getScope(), dependency.getType(), dependency.getClassifier() != null + ? dependency.getClassifier() : "default", null ); + } ); + + ArtifactMetadataSource artifactMetadataSourceMock = mock( ArtifactMetadataSource.class ); + when( artifactMetadataSourceMock.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + invocation -> + { + Artifact artifact = invocation.getArgument( 0 ); + if ( "dependency-artifact".equals( artifact.getArtifactId() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( "1.1.1-SNAPSHOT" ), + new DefaultArtifactVersion( "1.1.0" ), new DefaultArtifactVersion( "1.1.0-SNAPSHOT" ), + new DefaultArtifactVersion( "1.0.0" ), new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), + new DefaultArtifactVersion( "0.9.0" ) ); + } + fail(); + return null; + } ); + + changeRecorder = new TestChangeRecorder(); + + mojo = new UseLatestVersionsMojo() + {{ + MavenProject project = new MavenProject() + {{ + setModel( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "project-artifact" ); + setVersion( "1.0.0-SNAPSHOT" ); + + setDependencies( Collections.singletonList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "default", "pom", SCOPE_COMPILE ) ) ); + + setDependencyManagement( new DependencyManagement() ); + getDependencyManagement().setDependencies( Collections.singletonList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "default", "pom", SCOPE_COMPILE ) ) ); + }} ); + }}; + setProject( project ); + repositorySystem = repositorySystemMock; + artifactMetadataSource = artifactMetadataSourceMock; + setVariableValueToObject( this, "changeRecorder", changeRecorder ); + }}; + } + + private static class TestChangeRecorder implements ChangeRecorder + { + private final List changes = new LinkedList<>(); + + @Override + public void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ) + { + changes.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) ); + } + + @Override + public void serialize( OutputStream outputStream ) + { + } + + public List getChanges() + { + return changes; + } + } + + @Test + public void testDependenciesDowngradeIncremental() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "1.1.0" ) ) ); + } + + @Test + public void testDependenciesDowngradeMinor() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "1.0.0" ) ) ); + } + + @Test + public void testDependenciesDowngradeMajor() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", true ); + setVariableValueToObject( mojo, "allowMinorUpdates", false ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "0.9.0" ) ) ); + } + + @Test + public void testDependencyManagementDowngrade() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencyManagement", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "1.1.0" ) ) ); + } + + @Test + public void testParentDowngrade() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processParent", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "dependency-artifact", + "1.1.1-SNAPSHOT", "compile", "pom", "default", null ) ); + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( mojo.getProject().getParentArtifact().getGroupId() ); + setArtifactId( mojo.getProject().getParentArtifact().getArtifactId() ); + setVersion( mojo.getProject().getParentArtifact().getVersion() ); + }} ); + + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "1.1.0" ) ) ); + } +} \ No newline at end of file From 56dd51479cb065ecb1592a902cd225ccbe58d0a1 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 29 Aug 2022 15:51:10 +0200 Subject: [PATCH 105/441] Fixing #320: Correcting the delta computation --- .../rewriting/ModifiedPomXMLEventReader.java | 4 +- .../ModifiedPomXMLEventReaderTest.java | 138 ++++++++++++++++++ 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java b/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java index b65321dece..ea430c47d9 100644 --- a/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java +++ b/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java @@ -462,7 +462,7 @@ public void replace( String replacement ) return; } pom.replace( start, end, replacement ); - int delta = replacement.length() - lastEnd - lastStart; + int delta = replacement.length() - ( lastEnd - lastStart ); nextDelta += delta; for ( int i = 0; i < MAX_MARKS; i++ ) { @@ -563,7 +563,7 @@ public void replaceMark( int index, String replacement ) return; } pom.replace( start, end, replacement ); - int delta = replacement.length() - markEnd[index] - markStart[index]; + int delta = replacement.length() - ( markEnd[index] - markStart[index] ); nextDelta += delta; if ( lastStart == markStart[index] && lastEnd == markEnd[index] ) { diff --git a/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java b/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java new file mode 100644 index 0000000000..5ae699c20c --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java @@ -0,0 +1,138 @@ +package org.codehaus.mojo.versions.rewriting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import javax.xml.stream.Location; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +import java.io.StringReader; + +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +/** + * Unit tests for {@link ModifiedPomXMLEventReaderTest} + * + * @author Andrzej Jarmoniuk + */ + +@RunWith( MockitoJUnitRunner.class ) +public class ModifiedPomXMLEventReaderTest extends AbstractMojoTestCase +{ + private static final String[] STR = {"xyz", "0123456789abcdef"}; + private static final String REPLACEMENT = "abcdef"; + + @Mock + private Location location; + + @Mock + private XMLEvent xmlEvent; + + @Mock + private XMLEventReader xmlEventReader; + + @Mock + private XMLInputFactory xmlInputFactory; + + private ModifiedPomXMLEventReader pomXMLEventReader; + + @Before + public void setUp() throws Exception + { + super.setUp(); + + when( location.getCharacterOffset() ) + .thenReturn( STR[0].length() ) + .thenReturn( STR[0].length() + STR[1].length() ); + + when( xmlEvent.isCharacters() ).thenReturn( true ); + when( xmlEvent.getLocation() ).thenReturn( location ); + + when( xmlEventReader.hasNext() ) + .thenReturn( true ).thenReturn( true ) // str[0] + .thenReturn( true ).thenReturn( true ) // str[1] + .thenReturn( false ); // ∅ + when( xmlEventReader.nextEvent() ) + .thenReturn( xmlEvent ) + .thenReturn( xmlEvent ); + when( xmlEventReader.peek() ) + .thenReturn( xmlEvent ); + + when( xmlInputFactory.createXMLEventReader( any( StringReader.class ) ) ) + .thenReturn( xmlEventReader ); + + pomXMLEventReader = + new ModifiedPomXMLEventReader( new StringBuilder( STR[0] ).append( STR[1] ), xmlInputFactory, "" ); + } + + @Test + public void testReplace() throws XMLStreamException, IllegalAccessException + { + assertThat( pomXMLEventReader.hasNext(), is( true ) ); + assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + + assertThat( pomXMLEventReader.hasNext(), is( true ) ); + assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + + pomXMLEventReader.replace( REPLACEMENT ); + assertThat( pomXMLEventReader.asStringBuilder().toString(), is( STR[0] + REPLACEMENT ) ); + + pomXMLEventReader.mark( 0 ); + assertThat( pomXMLEventReader.getMarkVerbatim( 0 ), is( REPLACEMENT ) ); + + // more dangerous test since this touches the implementation + assertThat( getVariableValueFromObject( pomXMLEventReader, "lastEnd" ), + is( ( STR[0] + REPLACEMENT ).length() ) ); + } + + @Test + public void testReplaceMark() throws XMLStreamException, IllegalAccessException + { + assertThat( pomXMLEventReader.hasNext(), is( true ) ); + assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + + assertThat( pomXMLEventReader.hasNext(), is( true ) ); + assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + + pomXMLEventReader.mark( 0 ); + + pomXMLEventReader.replaceMark( 0, REPLACEMENT ); + assertThat( pomXMLEventReader.asStringBuilder().toString(), is( STR[0] + REPLACEMENT ) ); + + pomXMLEventReader.mark( 0 ); + assertThat( pomXMLEventReader.getMarkVerbatim( 0 ), is( REPLACEMENT ) ); + + // more dangerous test since this touches the implementation + assertThat( getVariableValueFromObject( pomXMLEventReader, "lastEnd" ), + is( ( STR[0] + REPLACEMENT ).length() ) ); + } +} From 87a414689aa811437bf3766a693280d90f1af389 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 31 Aug 2022 06:24:32 +0200 Subject: [PATCH 106/441] #361: Typo --- .../codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java index 3abfcdc41d..eb89ee036f 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java @@ -169,7 +169,7 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) String result = "\t%n" + "\t\t%d%n" + "\t\t%d%n" - + "\t\t%d%n" + + "\t\t%d%n" + "\t\t%d%n" + "\t\t%d%n" + "\t%n"; From 52cd445d3dc4d5ae17b753108e797f8cd71f6479 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 31 Aug 2022 06:52:38 +0200 Subject: [PATCH 107/441] New feature (#477): connection, developerConnection, url arguments for set-scm-tag --- src/it/it-set-scm-tag-001/invoker.properties | 3 +- src/it/it-set-scm-tag-001/pom.xml | 3 + src/it/it-set-scm-tag-001/verify.bsh | 32 ------- src/it/it-set-scm-tag-001/verify.groovy | 6 ++ .../codehaus/mojo/versions/SetScmTagMojo.java | 85 ++++++++++++++++--- 5 files changed, 81 insertions(+), 48 deletions(-) delete mode 100644 src/it/it-set-scm-tag-001/verify.bsh create mode 100644 src/it/it-set-scm-tag-001/verify.groovy diff --git a/src/it/it-set-scm-tag-001/invoker.properties b/src/it/it-set-scm-tag-001/invoker.properties index d6f553b788..62d509b5b2 100644 --- a/src/it/it-set-scm-tag-001/invoker.properties +++ b/src/it/it-set-scm-tag-001/invoker.properties @@ -1,2 +1 @@ -invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:set-scm-tag -DnewTag=v1.0 -invoker.buildResult.1=success +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:set-scm-tag -DnewTag=v1.0 -Dconnection=connection -DdeveloperConnection=developerConnection -Durl=url diff --git a/src/it/it-set-scm-tag-001/pom.xml b/src/it/it-set-scm-tag-001/pom.xml index 52c747ae7c..ff6cdb58b5 100644 --- a/src/it/it-set-scm-tag-001/pom.xml +++ b/src/it/it-set-scm-tag-001/pom.xml @@ -9,5 +9,8 @@ set-scm-tag HEAD + dummy + dummy + dummy diff --git a/src/it/it-set-scm-tag-001/verify.bsh b/src/it/it-set-scm-tag-001/verify.bsh deleted file mode 100644 index fb60555c17..0000000000 --- a/src/it/it-set-scm-tag-001/verify.bsh +++ /dev/null @@ -1,32 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E\\s*\\Q\\Ev1\\.0\\Q\\E\\s*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Setting new tag" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/it/it-set-scm-tag-001/verify.groovy b/src/it/it-set-scm-tag-001/verify.groovy new file mode 100644 index 0000000000..ff47e6ab50 --- /dev/null +++ b/src/it/it-set-scm-tag-001/verify.groovy @@ -0,0 +1,6 @@ +pom = new File( basedir, "pom.xml" ).text; + +assert pom =~ /v1\.0<\/tag>/ +assert pom =~ /connection<\/connection>/ +assert pom =~ /developerConnection<\/developerConnection>/ +assert pom =~ /url<\/url>/ \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 8c7300331a..b7bbc2b66a 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -3,9 +3,10 @@ import javax.xml.stream.XMLStreamException; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.model.Model; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -14,6 +15,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static org.apache.commons.lang3.StringUtils.isAllBlank; import static org.apache.commons.lang3.StringUtils.isBlank; /** @@ -23,8 +25,7 @@ * @since 2.5 */ @Mojo( name = "set-scm-tag", requiresDirectInvocation = true, aggregator = true, threadSafe = true ) -public class SetScmTagMojo - extends AbstractVersionsUpdaterMojo +public class SetScmTagMojo extends AbstractVersionsUpdaterMojo { /** @@ -35,6 +36,30 @@ public class SetScmTagMojo @Parameter( property = "newTag" ) private String newTag; + /** + * The new SCM connection property + * + * @since 2.12.0 + */ + @Parameter( property = "connection" ) + private String connection; + + /** + * The new SCM developerConnection property + * + * @since 2.12.0 + */ + @Parameter( property = "developerConnection" ) + private String developerConnection; + + /** + * The new SCM url property + * + * @since 2.12.0 + */ + @Parameter( property = "url" ) + private String url; + /** * Called when this mojo is executed. * @@ -42,12 +67,12 @@ public class SetScmTagMojo * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. */ @Override - public void execute() - throws MojoExecutionException, MojoFailureException + public void execute() throws MojoExecutionException, MojoFailureException { - if ( isBlank( newTag ) ) + if ( isAllBlank( newTag, connection, developerConnection, url ) ) { - throw new MojoFailureException( "'newTag' cannot be empty" ); + throw new MojoFailureException( + "One of: \"newTag\", \"connection\", \"developerConnection\", \"url\" should be provided." ); } super.execute(); @@ -55,22 +80,54 @@ public void execute() @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { try { - Model model = PomHelper.getRawModel( pom ); - Scm scm = model.getScm(); + Scm scm = PomHelper.getRawModel( pom ).getScm(); if ( scm == null ) { throw new MojoFailureException( "No was present" ); } - getLog().info( "Updating from tag " + scm.getTag() + " > " + newTag ); - boolean success = PomHelper.setProjectValue( pom, "/project/scm/tag", newTag ); - if ( !success ) + List failures = new ArrayList<>(); + if ( !isBlank( newTag ) ) + { + getLog().info( "Updating tag: " + scm.getTag() + " -> " + newTag ); + if ( !PomHelper.setProjectValue( pom, "/project/scm/tag", newTag ) ) + { + failures.add( "tag: " + newTag ); + } + } + if ( !isBlank( connection ) ) + { + getLog().info( "Updating connection: " + scm.getConnection() + " -> " + connection ); + if ( !PomHelper.setProjectValue( pom, "/project/scm/connection", connection ) ) + { + failures.add( "connection: " + connection ); + } + } + if ( !isBlank( developerConnection ) ) + { + getLog().info( "Updating developerConnection: " + scm.getDeveloperConnection() + " -> " + + developerConnection ); + if ( !PomHelper.setProjectValue( pom, "/project/scm/developerConnection", developerConnection ) ) + { + failures.add( "developerConnection: " + developerConnection ); + } + } + if ( !isBlank( url ) ) + { + getLog().info( "Updating url: " + scm.getUrl() + " -> " + url ); + if ( !PomHelper.setProjectValue( pom, "/project/scm/url", url ) ) + { + failures.add( "url: " + url ); + } + } + if ( !failures.isEmpty() ) { - throw new MojoFailureException( "Could not update the SCM tag" ); + throw new MojoFailureException( "Could not update one or more SCM elements: " + String.join( ", ", + failures ) + ". Please make sure they are present in the original POM. " ); } } catch ( IOException e ) From b551d90f0a9bfa284d613173bc7785305260b95e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 31 Aug 2022 08:10:40 +0200 Subject: [PATCH 108/441] Fixing #231 bug/feature: added "allowDowngrade", default "false", fixed range handling wrt downgrading --- .../versions/AbstractVersionsUpdaterMojo.java | 24 +- .../mojo/versions/UpdateParentMojo.java | 34 ++- .../versions/api/AbstractVersionDetails.java | 36 ++- .../mojo/versions/api/ArtifactVersions.java | 26 +- .../mojo/versions/UpdateParentMojoTest.java | 235 ++++++++++++++++-- .../versions/UseLatestVersionsMojoTest.java | 30 +-- .../versions/utils/TestChangeRecorder.java | 48 ++++ 7 files changed, 342 insertions(+), 91 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 83121bda23..113f733446 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -289,6 +289,27 @@ public void execute() */ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories ) + throws ArtifactMetadataRetrievalException, MojoExecutionException + { + return findLatestVersion( artifact, versionRange, allowingSnapshots, usePluginRepositories, false ); + } + + /** + * Finds the latest version of the specified artifact that matches the version range. + * + * @param artifact The artifact. + * @param versionRange The version range. + * @param allowingSnapshots null for no override, otherwise the local override to apply. + * @param usePluginRepositories Use plugin repositories + * @return The latest version of the specified artifact that matches the specified version range or + * null if no matching version could be found. + * @throws ArtifactMetadataRetrievalException If the artifact metadata could not be found. + * @throws MojoExecutionException if something goes wrong. + * @since 1.0-alpha-1 + */ + protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, + Boolean allowingSnapshots, boolean usePluginRepositories, + boolean allowDowngrade ) throws ArtifactMetadataRetrievalException, MojoExecutionException { boolean includeSnapshots = this.allowSnapshots; @@ -301,7 +322,8 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver includeSnapshots = false; } final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); - return artifactVersions.getNewestVersion( versionRange, includeSnapshots ); + return artifactVersions.getNewestVersion( versionRange, null, null, includeSnapshots, + true, true, allowDowngrade ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index bfa1253013..68893603f3 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -65,6 +65,17 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Parameter( property = "forceUpdate", defaultValue = "false" ) protected boolean forceUpdate = false; + /** + *

Whether to downgrade a snapshot dependency if allowSnapshots is false + * and there exists a version within the range fulfilling the criteria.

+ *

Default false

+ * + * @since 2.12.0 + */ + @Parameter( property = "allowDowngrade", + defaultValue = "false" ) + protected boolean allowDowngrade; + // -------------------------- OTHER METHODS -------------------------- /** @@ -98,33 +109,40 @@ protected void update( ModifiedPomXMLEventReader pom ) version = parentVersion; } + Dependency dependency = new Dependency(); + dependency.setGroupId( getProject().getParent().getGroupId() ); + dependency.setArtifactId( getProject().getParent().getArtifactId() ); + dependency.setVersion( version ); + dependency.setType( "pom" ); + Artifact artifact = getHelper().createDependencyArtifact( dependency ); + VersionRange versionRange; try { versionRange = VersionRange.createFromVersionSpec( version ); + if ( versionRange.getRecommendedVersion() != null ) + { + versionRange = versionRange.restrict( + VersionRange.createFromVersionSpec( "[" + versionRange.getRecommendedVersion() + ",)" ) ); + } } catch ( InvalidVersionSpecificationException e ) { throw new MojoExecutionException( "Invalid version range specification: " + version, e ); } - Dependency dependency = new Dependency(); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setVersion( version ); - dependency.setType( "pom" ); - Artifact artifact = getHelper().createDependencyArtifact( dependency ); - ArtifactVersion artifactVersion; try { - artifactVersion = findLatestVersion( artifact, versionRange, null, false ); + artifactVersion = findLatestVersion( artifact, versionRange, false, true, + allowDowngrade ); } catch ( ArtifactMetadataRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } + if ( !shouldApplyUpdate( artifact, currentVersion, artifactVersion, forceUpdate ) ) { return; diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index ee2a954df0..1cd11640fa 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -19,8 +19,11 @@ * under the License. */ +import java.util.Arrays; +import java.util.Collections; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -156,11 +159,26 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Artifa ArtifactVersion upperBound, boolean includeSnapshots, boolean includeLower, boolean includeUpper ) { - ArtifactVersion latest = null; + return getNewestVersion( versionRange, lowerBound, upperBound, includeSnapshots, includeLower, + includeUpper, false ); + } + + private static Iterable reverse( T[] array ) + { + return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); + } + + public final ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound, + ArtifactVersion upperBound, boolean includeSnapshots, + boolean includeLower, boolean includeUpper, boolean allowDowngrade ) + { final VersionComparator versionComparator = getVersionComparator(); - for ( ArtifactVersion candidate : getVersions( includeSnapshots ) ) + // reverse( getVersions( ... ) ) will contain versions sorted from latest to oldest, + // so we only need to find the first candidate fulfilling the criteria + for ( ArtifactVersion candidate : reverse( getVersions( includeSnapshots ) ) ) { - if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) ) + if ( !allowDowngrade && versionRange != null + && !ArtifactVersions.isVersionInRange( candidate, versionRange ) ) { continue; } @@ -178,17 +196,9 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Artifa { continue; } - if ( latest == null ) - { - latest = candidate; - } - else if ( versionComparator.compare( latest, candidate ) < 0 ) - { - latest = candidate; - } - + return candidate; } - return latest; + return null; } public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index bb15f2ec10..e5d9df192a 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -20,7 +20,6 @@ */ import java.util.List; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -96,7 +95,8 @@ public static boolean isVersionInRange( ArtifactVersion version, VersionRange ra { return false; } - for ( Restriction r : ( (List) range.getRestrictions() ) ) + + for ( Restriction r : range.getRestrictions() ) { if ( r.containsVersion( version ) ) { @@ -157,24 +157,10 @@ public String getArtifactId() public ArtifactVersion[] getVersions( boolean includeSnapshots ) { - Set result; - if ( includeSnapshots ) - { - result = versions; - } - else - { - result = new TreeSet<>( versionComparator ); - for ( ArtifactVersion candidate : versions ) - { - if ( ArtifactUtils.isSnapshot( candidate.toString() ) ) - { - continue; - } - result.add( candidate ); - } - } - return result.toArray( new ArtifactVersion[0] ); + return includeSnapshots + ? versions.toArray( new ArtifactVersion[0] ) + : versions.stream().filter( v -> !ArtifactUtils.isSnapshot( v.toString() ) ) + .toArray( ArtifactVersion[]::new ); } public VersionComparator getVersionComparator() diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index e5a25b1d38..0faeec3993 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -2,47 +2,238 @@ import javax.xml.stream.XMLStreamException; +import java.util.Arrays; import java.util.Collections; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.ProjectArtifact; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.MockedStatic; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; public class UpdateParentMojoTest { + private TestChangeRecorder changeRecorder; + + private UpdateParentMojo mojo; + + private ArtifactResolver artifactResolver; + + private static RepositorySystem repositorySystem; + + @SuppressWarnings( "deprecation" ) + private static ArtifactMetadataSource artifactMetadataSource; + + @BeforeClass + @SuppressWarnings( "deprecation" ) + public static void setUpStatic() throws ArtifactMetadataRetrievalException + { + repositorySystem = mockRepositorySystem(); + artifactMetadataSource = mockArtifactMetaDataSource(); + } + + @Before + public void setUp() throws IllegalAccessException + { + changeRecorder = new TestChangeRecorder(); + artifactResolver = mock( ArtifactResolver.class ); + + mojo = new UpdateParentMojo() + {{ + setProject( createProject() ); + reactorProjects = Collections.emptyList(); + repositorySystem = UpdateParentMojoTest.repositorySystem; + artifactMetadataSource = UpdateParentMojoTest.artifactMetadataSource; + resolver = UpdateParentMojoTest.this.artifactResolver; + + setVariableValueToObject( this, "changeRecorder", changeRecorder ); + }}; + } + + private MavenProject createProject() + { + return new MavenProject() + {{ + setModel( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "project-artifact" ); + setVersion( "1.0.1-SNAPSHOT" ); + }} ); + + setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "1.0.1-SNAPSHOT" ); + }} ); + }}; + } + + private static RepositorySystem mockRepositorySystem() + { + RepositorySystem repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), + dependency.getScope(), dependency.getType(), dependency.getClassifier() != null + ? dependency.getClassifier() : "default", null ); + } ); + return repositorySystem; + } + + @SuppressWarnings( "deprecation" ) + private static ArtifactMetadataSource mockArtifactMetaDataSource() throws ArtifactMetadataRetrievalException + { + ArtifactMetadataSource artifactMetadataSource = mock( ArtifactMetadataSource.class ); + when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + invocation -> + { + Artifact artifact = invocation.getArgument( 0 ); + if ( "parent-artifact".equals( artifact.getArtifactId() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( "1.0.1-SNAPSHOT" ), + new DefaultArtifactVersion( "1.0.0" ), + new DefaultArtifactVersion( "0.9.0" ) ); + } + else if ( "unknown-artifact".equals( artifact.getArtifactId() ) ) + { + return Collections.emptyList(); + } + fail(); + return null; + } ); + return artifactMetadataSource; + } @Test - public void testArtifactIdDoesNotExist() throws MojoExecutionException, XMLStreamException, MojoFailureException + @SuppressWarnings( "deprecation" ) + public void testArtifactIdDoesNotExist() + throws ArtifactMetadataRetrievalException, MojoExecutionException, + XMLStreamException, MojoFailureException, InvalidVersionSpecificationException { - UpdateParentMojo mojo = new UpdateParentMojo() + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "unknown-artifact" ); + setVersion( "1.0.1-SNAPSHOT" ); + }} ); + + Artifact artifact = + new DefaultArtifact( "default-group", "unknown-artifact", "1.0.1-SNAPSHOT", SCOPE_COMPILE, "pom", + "default", null ); + assertThat( + mojo.findLatestVersion( artifact, VersionRange.createFromVersionSpec( "1.0.1-SNAPSHOT" ), null, false ), + is( nullValue() ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); + mojo.update( null ); + } + } + + @Test + public void testParentDowngradeAllowed() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowDowngrade = true; + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "parent-artifact", "1.0.1-SNAPSHOT", + "1.0.0" ) ) ); + } + + @Test + public void testParentDowngradeForbidden() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowDowngrade = false; + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), is( empty() ) ); + } + + @Test + public void testParentDowngradeAllowedWithRange() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowDowngrade = true; + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "[1.0.1-SNAPSHOT,)" ); + }} ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "parent-artifact", "[1.0.1-SNAPSHOT,)", + "1.0.0" ) ) ); + } + + @Test + public void testParentDowngradeForbiddenWithRange() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowDowngrade = false; + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "[1.0.1-SNAPSHOT,)" ); + }} ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) { - { - project = new MavenProject(); - project.setParent( new MavenProject() ); - reactorProjects = Collections.emptyList(); - forceUpdate = true; - - repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any() ) ) - .thenReturn( new ProjectArtifact( project ) ); - } - - protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, - Boolean allowingSnapshots, boolean usePluginRepositories ) - { - return null; - } - }; - mojo.update( null ); + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), is( empty() ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 4d64826b32..5ac43e263b 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -2,11 +2,8 @@ import javax.xml.stream.XMLStreamException; -import java.io.OutputStream; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedList; -import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; @@ -22,7 +19,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.change.VersionChange; -import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; import org.junit.Test; import org.mockito.MockedStatic; @@ -70,8 +67,6 @@ public void setUp() throws Exception return null; } ); - changeRecorder = new TestChangeRecorder(); - mojo = new UseLatestVersionsMojo() {{ MavenProject project = new MavenProject() @@ -95,31 +90,12 @@ public void setUp() throws Exception setProject( project ); repositorySystem = repositorySystemMock; artifactMetadataSource = artifactMetadataSourceMock; + + changeRecorder = new TestChangeRecorder(); setVariableValueToObject( this, "changeRecorder", changeRecorder ); }}; } - private static class TestChangeRecorder implements ChangeRecorder - { - private final List changes = new LinkedList<>(); - - @Override - public void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ) - { - changes.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) ); - } - - @Override - public void serialize( OutputStream outputStream ) - { - } - - public List getChanges() - { - return changes; - } - } - @Test public void testDependenciesDowngradeIncremental() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException diff --git a/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java new file mode 100644 index 0000000000..2966cafe6e --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java @@ -0,0 +1,48 @@ +package org.codehaus.mojo.versions.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.OutputStream; +import java.util.LinkedList; +import java.util.List; + +import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.recording.ChangeRecorder; + +public class TestChangeRecorder implements ChangeRecorder +{ + private final List changes = new LinkedList<>(); + + @Override + public void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ) + { + changes.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) ); + } + + @Override + public void serialize( OutputStream outputStream ) + { + } + + public List getChanges() + { + return changes; + } +} \ No newline at end of file From 0db6ce4a14d217e0b08c2ad6c369b7a168128f50 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 3 Sep 2022 21:32:51 +0200 Subject: [PATCH 109/441] Fixing #315: Guarding against newVersion or property being empty if the properties file is not provided --- .../mojo/versions/SetPropertyMojo.java | 31 +++++++- .../mojo/versions/SetPropertyMojoTest.java | 73 +++++++++++++++++++ .../mojo/versions/utils/BaseMojoTestCase.java | 8 ++ .../set-property/null-new-version-pom.xml | 31 ++++++++ .../mojo/set-property/null-property-pom.xml | 31 ++++++++ 5 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java create mode 100644 src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 13acc9414f..ca3d6fbb48 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -22,7 +22,9 @@ import javax.xml.stream.XMLStreamException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; @@ -35,6 +37,8 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; +import static org.apache.commons.lang3.StringUtils.isBlank; + /** * Set a property to a given version without any sanity checks. Please be careful this can lead to changes which might * not build anymore. The sanity checks are done by other goals like update-properties or @@ -79,6 +83,31 @@ public class SetPropertyMojo @Parameter( property = "propertiesVersionsFile" ) private String propertiesVersionsFile; + /** + * {@inheritDoc} + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException + { + List problems = new ArrayList<>(); + if ( isBlank( propertiesVersionsFile ) ) + { + if ( isBlank( newVersion ) ) + { + problems.add( "newVersion must not be empty" ); + } + if ( isBlank( property ) ) + { + problems.add( "property must not be empty" ); + } + } + if ( !problems.isEmpty() ) + { + throw new MojoExecutionException( "Invalid execution arguments: " + String.join( ", ", problems ) ); + } + super.execute(); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong @@ -120,7 +149,7 @@ else if ( !StringUtils.isEmpty( property ) ) propertyConfig.setVersion( newVersion ); return propertyConfig; } ) - .toArray( size -> new Property[size] ); + .toArray( Property[]::new ); properties = property; } else diff --git a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java new file mode 100644 index 0000000000..b3aecf2e2b --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -0,0 +1,73 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; + +/** + * Basic tests for {@linkplain SetPropertyMojoTest}. + * + * @author Andrzej Jarmoniuk + */ +public class SetPropertyMojoTest extends BaseMojoTestCase +{ + @Test + public void testNullNewVersion() + throws Exception + { + SetPropertyMojo mojo = createMojo( "set-property", + "src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml" ); + assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); + try + { + mojo.execute(); + fail(); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), + containsString( "Invalid execution arguments: newVersion must not be empty" ) ); + } + } + + @Test + public void testNullProperty() + throws Exception + { + SetPropertyMojo mojo = createMojo( "set-property", + "src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml" ); + try + { + mojo.execute(); + fail(); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), + containsString( "Invalid execution arguments: property must not be empty" ) ); + } + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java index c9ed9c714f..d8a0e04f91 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.Properties; import org.apache.maven.model.Build; import org.apache.maven.model.Model; @@ -58,6 +59,7 @@ public abstract class BaseMojoTestCase extends AbstractMojoTestCase * @return a Mojo instance * @throws Exception thrown if mojo lookup fails */ + @SuppressWarnings( "unchecked" ) protected T createMojo( String goal, String pomFilePath ) throws Exception { File pomFile = new File( pomFilePath ); @@ -109,5 +111,11 @@ public File getBasedir() { return pomFile.getParentFile(); } + + @Override + public Properties getProperties() + { + return getModel().getProperties(); + } } } diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml b/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml new file mode 100644 index 0000000000..94e1f8d097 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + 1.0.0 + + + + + localhost + dummy-api + ${dummy-api-version} + + + + + + + versions-maven-plugin + + dummy-api-version + + + + + \ No newline at end of file diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml b/src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml new file mode 100644 index 0000000000..b429aa3b7b --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml @@ -0,0 +1,31 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + 1.0.0 + + + + + localhost + dummy-api + ${dummy-api-version} + + + + + + + versions-maven-plugin + + 2.0.0 + + + + + \ No newline at end of file From 5fa3693aa7317590f936f9be18edbd62cbcad35d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 1 Sep 2022 21:11:46 +0200 Subject: [PATCH 110/441] Fixing #251: proper handling of InvalidSegmentException and InvalidVersionSpecificationException --- .../versions/AbstractVersionsUpdaterMojo.java | 23 ++- .../versions/DisplayPropertyUpdatesMojo.java | 73 +++---- .../mojo/versions/PluginUpdatesDetails.java | 15 ++ .../mojo/versions/ResolveRangesMojo.java | 13 +- .../mojo/versions/UpdatePropertiesMojo.java | 29 ++- .../mojo/versions/UpdatePropertyMojo.java | 26 ++- .../mojo/versions/UseLatestReleasesMojo.java | 45 +++-- .../mojo/versions/UseLatestSnapshotsMojo.java | 81 ++++---- .../mojo/versions/UseLatestVersionsMojo.java | 58 +++--- .../mojo/versions/UseNextSnapshotsMojo.java | 39 ++-- .../versions/api/AbstractVersionDetails.java | 65 +++++-- .../mojo/versions/api/PropertyVersions.java | 63 +++--- .../mojo/versions/api/UpdateScope.java | 179 +++++++++++++----- .../mojo/versions/api/VersionDetails.java | 28 +-- .../ordering/AbstractVersionComparator.java | 5 +- .../ordering/InvalidSegmentException.java | 46 ++++- .../ordering/MavenVersionComparator.java | 4 +- .../ordering/MercuryVersionComparator.java | 4 +- .../ordering/NumericVersionComparator.java | 4 +- .../versions/ordering/VersionComparator.java | 2 +- .../versions/UseLatestVersionsMojoTest.java | 63 ++++-- .../ordering/MavenVersionComparatorTest.java | 4 +- .../ordering/VersionComparatorsTest.java | 10 +- 23 files changed, 593 insertions(+), 286 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 113f733446..836579f548 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; @@ -54,6 +55,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.recording.ChangeRecorder; import org.codehaus.mojo.versions.recording.ChangeRecorderNull; import org.codehaus.mojo.versions.recording.ChangeRecorderXML; @@ -101,7 +103,7 @@ public abstract class AbstractVersionsUpdaterMojo * @since 1.0-alpha-1 */ @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) - protected List reactorProjects; + protected List reactorProjects; /** * The artifact metadata source to use. @@ -216,8 +218,7 @@ public abstract class AbstractVersionsUpdaterMojo // --------------------- GETTER / SETTER METHODS --------------------- - public VersionsHelper getHelper() - throws MojoExecutionException + public VersionsHelper getHelper() throws MojoExecutionException { if ( helper == null ) { @@ -514,13 +515,22 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A } /** - * Based on the passed flags, determines which segment is unchangable. This can be used when determining an upper + *

Based on the passed flags, determines which segment (0-based), which is not to be changed.

+ *

The method will return, depending on the first parameter on the list to be true: + *

    + *
  • {@code allowMajorUpdates}: -1
  • + *
  • {@code allowMinorUpdates}: 0
  • + *
  • {@code allowIncrementalUpdates}: 1
  • + *
  • (none): 2
  • + *
+ * + * This can be used when determining an upper * bound for the "latest" version. * * @param allowMajorUpdates Allow major updates * @param allowMinorUpdates Allow minor updates * @param allowIncrementalUpdates Allow incremental updates - * @return Returns the segment that is unchangable. If any segment can change, returns -1. + * @return Returns the segment (0-based) that is unchangable. If any segment can change, returns -1. */ protected int determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, boolean allowIncrementalUpdates ) @@ -553,7 +563,8 @@ else if ( allowIncrementalUpdates ) protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, PropertyVersions version, String currentVersion, boolean allowDowngrade, int segment ) - throws MojoExecutionException, XMLStreamException + throws XMLStreamException, InvalidVersionSpecificationException, + InvalidSegmentException, MojoExecutionException { ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, this.reactorProjects, diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 57dcb4a557..4344a6da05 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -28,11 +28,13 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -138,44 +140,51 @@ public void execute() } int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, - this.reactorProjects, this.getHelper(), false, segment ); - - if ( winner != null && !currentVersion.equals( winner.toString() ) ) + try { - StringBuilder buf = new StringBuilder(); - buf.append( "${" ); - buf.append( property.getName() ); - buf.append( "} " ); - final String newVersion = winner.toString(); - int padding = - INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + getOutputLineWidthOffset(); - while ( buf.length() < padding ) + ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, + this.reactorProjects, this.getHelper(), false, segment ); + if ( winner != null && !currentVersion.equals( winner.toString() ) ) { - buf.append( '.' ); + StringBuilder buf = new StringBuilder(); + buf.append( "${" ); + buf.append( property.getName() ); + buf.append( "} " ); + final String newVersion = winner.toString(); + int padding = + INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 + + getOutputLineWidthOffset(); + while ( buf.length() < padding ) + { + buf.append( '.' ); + } + buf.append( ' ' ); + buf.append( currentVersion ); + buf.append( " -> " ); + buf.append( newVersion ); + updates.add( buf.toString() ); } - buf.append( ' ' ); - buf.append( currentVersion ); - buf.append( " -> " ); - buf.append( newVersion ); - updates.add( buf.toString() ); - } - else - { - StringBuilder buf = new StringBuilder(); - buf.append( "${" ); - buf.append( property.getName() ); - buf.append( "} " ); - int padding = INFO_PAD_SIZE - currentVersion.length() + getOutputLineWidthOffset(); - while ( buf.length() < padding ) + else { - buf.append( '.' ); + StringBuilder buf = new StringBuilder(); + buf.append( "${" ); + buf.append( property.getName() ); + buf.append( "} " ); + int padding = INFO_PAD_SIZE - currentVersion.length() + getOutputLineWidthOffset(); + while ( buf.length() < padding ) + { + buf.append( '.' ); + } + buf.append( ' ' ); + buf.append( currentVersion ); + current.add( buf.toString() ); } - buf.append( ' ' ); - buf.append( currentVersion ); - current.add( buf.toString() ); } - + catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), + property.getVersion(), e.getMessage() ) ); + } } logLine( false, "" ); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java index 5ab759516d..f8f7af3285 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java @@ -58,11 +58,21 @@ public Map getDependencyVersions() return dependencyVersions; } + /** + * Returns true if a new version of the artifact fulfilling the criteria (whether to include snapshots) can be found + * + * @return true if a new version can be found + */ public boolean isArtifactUpdateAvailable() { return artifactVersions.getAllUpdates( UpdateScope.ANY, includeSnapshots ).length > 0; } + /** + * Returns true if a new version of the dependency can be found + * + * @return true if a new version can be found + */ public boolean isDependencyUpdateAvailable() { for ( ArtifactVersions versions : dependencyVersions.values() ) @@ -76,6 +86,11 @@ public boolean isDependencyUpdateAvailable() return false; } + /** + * Returns true if a new version of the dependency can be found + * + * @return true if a new version can be found + */ public boolean isUpdateAvailable() { return isArtifactUpdateAvailable() || isDependencyUpdateAvailable(); diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 193fbc347f..937b68d170 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -30,6 +30,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -37,6 +38,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -294,8 +296,15 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom ) int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); // TODO: Check if we could add allowDowngrade ? - updatePropertyToNewestVersion( pom, property, version, currentVersion, false, segment ); - + try + { + updatePropertyToNewestVersion( pom, property, version, currentVersion, false, segment ); + } + catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), + property.getVersion(), e.getMessage() ) ); + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index cb1c8fcee1..c53e6eca0c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -24,12 +24,14 @@ import java.util.Map; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -166,21 +168,30 @@ protected void update( ModifiedPomXMLEventReader pom ) { int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); - - if ( targetVersion != null ) + try { - for ( final ArtifactAssociation association : version.getAssociations() ) + ArtifactVersion targetVersion = + updatePropertyToNewestVersion( pom, property, version, currentVersion, + allowDowngrade, segment ); + + if ( targetVersion != null ) { - if ( ( isIncluded( association.getArtifact() ) ) ) + for ( final ArtifactAssociation association : version.getAssociations() ) { - this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, - targetVersion.toString() ); + if ( ( isIncluded( association.getArtifact() ) ) ) + { + this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), + association.getArtifactId(), currentVersion, + targetVersion.toString() ); + } } } } + catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), + property.getVersion(), e.getMessage() ) ); + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 6390c29a59..5426698a06 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -24,12 +24,14 @@ import java.util.Map; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -146,18 +148,26 @@ protected void update( ModifiedPomXMLEventReader pom ) } int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); - - if ( targetVersion != null ) + try { - for ( final ArtifactAssociation association : version.getAssociations() ) + ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, + allowDowngrade, segment ); + + if ( targetVersion != null ) { - this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, - targetVersion.toString() ); + for ( final ArtifactAssociation association : version.getAssociations() ) + { + this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), + association.getArtifactId(), currentVersion, + targetVersion.toString() ); + } } } + catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), + property.getVersion(), e.getMessage() ) ); + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 4667cfd781..e4b09dd03b 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -41,6 +41,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -162,33 +163,41 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection 0 ) + try { - String newVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + ArtifactVersion[] newer = versions.getNewerVersions( version, segment, false ); + newer = filterVersionsWithIncludes( newer, artifact ); + + ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( selectedVersion, newer ); + if ( filteredVersions.length > 0 ) { - if ( artifact.getId().equals( getProject().getParentArtifact().getId() ) - && isProcessingParent() ) + String newVersion = filteredVersions[filteredVersions.length - 1].toString(); + if ( getProject().getParent() != null ) { - if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) + if ( artifact.getId().equals( getProject().getParentArtifact().getId() ) + && isProcessingParent() ) { - getLog().debug( "Made parent update from " + version + " to " + newVersion ); + if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) + { + getLog().debug( "Made parent update from " + version + " to " + newVersion ); + } } } - } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + newVersion, getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - this.getChangeRecorder().recordUpdate( "useLatestReleases", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); + this.getChangeRecorder().recordUpdate( "useLatestReleases", dep.getGroupId(), + dep.getArtifactId(), version, newVersion ); + } } } + catch ( InvalidSegmentException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), + dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + } } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index c20ca16029..7f2cc749de 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -39,6 +39,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -167,58 +168,66 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); + try + { + ArtifactVersion upperBound = + segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); + ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); + getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - String latestVersion; - ArrayList snapshotsOnly = new ArrayList<>(); + String latestVersion; + ArrayList snapshotsOnly = new ArrayList<>(); - for ( ArtifactVersion artifactVersion : newer ) - { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) + for ( ArtifactVersion artifactVersion : newer ) { - snapshotsOnly.add( artifactVersion ); + String newVersion = artifactVersion.toString(); + if ( matchSnapshotRegex.matcher( newVersion ).matches() ) + { + snapshotsOnly.add( artifactVersion ); + } } - } - getLog().debug( "Snapshot Only versions " + snapshotsOnly ); + getLog().debug( "Snapshot Only versions " + snapshotsOnly ); - ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( - selectedVersion, snapshotsOnly.toArray( new ArtifactVersion[0] ) ); - getLog().debug( "Filtered versions " + Arrays.asList( filteredVersions ) ); + ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( + selectedVersion, snapshotsOnly.toArray( new ArtifactVersion[0] ) ); + getLog().debug( "Filtered versions " + Arrays.asList( filteredVersions ) ); - if ( filteredVersions.length > 0 ) - { - latestVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + if ( filteredVersions.length > 0 ) { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) + latestVersion = filteredVersions[filteredVersions.length - 1].toString(); + if ( getProject().getParent() != null ) { - if ( PomHelper.setProjectParentVersion( pom, latestVersion ) ) + final Artifact parentArtifact = getProject().getParentArtifact(); + if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) { - getLog().debug( "Made parent update from " + version + " to " + latestVersion ); - - this.getChangeRecorder() - .recordUpdate( "useLatestSnapshots", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), version, latestVersion ); + if ( PomHelper.setProjectParentVersion( pom, latestVersion ) ) + { + getLog().debug( "Made parent update from " + version + " to " + latestVersion ); + + this.getChangeRecorder() + .recordUpdate( "useLatestSnapshots", parentArtifact.getGroupId(), + parentArtifact.getArtifactId(), version, latestVersion ); + } } } - } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - latestVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + latestVersion ); + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + latestVersion, getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + latestVersion ); - this.getChangeRecorder().recordUpdate( "useLatestSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, latestVersion ); + this.getChangeRecorder().recordUpdate( "useLatestSnapshots", dep.getGroupId(), + dep.getArtifactId(), version, latestVersion ); + } } } + catch ( InvalidSegmentException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), + dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + } } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index cbfb7adf9a..55640b1c92 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -145,7 +146,8 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + int unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); MajorMinorIncrementalFilter majorMinorIncfilter = new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); @@ -176,38 +178,46 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection 0 ) + try { - String newVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + ArtifactVersion[] newerVersions = versions.getNewerVersions( version, unchangedSegment, allowSnapshots, + allowDowngrade ); + + ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( selectedVersion, newerVersions ); + if ( filteredVersions.length > 0 ) { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) + String newVersion = filteredVersions[filteredVersions.length - 1].toString(); + if ( getProject().getParent() != null ) { - if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) + final Artifact parentArtifact = getProject().getParentArtifact(); + if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) { - getLog().debug( "Made parent update from " + version + " to " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useLatestVersions", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), version, - newVersion ); + if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) + { + getLog().debug( "Made parent update from " + version + " to " + newVersion ); + + this.getChangeRecorder().recordUpdate( "useLatestVersions", parentArtifact.getGroupId(), + parentArtifact.getArtifactId(), version, + newVersion ); + } } } - } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, newVersion, - getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + newVersion, + getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - this.getChangeRecorder().recordUpdate( "useLatestVersions", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); + this.getChangeRecorder().recordUpdate( "useLatestVersions", dep.getGroupId(), + dep.getArtifactId(), version, newVersion ); + } } } - + catch ( InvalidSegmentException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), + dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index a53ab8023d..520e12f695 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -149,27 +150,35 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - for ( ArtifactVersion artifactVersion : newer ) + try { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) + ArtifactVersion upperBound = + segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); + ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); + getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); + for ( ArtifactVersion artifactVersion : newer ) { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) + String newVersion = artifactVersion.toString(); + if ( matchSnapshotRegex.matcher( newVersion ).matches() ) { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useNextSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + newVersion, getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + + this.getChangeRecorder().recordUpdate( "useNextSnapshots", dep.getGroupId(), + dep.getArtifactId(), version, newVersion ); + } + break; } - break; } } + catch ( InvalidSegmentException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), + dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + } } } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 1cd11640fa..9aa9fbf1df 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.Collections; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; @@ -32,6 +33,9 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; +import static java.util.Optional.empty; +import static java.util.Optional.of; + /** * Base class for {@link org.codehaus.mojo.versions.api.VersionDetails}. * @@ -239,9 +243,12 @@ public final ArtifactVersion[] getNewerVersions( String version, boolean include * @param includeSnapshots whether snapshot versions should be included * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, int, boolean, boolean)} instead * @return array of newer versions fulfilling the criteria + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) */ @Deprecated public final ArtifactVersion[] getNewerVersions( String version, int upperBoundSegment, boolean includeSnapshots ) + throws InvalidSegmentException { return getNewerVersions( version, upperBoundSegment, includeSnapshots, false ); } @@ -256,9 +263,12 @@ public final ArtifactVersion[] getNewerVersions( String version, int upperBoundS * @param allowDowngrade whether to allow downgrading if the current version is a snapshots and snapshots * are disallowed * @return array of newer versions fulfilling the criteria + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) */ public final ArtifactVersion[] getNewerVersions( String versionString, int upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade ) + throws InvalidSegmentException { ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); ArtifactVersion lowerBound = @@ -368,16 +378,19 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactV } public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException { return getOldestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); } public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException { return getNewestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); } public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException { return getAllUpdates( currentVersion, updateScope, isIncludeSnapshots() ); } @@ -505,24 +518,48 @@ public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean inclu return getVersions( versionRange, getCurrentVersion(), null, includeSnapshots, false, true ); } - protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, int segment ) + /** + * Returns the lower bound version based on the given artifact version + * and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, + * implying that there is also no string designation of the lower bound version. + * + * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed + * @param unchangedSegment 0-based index of the first segment not to be changed; -1 means everything can change + * @return {@link ArtifactVersion} the lowest artifact version with the given segment held or null if no such + * version can be found + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) + */ + protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, int unchangedSegment ) + throws InvalidSegmentException { - String lowerBound = getLowerBound( version, segment ); - return lowerBound != null ? new DefaultArtifactVersion( lowerBound ) : null; + Optional lowerBound = getLowerBound( version, unchangedSegment ); + return lowerBound.map( DefaultArtifactVersion::new ).orElse( null ); } - protected String getLowerBound( ArtifactVersion version, int segment ) + /** + * Returns the string designation of the lower bound version based on the given artifact version + * and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, + * implying that there is also no string designation of the lower bound version. + * + * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed + * @param unchangedSegment 0-based index of the first segment not to be changed; -1 means everything can change + * @return {@link Optional} string containing the lowest artifact version with the given segment held + * @throws InvalidSegmentException if the requested segment is outside of the bounds (less than 1 or greater than + * the segment count) + */ + protected Optional getLowerBound( ArtifactVersion version, int unchangedSegment ) + throws InvalidSegmentException { - if ( segment < 0 ) + if ( unchangedSegment < 0 ) { - return null; + return empty(); } int segmentCount = getVersionComparator().getSegmentCount( version ); - if ( segment > segmentCount ) + if ( unchangedSegment > segmentCount ) { - throw new InvalidSegmentException( segment, segmentCount, - version.toString() ); + throw new InvalidSegmentException( unchangedSegment, segmentCount, version ); } StringBuilder newVersion = new StringBuilder(); @@ -530,26 +567,26 @@ protected String getLowerBound( ArtifactVersion version, int segment ) if ( segmentCount > 0 ) { newVersion.append( "." ) - .append( segment >= 1 ? version.getMinorVersion() : 0 ); + .append( unchangedSegment >= 1 ? version.getMinorVersion() : 0 ); } if ( segmentCount > 1 ) { newVersion.append( "." ) - .append( segment >= 2 ? version.getIncrementalVersion() : 0 ); + .append( unchangedSegment >= 2 ? version.getIncrementalVersion() : 0 ); } if ( segmentCount > 2 ) { if ( version.getQualifier() != null ) { newVersion.append( "-" ) - .append( segment >= 3 ? version.getQualifier() : "0" ); + .append( unchangedSegment >= 3 ? version.getQualifier() : "0" ); } else { newVersion.append( "-" ) - .append( segment >= 3 ? version.getBuildNumber() : "0" ); + .append( unchangedSegment >= 3 ? version.getBuildNumber() : "0" ); } } - return newVersion.toString(); + return of( newVersion.toString() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 4ab81204b5..be119df8df 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -36,8 +37,9 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; /** @@ -154,11 +156,9 @@ private VersionComparator[] lookupComparators() * @return The versions that can be resolved from the supplied Artifact instances or an empty array if no version * can be resolved (i.e. the property is not associated with any of the supplied artifacts or the property * is also associated to an artifact that has not been provided). - * @throws org.apache.maven.plugin.MojoExecutionException When things go wrong. * @since 1.0-alpha-3 */ public ArtifactVersion[] getVersions( Collection artifacts ) - throws MojoExecutionException { List result = new ArrayList<>(); // go through all the associations @@ -307,44 +307,46 @@ public String toString() public ArtifactVersion getNewestVersion( String currentVersion, Property property, boolean allowSnapshots, List reactorProjects, VersionsHelper helper ) - throws MojoExecutionException + throws InvalidVersionSpecificationException, InvalidSegmentException { return getNewestVersion( currentVersion, property, allowSnapshots, reactorProjects, helper, false, -1 ); } + /** + * Retrieves the newest artifact version for the given property-denoted artifact or {@code null} if no newer + * version could be found. + * + * @param currentVersion current version of the artifact + * @param property property name indicating the artifact + * @param allowSnapshots whether snapshots should be considered + * @param reactorProjects collection of reactor projects + * @param helper VersionHelper object + * @param allowDowngrade whether downgrades should be allowed + * @param unchangedSegment indicates the (0-based) most major segment which needs to stay unchanged; + * -1 means that the whole version can be changed + * @return newest artifact version fulfilling the criteria or null if no newer version could be found + * @throws InvalidSegmentException thrown if the {@code unchangedSegment} is not valid (e.g. greater than the number + * of segments in the version string) + * @throws InvalidVersionSpecificationException thrown if the version string in the property is not valid + */ public ArtifactVersion getNewestVersion( String currentVersion, Property property, boolean allowSnapshots, - List reactorProjects, VersionsHelper helper, boolean allowDowngrade, - int segment ) - throws MojoExecutionException + Collection reactorProjects, VersionsHelper helper, + boolean allowDowngrade, int unchangedSegment ) + throws InvalidSegmentException, InvalidVersionSpecificationException { final boolean includeSnapshots = !property.isBanSnapshots() && allowSnapshots; helper.getLog().debug( "getNewestVersion(): includeSnapshots='" + includeSnapshots + "'" ); helper.getLog().debug( "Property ${" + property.getName() + "}: Set of valid available versions is " + Arrays.asList( getVersions( includeSnapshots ) ) ); - VersionRange range; - try - { - if ( property.getVersion() != null ) - { - range = VersionRange.createFromVersionSpec( property.getVersion() ); - helper.getLog().debug( "Property ${" + property.getName() + "}: Restricting results to " + range ); - } - else - { - range = null; - helper.getLog().debug( "Property ${" + property.getName() + "}: Restricting results to " + range ); - } - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } + VersionRange range = property.getVersion() != null + ? VersionRange.createFromVersionSpec( property.getVersion() ) : null; + helper.getLog().debug( "Property ${" + property.getName() + "}: Restricting results to " + range ); ArtifactVersion lowerBoundArtifactVersion = helper.createArtifactVersion( currentVersion ); if ( allowDowngrade ) { - String updatedVersion = getLowerBound( lowerBoundArtifactVersion, segment ); - lowerBoundArtifactVersion = updatedVersion != null ? helper.createArtifactVersion( updatedVersion ) : null; + Optional updatedVersion = getLowerBound( lowerBoundArtifactVersion, unchangedSegment ); + lowerBoundArtifactVersion = updatedVersion.map( helper::createArtifactVersion ).orElse( null ); } if ( helper.getLog().isDebugEnabled() ) { @@ -352,9 +354,9 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert } ArtifactVersion upperBound = null; - if ( segment != -1 ) + if ( unchangedSegment != -1 ) { - upperBound = getVersionComparator().incrementSegment( lowerBoundArtifactVersion, segment ); + upperBound = getVersionComparator().incrementSegment( lowerBoundArtifactVersion, unchangedSegment ); helper.getLog().debug( "Property ${" + property.getName() + "}: upperBound is: " + upperBound ); } ArtifactVersion result = @@ -417,6 +419,7 @@ else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper helper, int segment, boolean includeSnapshots, VersionRange range ) + throws InvalidSegmentException { ArtifactVersion lowerBound = helper.createArtifactVersion( currentVersion ); ArtifactVersion upperBound = null; @@ -489,7 +492,7 @@ public int getSegmentCount( ArtifactVersion v ) return result; } - public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) + public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException { if ( !isAssociated() ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java index 0cefcec07e..e3bdb6d16a 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java +++ b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java @@ -26,6 +26,7 @@ import java.util.Map; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; /** @@ -51,10 +52,18 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getOldestVersion( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 + ? null + : versionDetails.getOldestVersion( currentVersion, + versionComparator.incrementSegment( currentVersion, 2 ), + includeSnapshots, false, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -62,10 +71,18 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getNewestVersion( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 + ? null + : versionDetails.getNewestVersion( currentVersion, + versionComparator.incrementSegment( currentVersion, 2 ), + includeSnapshots, false, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -73,10 +90,17 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getVersions( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 ? null + : versionDetails.getVersions( currentVersion, + versionComparator.incrementSegment( currentVersion, 2 ), + includeSnapshots, false, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } }; @@ -94,10 +118,17 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 ? null + : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 2 ), + versionComparator.incrementSegment( currentVersion, 1 ), + includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -105,10 +136,17 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 ? null + : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 2 ), + versionComparator.incrementSegment( currentVersion, 1 ), + includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -116,10 +154,17 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 3 ? null + : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 2 ), + versionComparator.incrementSegment( currentVersion, 1 ), includeSnapshots, true, + false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } }; @@ -137,10 +182,17 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 2 ? null + : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 1 ), + versionComparator.incrementSegment( currentVersion, 0 ), + includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -148,10 +200,17 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 2 ? null + : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 1 ), + versionComparator.incrementSegment( currentVersion, 0 ), includeSnapshots, true, + false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -159,10 +218,17 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 2 ? null + : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 1 ), + versionComparator.incrementSegment( currentVersion, 0 ), + includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } }; @@ -180,9 +246,16 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 1 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 0 ), - null, includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 1 ? null + : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 0 ), + null, includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -190,9 +263,16 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 1 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 0 ), - null, includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 1 ? null + : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 0 ), + null, includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } /** {@inheritDoc} */ @@ -200,9 +280,17 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV boolean includeSnapshots ) { VersionComparator versionComparator = versionDetails.getVersionComparator(); - return versionComparator.getSegmentCount( currentVersion ) < 1 ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 0 ), null, - includeSnapshots, true, false ); + try + { + return versionComparator.getSegmentCount( currentVersion ) < 1 + ? null + : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 0 ), + null, includeSnapshots, true, false ); + } + catch ( InvalidSegmentException e ) + { + throw new RuntimeException( e ); + } } }; @@ -432,6 +520,7 @@ public static UpdateScope[] values() * @return The update classification. */ public static UpdateScope classifyUpdate( VersionComparator comparator, ArtifactVersion from, ArtifactVersion to ) + throws InvalidSegmentException { if ( comparator.compare( from, to ) >= 0 ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 144121e528..65ea069672 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -21,6 +21,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; /** @@ -266,7 +267,8 @@ ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion low * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ); + ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -278,7 +280,8 @@ ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion low * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ); + ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -288,7 +291,8 @@ ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion low * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ); + ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ) + throws InvalidSegmentException; /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or @@ -302,7 +306,7 @@ ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion low * @since 1.0-beta-1 */ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, - boolean includeSnapshots ); + boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -316,7 +320,7 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope upd * @since 1.0-beta-1 */ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, - boolean includeSnapshots ); + boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -328,7 +332,7 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope upd * @since 1.0-beta-1 */ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope, - boolean includeSnapshots ); + boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or @@ -449,7 +453,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( UpdateScope updateScope ); + ArtifactVersion getOldestUpdate( UpdateScope updateScope ) throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -460,7 +464,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( UpdateScope updateScope ); + ArtifactVersion getNewestUpdate( UpdateScope updateScope ) throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -469,7 +473,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( UpdateScope updateScope ); + ArtifactVersion[] getAllUpdates( UpdateScope updateScope ) throws InvalidSegmentException; /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or @@ -481,7 +485,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( UpdateScope updateScope, boolean includeSnapshots ); + ArtifactVersion getOldestUpdate( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -493,7 +497,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( UpdateScope updateScope, boolean includeSnapshots ); + ArtifactVersion getNewestUpdate( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -503,7 +507,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( UpdateScope updateScope, boolean includeSnapshots ); + ArtifactVersion[] getAllUpdates( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; /** * Returns the oldest version newer than the current version, but within the the specified update scope or diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 29d005cbc7..afed874df2 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -56,7 +56,7 @@ public final int getSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ - public final ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) + public final ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException { if ( VersionComparators.isSnapshot( v ) ) { @@ -66,7 +66,8 @@ public final ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) return innerIncrementSegment( v, segment ); } - protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ); + protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) + throws InvalidSegmentException; /** * Returns a hash code value for the comparator class. diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java b/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java index e03c794f49..ce704ff423 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java @@ -19,22 +19,56 @@ * under the License. */ +import org.apache.maven.artifact.versioning.ArtifactVersion; + /** * Represents an invalid segment being identified within a version. */ -public class InvalidSegmentException - extends RuntimeException +public class InvalidSegmentException extends Exception { + private final int segment; + + private final int segmentCount; + + private final ArtifactVersion version; + /** - * Constructs a new exception. + * Constructs the exception object * * @param segment the invalid segment index. * @param segmentCount the number of segments. - * @param version the version string. + * @param version the version object. */ - public InvalidSegmentException( int segment, int segmentCount, String version ) + public InvalidSegmentException( int segment, int segmentCount, ArtifactVersion version ) { super( String.format( "Invalid segment, %d, for the %d segment version: '%s'", segment, segmentCount, - version ) ); + version.toString() ) ); + this.segment = segment; + this.segmentCount = segmentCount; + this.version = version; + } + + /** + * @return segment + */ + public int getSegment() + { + return segment; + } + + /** + * @return segment count + */ + public int getSegmentCount() + { + return segmentCount; + } + + /** + * @return version object + */ + public ArtifactVersion getVersion() + { + return version; } } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index e13d3da951..b0ee00c9cc 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -92,12 +92,12 @@ protected int innerGetSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException { int segmentCount = innerGetSegmentCount( v ); if ( segment < 0 || segment >= segmentCount ) { - throw new InvalidSegmentException( segment, segmentCount, v.toString() ); + throw new InvalidSegmentException( segment, segmentCount, v ); } String version = v.toString(); if ( segmentCount == 1 ) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java index b26e88517a..335538a0c7 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java @@ -52,12 +52,12 @@ protected int innerGetSegmentCount( ArtifactVersion v ) return tok.countTokens(); } - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException { final int segmentCount = getSegmentCount( v ); if ( segment < 0 || segment > segmentCount ) { - throw new InvalidSegmentException( segment, segmentCount, v.toString() ); + throw new InvalidSegmentException( segment, segmentCount, v ); } final String version = v.toString(); StringBuilder result = new StringBuilder( version.length() + 10 ); diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java index 1468717b9b..85443c2767 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java @@ -163,12 +163,12 @@ protected int innerGetSegmentCount( ArtifactVersion v ) * {@inheritDoc} */ @SuppressWarnings( "checkstyle:MethodLength" ) - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException { final int segmentCount = innerGetSegmentCount( v ); if ( segment < 0 || segment > segmentCount ) { - throw new InvalidSegmentException( segment, segmentCount, v.toString() ); + throw new InvalidSegmentException( segment, segmentCount, v ); } final String version = v.toString(); StringBuilder buf = new StringBuilder(); diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index ee2956a7cb..fbf6fb14e6 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -46,5 +46,5 @@ public interface VersionComparator * @return An artifact version with the specified segment incremented. * @since 1.0-beta-1 */ - ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, int segment ); + ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, int segment ) throws InvalidSegmentException; } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 5ac43e263b..fbd94b2c0e 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -47,8 +47,8 @@ public void setUp() throws Exception { Dependency dependency = invocation.getArgument( 0 ); return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), dependency.getClassifier() != null - ? dependency.getClassifier() : "default", null ); + dependency.getScope(), dependency.getType(), + dependency.getClassifier() != null ? dependency.getClassifier() : "default", null ); } ); ArtifactMetadataSource artifactMetadataSourceMock = mock( ArtifactMetadataSource.class ); @@ -63,6 +63,15 @@ public void setUp() throws Exception new DefaultArtifactVersion( "1.0.0" ), new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), new DefaultArtifactVersion( "0.9.0" ) ); } + else if ( "poison-artifact".equals( artifact.getArtifactId() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( "1.1.1.1-SNAPSHOT" ), + new DefaultArtifactVersion( "1.1.1.0" ), + new DefaultArtifactVersion( "1.1.1.0-SNAPSHOT" ), + new DefaultArtifactVersion( "1.0.0.0" ), + new DefaultArtifactVersion( "1.0.0.0-SNAPSHOT" ), + new DefaultArtifactVersion( "0.9.0.0" ) ); + } fail(); return null; } ); @@ -114,8 +123,7 @@ public void testDependenciesDowngradeIncremental() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.1.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -136,8 +144,7 @@ public void testDependenciesDowngradeMinor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.0.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.0.0" ) ) ); } @Test @@ -158,8 +165,7 @@ public void testDependenciesDowngradeMajor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "0.9.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "0.9.0" ) ) ); } @Test @@ -182,8 +188,7 @@ public void testDependencyManagementDowngrade() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.1.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -197,8 +202,9 @@ public void testParentDowngrade() setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); setVariableValueToObject( mojo, "allowDowngrade", true ); - mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "dependency-artifact", - "1.1.1-SNAPSHOT", "compile", "pom", "default", null ) ); + mojo.getProject().setParentArtifact( + new DefaultArtifact( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "compile", "pom", + "default", null ) ); mojo.getProject().setParent( new MavenProject() {{ setGroupId( mojo.getProject().getParentArtifact().getGroupId() ); @@ -213,8 +219,39 @@ public void testParentDowngrade() .thenReturn( true ); mojo.update( null ); } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + } + + @Test + public void testPoisonDependencyVersion() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + mojo.getProject().getModel().setDependencies( Arrays.asList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", + "default", "pom", SCOPE_COMPILE ), + DependencyBuilder.dependencyWith( "default-group", "poison-artifact", "1.1.1.1-SNAPSHOT", + "default", "pom", SCOPE_COMPILE ) + ) ); + + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowDowngrade", true ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + // So, the regular update should take place despite an irregular, or — if I may — "poison", dependency + // being present in the dependency list assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.1.0" ) ) ); + "1.0.0" ) ) ); } + } \ No newline at end of file diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index e3aa2dfd24..d691557152 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -42,7 +42,7 @@ public void testSegmentCounting() @Test public void testSegmentIncrementing() - throws Exception + throws InvalidSegmentException { assertIncrement( "6", "5", 0 ); assertIncrement( "6.0", "5.0", 0 ); @@ -58,7 +58,7 @@ public void testSegmentIncrementing() assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", 3 ); } - private void assertIncrement( String expected, String initial, int segment ) + private void assertIncrement( String expected, String initial, int segment ) throws InvalidSegmentException { assertEquals( expected, instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java index d6ec074b96..06bdbf7f3d 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java @@ -38,24 +38,24 @@ public class VersionComparatorsTest }; @Test - public void testMavenVersionComparator() + public void testMavenVersionComparator() throws InvalidSegmentException { assertVersions( new MavenVersionComparator() ); } @Test - public void testMercuryVersionComparator() + public void testMercuryVersionComparator() throws InvalidSegmentException { assertVersions( new MercuryVersionComparator() ); } @Test - public void testNumericVersionComparator() + public void testNumericVersionComparator() throws InvalidSegmentException { assertVersions( new NumericVersionComparator() ); } - public void assertVersions( VersionComparator instance ) + public void assertVersions( VersionComparator instance ) throws InvalidSegmentException { for ( int i = 0; i < versionDataset.length; i++ ) { @@ -64,7 +64,7 @@ public void assertVersions( VersionComparator instance ) } } - public void assertLater( String version, VersionComparator instance ) + public void assertLater( String version, VersionComparator instance ) throws InvalidSegmentException { ArtifactVersion v1 = new DefaultArtifactVersion( version ); int count = instance.getSegmentCount( v1 ); From f9a90e52d9b65ce289c14fdea855e1e89ec1ebf2 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 5 Sep 2022 18:44:42 +0200 Subject: [PATCH 111/441] Amended #258: Adding plugin and plugin management dependency includes/excludes --- .../invoker.properties | 9 ++ .../pom.xml | 47 ++++++ .../verify.groovy | 18 +++ .../verify.groovy | 1 - .../verify.groovy | 1 - .../verify.groovy | 1 - .../verify.groovy | 1 - .../verify.groovy | 1 - .../verify.groovy | 1 - .../DisplayDependencyUpdatesMojo.java | 153 ++++++++++++++++-- .../DisplayDependencyUpdatesMojoTest.java | 47 ++++++ 11 files changed, 264 insertions(+), 16 deletions(-) create mode 100644 src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy create mode 100644 src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties new file mode 100644 index 0000000000..c9c201cafa --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties @@ -0,0 +1,9 @@ +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dverbose=true -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 -DprocessPluginDependenciesInPluginManagement=false -DpluginDependencyIncludes=localhost:dummy-api + +invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dverbose=true -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -DprocessPluginDependenciesInPluginManagement=false -DpluginDependencyExcludes=localhost:dummy-api + +invoker.goals.3=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dverbose=true -Dversions.outputFile=./output3.txt -DoutputEncoding=UTF-8 -DprocessPluginDependencies=false -DpluginManagementDependencyIncludes=localhost:dummy-impl + +invoker.goals.4=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dverbose=true -Dversions.outputFile=./output4.txt -DoutputEncoding=UTF-8 -DprocessPluginDependencies=false -DpluginManagementDependencyExcludes=localhost:dummy-impl + +invoker.goals.5=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dverbose=true -Dversions.outputFile=./output5.txt -DoutputEncoding=UTF-8 -DprocessPluginDependencies=false -DpluginManagementDependencyExcludes=localhost \ No newline at end of file diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml new file mode 100644 index 0000000000..aebe5f65d1 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes + 1.0 + pom + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.0 + + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-impl + 1.0 + + + localhost + dummy-parent2 + 1.0 + + + + + + + \ No newline at end of file diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy new file mode 100644 index 0000000000..cdce154d8a --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy @@ -0,0 +1,18 @@ +output = new File(basedir, "output1.txt").text +assert output =~ /localhost:dummy-api/ +assert output !=~ /localhost:dummy-impl/ + +output = new File(basedir, "output2.txt").text +assert output !=~ /localhost:dummy-api/ +assert output =~ /localhost:dummy-impl/ + +output = new File(basedir, "output3.txt").text +assert output =~ /localhost:dummy-impl/ +assert output !=~ /localhost:dummy-parent2/ + +output = new File(basedir, "output4.txt").text +assert output !=~ /localhost:dummy-impl/ +assert output =~ /localhost:dummy-parent2/ + +output = new File(basedir, "output5.txt") +assert !output.exists( ) diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy index aadb8bd46a..d2db90cc15 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy @@ -4,7 +4,6 @@ assert buildLog.text.contains( """ [INFO] The following dependencies in Dependencies have newer versions: [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy index 4845c5558e..9441f237ea 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy @@ -5,7 +5,6 @@ assert buildLog.text.contains(""" [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy index 4845c5558e..9441f237ea 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy @@ -5,7 +5,6 @@ assert buildLog.text.contains(""" [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy index 347f310aee..f324a47060 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy @@ -4,7 +4,6 @@ assert buildLog.text.contains(""" [INFO] The following dependencies in Dependencies have newer versions: [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy index df3e5a07e1..f6bbd04f77 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy @@ -5,7 +5,6 @@ assert buildLog.text.contains(""" [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy index df3e5a07e1..f6bbd04f77 100644 --- a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy @@ -5,7 +5,6 @@ assert buildLog.text.contains(""" [INFO] localhost:dummy-api ....................................... 1.0 -> 3.0 [INFO] localhost:dummy-impl ...................................... 1.0 -> 2.2 [INFO] -[INFO] ------------------------------------------------------------------------ """.replaceAll( "\n", System.lineSeparator() ) ) return true diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index f4cf8274bb..73a4f353a1 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -28,6 +28,7 @@ import java.util.Objects; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -49,6 +50,8 @@ import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.util.StringUtils; +import static org.apache.commons.lang3.StringUtils.countMatches; + /** * Displays all dependencies that have newer versions available. * It will also display dependencies which are used by a plugin or @@ -107,7 +110,7 @@ public class DisplayDependencyUpdatesMojo *

* *

- * Example: "mygroup:artifact:*,*:*:*:*:*:compile" + * Example: {@code "mygroup:artifact:*,*:*:*:*:*:compile"} *

* * @since 2.12.0 @@ -129,7 +132,7 @@ public class DisplayDependencyUpdatesMojo *

* *

- * Example: "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system" + * Example: {@code "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system"} *

* * @since 2.12.0 @@ -159,7 +162,7 @@ public class DisplayDependencyUpdatesMojo *

* *

- * Example: "mygroup:artifact:*,*:*:*:*:*:compile" + * Example: {@code "mygroup:artifact:*,*:*:*:*:*:compile"} *

* * @since 2.12.0 @@ -181,7 +184,7 @@ public class DisplayDependencyUpdatesMojo *

* *

- * Example: "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system" + * Example: {@code "mygroup:artifact:*,*:*:*:*:*:provided,*:*:*:*:*:system"} *

* * @since 2.12.0 @@ -257,6 +260,77 @@ public class DisplayDependencyUpdatesMojo @Parameter( property = "verbose", defaultValue = "false" ) private boolean verbose; + /** + *

Only take these artifacts into consideration:
+ * Comma-separated list of {@code groupId:[artifactId[:version]]} patterns

+ * + *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: {@code "mygroup:artifact:*,othergroup:*,anothergroup"} + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "pluginDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + private List pluginDependencyIncludes; + + /** + *

Exclude these artifacts into consideration:
+ * Comma-separated list of {@code groupId:[artifactId[:version]]} patterns

+ * + *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: {@code "mygroup:artifact:*,othergroup:*,anothergroup"} + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "pluginDependencyExcludes" ) + private List pluginDependencyExcludes; + + /** + *

Only take these artifacts into consideration:
+ * Comma-separated list of {@code groupId:[artifactId[:version]]} patterns

+ + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: {@code "mygroup:artifact:*,othergroup:*,anothergroup"} + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "pluginManagementDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + private List pluginManagementDependencyIncludes; + + /** + *

Exclude these artifacts into consideration:
+ * Comma-separated list of {@code groupId:[artifactId[:version]]} patterns

+ * + *

+ * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + *

+ * + *

+ * Example: {@code "mygroup:artifact:*,othergroup:*,anothergroup"} + *

+ * + * @since 2.12.0 + */ + @Parameter( property = "pluginManagementDependencyExcludes" ) + private List pluginManagementDependencyExcludes; + // --------------------- GETTER / SETTER METHODS --------------------- private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) @@ -392,6 +466,8 @@ public void execute() { logInit(); + validateInput(); + Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); DependencyManagement projectDependencyManagement = getProjectDependencyManagement( getProject() ); if ( projectDependencyManagement != null ) @@ -480,11 +556,16 @@ public void execute() } if ( isProcessPluginDependenciesInDependencyManagement() ) { + pluginDependenciesInPluginManagement = + filterPluginManagementIncludes( pluginDependenciesInPluginManagement ); + logUpdates( getHelper().lookupDependenciesUpdates( pluginDependenciesInPluginManagement, false ), "pluginManagement of plugins" ); } if ( isProcessingPluginDependencies() ) { + pluginDependencies = filterPluginDependencyIncludes( pluginDependencies ); + logUpdates( getHelper().lookupDependenciesUpdates( pluginDependencies, false ), "Plugin Dependencies" ); } } @@ -494,15 +575,56 @@ public void execute() } } + private void validateInput() throws MojoExecutionException + { + validateGAVList( dependencyIncludes, 6, "dependencyIncludes" ); + validateGAVList( dependencyExcludes, 6, "dependencyExcludes" ); + validateGAVList( dependencyManagementIncludes, 6, "dependencyManagementIncludes" ); + validateGAVList( dependencyManagementIncludes, 6, "dependencyManagementExcludes" ); + validateGAVList( pluginDependencyIncludes, 3, "pluginDependencyIncludes" ); + validateGAVList( pluginDependencyExcludes, 3, "pluginDependencyExcludes" ); + validateGAVList( pluginManagementDependencyIncludes, 3, "pluginManagementDependencyIncludes" ); + validateGAVList( pluginManagementDependencyExcludes, 3, "pluginManagementDependencyExcludes" ); + } + + /** + * Validates a list of GAV strings + * @param gavList list of the input GAV strings + * @param numSections number of sections in the GAV to verify against + * @param argumentName argument name to indicate in the exception + * @throws MojoExecutionException if the argument is invalid + */ + static void validateGAVList( List gavList, int numSections, String argumentName ) + throws MojoExecutionException + { + if ( gavList != null && gavList.stream().anyMatch( gav -> countMatches( gav, ":" ) >= numSections ) ) + { + throw new MojoExecutionException( argumentName + " should not contain more than 6 segments" ); + } + } + private Set filterDependencyIncludes( Set dependencies ) { - return filterDependencies( dependencies, dependencyIncludes, dependencyExcludes, "dependencies" ); + return filterDependencies( dependencies, dependencyIncludes, dependencyExcludes, "Dependencies" ); } private Set filterDependencyManagementIncludes( Set dependencyManagement ) { return filterDependencies( dependencyManagement, - dependencyManagementIncludes, dependencyManagementExcludes, "dependecyManagement" ); + dependencyManagementIncludes, dependencyManagementExcludes, "Dependecy Management" ); + } + + private Set filterPluginDependencyIncludes( Set dependencies ) + { + return filterDependencies( dependencies, pluginDependencyIncludes, pluginDependencyExcludes, + "Plugin Dependencies" ); + } + + private Set filterPluginManagementIncludes( Set dependencyManagement ) + { + return filterDependencies( dependencyManagement, + pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, + "Plugin Management Dependencies" ); } private Set filterDependencies( @@ -515,15 +637,26 @@ private Set filterDependencies( DependencyFilter includeDeps = DependencyFilter.parseFrom( includes ); DependencyFilter excludeDeps = DependencyFilter.parseFrom( excludes ); - getLog().debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); - getLog().debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); + Set filtered = includeDeps.retainingIn( dependencies ); + filtered = excludeDeps.removingFrom( filtered ); - Set onlyIncludes = includeDeps.retainingIn( dependencies ); - Set filtered = excludeDeps.removingFrom( onlyIncludes ); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); + getLog().debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); + getLog().debug( String.format( "Unfiltered %s: ", section ) + output( dependencies ) ); + getLog().debug( String.format( "Filtered %s: ", section ) + output( filtered ) ); + } return filtered; } + private String output( Set dependencies ) + { + return dependencies.stream() + .map( d -> String.format( "%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion() ) ) + .collect( Collectors.joining( ", " ) ); + } private DependencyManagement getProjectDependencyManagement( MavenProject project ) { if ( processDependencyManagementTransitive ) diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java new file mode 100644 index 0000000000..5e31adcb42 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -0,0 +1,47 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Arrays; + +import org.apache.maven.plugin.MojoExecutionException; +import org.junit.Test; + +/** + * Basic tests for {@linkplain DisplayDependencyUpdatesMojo}. + * + * @author Andrzej Jarmoniuk + */ +public class DisplayDependencyUpdatesMojoTest +{ + @Test + public void testValidateGAVListSuccessful() throws MojoExecutionException + { + DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group", "group:artifact", + "group:artifact:version" ), 3, "" ); + } + + @Test( expected = MojoExecutionException.class ) + public void testValidateGAVListFailed() throws MojoExecutionException + { + DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group:artifact:version", + "group:artifact:version:type" ), 3, "" ); + } +} From e2c7dcadf335c747bb4dc77ee42c10bb79a3106a Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 6 Sep 2022 08:39:47 +0200 Subject: [PATCH 112/441] [maven-release-plugin] prepare release versions-maven-plugin-2.12.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b515a15d6a..81e19d8012 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.12.0-SNAPSHOT + 2.12.0 maven-plugin Versions Maven Plugin @@ -102,7 +102,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/master - HEAD + versions-maven-plugin-2.12.0
@@ -115,7 +115,7 @@ 1.11.1 ${project.version} 3.7 - 2022-05-20T13:01:33Z + 2022-09-06T06:39:19Z From e3beb056637544e8a3e44e1d59fb88d68ec2c4bc Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Tue, 6 Sep 2022 08:39:51 +0200 Subject: [PATCH 113/441] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 81e19d8012..cdd5c330ea 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.12.0 + 2.12.1-SNAPSHOT maven-plugin Versions Maven Plugin @@ -102,7 +102,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/master - versions-maven-plugin-2.12.0 + HEAD @@ -115,7 +115,7 @@ 1.11.1 ${project.version} 3.7 - 2022-09-06T06:39:19Z + 2022-09-06T06:39:51Z From b14af605f6fac74409ea65304f24690f596fb92f Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Tue, 6 Sep 2022 13:36:47 +0200 Subject: [PATCH 114/441] Fixing #670: allowSnapshots was disabled in PR #665; usePluginRepositories was incorrectly enabled --- src/it-repo/dummy-parent4-70.pom | 9 ++++ src/it-repo/dummy-parent4-71-SNAPSHOT.pom | 9 ++++ .../invoker.properties | 1 + src/it/it-update-parent-005-issue-670/pom.xml | 16 ++++++ .../verify.groovy | 3 ++ .../mojo/versions/UpdateParentMojo.java | 4 +- .../mojo/versions/UpdateParentMojoTest.java | 52 +++++++++++++++++++ 7 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/it-repo/dummy-parent4-70.pom create mode 100644 src/it-repo/dummy-parent4-71-SNAPSHOT.pom create mode 100644 src/it/it-update-parent-005-issue-670/invoker.properties create mode 100644 src/it/it-update-parent-005-issue-670/pom.xml create mode 100644 src/it/it-update-parent-005-issue-670/verify.groovy diff --git a/src/it-repo/dummy-parent4-70.pom b/src/it-repo/dummy-parent4-70.pom new file mode 100644 index 0000000000..b0e715a740 --- /dev/null +++ b/src/it-repo/dummy-parent4-70.pom @@ -0,0 +1,9 @@ + + 4.0.0 + + localhost + dummy-parent4 + 70 + pom + diff --git a/src/it-repo/dummy-parent4-71-SNAPSHOT.pom b/src/it-repo/dummy-parent4-71-SNAPSHOT.pom new file mode 100644 index 0000000000..d4efa088df --- /dev/null +++ b/src/it-repo/dummy-parent4-71-SNAPSHOT.pom @@ -0,0 +1,9 @@ + + 4.0.0 + + localhost + dummy-parent4 + 71-SNAPSHOT + pom + diff --git a/src/it/it-update-parent-005-issue-670/invoker.properties b/src/it/it-update-parent-005-issue-670/invoker.properties new file mode 100644 index 0000000000..f95f04c757 --- /dev/null +++ b/src/it/it-update-parent-005-issue-670/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-parent -DparentVersion=71-SNAPSHOT -DallowSnapshots \ No newline at end of file diff --git a/src/it/it-update-parent-005-issue-670/pom.xml b/src/it/it-update-parent-005-issue-670/pom.xml new file mode 100644 index 0000000000..a06e670cd5 --- /dev/null +++ b/src/it/it-update-parent-005-issue-670/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + localhost + dummy-parent4 + 70 + + + localhsot + issue-670 + 0.31-SNAPSHOT + pom + + \ No newline at end of file diff --git a/src/it/it-update-parent-005-issue-670/verify.groovy b/src/it/it-update-parent-005-issue-670/verify.groovy new file mode 100644 index 0000000000..9e458aecc3 --- /dev/null +++ b/src/it/it-update-parent-005-issue-670/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text + +assert pom =~ /71-SNAPSHOT<\/version>/ \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 68893603f3..46db1a384a 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -134,15 +134,13 @@ protected void update( ModifiedPomXMLEventReader pom ) ArtifactVersion artifactVersion; try { - artifactVersion = findLatestVersion( artifact, versionRange, false, true, - allowDowngrade ); + artifactVersion = findLatestVersion( artifact, versionRange, null, false, allowDowngrade ); } catch ( ArtifactMetadataRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } - if ( !shouldApplyUpdate( artifact, currentVersion, artifactVersion, forceUpdate ) ) { return; diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 0faeec3993..f6e95f52da 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -126,6 +126,11 @@ private static ArtifactMetadataSource mockArtifactMetaDataSource() throws Artifa new DefaultArtifactVersion( "1.0.0" ), new DefaultArtifactVersion( "0.9.0" ) ); } + else if ( "issue-670-artifact".equals( artifact.getArtifactId() ) ) + { + return Arrays.asList( new DefaultArtifactVersion( "0.0.1-1" ), + new DefaultArtifactVersion( "0.0.1-1-impl-SNAPSHOT" ) ); + } else if ( "unknown-artifact".equals( artifact.getArtifactId() ) ) { return Collections.emptyList(); @@ -236,4 +241,51 @@ public void testParentDowngradeForbiddenWithRange() } assertThat( changeRecorder.getChanges(), is( empty() ) ); } + + @Test + public void testAllowSnapshots() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowSnapshots = true; + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "issue-670-artifact" ); + setVersion( "0.0.1-1" ); + }} ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", + "issue-670-artifact", "0.0.1-1", + "0.0.1-1-impl-SNAPSHOT" ) ) ); + } + + @Test + public void testAllowSnapshotsWithParentVersion() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.allowSnapshots = true; + mojo.parentVersion = "0.0.1-1-impl-SNAPSHOT"; + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "issue-670-artifact" ); + setVersion( "0.0.1-1" ); + }} ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", + "issue-670-artifact", "0.0.1-1", + "0.0.1-1-impl-SNAPSHOT" ) ) ); + } } From ff7f20967632f295f2a88d11ab9b32769de8a8c4 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 7 Sep 2022 20:53:48 +0200 Subject: [PATCH 115/441] #673: Fixing NPE in UseDepVersionMojo caused by PatternIncludesArtifactFilter expecting a non-null classifier when using wildcards --- pom.xml | 8 +++- .../mojo/versions/UseDepVersionMojoTest.java | 47 +++++++++++++++++++ .../mojo/versions/utils/BaseMojoTestCase.java | 15 ++++++ .../mojo/use-dep-version/issue-637-pom.xml | 29 ++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java create mode 100644 src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml diff --git a/pom.xml b/pom.xml index cdd5c330ea..3a3ec35d96 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ org.apache.maven.shared maven-common-artifact-filters - 3.3.1 + 3.3.0 org.apache.maven.wagon @@ -274,6 +274,12 @@ 2.2 test + + org.slf4j + slf4j-simple + 1.7.36 + test + diff --git a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java new file mode 100644 index 0000000000..be965fd487 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java @@ -0,0 +1,47 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collections; + +import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.junit.Test; + +/** + * Basic tests for {@linkplain UseDepVersionMojo}. + * + * @author Andrzej Jarmoniuk + */ +public class UseDepVersionMojoTest extends BaseMojoTestCase +{ + @Test + public void testIssue673() throws Exception + { + UseDepVersionMojo mojo = createMojo( "use-dep-version", + "src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml" ); + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "processDependencyManagement", true ); + setVariableValueToObject( mojo, "excludeReactor", true ); + setVariableValueToObject( mojo, "serverId", "serverId" ); + setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( mojo.getProject() ) ); + + mojo.execute(); + } +} \ No newline at end of file diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java index d8a0e04f91..4d499afd14 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java @@ -3,9 +3,12 @@ import java.io.File; import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.Properties; import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.Mojo; @@ -117,5 +120,17 @@ public Properties getProperties() { return getModel().getProperties(); } + + @Override + public List getDependencies() + { + return getModel().getDependencies(); + } + + @Override + public DependencyManagement getDependencyManagement() + { + return getModel().getDependencyManagement(); + } } } diff --git a/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml b/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml new file mode 100644 index 0000000000..5f2edfe99f --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + + test-group + test-artifact + DEVELOP-SNAPSHOT + + + + test-group + dep-artifact + 22.09.21 + + + + + + + versions-maven-plugin + + DEVELOP-SNAPSHOT + test-group*:::JET*-SNAPSHOT + + + + + + \ No newline at end of file From 81782310e26bc5e73b88e04b915012ffef08994e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Sep 2022 13:49:08 +0000 Subject: [PATCH 116/441] Bump mockito-inline from 4.7.0 to 4.8.0 Bumps [mockito-inline](https://github.com/mockito/mockito) from 4.7.0 to 4.8.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.7.0...v4.8.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-inline dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a3ec35d96..ae22aee30d 100644 --- a/pom.xml +++ b/pom.xml @@ -265,7 +265,7 @@ org.mockito mockito-inline - 4.7.0 + 4.8.0 test From fb89924d7931558a8c166341750e4443345cccf5 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 9 Sep 2022 06:59:20 +0200 Subject: [PATCH 117/441] Fixed #682: Restoring the ability to provide an empty "newVersion" argument --- .../mojo/versions/SetPropertyMojo.java | 49 +++++------------ .../mojo/versions/SetPropertyMojoTest.java | 52 ++++++++++++++----- .../mojo/versions/utils/BaseMojoTestCase.java | 1 + .../set-property/null-new-version-pom.xml | 31 ----------- .../{null-property-pom.xml => pom.xml} | 4 +- 5 files changed, 53 insertions(+), 84 deletions(-) delete mode 100644 src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml rename src/test/resources/org/codehaus/mojo/set-property/{null-property-pom.xml => pom.xml} (88%) diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index ca3d6fbb48..a84b1b62ad 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -22,12 +22,9 @@ import javax.xml.stream.XMLStreamException; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.Map; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -37,7 +34,9 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; -import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.defaultString; +import static org.apache.commons.lang3.StringUtils.isEmpty; +import static org.apache.commons.lang3.StringUtils.split; /** * Set a property to a given version without any sanity checks. Please be careful this can lead to changes which might @@ -83,31 +82,6 @@ public class SetPropertyMojo @Parameter( property = "propertiesVersionsFile" ) private String propertiesVersionsFile; - /** - * {@inheritDoc} - */ - @Override - public void execute() throws MojoExecutionException, MojoFailureException - { - List problems = new ArrayList<>(); - if ( isBlank( propertiesVersionsFile ) ) - { - if ( isBlank( newVersion ) ) - { - problems.add( "newVersion must not be empty" ); - } - if ( isBlank( property ) ) - { - problems.add( "property must not be empty" ); - } - } - if ( !problems.isEmpty() ) - { - throw new MojoExecutionException( "Invalid execution arguments: " + String.join( ", ", problems ) ); - } - super.execute(); - } - /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong @@ -118,9 +92,9 @@ public void execute() throws MojoExecutionException, MojoFailureException protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - Property[] propertiesConfig = null; - String properties = ""; - if ( !StringUtils.isEmpty( propertiesVersionsFile ) ) + Property[] propertiesConfig; + String properties; + if ( !isEmpty( propertiesVersionsFile ) ) { logWrongConfigWarning(); getLog().debug( "Reading properties and versions to update from file: " + propertiesVersionsFile ); @@ -139,10 +113,10 @@ protected void update( ModifiedPomXMLEventReader pom ) propertiesConfig = reader.getPropertiesConfig(); properties = reader.getProperties(); } - else if ( !StringUtils.isEmpty( property ) ) + else if ( !isEmpty( property ) ) { getLog().debug( "Reading properties and versions to update from property and newVersion " ); - propertiesConfig = Arrays.stream( StringUtils.split( property, "," ) ).map( + propertiesConfig = Arrays.stream( split( property, "," ) ).map( prp -> { Property propertyConfig = new Property( prp ); @@ -177,17 +151,18 @@ private void update( ModifiedPomXMLEventReader pom, Property[] propertiesConfig, { continue; } - PomHelper.setPropertyVersion( pom, version.getProfileId(), currentProperty.getName(), newVersionGiven ); + PomHelper.setPropertyVersion( pom, version.getProfileId(), currentProperty.getName(), + defaultString( newVersionGiven ) ); } } private void logWrongConfigWarning() { - if ( !StringUtils.isEmpty( property ) ) + if ( !isEmpty( property ) ) { getLog().warn( "-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used" ); } - if ( !StringUtils.isEmpty( newVersion ) ) + if ( !isEmpty( newVersion ) ) { getLog().warn( "-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used" ); } diff --git a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java index b3aecf2e2b..f96d35e4b8 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -19,6 +19,8 @@ * under the License. */ +import java.nio.file.Files; + import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.mojo.versions.utils.BaseMojoTestCase; import org.junit.Test; @@ -26,6 +28,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; /** * Basic tests for {@linkplain SetPropertyMojoTest}. @@ -39,18 +42,37 @@ public void testNullNewVersion() throws Exception { SetPropertyMojo mojo = createMojo( "set-property", - "src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml" ); + "target/test-classes/org/codehaus/mojo/set-property/pom.xml" ); assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); - try - { - mojo.execute(); - fail(); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), - containsString( "Invalid execution arguments: newVersion must not be empty" ) ); - } + + setVariableValueToObject( mojo, "property", "dummy-api-version" ); + setVariableValueToObject( mojo, "newVersion", null ); + + mojo.execute(); + + String output = String.join( "", Files.readAllLines( mojo.getProject().getFile().toPath() ) ) + .replaceAll( "\\s*", "" ); + assertThat( output, + matchesPattern( ".*.*.*.*" ) ); + } + + @Test + public void testNewVersionEmpty() + throws Exception + { + SetPropertyMojo mojo = createMojo( "set-property", + "target/test-classes/org/codehaus/mojo/set-property/pom.xml" ); + assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); + + setVariableValueToObject( mojo, "property", "dummy-api-version" ); + setVariableValueToObject( mojo, "newVersion", "" ); + + mojo.execute(); + + String output = String.join( "", Files.readAllLines( mojo.getProject().getFile().toPath() ) ) + .replaceAll( "\\s*", "" ); + assertThat( output, + matchesPattern( ".*.*.*.*" ) ); } @Test @@ -58,7 +80,11 @@ public void testNullProperty() throws Exception { SetPropertyMojo mojo = createMojo( "set-property", - "src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml" ); + "src/test/resources/org/codehaus/mojo/set-property/pom.xml" ); + + setVariableValueToObject( mojo, "property", null ); + setVariableValueToObject( mojo, "propertiesVersionsFile", null ); + setVariableValueToObject( mojo, "newVersion", "2.0.0" ); try { mojo.execute(); @@ -67,7 +93,7 @@ public void testNullProperty() catch ( MojoExecutionException e ) { assertThat( e.getMessage(), - containsString( "Invalid execution arguments: property must not be empty" ) ); + containsString( "Please provide either 'property' or 'propertiesVersionsFile' parameter." ) ); } } } diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java index 4d499afd14..1bdb484d57 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java @@ -57,6 +57,7 @@ public abstract class BaseMojoTestCase extends AbstractMojoTestCase * Lookup the mojo leveraging the actual subprojects pom * and injects the project using the given pom file path. * + * @param target Mojo subclass * @param goal to execute on the plugin * @param pomFilePath path to the pom project to inject * @return a Mojo instance diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml b/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml deleted file mode 100644 index 94e1f8d097..0000000000 --- a/src/test/resources/org/codehaus/mojo/set-property/null-new-version-pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - 4.0.0 - default-group - default-artifact - 1.0 - pom - - - 1.0.0 - - - - - localhost - dummy-api - ${dummy-api-version} - - - - - - - versions-maven-plugin - - dummy-api-version - - - - - \ No newline at end of file diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml b/src/test/resources/org/codehaus/mojo/set-property/pom.xml similarity index 88% rename from src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml rename to src/test/resources/org/codehaus/mojo/set-property/pom.xml index b429aa3b7b..303db45ef6 100644 --- a/src/test/resources/org/codehaus/mojo/set-property/null-property-pom.xml +++ b/src/test/resources/org/codehaus/mojo/set-property/pom.xml @@ -22,9 +22,7 @@ versions-maven-plugin - - 2.0.0 - + From f0092d0c4c0ef2663f36385bf6e52915b93cb90f Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 9 Sep 2022 17:42:24 +0200 Subject: [PATCH 118/441] Implementing #684: allow providing ruleSet in POM --- .../invoker.properties | 1 + .../pom.xml | 51 ++++ .../verify.groovy | 2 + .../invoker.properties | 6 +- .../verify.bsh | 25 -- .../verify.groovy | 6 + .../verify.groovy | 8 +- .../invoker.properties | 5 + .../pom.xml | 61 ++++ .../verify.groovy | 7 + .../invoker.properties | 7 +- .../it-display-plugin-updates-001/verify.bsh | 25 -- .../verify.groovy | 6 + .../invoker.properties | 5 + .../pom.xml | 57 ++++ .../verify.groovy | 7 + .../invoker.properties | 6 +- .../verify.bsh | 25 -- .../verify.groovy | 5 + .../invoker.properties | 5 + .../pom.xml | 59 ++++ .../verify.groovy | 8 + .../invoker.properties | 1 + .../pom.xml | 88 ++++++ .../verify.groovy | 6 + .../invoker.properties | 1 + .../pom.xml | 88 ++++++ .../verify.groovy | 6 + .../versions/AbstractVersionsDisplayMojo.java | 8 +- .../mojo/versions/AbstractVersionsReport.java | 50 +++- .../versions/AbstractVersionsUpdaterMojo.java | 50 +++- .../versions/DisplayPluginUpdatesMojo.java | 1 - .../versions/api/AbstractVersionDetails.java | 3 - .../api/DefaultArtifactAssociation.java | 7 +- .../versions/api/DefaultVersionsHelper.java | 274 +++++++++++++----- .../mojo/versions/change/VersionChange.java | 7 +- .../versions/ordering/VersionComparators.java | 3 +- .../recording/ChangeRecorderNull.java | 3 +- src/site/apt/version-rules.apt.vm | 84 +++++- .../AbstractVersionsUpdaterMojoTest.java | 4 +- .../versions/DependencyUpdatesReportTest.java | 66 +++-- .../DisplayDependencyUpdatesMojoTest.java | 80 ++++- .../versions/PluginUpdatesReportTest.java | 68 +++-- .../mojo/versions/UpdateParentMojoTest.java | 61 ++-- .../versions/UseLatestVersionsMojoTest.java | 60 ++-- .../api/DefaultVersionsHelperTest.java | 101 +++++-- .../versions/model/TestIgnoreVersions.java | 93 ++++++ .../mojo/versions/utils/MockUtils.java | 86 ++++++ .../ruleset/pom.xml | 57 ++++ .../display-plugin-updates/ruleset/pom.xml | 45 +++ 50 files changed, 1453 insertions(+), 335 deletions(-) create mode 100644 src/it/it-dependency-updates-report-issue-684-001/invoker.properties create mode 100644 src/it/it-dependency-updates-report-issue-684-001/pom.xml create mode 100644 src/it/it-dependency-updates-report-issue-684-001/verify.groovy delete mode 100644 src/it/it-display-dependency-updates-001/verify.bsh create mode 100644 src/it/it-display-dependency-updates-001/verify.groovy create mode 100644 src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties create mode 100644 src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml create mode 100644 src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy delete mode 100644 src/it/it-display-plugin-updates-001/verify.bsh create mode 100644 src/it/it-display-plugin-updates-001/verify.groovy create mode 100644 src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties create mode 100644 src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml create mode 100644 src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy delete mode 100644 src/it/it-display-property-updates-001/verify.bsh create mode 100644 src/it/it-display-property-updates-001/verify.groovy create mode 100644 src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties create mode 100644 src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml create mode 100644 src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy create mode 100644 src/it/it-plugin-updates-report-issue-684-001/invoker.properties create mode 100644 src/it/it-plugin-updates-report-issue-684-001/pom.xml create mode 100644 src/it/it-plugin-updates-report-issue-684-001/verify.groovy create mode 100644 src/it/it-property-updates-report-issue-684-001/invoker.properties create mode 100644 src/it/it-property-updates-report-issue-684-001/pom.xml create mode 100644 src/it/it-property-updates-report-issue-684-001/verify.groovy create mode 100644 src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java create mode 100644 src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java create mode 100644 src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml diff --git a/src/it/it-dependency-updates-report-issue-684-001/invoker.properties b/src/it/it-dependency-updates-report-issue-684-001/invoker.properties new file mode 100644 index 0000000000..6832c404b6 --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-684-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report diff --git a/src/it/it-dependency-updates-report-issue-684-001/pom.xml b/src/it/it-dependency-updates-report-issue-684-001/pom.xml new file mode 100644 index 0000000000..273e1134af --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-684-001/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + localhost + it-abstract-versions-report-001 + 1.0 + pom + abstract-versions-report + http://localhost/ + + + Testing command line invocation of dependency- and plugin-updates-report + + + + + localhost + dummy-api + 1.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 3.0 + + + + + + + + + + diff --git a/src/it/it-dependency-updates-report-issue-684-001/verify.groovy b/src/it/it-dependency-updates-report-issue-684-001/verify.groovy new file mode 100644 index 0000000000..cd8571e77a --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-684-001/verify.groovy @@ -0,0 +1,2 @@ +output = new File( basedir, "target/site/dependency-updates-report.html" ).text +assert ! ( output =~ /\b3.0\b/ ) diff --git a/src/it/it-display-dependency-updates-001/invoker.properties b/src/it/it-display-dependency-updates-001/invoker.properties index d065873965..fad6299506 100644 --- a/src/it/it-display-dependency-updates-001/invoker.properties +++ b/src/it/it-display-dependency-updates-001/invoker.properties @@ -1 +1,5 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -Dmaven.version.ignore=3.0 diff --git a/src/it/it-display-dependency-updates-001/verify.bsh b/src/it/it-display-dependency-updates-001/verify.bsh deleted file mode 100644 index 844bf2d3eb..0000000000 --- a/src/it/it-display-dependency-updates-001/verify.bsh +++ /dev/null @@ -1,25 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "build.log" ); - String buf = FileUtils.fileRead( file ); - - Pattern p = Pattern.compile( "\\Qlocalhost:dummy-api\\E\\s*\\.*\\s*1\\.1\\s+->\\s+3\\.0" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not suggest updating dummy-api to version 3.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/it/it-display-dependency-updates-001/verify.groovy b/src/it/it-display-dependency-updates-001/verify.groovy new file mode 100644 index 0000000000..eee26c892b --- /dev/null +++ b/src/it/it-display-dependency-updates-001/verify.groovy @@ -0,0 +1,6 @@ +output = new File(basedir, "output1.txt").text +assert output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+3\.0\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+3\.0\b/ ) +assert output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+2\.1\b/ diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy index cdce154d8a..d4e3cc4e8e 100644 --- a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy +++ b/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy @@ -1,17 +1,17 @@ output = new File(basedir, "output1.txt").text assert output =~ /localhost:dummy-api/ -assert output !=~ /localhost:dummy-impl/ +assert ! ( output =~ /localhost:dummy-impl/ ) output = new File(basedir, "output2.txt").text -assert output !=~ /localhost:dummy-api/ +assert ! ( output =~ /localhost:dummy-api/ ) assert output =~ /localhost:dummy-impl/ output = new File(basedir, "output3.txt").text assert output =~ /localhost:dummy-impl/ -assert output !=~ /localhost:dummy-parent2/ +assert ! ( output =~ /localhost:dummy-parent2/ ) output = new File(basedir, "output4.txt").text -assert output !=~ /localhost:dummy-impl/ +assert ! ( output =~ /localhost:dummy-impl/ ) assert output =~ /localhost:dummy-parent2/ output = new File(basedir, "output5.txt") diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties new file mode 100644 index 0000000000..cb607ec2ec --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties @@ -0,0 +1,5 @@ +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -Dmaven.version.ignore=2.1 diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml new file mode 100644 index 0000000000..b3023c5055 --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + localhost + it-display-dependency-updates-issue-684-pom-based-rules + 1.0 + pom + + + + localhost + dummy-api + 1.1 + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 3.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy new file mode 100644 index 0000000000..a150dec35d --- /dev/null +++ b/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy @@ -0,0 +1,7 @@ +output = new File(basedir, "output1.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+3\.0\b/ ) +assert output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+2\.1\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+2\.1\b/ ) +assert output =~ /\Qlocalhost:dummy-api\E\s*\.*\s*1\.1\s+->\s+2\.0\b/ diff --git a/src/it/it-display-plugin-updates-001/invoker.properties b/src/it/it-display-plugin-updates-001/invoker.properties index 3e9221daf4..bef19502c7 100644 --- a/src/it/it-display-plugin-updates-001/invoker.properties +++ b/src/it/it-display-plugin-updates-001/invoker.properties @@ -1 +1,6 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 + +invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -Dmaven.version.ignore=3.0 + diff --git a/src/it/it-display-plugin-updates-001/verify.bsh b/src/it/it-display-plugin-updates-001/verify.bsh deleted file mode 100644 index 6d63188f17..0000000000 --- a/src/it/it-display-plugin-updates-001/verify.bsh +++ /dev/null @@ -1,25 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "build.log" ); - String buf = FileUtils.fileRead( file ); - - Pattern p = Pattern.compile( "\\Qlocalhost:dummy-maven-plugin\\E\\s*\\.*\\s*1\\.0\\s+->\\s+3\\.0" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not suggest updating dummy-maven-plugin to version 3.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/it/it-display-plugin-updates-001/verify.groovy b/src/it/it-display-plugin-updates-001/verify.groovy new file mode 100644 index 0000000000..765fed6879 --- /dev/null +++ b/src/it/it-display-plugin-updates-001/verify.groovy @@ -0,0 +1,6 @@ +output = new File(basedir, "output1.txt").text +assert output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+3\.0\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+3\.0\b/ ) +assert output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+2\.1\b/ diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties new file mode 100644 index 0000000000..da614b7ca1 --- /dev/null +++ b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties @@ -0,0 +1,5 @@ +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -Dmaven.version.ignore=2.1 diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml new file mode 100644 index 0000000000..65659c4679 --- /dev/null +++ b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + + localhost + it-101 + 1.0 + pom + display-plugin-updates + + + 2.0.6 + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 3.0 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy new file mode 100644 index 0000000000..44e1b8eb69 --- /dev/null +++ b/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy @@ -0,0 +1,7 @@ +output = new File(basedir, "output1.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+3\.0\b/ ) +assert output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+2\.1\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+2\.1\b/ ) +assert output =~ /\Qlocalhost:dummy-maven-plugin\E\s*\.*\s*1\.0\s+->\s+2\.0\b/ diff --git a/src/it/it-display-property-updates-001/invoker.properties b/src/it/it-display-property-updates-001/invoker.properties index 27e7c440cf..2b9ac63e46 100644 --- a/src/it/it-display-property-updates-001/invoker.properties +++ b/src/it/it-display-property-updates-001/invoker.properties @@ -1 +1,5 @@ -invoker.goals=-DautoLinkItems=true ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 -DautoLinkItems=true + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -DautoLinkItems=true -Dmaven.version.ignore=2.0 diff --git a/src/it/it-display-property-updates-001/verify.bsh b/src/it/it-display-property-updates-001/verify.bsh deleted file mode 100644 index d3e8c541e3..0000000000 --- a/src/it/it-display-property-updates-001/verify.bsh +++ /dev/null @@ -1,25 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "build.log" ); - String buf = FileUtils.fileRead( file ); - - Pattern p = Pattern.compile( "\\Q${api}\\E\\s*\\.*\\s*1\\.0\\s+->\\s+2\\.0" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not suggest updating ${api} to version 2.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/it/it-display-property-updates-001/verify.groovy b/src/it/it-display-property-updates-001/verify.groovy new file mode 100644 index 0000000000..53dab60be1 --- /dev/null +++ b/src/it/it-display-property-updates-001/verify.groovy @@ -0,0 +1,5 @@ +output = new File(basedir, "output1.txt").text +assert output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+2\.0\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+2\.0\b/ ) diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties b/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties new file mode 100644 index 0000000000..bd427d468d --- /dev/null +++ b/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties @@ -0,0 +1,5 @@ +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates +invoker.mavenOpts.1 = -Dversions.outputFile=./output1.txt -DoutputEncoding=UTF-8 -DautoLinkItems=true + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:display-property-updates +invoker.mavenOpts.2 = -Dversions.outputFile=./output2.txt -DoutputEncoding=UTF-8 -DautoLinkItems=true -Dmaven.version.ignore=1.3 diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml b/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml new file mode 100644 index 0000000000..27f167411b --- /dev/null +++ b/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + + localhost + it-004 + 1.0 + pom + update-properties with one property auto-linked and range limited + + + 1.0 + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 2.0 + + + + + + + maven-clean-plugin + 2.2 + + + localhost + dummy-api + [${api},2.1-!) + + + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + + + + diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy b/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy new file mode 100644 index 0000000000..b7869dc19e --- /dev/null +++ b/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy @@ -0,0 +1,8 @@ +output = new File(basedir, "output1.txt").text +assert ! ( output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+2\.0\b/ ) +assert output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+1\.3\b/ + +output = new File(basedir, "output2.txt").text +assert ! ( output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+2\.0\b/ ) +assert ! ( output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+1\.3\b/ ) +assert output =~ /\Q\u0024{api}\E\s*\.*\s*1\.0\s+->\s+1\.2.2\b/ diff --git a/src/it/it-plugin-updates-report-issue-684-001/invoker.properties b/src/it/it-plugin-updates-report-issue-684-001/invoker.properties new file mode 100644 index 0000000000..526cf26e97 --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-684-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:plugin-updates-report diff --git a/src/it/it-plugin-updates-report-issue-684-001/pom.xml b/src/it/it-plugin-updates-report-issue-684-001/pom.xml new file mode 100644 index 0000000000..a60084db74 --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-684-001/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + localhost + it-dependency-updates-report-001 + 1.0 + pom + plugin-updates-report + http://localhost/ + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 3.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.1 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + @sitePluginVersion@ + + + maven-project-info-reports-plugin + 2.1 + + + + + + + + + maven-project-info-reports-plugin + 2.1 + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + plugin-updates-report + + + + + + + + diff --git a/src/it/it-plugin-updates-report-issue-684-001/verify.groovy b/src/it/it-plugin-updates-report-issue-684-001/verify.groovy new file mode 100644 index 0000000000..1d0370e86f --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-684-001/verify.groovy @@ -0,0 +1,6 @@ +output = new File( basedir, 'target/site/plugin-updates-report.html' ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) +assert ! ( output =~ /\blocalhost dummy-maven-plugin 1.0 3.1\b/ ) +assert output =~ /\blocalhost dummy-maven-plugin 1.0 3.0\b/ diff --git a/src/it/it-property-updates-report-issue-684-001/invoker.properties b/src/it/it-property-updates-report-issue-684-001/invoker.properties new file mode 100644 index 0000000000..526cf26e97 --- /dev/null +++ b/src/it/it-property-updates-report-issue-684-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:plugin-updates-report diff --git a/src/it/it-property-updates-report-issue-684-001/pom.xml b/src/it/it-property-updates-report-issue-684-001/pom.xml new file mode 100644 index 0000000000..a60084db74 --- /dev/null +++ b/src/it/it-property-updates-report-issue-684-001/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + localhost + it-dependency-updates-report-001 + 1.0 + pom + plugin-updates-report + http://localhost/ + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + + 3.1 + + + + + + + localhost + dummy-maven-plugin + 1.0 + + + localhost + dummy-api + 1.1 + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + @sitePluginVersion@ + + + maven-project-info-reports-plugin + 2.1 + + + + + + + + + maven-project-info-reports-plugin + 2.1 + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + plugin-updates-report + + + + + + + + diff --git a/src/it/it-property-updates-report-issue-684-001/verify.groovy b/src/it/it-property-updates-report-issue-684-001/verify.groovy new file mode 100644 index 0000000000..1d0370e86f --- /dev/null +++ b/src/it/it-property-updates-report-issue-684-001/verify.groovy @@ -0,0 +1,6 @@ +output = new File( basedir, 'target/site/plugin-updates-report.html' ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) +assert ! ( output =~ /\blocalhost dummy-maven-plugin 1.0 3.1\b/ ) +assert output =~ /\blocalhost dummy-maven-plugin 1.0 3.0\b/ diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index c7db3a478b..bab4092b22 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -47,7 +47,7 @@ public abstract class AbstractVersionsDisplayMojo * @since 2.2 */ @Parameter( property = "versions.outputFile" ) - private File outputFile; + protected File outputFile; /** * Controls whether the display output is logged to the console. @@ -55,7 +55,7 @@ public abstract class AbstractVersionsDisplayMojo * @since 2.2 */ @Parameter( property = "versions.logOutput", defaultValue = "true" ) - private boolean logOutput; + protected boolean logOutput; /** * The character encoding to use when writing to {@link #outputFile}. @@ -63,7 +63,7 @@ public abstract class AbstractVersionsDisplayMojo * @since 2.2 */ @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" ) - private String outputEncoding; + protected String outputEncoding; /** * Line width which should be used to format the padding of the version info list output. @@ -72,7 +72,7 @@ public abstract class AbstractVersionsDisplayMojo */ @Parameter( property = "versions.outputLineWidth", defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "" ) - private int outputLineWidth; + protected int outputLineWidth; private boolean outputFileError = false; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 61fb7b63b8..0a7591adf2 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -22,6 +22,7 @@ import java.io.File; import java.util.List; import java.util.Locale; +import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -46,6 +47,7 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.plexus.i18n.I18N; /** @@ -169,6 +171,33 @@ public abstract class AbstractVersionsReport @Component protected ArtifactResolver artifactResolver; + /** + *

Allows specifying the {@linkplain RuleSet} object describing rules + * on artifact versions to ignore when considering updates.

+ * + * @see + * Using the ruleSet element in the POM + * + * @since 2.13.0 + */ + @Parameter + protected RuleSet ruleSet; + + /** + *

Allows specifying ignored versions directly as an alternative + * to providing the {@linkplain #ruleSet} parameter; mainly created + * for {@code -D} property usage.

+ * + *

+ * Example: {@code "1\.0\.1,.+-M.,.*-SNAPSHOT"} + *

+ * + *

Currently, this parameter will override the defined {@link #ruleSet}

+ * @since 2.13.0 + */ + @Parameter( property = "maven.version.ignore" ) + protected Set ignoredVersions; + // --------------------- GETTER / SETTER METHODS --------------------- public VersionsHelper getHelper() @@ -178,10 +207,23 @@ public VersionsHelper getHelper() { try { - helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, - remoteArtifactRepositories, remotePluginRepositories, - localRepository, wagonManager, settings, serverId, rulesUri, - getLog(), session, mojoExecution ); + helper = new DefaultVersionsHelper.Builder() + .withRepositorySystem( repositorySystem ) + .withArtifactResolver( artifactResolver ) + .withArtifactMetadataSource( artifactMetadataSource ) + .withRemoteArtifactRepositories( remoteArtifactRepositories ) + .withRemotePluginRepositories( remotePluginRepositories ) + .withLocalRepository( localRepository ) + .withWagonManager( wagonManager ) + .withSettings( settings ) + .withServerId( serverId ) + .withRulesUri( rulesUri ) + .withRuleSet( ruleSet ) + .withIgnoredVersions( ignoredVersions ) + .withLog( getLog() ) + .withMavenSession( session ) + .withMojoExecution( mojoExecution ) + .build(); } catch ( MojoExecutionException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 836579f548..215af4a29d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.Writer; import java.util.List; +import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -55,6 +56,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.recording.ChangeRecorder; import org.codehaus.mojo.versions.recording.ChangeRecorderNull; @@ -216,16 +218,56 @@ public abstract class AbstractVersionsUpdaterMojo */ private ChangeRecorder changeRecorder; + /** + *

Allows specifying the {@linkplain RuleSet} object describing rules + * on artifact versions to ignore when considering updates.

+ * + * @see + * Using the ruleSet element in the POM + * + * @since 2.13.0 + */ + @Parameter + protected RuleSet ruleSet; + + /** + *

Allows specifying ignored versions directly as an alternative + * to providing the {@linkplain #ruleSet} parameter; mainly created + * for {@code -D} property usage.

+ * + *

+ * Example: {@code "1\.0\.1,.+-M.,.*-SNAPSHOT"} + *

+ * + *

Currently, this parameter will override the defined {@link #ruleSet}

+ * @since 2.13.0 + */ + @Parameter( property = "maven.version.ignore" ) + protected Set ignoredVersions; + // --------------------- GETTER / SETTER METHODS --------------------- public VersionsHelper getHelper() throws MojoExecutionException { if ( helper == null ) { - helper = new DefaultVersionsHelper( repositorySystem, artifactResolver, artifactMetadataSource, - remoteArtifactRepositories, remotePluginRepositories, localRepository, - wagonManager, settings, serverId, rulesUri, getLog(), - session, mojoExecution ); + helper = new DefaultVersionsHelper.Builder() + .withRepositorySystem( repositorySystem ) + .withArtifactResolver( artifactResolver ) + .withArtifactMetadataSource( artifactMetadataSource ) + .withRemoteArtifactRepositories( remoteArtifactRepositories ) + .withRemotePluginRepositories( remotePluginRepositories ) + .withLocalRepository( localRepository ) + .withWagonManager( wagonManager ) + .withSettings( settings ) + .withServerId( serverId ) + .withRulesUri( rulesUri ) + .withRuleSet( ruleSet ) + .withIgnoredVersions( ignoredVersions ) + .withLog( getLog() ) + .withMavenSession( session ) + .withMojoExecution( mojoExecution ) + .build(); } return helper; } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 67f62ca5ed..e4e931e3ee 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -1813,7 +1813,6 @@ protected void update( ModifiedPomXMLEventReader pom ) // do nothing } - @SuppressWarnings( "unchecked" ) private static int compare( ArtifactVersion a, ArtifactVersion b ) { return a.compareTo( b ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 9aa9fbf1df..f188ccceef 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -378,19 +378,16 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactV } public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException { return getOldestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); } public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException { return getNewestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); } public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException { return getAllUpdates( currentVersion, updateScope, isIncludeSnapshots() ); } diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java index 3b85131ff7..f612462f07 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java @@ -114,12 +114,7 @@ public boolean equals( Object o ) { return false; } - if ( !getGroupId().equals( that.getGroupId() ) ) - { - return false; - } - - return true; + return getGroupId().equals( that.getGroupId() ); } public int hashCode() diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index cb679d3621..60108d96a1 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -44,6 +44,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -111,62 +112,61 @@ public class DefaultVersionsHelper * The artifact comparison rules to use. * * @since 1.0-alpha-3 - * @deprecated */ - private final RuleSet ruleSet; + private RuleSet ruleSet; /** * The artifact metadata source to use. * * @since 1.0-alpha-3 */ - private final ArtifactMetadataSource artifactMetadataSource; + private ArtifactMetadataSource artifactMetadataSource; /** * The local repository to consult. * * @since 1.0-alpha-3 */ - private final ArtifactRepository localRepository; + private ArtifactRepository localRepository; /** * The remote artifact repositories to consult. * * @since 1.0-alpha-3 */ - private final List remoteArtifactRepositories; + private List remoteArtifactRepositories; /** * The remote plugin repositories to consult. * * @since 1.0-alpha-3 */ - private final List remotePluginRepositories; + private List remotePluginRepositories; - private final RepositorySystem repositorySystem; + private RepositorySystem repositorySystem; /** * The {@link Log} to send log messages to. * * @since 1.0-alpha-3 */ - private final Log log; + private Log log; /** * The maven session. * * @since 1.0-beta-1 */ - private final MavenSession mavenSession; + private MavenSession mavenSession; /** * The artifact resolver. * * @since 1.3 */ - private final ArtifactResolver artifactResolver; + private ArtifactResolver artifactResolver; - private final MojoExecution mojoExecution; + private MojoExecution mojoExecution; /** * A cache mapping artifacts to their best fitting rule, since looking up @@ -177,42 +177,10 @@ public class DefaultVersionsHelper private final Map artifactBestFitRule = new HashMap<>(); /** - * Constructs a new {@link DefaultVersionsHelper}. - * - * @param repositorySystem The repositorySystem. - * @param artifactResolver Artifact resolver - * @param artifactMetadataSource The artifact metadata source to use. - * @param remoteArtifactRepositories The remote artifact repositories to consult. - * @param remotePluginRepositories The remote plugin repositories to consult. - * @param localRepository The local repository to consult. - * @param wagonManager The wagon manager (used if rules need to be retrieved). - * @param settings The settings (used to provide proxy information to the wagon manager). - * @param serverId The serverId hint for the wagon manager. - * @param rulesUri The URL to retrieve the versioning rules from. - * @param log The {@link org.apache.maven.plugin.logging.Log} to send log messages to. - * @param mavenSession The maven session information. - * @throws MojoExecutionException if something goes wrong. - * @since 1.0-alpha-3 + * Private constructor used by the builder */ - @SuppressWarnings( "checkstyle:ParameterNumber" ) - public DefaultVersionsHelper( RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, - List remoteArtifactRepositories, - List remotePluginRepositories, ArtifactRepository localRepository, - WagonManager wagonManager, Settings settings, String serverId, String rulesUri, - Log log, MavenSession mavenSession, MojoExecution mojoExecution ) - throws MojoExecutionException + private DefaultVersionsHelper() { - this.repositorySystem = repositorySystem; - this.artifactResolver = artifactResolver; - this.mavenSession = mavenSession; - this.mojoExecution = mojoExecution; - this.ruleSet = loadRuleSet( serverId, settings, wagonManager, rulesUri, log ); - this.artifactMetadataSource = artifactMetadataSource; - this.localRepository = localRepository; - this.remoteArtifactRepositories = remoteArtifactRepositories; - this.remotePluginRepositories = remotePluginRepositories; - this.log = log; } @Deprecated @@ -264,30 +232,48 @@ static boolean match( String wildcardRule, String value ) return p.matcher( value ).matches(); } - private static RuleSet loadRuleSet( String serverId, Settings settings, WagonManager wagonManager, String rulesUri, - Log logger ) - throws MojoExecutionException + /** + *

Creates the enriched version of the ruleSet given as parameter; the ruleSet will contain the + * set of ignored versions passed on top of its own (if defined).

+ * + *

If the {@code originalRuleSet} is {@code null}, a new {@linkplain RuleSet} will be created as + * a result.

+ * + *

The method does not change the {@code originalRuleSet} object.

+ * + * @param ignoredVersions collection of ignored version to enrich the clone of the original rule set + * @param originalRuleSet original rule set + * @return new RuleSet object containing the (if passed) cloned version of the rule set, enriched with + * the given set of ignored versions + */ + @SuppressWarnings( "checkstyle:AvoidNestedBlocks" ) + private static RuleSet enrichRuleSet( Collection ignoredVersions, RuleSet originalRuleSet ) { RuleSet ruleSet = new RuleSet(); - boolean rulesUriGiven = isRulesUriNotBlank( rulesUri ); - - if ( rulesUriGiven ) + if ( originalRuleSet != null ) { - RuleSet loadedRules; - - if ( isClasspathUri( rulesUri ) ) + ruleSet.setComparisonMethod( originalRuleSet.getComparisonMethod() ); + if ( originalRuleSet.getRules() != null ) { - loadedRules = getRulesFromClasspath( rulesUri, logger ); + ruleSet.setRules( new ArrayList<>( originalRuleSet.getRules() ) ); } - else + if ( originalRuleSet.getIgnoreVersions() != null ) { - loadedRules = getRulesViaWagon( rulesUri, logger, serverId, serverId, wagonManager, - settings ); + ruleSet.setIgnoreVersions( new ArrayList<>( originalRuleSet.getIgnoreVersions() ) ); } + } - ruleSet.setIgnoreVersions( loadedRules.getIgnoreVersions() ); - ruleSet.setRules( loadedRules.getRules() ); + if ( ruleSet.getIgnoreVersions() == null ) + { + ruleSet.setIgnoreVersions( new ArrayList<>() ); } + ruleSet.getIgnoreVersions().addAll( ignoredVersions.stream().map( v -> + { + IgnoreVersion ignoreVersion = new IgnoreVersion(); + ignoreVersion.setType( TYPE_REGEX ); + ignoreVersion.setVersion( v ); + return ignoreVersion; + } ).collect( Collectors.toList() ) ); return ruleSet; } @@ -320,11 +306,6 @@ private static RuleSet getRulesFromClasspath( String uri, Log logger ) } } - private static boolean isRulesUriNotBlank( String rulesUri ) - { - return rulesUri != null && rulesUri.trim().length() != 0; - } - private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String serverId, String id, WagonManager wagonManager, Settings settings ) throws MojoExecutionException @@ -1039,4 +1020,167 @@ public PluginPluginUpdatesDetails call() } } + /** + * Builder class for {@linkplain DefaultVersionsHelper} + */ + public static class Builder + { + private RepositorySystem repositorySystem; + private ArtifactResolver artifactResolver; + private ArtifactMetadataSource artifactMetadataSource; + private List remoteArtifactRepositories; + private List remotePluginRepositories; + private ArtifactRepository localRepository; + private Collection ignoredVersions; + private RuleSet ruleSet; + private WagonManager wagonManager; + private Settings settings; + private String serverId; + private String rulesUri; + private Log log; + private MavenSession mavenSession; + private MojoExecution mojoExecution; + + public Builder() + { + } + + public Builder withRepositorySystem( RepositorySystem repositorySystem ) + { + this.repositorySystem = repositorySystem; + return this; + } + + public Builder withArtifactResolver( ArtifactResolver artifactResolver ) + { + this.artifactResolver = artifactResolver; + return this; + } + + public Builder withArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource ) + { + this.artifactMetadataSource = artifactMetadataSource; + return this; + } + + public Builder withRemoteArtifactRepositories( + List remoteArtifactRepositories ) + { + this.remoteArtifactRepositories = remoteArtifactRepositories; + return this; + } + + public Builder withRemotePluginRepositories( + List remotePluginRepositories ) + { + this.remotePluginRepositories = remotePluginRepositories; + return this; + } + + public Builder withLocalRepository( ArtifactRepository localRepository ) + { + this.localRepository = localRepository; + return this; + } + + public Builder withIgnoredVersions( Collection ignoredVersions ) + { + this.ignoredVersions = ignoredVersions; + return this; + } + + public Builder withRuleSet( RuleSet ruleSet ) + { + this.ruleSet = ruleSet; + return this; + } + + public Builder withWagonManager( WagonManager wagonManager ) + { + this.wagonManager = wagonManager; + return this; + } + + public Builder withSettings( Settings settings ) + { + this.settings = settings; + return this; + } + + public Builder withServerId( String serverId ) + { + this.serverId = serverId; + return this; + } + + public Builder withRulesUri( String rulesUri ) + { + this.rulesUri = rulesUri; + return this; + } + + public Builder withLog( Log log ) + { + this.log = log; + return this; + } + + public Builder withMavenSession( MavenSession mavenSession ) + { + this.mavenSession = mavenSession; + return this; + } + + public Builder withMojoExecution( MojoExecution mojoExecution ) + { + this.mojoExecution = mojoExecution; + return this; + } + + /** + * Builds the constructed {@linkplain DefaultVersionsHelper} object + * @return constructed {@linkplain DefaultVersionsHelper} + * @throws MojoExecutionException should the constructor with the Wagon go wrong + */ + public DefaultVersionsHelper build() throws MojoExecutionException + { + DefaultVersionsHelper instance = new DefaultVersionsHelper(); + instance.repositorySystem = repositorySystem; + instance.artifactResolver = artifactResolver; + instance.mavenSession = mavenSession; + instance.mojoExecution = mojoExecution; + if ( ruleSet != null ) + { + if ( !isBlank( rulesUri ) ) + { + log.warn( "rulesUri is ignored if rules are specified in pom or as parameters" ); + } + instance.ruleSet = ruleSet; + } + else + { + instance.ruleSet = isBlank( rulesUri ) + ? new RuleSet() + : isClasspathUri( rulesUri ) + ? getRulesFromClasspath( rulesUri, log ) + : getRulesViaWagon( rulesUri, log, serverId, serverId, wagonManager, + settings ); + } + if ( ignoredVersions != null && !ignoredVersions.isEmpty() ) + { + instance.ruleSet = enrichRuleSet( ignoredVersions, instance.ruleSet ); + } + instance.artifactMetadataSource = artifactMetadataSource; + instance.localRepository = localRepository; + instance.remoteArtifactRepositories = remoteArtifactRepositories; + instance.remotePluginRepositories = remotePluginRepositories; + instance.log = log; + return instance; + } + + private static boolean isBlank( String s ) + { + return s == null || s.trim().isEmpty(); + } + } } diff --git a/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java b/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java index 1c63d956ba..753f3c81a6 100644 --- a/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java +++ b/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java @@ -90,12 +90,7 @@ public boolean equals( Object o ) { return false; } - if ( !Objects.equals( oldVersion, versionChange.oldVersion ) ) - { - return false; - } - - return true; + return Objects.equals( oldVersion, versionChange.oldVersion ); } public int hashCode() diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java index 0576b0104f..2693bb6a51 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java @@ -166,8 +166,7 @@ static ArtifactVersion copySnapshot( ArtifactVersion source, ArtifactVersion des { destination = stripSnapshot( destination ); } - Pattern matchSnapshotRegex = SNAPSHOT_PATTERN; - final Matcher matcher = matchSnapshotRegex.matcher( source.toString() ); + final Matcher matcher = SNAPSHOT_PATTERN.matcher( source.toString() ); if ( matcher.find() ) { return new DefaultArtifactVersion( destination.toString() + "-" + matcher.group( 0 ) ); diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index e2bf312b54..b3c3c2c67b 100644 --- a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -19,7 +19,6 @@ * under the License. */ -import java.io.IOException; import java.io.OutputStream; import java.util.Objects; @@ -57,7 +56,7 @@ public final void recordUpdate( final String kind, final String groupId, final S } @Override - public final void serialize( final OutputStream outputStream ) throws IOException + public final void serialize( final OutputStream outputStream ) { } diff --git a/src/site/apt/version-rules.apt.vm b/src/site/apt/version-rules.apt.vm index 4c18d16894..eb28a0adf9 100644 --- a/src/site/apt/version-rules.apt.vm +++ b/src/site/apt/version-rules.apt.vm @@ -60,7 +60,13 @@ Version number rules * Rules.xml - To specify the version schemes to use, you must define a {{{./rule.html}rule-set xml file}}, for example: + To specify the version schemes to use, you may define a {{{./rule.html}rule-set xml file}}, use the <<>> + element in the <<>> plugin configuration, or specify ignored versions via + the <<>> property. + +** Using the <<>> file + + The <<>> file should conform to the xsd specified in the example below. --- >> attribute in the <<>> elements has a lazy <<<.*>>> at the end, such that <<>> will match <<>>, <<>>, <<>>, etc. - + +** Using the <<>> element in the POM + + As an alternative to providing a separate <<>> file, starting with version <<<2.13.0>>> it is possible + to provide the <<>> element directly in the POM. The structure is somewhat simpler to + the <<>> file: + +--- + + ... + + ... + + ... + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + + + + + + 1.0.0 + + + + regex + (.+-SNAPSHOT|.+-M\d) + + + regex + .+-(alpha|beta) + + + + + + + + + org.codehaus.mojo + + + + ... + + + + maven + + + +--- + +** Using the <<>> property + + The <<>> property can list *comma-separated* list of global version **regex** patterns, which + will be ignored when considering available versions. + + Examples: + + * <<<1.0.0>>> + + * <<<.+-SNAPSHOT>>> + + * <<<(.+-SNAPSHOT|.+-M\d),.+-(alpha|beta),3.0.0>>> + ** Ignoring certain versions It is possible to ignore versions on a global and on a per-rule basis. + The other methods (via the <<<>>> element and via the <<>>) property have been + explained above. The described + --- 0 ); assertTrue( instanceCompare( "5.1.0.0.2a4", "5.1.0.0.9" ) < 0 ); } -} \ No newline at end of file +} diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index 9d8b53ddb8..d3ee871aaf 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -25,12 +25,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.Locale; +import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.doxia.tools.SiteTool; @@ -41,10 +39,12 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.plexus.i18n.I18N; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; @@ -64,7 +64,6 @@ public class DependencyUpdatesReportTest { private static class TestDependencyUpdatesReport extends DependencyUpdatesReport { - @SuppressWarnings( "deprecation" ) TestDependencyUpdatesReport() { mockPlexusComponents(); @@ -74,32 +73,7 @@ private static class TestDependencyUpdatesReport extends DependencyUpdatesReport project.getOriginalModel().setDependencyManagement( new DependencyManagement() ); project.getModel().setDependencyManagement( new DependencyManagement() ); - artifactMetadataSource = mock( ArtifactMetadataSource.class ); - try - { - when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> - { - Artifact artifact = invocation.getArgument( 0 ); - if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "2.0.0" ) ); - } - if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "1.1.0" ) ); - } - return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); - } ); - } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new RuntimeException( e ); - } + artifactMetadataSource = mockArtifactMetadataSource(); } public TestDependencyUpdatesReport withDependencies( Dependency... dependencies ) @@ -148,6 +122,20 @@ public TestDependencyUpdatesReport withOnlyProjectDependencies( return this; } + public TestDependencyUpdatesReport withRuleSet( + RuleSet ruleSet ) + { + this.ruleSet = ruleSet; + return this; + } + + public TestDependencyUpdatesReport withIgnoredVersions( + Set ignoredVersions ) + { + this.ignoredVersions = ignoredVersions; + return this; + } + /** *

Mocks some Plexus components to speed up test execution.

*

Note: these components could just as well be injected using @@ -262,4 +250,22 @@ public void testOnlyProjectDependencies() throws IOException, MavenReportExcepti assertThat( output, containsString( "artifactA" ) ); assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); } + + @Test + public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withDependencies( dependencyOf( "artifactA" ) ) + .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), + dependencyOf( "artifactC" ) ) + .withProcessDependencyManagement( true ) + .withOnlyProjectDependencies( true ) + .withIgnoredVersions( Collections.singleton( "2.0.0" ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString().replaceAll( "\n", "" ); + assertThat( output, containsString( "report.noUpdatesAvailable" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 5e31adcb42..3b113f7f58 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -19,18 +19,41 @@ * under the License. */ +import java.io.File; +import java.nio.file.Files; import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.codehaus.mojo.versions.model.TestIgnoreVersions; +import org.hamcrest.Matchers; +import org.junit.Rule; import org.junit.Test; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.codehaus.mojo.versions.model.TestIgnoreVersions.TYPE_REGEX; +import static org.codehaus.mojo.versions.model.TestIgnoreVersions.matches; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; + /** * Basic tests for {@linkplain DisplayDependencyUpdatesMojo}. * * @author Andrzej Jarmoniuk */ -public class DisplayDependencyUpdatesMojoTest +public class DisplayDependencyUpdatesMojoTest extends AbstractMojoTestCase { + @Rule + public final MojoRule mojoRule = new MojoRule( this ); + @Test public void testValidateGAVListSuccessful() throws MojoExecutionException { @@ -38,10 +61,57 @@ public void testValidateGAVListSuccessful() throws MojoExecutionException "group:artifact:version" ), 3, "" ); } - @Test( expected = MojoExecutionException.class ) - public void testValidateGAVListFailed() throws MojoExecutionException + @Test + public void testValidateGAVListFailed() + { + try + { + DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group:artifact:version", + "group:artifact:version:type" ), 3, "" ); + fail( "Method should have thrown a MojoExecutionException" ); + } + catch ( MojoExecutionException e ) + { + } + } + + @Test + public void testRuleSetPresentAndWorking() throws Exception { - DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group:artifact:version", - "group:artifact:version:type" ), 3, "" ); + File outputFile = null; + try + { + outputFile = File.createTempFile( "display-dependency-updates", "" ); + assert outputFile.exists(); + + DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( + new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset" ), + "display-dependency-updates" ); + assertThat( mojo.ruleSet, notNullValue() ); + assertThat( mojo.ruleSet.getIgnoreVersions(), notNullValue() ); + assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + assertThat( mojo.ruleSet.getIgnoreVersions(), hasItem( matches( + new TestIgnoreVersions().withVersion( "1.0.1" ) ) ) ); + assertThat( mojo.ruleSet.getIgnoreVersions(), containsInAnyOrder( + matches( new TestIgnoreVersions().withVersion( "1.0.1" ) ), + matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-SNAPSHOT" ) ), + matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-M\\d+" ) ) ) ); + + // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging + mojo.outputFile = outputFile; + mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + {{ + put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); + }} ); + + assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + mojo.execute(); + List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); + assertThat( output, not( hasItem( containsString( "1.1.0-M1" ) ) ) ); + } + finally + { + assert outputFile == null || !outputFile.exists() || outputFile.delete(); + } } } diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java index ce0376a64f..ddc3baa753 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java @@ -25,12 +25,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.Locale; +import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.doxia.tools.SiteTool; @@ -41,15 +39,18 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.plexus.i18n.I18N; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.matchesPattern; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -64,7 +65,6 @@ public class PluginUpdatesReportTest { private static class TestPluginUpdatesReport extends PluginUpdatesReport { - @SuppressWarnings( "deprecation" ) TestPluginUpdatesReport() { mockPlexusComponents(); @@ -73,32 +73,7 @@ private static class TestPluginUpdatesReport extends PluginUpdatesReport project.setBuild( new Build() ); project.getBuild().setPluginManagement( new PluginManagement() ); - artifactMetadataSource = mock( ArtifactMetadataSource.class ); - try - { - when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> - { - Artifact artifact = invocation.getArgument( 0 ); - if ( "artifactA".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "2.0.0" ) ); - } - if ( "artifactB".equals( artifact.getArtifactId() ) && "1.0.0".equals( - artifact.getVersion() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( artifact.getVersion() ), - new DefaultArtifactVersion( "1.1.0" ) ); - } - return Collections.singletonList( new DefaultArtifactVersion( artifact.getVersion() ) ); - } ); - } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new RuntimeException( e ); - } + artifactMetadataSource = mockArtifactMetadataSource(); } public TestPluginUpdatesReport withPlugins( Plugin... plugins ) @@ -125,6 +100,20 @@ public TestPluginUpdatesReport withOnlyProjectPlugins( boolean onlyProjectPlugin return this; } + public TestPluginUpdatesReport withRuleSet( + RuleSet ruleSet ) + { + this.ruleSet = ruleSet; + return this; + } + + public TestPluginUpdatesReport withIgnoredVersions( + Set ignoredVersions ) + { + this.ignoredVersions = ignoredVersions; + return this; + } + /** *

Mocks some Plexus components to speed up test execution.

*

Note: these components could just as well be injected using @@ -224,4 +213,23 @@ public void testOnlyProjectPlugins() throws IOException, MavenReportException assertThat( output, containsString( "artifactA" ) ); assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); } + + @Test + public void testOnlyProjectPluginsWithIgnoredVersions() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestPluginUpdatesReport() + .withPlugins( pluginOf( "artifactA" ) ) + .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), + pluginOf( "artifactC" ) ) + .withOnlyUpgradable( true ) + .withOnlyProjectPlugins( true ) + .withIgnoredVersions( Collections.singleton( "2.0.0" ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString().replaceAll( "\\s", " " ) + .replaceAll( "<[^>]+>", " " ).replaceAll( "&[^;]+;", " " ); + assertThat( output, matchesPattern( ".*\\breport.overview.numNewerVersionAvailable\\s+0\\b.*" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index f6e95f52da..f73073f341 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -2,15 +2,14 @@ import javax.xml.stream.XMLStreamException; -import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -27,14 +26,15 @@ import org.junit.Test; import org.mockito.MockedStatic; +import static java.util.Collections.singleton; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; @@ -58,7 +58,12 @@ public class UpdateParentMojoTest public static void setUpStatic() throws ArtifactMetadataRetrievalException { repositorySystem = mockRepositorySystem(); - artifactMetadataSource = mockArtifactMetaDataSource(); + artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + {{ + put( "parent-artifact", new String[] { "1.0.1-SNAPSHOT", "1.0.0", "0.9.0" } ); + put( "issue-670-artifact", new String[] { "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" } ); + put( "unknown-artifact", new String[0] ); + }} ); } @Before @@ -112,35 +117,6 @@ private static RepositorySystem mockRepositorySystem() return repositorySystem; } - @SuppressWarnings( "deprecation" ) - private static ArtifactMetadataSource mockArtifactMetaDataSource() throws ArtifactMetadataRetrievalException - { - ArtifactMetadataSource artifactMetadataSource = mock( ArtifactMetadataSource.class ); - when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> - { - Artifact artifact = invocation.getArgument( 0 ); - if ( "parent-artifact".equals( artifact.getArtifactId() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( "1.0.1-SNAPSHOT" ), - new DefaultArtifactVersion( "1.0.0" ), - new DefaultArtifactVersion( "0.9.0" ) ); - } - else if ( "issue-670-artifact".equals( artifact.getArtifactId() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( "0.0.1-1" ), - new DefaultArtifactVersion( "0.0.1-1-impl-SNAPSHOT" ) ); - } - else if ( "unknown-artifact".equals( artifact.getArtifactId() ) ) - { - return Collections.emptyList(); - } - fail(); - return null; - } ); - return artifactMetadataSource; - } - @Test @SuppressWarnings( "deprecation" ) public void testArtifactIdDoesNotExist() @@ -288,4 +264,23 @@ public void testAllowSnapshotsWithParentVersion() "issue-670-artifact", "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" ) ) ); } + + @Test + public void testIgnoredVersions() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "0.9.0" ); + }} ); + setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.0.0" ) ); + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), is( empty() ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index fbd94b2c0e..daac6a2106 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -4,28 +4,31 @@ import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.change.VersionChange; import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.hamcrest.core.Is; import org.junit.Before; import org.junit.Test; import org.mockito.MockedStatic; +import static java.util.Collections.singleton; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -33,7 +36,7 @@ import static org.mockito.Mockito.when; @SuppressWarnings( "deprecation" ) -public class UseLatestVersionsMojoTest extends AbstractMojoTestCase +public class UseLatestVersionsMojoTest { private UseLatestVersionsMojo mojo; private TestChangeRecorder changeRecorder; @@ -41,7 +44,6 @@ public class UseLatestVersionsMojoTest extends AbstractMojoTestCase @Before public void setUp() throws Exception { - super.setUp(); RepositorySystem repositorySystemMock = mock( RepositorySystem.class ); when( repositorySystemMock.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> { @@ -51,30 +53,13 @@ public void setUp() throws Exception dependency.getClassifier() != null ? dependency.getClassifier() : "default", null ); } ); - ArtifactMetadataSource artifactMetadataSourceMock = mock( ArtifactMetadataSource.class ); - when( artifactMetadataSourceMock.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( - invocation -> - { - Artifact artifact = invocation.getArgument( 0 ); - if ( "dependency-artifact".equals( artifact.getArtifactId() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( "1.1.1-SNAPSHOT" ), - new DefaultArtifactVersion( "1.1.0" ), new DefaultArtifactVersion( "1.1.0-SNAPSHOT" ), - new DefaultArtifactVersion( "1.0.0" ), new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), - new DefaultArtifactVersion( "0.9.0" ) ); - } - else if ( "poison-artifact".equals( artifact.getArtifactId() ) ) - { - return Arrays.asList( new DefaultArtifactVersion( "1.1.1.1-SNAPSHOT" ), - new DefaultArtifactVersion( "1.1.1.0" ), - new DefaultArtifactVersion( "1.1.1.0-SNAPSHOT" ), - new DefaultArtifactVersion( "1.0.0.0" ), - new DefaultArtifactVersion( "1.0.0.0-SNAPSHOT" ), - new DefaultArtifactVersion( "0.9.0.0" ) ); - } - fail(); - return null; - } ); + ArtifactMetadataSource artifactMetadataSourceMock = mockArtifactMetadataSource( new HashMap() + {{ + put( "dependency-artifact", new String[] {"1.1.1-SNAPSHOT", "1.1.0", "1.1.0-SNAPSHOT", "1.0.0", + "1.0.0-SNAPSHOT", "0.9.0"} ); + put( "poison-artifact", new String[] {"1.1.1.1-SNAPSHOT", "1.1.1.0", "1.1.1.0-SNAPSHOT", "1.0.0.0", + "1.0.0.0-SNAPSHOT", "0.9.0.0"} ); + }} ); mojo = new UseLatestVersionsMojo() {{ @@ -254,4 +239,19 @@ public void testPoisonDependencyVersion() "1.0.0" ) ) ); } -} \ No newline at end of file + @Test + public void testIgnoredVersions() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.1.0" ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), Is.is( empty() ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 0bf4622945..625a115dd9 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -20,8 +20,10 @@ */ import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -34,19 +36,28 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.model.IgnoreVersion; +import org.codehaus.mojo.versions.model.Rule; +import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.VersionComparators; import org.hamcrest.CoreMatchers; import org.junit.Test; import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsIterableContaining.hasItems; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyList; @@ -204,32 +215,76 @@ private DefaultVersionsHelper createHelper( ArtifactMetadataSource metadataSourc { final String resourcePath = "/" + getClass().getPackage().getName().replace( '.', '/' ) + "/rules.xml"; final String rulesUri = getClass().getResource( resourcePath ).toExternalForm(); - DefaultVersionsHelper helper = createHelper( rulesUri, metadataSource ); - return helper; + return new DefaultVersionsHelper.Builder() + .withRepositorySystem( lookup( RepositorySystem.class ) ) + .withArtifactResolver( new DefaultArtifactResolver() ) + .withArtifactMetadataSource( metadataSource ) + .withRemoteArtifactRepositories( new ArrayList<>() ) + .withRemotePluginRepositories( new ArrayList<>() ) + .withLocalRepository( new DefaultArtifactRepository( + "", "", new DefaultRepositoryLayout() ) ) + .withWagonManager( lookup( WagonManager.class ) ) + .withSettings( new Settings() ) + .withServerId( "" ) + .withRulesUri( rulesUri ) + .withLog( mock( Log.class ) ) + .withMavenSession( mock( MavenSession.class ) ) + .withMojoExecution( mock( MojoExecution.class ) ).build(); } - private DefaultVersionsHelper createHelper( String rulesUri, ArtifactMetadataSource metadataSource ) - throws Exception + @Test + public void testIgnoredVersionsShouldBeTheOnlyPresentInAnEmptyRuleSet() + throws MojoExecutionException, IllegalAccessException { - WagonManager wagonManager = lookup( WagonManager.class ); - // new DefaultWagonManager() - // { - // @Override - // public Wagon getWagon( String protocol ) - // throws UnsupportedProtocolException - // { - // return new FileWagon(); - // } - // }; - - DefaultVersionsHelper helper = - new DefaultVersionsHelper( lookup( RepositorySystem.class ), new DefaultArtifactResolver(), metadataSource, - new ArrayList(), - new ArrayList(), - new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ), - wagonManager, new Settings(), "", rulesUri, mock( Log.class ), - mock( MavenSession.class ), mock( MojoExecution.class ) ); - return helper; + DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() + .withLog( new SystemStreamLog() ) + .withIgnoredVersions( Arrays.asList( ".*-M.", ".*-SNAPSHOT" ) ) + .build(); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); + assertThat( ruleSet.getIgnoreVersions(), hasSize( 2 ) ); + assertThat( ruleSet.getIgnoreVersions().stream().map( IgnoreVersion::getVersion ) + .collect( Collectors.toList() ), containsInAnyOrder( ".*-M.", ".*-SNAPSHOT" ) ); } + @Test + public void testDefaultsShouldBePresentInAnEmptyRuleSet() + throws MojoExecutionException, IllegalAccessException + { + DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() + .withLog( new SystemStreamLog() ) + .withIgnoredVersions( singletonList( ".*-M." ) ) + .build(); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); + assertThat( ruleSet.getComparisonMethod(), is( "maven" ) ); + } + + @Test + public void testIgnoredVersionsShouldExtendTheRuleSet() throws MojoExecutionException, IllegalAccessException + { + DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() + .withLog( new SystemStreamLog() ) + .withRuleSet( new RuleSet() + {{ + setIgnoreVersions( new ArrayList<>( singletonList( new IgnoreVersion() + {{ + setVersion( "1.0.0" ); + }} ) ) ); + setRules( singletonList( new Rule() + {{ + setGroupId( "org.slf4j" ); + setArtifactId( "slf4j-api" ); + setIgnoreVersions( singletonList( new IgnoreVersion() + {{ + setType( "regex" ); + setVersion( "^[^1]\\.*" ); + }} ) ); + }} ) ); + }} ) + .withIgnoredVersions( Arrays.asList( ".*-M.", ".*-SNAPSHOT" ) ) + .build(); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); + assertThat( ruleSet.getIgnoreVersions(), hasSize( 3 ) ); + assertThat( ruleSet.getIgnoreVersions().stream().map( IgnoreVersion::getVersion ) + .collect( Collectors.toList() ), containsInAnyOrder( ".*-M.", ".*-SNAPSHOT", "1.0.0" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java b/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java new file mode 100644 index 0000000000..e70da476ea --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.codehaus.mojo.versions.model; + +import java.util.Objects; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +/** + * Convenience class for quickly creating {@link IgnoreVersion} instances. + */ +public class TestIgnoreVersions extends IgnoreVersion +{ + public static final String TYPE_REGEX = "regex"; + + public static final String TYPE_EXACT = "exact"; + + /** + * Sets the given type returning the modified instance. + * + * @param type required type + * @return modified instance + */ + public TestIgnoreVersions withType( String type ) + { + setType( type ); + return this; + } + + /** + * Sets the given version returning the modified instance. + * + * @param version required version + * @return modified instance + */ + public TestIgnoreVersions withVersion( String version ) + { + setVersion( version ); + return this; + } + + /** + * Produces a {@linkplain Matcher} instance to match against {@linkplain IgnoreVersion} instances, + * which don't have {@linkplain #equals(Object)} and {@linkplain #hashCode()} + * @param ignoreVersion this ignoreVersion object + * @return Matcher returning true if another object matches the given instance + * @param

class of the ignoreVersion instance + */ + public static

Matcher

matches( P ignoreVersion ) + { + return new TypeSafeMatcher

() + { + @Override + public void describeTo( Description description ) + { + description.appendText( Objects.toString( ignoreVersion ) ); + } + + @Override + protected void describeMismatchSafely( P other, Description description ) + { + description.appendText( Objects.toString( other ) ); + } + + @Override + protected boolean matchesSafely( P other ) + { + return Objects.equals( ignoreVersion.getType(), other.getType() ) + && Objects.equals( ignoreVersion.getVersion(), other.getVersion() ); + } + }; + } + +} diff --git a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java new file mode 100644 index 0000000000..0d9ea6234e --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.codehaus.mojo.versions.utils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * Various mock creating utilities + */ +public class MockUtils +{ + private static final Map DEFAULT_VERSION_MAP = new HashMap() + {{ + put( "artifactA", new String[] {"1.0.0", "2.0.0"} ); + put( "artifactB", new String[] {"1.0.0", "1.1.0"} ); + put( "artifactC", new String[] {"1.0.0"} ); + }}; + + /** + * Creates a mocked {@linkplain ArtifactMetadataSource}, providing the default version set + * @return mocked {@linkplain ArtifactMetadataSource} + */ + public static ArtifactMetadataSource mockArtifactMetadataSource() + { + return mockArtifactMetadataSource( DEFAULT_VERSION_MAP ); + } + + /** + * Creates a mocked {@linkplain ArtifactMetadataSource}, providing the version map given in the argument + * @param versionMap requested version map + * @return mocked {@linkplain ArtifactMetadataSource} + */ + public static ArtifactMetadataSource mockArtifactMetadataSource( Map versionMap ) + { + ArtifactMetadataSource artifactMetadataSource = mock( ArtifactMetadataSource.class ); + try + { + when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + invocation -> + { + Artifact artifact = invocation.getArgument( 0 ); + return versionMap.entrySet().stream() + .filter( e -> e.getKey().equals( artifact.getArtifactId() ) ) + .findAny() + .map( e -> Arrays.stream( e.getValue() ) + .map( DefaultArtifactVersion::new ) + .collect( ArrayList::new, ArrayList::add, ArrayList::add ) ) + .orElse( null ); // should tell us if we haven't populated all cases in the test + } ); + } + catch ( ArtifactMetadataRetrievalException e ) + { + throw new RuntimeException( e ); + } + return artifactMetadataSource; + } +} diff --git a/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml b/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml new file mode 100644 index 0000000000..47dc651b0a --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml @@ -0,0 +1,57 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + + + localhost + dummy-api + 1.0.0 + + + + + + + localhost + dummy-api + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${project.version} + + display-dependency-updates + + + + + + + + regex + .+-SNAPSHOT + + + regex + .+-M\d+ + + + 1.0.1 + + + + + + + + diff --git a/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml b/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml new file mode 100644 index 0000000000..eccd53194e --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + + + org.codehaus.mojo + versions-maven-plugin + ${project.version} + + display-plugin-updates + + + + + + + + regex + .+-SNAPSHOT + + + regex + .+-M\d+ + + + 1.0.1 + + + + + + + localhost + dummy-api + 1.0.0 + + + + From 4637b2df8adadb29347d26273f982ab50fa20024 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 12 Sep 2022 12:28:57 +0200 Subject: [PATCH 119/441] #687: Using the DependencyBuilder across the project --- ...AbstractVersionsDependencyUpdaterMojo.java | 15 +- .../versions/CompareDependenciesMojo.java | 11 +- .../versions/DisplayParentUpdatesMojo.java | 15 +- .../versions/DisplayPluginUpdatesMojo.java | 33 ++- .../mojo/versions/UpdateParentMojo.java | 14 +- .../mojo/versions/UseLatestReleasesMojo.java | 17 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 18 +- .../mojo/versions/UseLatestVersionsMojo.java | 16 +- .../mojo/versions/UseReleasesMojo.java | 14 +- .../versions/api/DefaultVersionsHelper.java | 19 +- .../codehaus/mojo/versions/api/PomHelper.java | 15 +- .../versions/utils/DependencyBuilder.java | 192 ++++++++++++++++++ .../mojo/versions/DependencyBuilder.java | 133 ------------ .../versions/DependencyUpdatesReportTest.java | 2 + .../versions/UseLatestVersionsMojoTest.java | 1 + .../filtering/DependencyFilterTest.java | 2 +- .../filtering/TokenizedMatcherTest.java | 30 +-- 17 files changed, 305 insertions(+), 242 deletions(-) create mode 100644 src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java delete mode 100644 src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index f3349023a5..6ebbdb09d8 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; +import org.codehaus.mojo.versions.utils.DependencyBuilder; /** * Base class for a mojo that updates dependency versions. @@ -239,13 +240,13 @@ protected Artifact toArtifact( Dependency dependency ) protected Artifact toArtifact( Parent model ) throws MojoExecutionException { - Dependency d = new Dependency(); - d.setArtifactId( model.getArtifactId() ); - d.setGroupId( model.getGroupId() ); - d.setVersion( model.getVersion() ); - d.setType( "pom" ); - d.setScope( Artifact.SCOPE_COMPILE ); - return this.toArtifact( d ); + return this.toArtifact( DependencyBuilder.newBuilder() + .withGroupId( model.getGroupId() ) + .withArtifactId( model.getArtifactId() ) + .withVersion( model.getVersion() ) + .withType( "pom" ) + .withScope( Artifact.SCOPE_COMPILE ) + .build() ); } protected String toString( MavenProject project ) diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index ad0a716887..4b2371769c 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -44,6 +44,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; /** * Compare dependency versions of the current project to dependencies or dependency management of a remote repository @@ -146,12 +147,10 @@ protected void update( ModifiedPomXMLEventReader pom ) String rArtifactId = remotePomParts[1]; String rVersion = remotePomParts[2]; - Dependency remoteDependency = new Dependency(); - remoteDependency.setGroupId( rGroupId ); - remoteDependency.setArtifactId( rArtifactId ); - remoteDependency.setVersion( rVersion ); - - Artifact remoteArtifact = this.toArtifact( remoteDependency ); + Artifact remoteArtifact = this.toArtifact( DependencyBuilder.newBuilder() + .withGroupId( rGroupId ) + .withArtifactId( rArtifactId ) + .withVersion( rVersion ).build() ); MavenProject remoteMavenProject = null; try { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index dca737c981..7ef2a9167f 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -26,11 +26,11 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; /** * Displays any updates of the project's parent project @@ -75,13 +75,12 @@ public void execute() throw new MojoExecutionException( "Invalid version range specification: " + version, e ); } - Dependency dependency = new Dependency(); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setVersion( version ); - dependency.setType( "pom" ); - - Artifact artifact = getHelper().createDependencyArtifact( dependency ); + Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( version ) + .withType( "pom" ) + .build() ); ArtifactVersion artifactVersion; try diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index e4e931e3ee..f7cd5e8e4d 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -61,7 +61,6 @@ import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; import org.apache.maven.lifecycle.mapping.LifecycleMapping; -import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Prerequisites; @@ -92,6 +91,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.PluginComparator; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.IOUtil; @@ -427,15 +427,13 @@ public void execute() ArtifactVersion minRequires = null; for ( int j = newerVersions.length - 1; j >= 0; j-- ) { - - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setVersion( newerVersions[j].toString() ); - dependency.setType( "pom" ); - dependency.setScope( "runtime" ); - - Artifact probe = getHelper().createDependencyArtifact( dependency ); + Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( newerVersions[j].toString() ) + .withType( "pom" ) + .withScope( Artifact.SCOPE_RUNTIME ) + .build() ); try { getHelper().resolveArtifact( probe, true ); @@ -493,14 +491,13 @@ public void execute() } if ( effectiveVersion != null ) { - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setVersion( effectiveVersion ); - dependency.setType( "pom" ); - dependency.setScope( "runtime" ); - - Artifact probe = getHelper().createDependencyArtifact( dependency ); + Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( effectiveVersion ) + .withType( "pom" ) + .withScope( Artifact.SCOPE_RUNTIME ) + .build() ); try { getHelper().resolveArtifact( probe, true ); diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 46db1a384a..50fcfdf27f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -26,13 +26,13 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; /** * Sets the parent version to the latest parent version. @@ -109,12 +109,12 @@ protected void update( ModifiedPomXMLEventReader pom ) version = parentVersion; } - Dependency dependency = new Dependency(); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setVersion( version ); - dependency.setType( "pom" ); - Artifact artifact = getHelper().createDependencyArtifact( dependency ); + Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( version ) + .withType( "pom" ) + .build() ); VersionRange versionRange; try diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index e4b09dd03b..501e622edf 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -44,6 +44,9 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; + +import static java.util.Collections.singletonList; /** * Replaces any release versions with the latest release version. @@ -111,14 +114,12 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - Dependency dependency = new Dependency(); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setVersion( getProject().getParent().getVersion() ); - dependency.setType( "pom" ); - List list = new ArrayList(); - list.add( dependency ); - useLatestReleases( pom, list ); + useLatestReleases( pom, singletonList( DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( getProject().getParent().getVersion() ) + .withType( "pom" ) + .build() ) ); } } catch ( ArtifactMetadataRetrievalException e ) diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 7f2cc749de..17567a4aab 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -43,6 +42,9 @@ import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; + +import static java.util.Collections.singletonList; /** * Replaces any release versions with the latest snapshot version (if it has been deployed). @@ -110,14 +112,12 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - Dependency dependency = new Dependency(); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setVersion( getProject().getParent().getVersion() ); - dependency.setType( "pom" ); - List list = new ArrayList(); - list.add( dependency ); - useLatestSnapshots( pom, list ); + useLatestSnapshots( pom, singletonList( DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( getProject().getParent().getVersion() ) + .withType( "pom" ) + .build() ) ); } } catch ( ArtifactMetadataRetrievalException e ) diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 55640b1c92..25380e4d3e 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.Collection; -import java.util.Collections; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -40,6 +39,9 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; + +import static java.util.Collections.singletonList; /** * Replaces any version with the latest version. @@ -129,12 +131,12 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - Dependency dependency = new Dependency(); - dependency.setArtifactId( getProject().getParent().getArtifactId() ); - dependency.setGroupId( getProject().getParent().getGroupId() ); - dependency.setVersion( getProject().getParent().getVersion() ); - dependency.setType( "pom" ); - useLatestVersions( pom, Collections.singletonList( dependency ) ); + useLatestVersions( pom, singletonList( DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( getProject().getParent().getVersion() ) + .withType( "pom" ) + .build() ) ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index bd25c628f8..0cb8c751c9 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -38,6 +38,7 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; /** * Replaces any -SNAPSHOT versions with the corresponding release version (if it has been released). @@ -119,13 +120,12 @@ private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project ) final MavenProject parent = getProject().getParent(); - Dependency dependency = new Dependency(); - dependency.setGroupId( parent.getGroupId() ); - dependency.setArtifactId( parent.getArtifactId() ); - dependency.setVersion( releaseVersion ); - dependency.setType( "pom" ); - - Artifact artifact = getHelper().createDependencyArtifact( dependency ); + Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( parent.getGroupId() ) + .withArtifactId( parent.getArtifactId() ) + .withVersion( releaseVersion ) + .withType( "pom" ) + .build() ); if ( !isIncluded( artifact ) ) { return; diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 60108d96a1..3251311d6e 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -81,6 +81,7 @@ import org.codehaus.mojo.versions.model.io.xpp3.RuleXpp3Reader; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.ordering.VersionComparators; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.mojo.versions.utils.PluginComparator; import org.codehaus.mojo.versions.utils.RegexUtils; @@ -622,15 +623,15 @@ public Artifact createPluginArtifact( String groupId, String artifactId, String public Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, String classifier, String scope, boolean optional ) { - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setType( type ); - dependency.setClassifier( classifier ); - dependency.setScope( scope ); - dependency.setOptional( optional ); - dependency.setVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ); - return repositorySystem.createDependencyArtifact( dependency ); + return repositorySystem.createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withType( type ) + .withClassifier( classifier ) + .withScope( scope ) + .withOptional( optional ) + .withVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ) + .build() ); } @Override diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index e3d625d459..0df81259c5 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -62,6 +62,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.RegexUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; @@ -1667,13 +1668,13 @@ public static List readImportedPOMsFromDependencyManagementSection( { if ( "pom".equals( depData.get( typeElement ) ) && "import".equals( depData.get( scopeElement ) ) ) { - Dependency dependency = new Dependency(); - dependency.setGroupId( depData.get( groupIdElement ) ); - dependency.setArtifactId( depData.get( artifactIdElement ) ); - dependency.setVersion( depData.get( versionElement ) ); - dependency.setType( depData.get( typeElement ) ); - dependency.setScope( depData.get( scopeElement ) ); - importedPOMs.add( dependency ); + importedPOMs.add( DependencyBuilder.newBuilder() + .withGroupId( depData.get( groupIdElement ) ) + .withArtifactId( depData.get( artifactIdElement ) ) + .withVersion( depData.get( versionElement ) ) + .withType( depData.get( typeElement ) ) + .withScope( depData.get( scopeElement ) ) + .build() ); } depData.clear(); } diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java new file mode 100644 index 0000000000..dfab65532b --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java @@ -0,0 +1,192 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.codehaus.mojo.versions.utils; + +import java.util.Optional; + +import org.apache.maven.model.Dependency; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; + +/** + * Builder class for {@linkplain Dependency} + */ +@SuppressWarnings( "OptionalUsedAsFieldOrParameterType" ) +public class DependencyBuilder +{ + private Optional groupId = empty(); + private Optional artifactId = empty(); + private Optional version = empty(); + private Optional type = empty(); + private Optional classifier = empty(); + private Optional scope = empty(); + private Optional optional = empty(); + + private DependencyBuilder() + { + } + + /** + * Passes groupId to the builder + * @param groupId given groupId + * @return builder instance + */ + public DependencyBuilder withGroupId( String groupId ) + { + this.groupId = ofNullable( groupId ); + return this; + } + + /** + * Passes artifactId to the builder + * @param artifactId given artifactId + * @return builder instance + */ + public DependencyBuilder withArtifactId( String artifactId ) + { + this.artifactId = ofNullable( artifactId ); + return this; + } + + /** + * Passes version to the builder + * @param version given version + * @return builder instance + */ + public DependencyBuilder withVersion( String version ) + { + this.version = ofNullable( version ); + return this; + } + + /** + * Passes type to the builder + * @param type given type + * @return builder instance + */ + public DependencyBuilder withType( String type ) + { + this.type = ofNullable( type ); + return this; + } + + /** + * Passes classifier to the builder + * @param classifier given classifier + * @return builder instance + */ + public DependencyBuilder withClassifier( String classifier ) + { + this.classifier = ofNullable( classifier ); + return this; + } + + /** + * Passes scope to the builder + * @param scope given scope + * @return builder instance + */ + public DependencyBuilder withScope( String scope ) + { + this.scope = ofNullable( scope ); + return this; + } + + /** + * Passes optional to the builder as String + * @param optional given optional as String + * @return builder instance + */ + public DependencyBuilder withOptional( String optional ) + { + this.optional = ofNullable( optional ); + return this; + } + + /** + * Passes optional to the builder as boolean + * @param optional given optional as boolean + * @return builder instance + */ + public DependencyBuilder withOptional( boolean optional ) + { + this.optional = of( String.valueOf( optional ) ); + return this; + } + + /** + * Creates a new instance of the builder + * @return new instance of the builder + */ + public static DependencyBuilder newBuilder() + { + return new DependencyBuilder(); + } + + /** + * Convenience builder method + * @return new instance of {@linkplain Dependency} + */ + public static Dependency dependencyWith( String groupId, String artifactId, String version ) + { + return newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ) + .build(); + } + + /** + * Convenience builder method + * @return new instance of {@linkplain Dependency} + */ + public static Dependency dependencyWith( String groupId, String artifactId, String version, String type, + String classifier, String scope ) + { + return newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ) + .withType( type ) + .withClassifier( classifier ) + .withScope( scope ) + .build(); + } + + /** + * Builds the {@linkplain Dependency} instance + * @return {@linkplain Dependency} instance + */ + public Dependency build() + { + Dependency inst = new Dependency(); + groupId.ifPresent( inst::setGroupId ); + artifactId.ifPresent( inst::setArtifactId ); + version.ifPresent( inst::setVersion ); + type.ifPresent( inst::setType ); + classifier.ifPresent( inst::setClassifier ); + scope.ifPresent( inst::setScope ); + optional.ifPresent( inst::setOptional ); + + return inst; + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java b/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java deleted file mode 100644 index 05bf3817b1..0000000000 --- a/src/test/java/org/codehaus/mojo/versions/DependencyBuilder.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.codehaus.mojo.versions; - -import org.apache.maven.model.Dependency; - -public class DependencyBuilder -{ - - public String getGroupId() - { - return groupId; - } - - public DependencyBuilder withGroupId( String groupId ) - { - this.groupId = groupId; - return this; - } - - public String getArtifactId() - { - return artifactId; - } - - public DependencyBuilder withArtifactId( String artifactId ) - { - this.artifactId = artifactId; - return this; - } - - public String getVersion() - { - return version; - } - - public DependencyBuilder withVersion( String version ) - { - this.version = version; - return this; - } - - public String getType() - { - return type; - } - - public DependencyBuilder withType( String type ) - { - this.type = type; - return this; - } - - public String getClassifier() - { - return classifier; - } - - public DependencyBuilder withClassifier( String classifier ) - { - this.classifier = classifier; - return this; - } - - public String getScope() - { - return scope; - } - - public DependencyBuilder withScope( String scope ) - { - this.scope = scope; - return this; - } - - private String groupId = null; - private String artifactId = null; - private String version = null; - private String type = null; - private String classifier = null; - private String scope = null; - - public static DependencyBuilder newBuilder() - { - return new DependencyBuilder(); - } - - public static DependencyBuilder newBuilder( String groupId, String artifactId, String version, String type, - String classifier, String scope ) - { - return newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ) - .withType( type ) - .withClassifier( classifier ) - .withScope( scope ); - } - - public static DependencyBuilder newBuilder( String groupId, String artifactId, String version ) - { - return newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ); - } - - public static Dependency dependencyWith( String groupId, String artifactId, String version ) - { - return newBuilder( groupId, artifactId, version ) - .build(); - } - - public static Dependency dependencyWith( String groupId, String artifactId, String version, String type, - String classifier, String scope ) - { - return newBuilder( groupId, artifactId, version, type, classifier, scope ) - .build(); - } - - - public Dependency build() - { - Dependency dep = new Dependency(); - dep.setGroupId( groupId ); - dep.setArtifactId( artifactId ); - dep.setVersion( version ); - dep.setType( type ); - dep.setClassifier( classifier ); - dep.setScope( scope ); - - return dep; - } - -} diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index d3ee871aaf..02bd99b3e0 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -39,6 +39,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.plexus.i18n.I18N; import org.junit.Test; @@ -64,6 +65,7 @@ public class DependencyUpdatesReportTest { private static class TestDependencyUpdatesReport extends DependencyUpdatesReport { + @SuppressWarnings( "deprecation" ) TestDependencyUpdatesReport() { mockPlexusComponents(); diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index daac6a2106..6072d925ee 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -17,6 +17,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.core.Is; import org.junit.Before; diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java index aca6d8697a..9458df0b20 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -4,7 +4,7 @@ import java.util.Set; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.DependencyBuilder; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java index e5ad0f2249..62dd78791c 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java @@ -1,7 +1,7 @@ package org.codehaus.mojo.versions.filtering; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.DependencyBuilder; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -92,13 +92,13 @@ void acceptsWildcards() @Nested class NullClassifier { - private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( - "foo", - "foo", - "foo", - "foo", - "foo", - "foo" ); + private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder() + .withGroupId( "foo" ) + .withArtifactId( "foo" ) + .withVersion( "foo" ) + .withType( "foo" ) + .withClassifier( "foo" ) + .withScope( "foo" ); private final TokenizedMatcher matcher = TokenizedMatcher .parse( "*:*:*:*:null:*" ); @@ -127,13 +127,13 @@ void rejectsNonnullScope() @Nested class NullScope { - private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder( - "foo", - "foo", - "foo", - "foo", - "foo", - "foo" ); + private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder() + .withGroupId( "foo" ) + .withArtifactId( "foo" ) + .withVersion( "foo" ) + .withType( "foo" ) + .withClassifier( "foo" ) + .withScope( "foo" ); private final TokenizedMatcher matcher = TokenizedMatcher .parse( "*:*:*:*:*:null" ); From 9ea2e83cb0c0c92ffce3e776eb6de48a75da9a2c Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Thu, 15 Sep 2022 00:38:48 +0200 Subject: [PATCH 120/441] Restriction as parameter to prevent more than 7 parameters in methods in the next PRs. --- .../mojo/versions/AbstractVersionsReport.java | 12 +- .../versions/AbstractVersionsUpdaterMojo.java | 13 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 4 +- .../mojo/versions/UseNextSnapshotsMojo.java | 4 +- .../versions/api/AbstractVersionDetails.java | 102 +++++------- .../mojo/versions/api/PropertyVersions.java | 18 ++- .../mojo/versions/api/UpdateScope.java | 148 ++++++++++++------ .../mojo/versions/api/VersionDetails.java | 49 ++---- 8 files changed, 172 insertions(+), 178 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 0a7591adf2..8e093ccc3d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -276,18 +276,10 @@ protected abstract void doGenerateReport( Locale locale, Sink sink ) * @since 1.0-alpha-1 */ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, - boolean allowingSnapshots, boolean usePluginRepositories ) + Boolean allowingSnapshots, boolean usePluginRepositories ) throws MavenReportException { - boolean includeSnapshots = this.allowSnapshots; - if ( allowingSnapshots ) - { - includeSnapshots = true; - } - if ( allowingSnapshots ) - { - includeSnapshots = false; - } + boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; try { final ArtifactVersions artifactVersions = diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 215af4a29d..b2a45dbd5d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -355,18 +355,9 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver boolean allowDowngrade ) throws ArtifactMetadataRetrievalException, MojoExecutionException { - boolean includeSnapshots = this.allowSnapshots; - if ( Boolean.TRUE.equals( allowingSnapshots ) ) - { - includeSnapshots = true; - } - if ( Boolean.FALSE.equals( allowingSnapshots ) ) - { - includeSnapshots = false; - } + boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); - return artifactVersions.getNewestVersion( versionRange, null, null, includeSnapshots, - true, true, allowDowngrade ); + return artifactVersions.getNewestVersion( versionRange, null, includeSnapshots, allowDowngrade ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 17567a4aab..16e9d87558 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -173,7 +174,8 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + ArtifactVersion[] newer = versions.getVersions( restriction, true ); getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); String latestVersion; diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 520e12f695..b13960609f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -30,6 +30,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -155,7 +156,8 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - ArtifactVersion[] newer = versions.getVersions( lowerBound, upperBound, true, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + ArtifactVersion[] newer = versions.getVersions( restriction, true ); getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); for ( ArtifactVersion artifactVersion : newer ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index f188ccceef..f4bbc04a50 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -29,6 +29,7 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; @@ -129,23 +130,25 @@ public final ArtifactVersion[] getVersions() public final ArtifactVersion[] getVersions( VersionRange versionRange, boolean includeSnapshots ) { - return getVersions( versionRange, null, null, includeSnapshots, true, true ); + return getVersions( versionRange, null, includeSnapshots ); } - public final ArtifactVersion[] getVersions( ArtifactVersion currentVersion, ArtifactVersion upperBound ) + public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound ) { - return getVersions( currentVersion, upperBound, isIncludeSnapshots() ); + return getVersions( lowerBound, upperBound, isIncludeSnapshots() ); } - public final ArtifactVersion[] getVersions( ArtifactVersion currentVersion, ArtifactVersion upperBound, + public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ) { - return getVersions( currentVersion, upperBound, includeSnapshots, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + return getVersions( restriction, includeSnapshots ); } private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) { - return getVersions( version, null, includeSnapshots, false, true ); + Restriction restriction = new Restriction( version, false, null, false ); + return getVersions( restriction, includeSnapshots ); } public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) @@ -156,15 +159,14 @@ public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, Artif public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ) { - return getNewestVersion( lowerBound, upperBound, includeSnapshots, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + return getNewestVersion( restriction, includeSnapshots ); } - public final ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound, - ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ) + public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, + boolean includeSnapshots ) { - return getNewestVersion( versionRange, lowerBound, upperBound, includeSnapshots, includeLower, - includeUpper, false ); + return getNewestVersion( versionRange, restriction, includeSnapshots, false ); } private static Iterable reverse( T[] array ) @@ -172,9 +174,8 @@ private static Iterable reverse( T[] array ) return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); } - public final ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound, - ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper, boolean allowDowngrade ) + public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, + boolean includeSnapshots, boolean allowDowngrade ) { final VersionComparator versionComparator = getVersionComparator(); // reverse( getVersions( ... ) ) will contain versions sorted from latest to oldest, @@ -186,13 +187,7 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Artifa { continue; } - int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate ); - int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate ); - if ( lower > 0 || upper < 0 ) - { - continue; - } - if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) + if ( restriction != null && !restriction.containsVersion( candidate ) ) { continue; } @@ -205,16 +200,14 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Artifa return null; } - public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, - boolean includeUpper ) + public final ArtifactVersion getNewestVersion( Restriction restriction, boolean includeSnapshots ) { - return getNewestVersion( null, lowerBound, upperBound, includeSnapshots, includeLower, includeUpper ); + return getNewestVersion( null, restriction, includeSnapshots ); } public final ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ) { - return getNewestVersion( versionRange, null, null, includeSnapshots, true, true ); + return getNewestVersion( versionRange, null, includeSnapshots ); } public final boolean containsVersion( String version ) @@ -276,7 +269,8 @@ public final ArtifactVersion[] getNewerVersions( String versionString, int upper ArtifactVersion upperBound = upperBoundSegment == -1 ? null : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment ); - return getVersions( lowerBound, upperBound, includeSnapshots, allowDowngrade, allowDowngrade ); + Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); + return getVersions( restriction, includeSnapshots ); } public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) @@ -286,25 +280,24 @@ public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, Artif public final ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ) { - return getOldestVersion( versionRange, null, null, includeSnapshots, true, true ); + return getOldestVersion( versionRange, null, includeSnapshots ); } public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ) { - return getOldestVersion( lowerBound, upperBound, includeSnapshots, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + return getOldestVersion( restriction, includeSnapshots ); } - public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, - boolean includeUpper ) + public final ArtifactVersion getOldestVersion( Restriction restriction, + boolean includeSnapshots ) { - return getOldestVersion( null, lowerBound, upperBound, includeSnapshots, includeLower, includeUpper ); + return getOldestVersion( null, restriction, includeSnapshots ); } - public final ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion lowerBound, - ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ) + public final ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, + boolean includeSnapshots ) { ArtifactVersion oldest = null; final VersionComparator versionComparator = getVersionComparator(); @@ -314,13 +307,7 @@ public final ArtifactVersion getOldestVersion( VersionRange versionRange, Artifa { continue; } - int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate ); - int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate ); - if ( lower > 0 || upper < 0 ) - { - continue; - } - if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) + if ( restriction != null && !restriction.containsVersion( candidate ) ) { continue; } @@ -340,15 +327,13 @@ else if ( versionComparator.compare( oldest, candidate ) > 0 ) return oldest; } - public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, boolean includeUpper ) + public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ) { - return getVersions( null, lowerBound, upperBound, includeSnapshots, includeLower, includeUpper ); + return getVersions( null, restriction, includeSnapshots ); } - public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactVersion lowerBound, - ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ) + public final ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, + boolean includeSnapshots ) { final VersionComparator versionComparator = getVersionComparator(); Set result = new TreeSet<>( versionComparator ); @@ -358,13 +343,7 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactV { continue; } - int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate ); - int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate ); - if ( lower > 0 || upper < 0 ) - { - continue; - } - if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) + if ( restriction != null && !restriction.containsVersion( candidate ) ) { continue; } @@ -502,17 +481,20 @@ public final ArtifactVersion[] getAllUpdates( VersionRange versionRange ) public ArtifactVersion getOldestUpdate( VersionRange versionRange, boolean includeSnapshots ) { - return getOldestVersion( versionRange, getCurrentVersion(), null, includeSnapshots, false, true ); + Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); + return getOldestVersion( versionRange, restriction, includeSnapshots ); } public ArtifactVersion getNewestUpdate( VersionRange versionRange, boolean includeSnapshots ) { - return getNewestVersion( versionRange, getCurrentVersion(), null, includeSnapshots, false, true ); + Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); + return getNewestVersion( versionRange, restriction, includeSnapshots ); } public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ) { - return getVersions( versionRange, getCurrentVersion(), null, includeSnapshots, false, true ); + Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); + return getVersions( versionRange, restriction, includeSnapshots ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index be119df8df..6292349644 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -36,6 +36,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.OverConstrainedVersionException; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.Property; @@ -342,25 +343,25 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert ? VersionRange.createFromVersionSpec( property.getVersion() ) : null; helper.getLog().debug( "Property ${" + property.getName() + "}: Restricting results to " + range ); - ArtifactVersion lowerBoundArtifactVersion = helper.createArtifactVersion( currentVersion ); + ArtifactVersion lowerBound = helper.createArtifactVersion( currentVersion ); if ( allowDowngrade ) { - Optional updatedVersion = getLowerBound( lowerBoundArtifactVersion, unchangedSegment ); - lowerBoundArtifactVersion = updatedVersion.map( helper::createArtifactVersion ).orElse( null ); + Optional updatedVersion = getLowerBound( lowerBound, unchangedSegment ); + lowerBound = updatedVersion.map( helper::createArtifactVersion ).orElse( null ); } if ( helper.getLog().isDebugEnabled() ) { - helper.getLog().debug( "lowerBoundArtifactVersion: " + lowerBoundArtifactVersion ); + helper.getLog().debug( "lowerBoundArtifactVersion: " + lowerBound ); } ArtifactVersion upperBound = null; if ( unchangedSegment != -1 ) { - upperBound = getVersionComparator().incrementSegment( lowerBoundArtifactVersion, unchangedSegment ); + upperBound = getVersionComparator().incrementSegment( lowerBound, unchangedSegment ); helper.getLog().debug( "Property ${" + property.getName() + "}: upperBound is: " + upperBound ); } - ArtifactVersion result = - getNewestVersion( range, lowerBoundArtifactVersion, upperBound, includeSnapshots, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + ArtifactVersion result = getNewestVersion( range, restriction, includeSnapshots ); helper.getLog().debug( "Property ${" + property.getName() + "}: Current winner is: " + result ); @@ -427,7 +428,8 @@ private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper { upperBound = getVersionComparator().incrementSegment( lowerBound, segment ); } - return getNewestVersion( range, lowerBound, upperBound, includeSnapshots, false, false ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + return getNewestVersion( range, restriction, includeSnapshots ); } private final class PropertyVersionComparator diff --git a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java index e3bdb6d16a..5dbdb2eb3f 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java +++ b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java @@ -26,6 +26,7 @@ import java.util.Map; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; @@ -54,11 +55,13 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 - ? null - : versionDetails.getOldestVersion( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); + Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); + return versionDetails.getOldestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -73,11 +76,13 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 - ? null - : versionDetails.getNewestVersion( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); + Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); + return versionDetails.getNewestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -92,10 +97,13 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getVersions( currentVersion, - versionComparator.incrementSegment( currentVersion, 2 ), - includeSnapshots, false, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); + Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); + return versionDetails.getVersions( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -120,10 +128,14 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), - includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getOldestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -138,10 +150,14 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), - includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getNewestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -156,10 +172,14 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 3 ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 2 ), - versionComparator.incrementSegment( currentVersion, 1 ), includeSnapshots, true, - false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getVersions( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -184,10 +204,14 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), - includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getOldestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -202,10 +226,14 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), includeSnapshots, true, - false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getNewestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -220,10 +248,14 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 2 ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 1 ), - versionComparator.incrementSegment( currentVersion, 0 ), - includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); + ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); + return versionDetails.getVersions( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -248,9 +280,13 @@ public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 1 ? null - : versionDetails.getOldestVersion( versionComparator.incrementSegment( currentVersion, 0 ), - null, includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, null, false ); + return versionDetails.getOldestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -265,9 +301,13 @@ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 1 ? null - : versionDetails.getNewestVersion( versionComparator.incrementSegment( currentVersion, 0 ), - null, includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, null, false ); + return versionDetails.getNewestVersion( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -282,10 +322,13 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV VersionComparator versionComparator = versionDetails.getVersionComparator(); try { - return versionComparator.getSegmentCount( currentVersion ) < 1 - ? null - : versionDetails.getVersions( versionComparator.incrementSegment( currentVersion, 0 ), - null, includeSnapshots, true, false ); + if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) + { + return null; + } + ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); + Restriction restriction = new Restriction( lowerBound, true, null, false ); + return versionDetails.getVersions( restriction, includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -306,21 +349,24 @@ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactV public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, boolean includeSnapshots ) { - return versionDetails.getOldestVersion( currentVersion, null, includeSnapshots, false, false ); + Restriction restriction = new Restriction( currentVersion, false, null, false ); + return versionDetails.getOldestVersion( restriction, includeSnapshots ); } /** {@inheritDoc} */ public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, boolean includeSnapshots ) { - return versionDetails.getNewestVersion( currentVersion, null, includeSnapshots, false, false ); + Restriction restriction = new Restriction( currentVersion, false, null, false ); + return versionDetails.getNewestVersion( restriction, includeSnapshots ); } /** {@inheritDoc} */ public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, boolean includeSnapshots ) { - return versionDetails.getVersions( currentVersion, null, includeSnapshots, false, false ); + Restriction restriction = new Restriction( currentVersion, false, null, false ); + return versionDetails.getVersions( restriction, includeSnapshots ); } }; diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 65ea069672..399efbedaa 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -20,6 +20,7 @@ */ import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; @@ -100,32 +101,24 @@ public interface VersionDetails /** * Returns all available versions within the specified bounds. * - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ); + ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ); /** * Returns all available versions within the specified bounds. * * @param versionRange The version range within which the version must exist where null imples * [,). - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( VersionRange versionRange, ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, boolean includeUpper ); + ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); /** * Returns the latest version newer than the specified lowerBound, but less than the specified upper bound or @@ -155,16 +148,12 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * Returns the latest version newer than the specified current version, but less than the specified upper bound or * null if no such version exists. * - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return the latest version between lowerBound and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ); + ArtifactVersion getNewestVersion( Restriction restriction, boolean includeSnapshots ); /** * Returns the latest version newer than the specified current version, but less than the specified upper bound or @@ -172,16 +161,12 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * * @param versionRange The version range within which the version must exist where null imples * [,). - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return the latest version between lowerBound and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( VersionRange versionRange, ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, boolean includeUpper ); + ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); /** * Returns the latest version within the specified version range or null if no such version exists. @@ -230,32 +215,24 @@ ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion up /** * Returns the oldest version within the specified bounds or null if no such version exists. * - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return the oldest version between lowerBound and upperBound or null if no version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots, - boolean includeLower, boolean includeUpper ); + ArtifactVersion getOldestVersion( Restriction restriction, boolean includeSnapshots ); /** * Returns the oldest version within the specified bounds or null if no such version exists. * * @param versionRange The version range within which the version must exist where null imples * [,). - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. + * @param restriction version criteria. * @param includeSnapshots true if snapshots are to be included. - * @param includeLower true if the lower bound is inclusive. - * @param includeUpper true if the upper bound is inclusive. * @return the oldest version between lowerBound and upperBound or null if no version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestVersion( VersionRange versionRange, ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots, boolean includeLower, boolean includeUpper ); + ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or From 44b8e877673d997040fcebf7a1960a7ba74f905c Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Thu, 15 Sep 2022 20:33:02 +0200 Subject: [PATCH 121/441] Restriction as parameter to prevent more than 7 parameters in methods in the next PRs. --- .../versions/api/AbstractVersionDetails.java | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index f4bbc04a50..1f5a9b71e0 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -147,7 +147,7 @@ public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, Artifact private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) { - Restriction restriction = new Restriction( version, false, null, false ); + Restriction restriction = new Restriction( version, false, null, false ); return getVersions( restriction, includeSnapshots ); } @@ -187,7 +187,7 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restri { continue; } - if ( restriction != null && !restriction.containsVersion( candidate ) ) + if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) { continue; } @@ -307,7 +307,7 @@ public final ArtifactVersion getOldestVersion( VersionRange versionRange, Restri { continue; } - if ( restriction != null && !restriction.containsVersion( candidate ) ) + if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) { continue; } @@ -343,7 +343,7 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, Restricti { continue; } - if ( restriction != null && !restriction.containsVersion( candidate ) ) + if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) { continue; } @@ -568,4 +568,33 @@ protected Optional getLowerBound( ArtifactVersion version, int unchanged } return of( newVersion.toString() ); } + + /** + * Checks if the candidate version is in the range of the restriction. + * a custom comparator is/can be used to have milestones and rcs before final releases, + * which is not yet possible with {@link Restriction#containsVersion(ArtifactVersion)}. + * @param restriction the range to check against. + * @param candidate the version to check. + * @return true if the candidate version is within the range of the restriction parameter. + */ + private boolean isVersionInRestriction( Restriction restriction, ArtifactVersion candidate ) + { + ArtifactVersion lowerBound = restriction.getLowerBound(); + ArtifactVersion upperBound = restriction.getUpperBound(); + boolean includeLower = restriction.isLowerBoundInclusive(); + boolean includeUpper = restriction.isUpperBoundInclusive(); + final VersionComparator versionComparator = getVersionComparator(); + int lower = lowerBound == null ? -1 : versionComparator.compare( lowerBound, candidate ); + int upper = upperBound == null ? +1 : versionComparator.compare( upperBound, candidate ); + if ( lower > 0 || upper < 0 ) + { + return false; + } + if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) + { + return false; + } + return true; + } + } From cb7ef703c4b20d305913b80ddc7f246b8b9f009c Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 12 Sep 2022 12:28:57 +0200 Subject: [PATCH 122/441] #610: Adding the possibility to skip version resolution if parentVersion is set --- .../invoker.properties | 2 + src/it/it-update-parent-005-issue-610/pom.xml | 16 ++++ .../verify.groovy | 3 + .../mojo/versions/UpdateParentMojo.java | 96 ++++++++++++------- .../mojo/versions/UpdateParentMojoTest.java | 50 +++++++++- 5 files changed, 128 insertions(+), 39 deletions(-) create mode 100644 src/it/it-update-parent-005-issue-610/invoker.properties create mode 100644 src/it/it-update-parent-005-issue-610/pom.xml create mode 100644 src/it/it-update-parent-005-issue-610/verify.groovy diff --git a/src/it/it-update-parent-005-issue-610/invoker.properties b/src/it/it-update-parent-005-issue-610/invoker.properties new file mode 100644 index 0000000000..c46b21a9dd --- /dev/null +++ b/src/it/it-update-parent-005-issue-610/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-parent +invoker.mavenOpts = -DparentVersion=999 -DskipResolution=true \ No newline at end of file diff --git a/src/it/it-update-parent-005-issue-610/pom.xml b/src/it/it-update-parent-005-issue-610/pom.xml new file mode 100644 index 0000000000..a06e670cd5 --- /dev/null +++ b/src/it/it-update-parent-005-issue-610/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + + localhost + dummy-parent4 + 70 + + + localhsot + issue-670 + 0.31-SNAPSHOT + pom + + \ No newline at end of file diff --git a/src/it/it-update-parent-005-issue-610/verify.groovy b/src/it/it-update-parent-005-issue-610/verify.groovy new file mode 100644 index 0000000000..aa7ed9ebb3 --- /dev/null +++ b/src/it/it-update-parent-005-issue-610/verify.groovy @@ -0,0 +1,3 @@ +pom = new File( basedir, "pom.xml" ).text + +assert pom =~ /999<\/version>/ \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 50fcfdf27f..bd1e789816 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.MojoExecutionException; @@ -34,6 +35,8 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import static org.apache.maven.shared.utils.StringUtils.isBlank; + /** * Sets the parent version to the latest parent version. * @@ -50,8 +53,12 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo // ------------------------------ FIELDS ------------------------------ /** - * Version specification to control artifact resolution. + *

If {@code skipResolution} is not set, specifies the bottom version considered + * for target version resolution. If it is a version range, the resolved version will be + * restricted by that range.

* + *

If {@code skipResolution} is {@code true}, will specify the target version to which + * the parent artifact will be updated.

* @since 1.0-alpha-1 */ @Parameter( property = "parentVersion" ) @@ -65,6 +72,15 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Parameter( property = "forceUpdate", defaultValue = "false" ) protected boolean forceUpdate = false; + /** + * Skips version resolution, only valid if {@code parentVersion} is set. + * Will effectively set the new parent version to the one from {@code parentVersion} + * + * @since 2.13.0 + */ + @Parameter( property = "skipResolution", defaultValue = "false" ) + protected boolean skipResolution = false; + /** *

Whether to downgrade a snapshot dependency if allowSnapshots is false * and there exists a version within the range fulfilling the criteria.

@@ -87,7 +103,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * @since 1.0-alpha-1 */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( getProject().getParent() == null ) { @@ -101,60 +117,70 @@ protected void update( ModifiedPomXMLEventReader pom ) return; } - String currentVersion = getProject().getParent().getVersion(); - String version = currentVersion; - - if ( parentVersion != null ) + if ( skipResolution && isBlank( parentVersion ) ) { - version = parentVersion; + throw new MojoExecutionException( "skipResolution is only valid if parentVersion is set" ); } - Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( version ) - .withType( "pom" ) - .build() ); - - VersionRange versionRange; + String initialVersion = parentVersion == null ? getProject().getParent().getVersion() : parentVersion; try { - versionRange = VersionRange.createFromVersionSpec( version ); - if ( versionRange.getRecommendedVersion() != null ) + ArtifactVersion artifactVersion = skipResolution ? new DefaultArtifactVersion( parentVersion ) + : resolveTargetVersion( initialVersion ); + if ( artifactVersion != null ) { - versionRange = versionRange.restrict( - VersionRange.createFromVersionSpec( "[" + versionRange.getRecommendedVersion() + ",)" ) ); + getLog().info( "Updating parent from " + getProject().getParent().getVersion() + + " to " + artifactVersion.toString() ); + + if ( PomHelper.setProjectParentVersion( pom, artifactVersion.toString() ) ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Made an update from " + getProject().getParent().getVersion() + + " to " + artifactVersion ); + } + getChangeRecorder().recordUpdate( "updateParent", getProject().getParent().getGroupId(), + getProject().getParent().getArtifactId(), getProject().getParent().getVersion(), + artifactVersion.toString() ); + } } } catch ( InvalidVersionSpecificationException e ) { - throw new MojoExecutionException( "Invalid version range specification: " + version, e ); - } - - ArtifactVersion artifactVersion; - try - { - artifactVersion = findLatestVersion( artifact, versionRange, null, false, allowDowngrade ); + throw new MojoExecutionException( "Invalid version range specification: " + initialVersion, e ); } catch ( ArtifactMetadataRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } + } + + private ArtifactVersion resolveTargetVersion( String initialVersion ) + throws MojoExecutionException, ArtifactMetadataRetrievalException, InvalidVersionSpecificationException + { + Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder + .newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( initialVersion ) + .withType( "pom" ) + .build() ); - if ( !shouldApplyUpdate( artifact, currentVersion, artifactVersion, forceUpdate ) ) + VersionRange targetVersionRange = VersionRange.createFromVersionSpec( initialVersion ); + if ( targetVersionRange.getRecommendedVersion() != null ) { - return; + targetVersionRange = targetVersionRange.restrict( + VersionRange.createFromVersionSpec( "[" + targetVersionRange.getRecommendedVersion() + ",)" ) ); } - getLog().info( "Updating parent from " + currentVersion + " to " + artifactVersion.toString() ); - - if ( PomHelper.setProjectParentVersion( pom, artifactVersion.toString() ) ) + ArtifactVersion artifactVersion = findLatestVersion( artifact, targetVersionRange, null, + false, allowDowngrade ); + if ( !shouldApplyUpdate( artifact, getProject().getParent().getVersion(), artifactVersion, forceUpdate ) ) { - getLog().debug( "Made an update from " + currentVersion + " to " + artifactVersion ); - - this.getChangeRecorder().recordUpdate( "updateParent", artifact.getGroupId(), artifact.getArtifactId(), - currentVersion, artifactVersion.toString() ); + getLog().debug( "Update not applied. Exiting." ); + return null; } + return artifactVersion; } } diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index f73073f341..76d9191f81 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -50,17 +50,15 @@ public class UpdateParentMojoTest private static RepositorySystem repositorySystem; - @SuppressWarnings( "deprecation" ) private static ArtifactMetadataSource artifactMetadataSource; @BeforeClass - @SuppressWarnings( "deprecation" ) - public static void setUpStatic() throws ArtifactMetadataRetrievalException + public static void setUpStatic() { repositorySystem = mockRepositorySystem(); artifactMetadataSource = mockArtifactMetadataSource( new HashMap() {{ - put( "parent-artifact", new String[] { "1.0.1-SNAPSHOT", "1.0.0", "0.9.0" } ); + put( "parent-artifact", new String[] { "0.9.0", "1.0.0", "1.0.1-SNAPSHOT" } ); put( "issue-670-artifact", new String[] { "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" } ); put( "unknown-artifact", new String[0] ); }} ); @@ -283,4 +281,48 @@ public void testIgnoredVersions() } assertThat( changeRecorder.getChanges(), is( empty() ) ); } + + @Test + public void testSkipResolutionDowngradeUnknownVersion() + { + testSkipResolution( "0.8.0" ); + } + + @Test + public void testSkipResolutionDowngrade() + { + testSkipResolution( "0.9.0" ); + } + + @Test + public void testSkipResolutionUpgradeUnknownVersion() + { + testSkipResolution( "2.0.0" ); + } + + private void testSkipResolution( String version ) + { + mojo.parentVersion = version; + mojo.skipResolution = true; + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "1.0.0" ); + }} ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + catch ( MojoExecutionException | XMLStreamException | MojoFailureException e ) + { + throw new RuntimeException( e ); + } + + assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", + "parent-artifact", "1.0.0", version ) ) ); + } } From f5e8c9d65a070780394b886ed7217847b8677c77 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 7 Sep 2022 07:53:09 +0200 Subject: [PATCH 123/441] #342: Adding the possibility of adding new scm tags --- .../codehaus/mojo/versions/SetScmTagMojo.java | 22 ++- .../codehaus/mojo/versions/api/PomHelper.java | 163 ++++++++++++++---- .../mojo/versions/SetScmTagMojoTest.java | 57 ++++++ .../mojo/versions/api/PomHelperTest.java | 82 ++++++++- .../utils/ModifiedPomXMLEventReaderUtils.java | 62 +++++++ .../mojo/set-scm-tag/issue-342-pom.xml | 24 +++ .../org/codehaus/mojo/set-scm-tag/pom.xml | 24 +++ 7 files changed, 392 insertions(+), 42 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java create mode 100644 src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java create mode 100644 src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index b7bbc2b66a..46d5cbdd0e 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -93,33 +93,39 @@ protected void update( ModifiedPomXMLEventReader pom ) List failures = new ArrayList<>(); if ( !isBlank( newTag ) ) { - getLog().info( "Updating tag: " + scm.getTag() + " -> " + newTag ); - if ( !PomHelper.setProjectValue( pom, "/project/scm/tag", newTag ) ) + getLog().info( "Updating tag: " + ( scm != null && scm.getTag() != null + ? scm.getTag() : "(empty)" ) + " -> " + newTag ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "tag", newTag ) ) { failures.add( "tag: " + newTag ); } } if ( !isBlank( connection ) ) { - getLog().info( "Updating connection: " + scm.getConnection() + " -> " + connection ); - if ( !PomHelper.setProjectValue( pom, "/project/scm/connection", connection ) ) + getLog().info( "Updating connection: " + ( scm != null && scm.getConnection() != null + ? scm.getConnection() : "(empty)" ) + " -> " + connection ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "connection", connection ) ) { failures.add( "connection: " + connection ); } } if ( !isBlank( developerConnection ) ) { - getLog().info( "Updating developerConnection: " + scm.getDeveloperConnection() + " -> " + getLog().info( "Updating developerConnection: " + + ( scm != null && scm.getDeveloperConnection() != null + ? scm.getDeveloperConnection() : "(empty)" ) + " -> " + developerConnection ); - if ( !PomHelper.setProjectValue( pom, "/project/scm/developerConnection", developerConnection ) ) + if ( !PomHelper.setElementValue( pom, "/project/scm", "developerConnection", + developerConnection ) ) { failures.add( "developerConnection: " + developerConnection ); } } if ( !isBlank( url ) ) { - getLog().info( "Updating url: " + scm.getUrl() + " -> " + url ); - if ( !PomHelper.setProjectValue( pom, "/project/scm/url", url ) ) + getLog().info( "Updating url: " + ( scm != null && scm.getUrl() != null + ? scm.getUrl() : "(empty)" ) + " -> " + url ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "url", url ) ) { failures.add( "url: " + url ); } diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 0df81259c5..b7dde0e88b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -71,6 +71,8 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import static java.util.stream.IntStream.range; + /** * Helper class for modifying pom files. * @@ -232,59 +234,156 @@ else if ( matchScopeRegex.matcher( path ).matches() ) public static boolean setProjectVersion( final ModifiedPomXMLEventReader pom, final String value ) throws XMLStreamException { - return setProjectValue( pom, "/project/version", value ); + return setElementValue( pom, "/project", "version", value, false ); } /** - * Searches the pom re-defining a project value using the given pattern. + * Sets the value of the given element given its parent element path. + * Will only consider the first found occurrence of the parent element. + * If the element is not found in the parent element, the method will create the element. * - * @param pom The pom to modify. - * @param pattern The pattern to look for. - * @param value The new value of the property. - * @return true if a replacement was made. - * @throws XMLStreamException if something went wrong. + * @param pom pom to modify + * @param parentPath path of the parent element + * @param elementName name of the element to set or create + * @param value the new value of the element + * @return {@code true} if the element was created or replaced + * @throws XMLStreamException if something went wrong */ - public static boolean setProjectValue( final ModifiedPomXMLEventReader pom, String pattern, final String value ) - throws XMLStreamException + public static boolean setElementValue( ModifiedPomXMLEventReader pom, String parentPath, + String elementName, String value ) + throws XMLStreamException { - Stack stack = new Stack<>(); - String path = ""; - final Pattern matchScopeRegex; - boolean madeReplacement = false; - matchScopeRegex = Pattern.compile( pattern ); - pom.rewind(); + return setElementValue( pom, parentPath, elementName, value, true ); + } - while ( pom.hasNext() ) + /** + * Sets the value of the given element given its parent element path. + * Will only consider the first found occurrence of the parent element. + * If the element is not found in the parent element, the method will create the element + * if {@code shouldCreate} is {@code true}. + * + * @param pom pom to modify + * @param parentPath path of the parent element + * @param elementName name of the element to set or create + * @param value the new value of the element + * @param shouldCreate should the element be created if it's not found in the first encountered parent element + * matching the parentPath + * @return {@code true} if the element was created or replaced + * @throws XMLStreamException if something went wrong + */ + public static boolean setElementValue( ModifiedPomXMLEventReader pom, String parentPath, + String elementName, String value, boolean shouldCreate ) + throws XMLStreamException + { + class ElementValueInternal { - XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) + private final String parentName; + private final String superParentPath; + + private static final int MARK_CHILD_BEGIN = 0; + private static final int MARK_OPTION = 1; + private static final int PARENT_BEGIN = 2; + + ElementValueInternal() { - stack.push( path ); - path = path + "/" + event.asStartElement().getName().getLocalPart(); + int lastDelimeterIndex = parentPath.lastIndexOf( '/' ); + parentName = parentPath.substring( lastDelimeterIndex + 1 ); + superParentPath = parentPath.substring( 0, lastDelimeterIndex ); + } - if ( matchScopeRegex.matcher( path ).matches() ) + boolean process( String currentPath ) throws XMLStreamException + { + boolean replacementMade = false; + while ( !replacementMade && pom.hasNext() ) { - pom.mark( 0 ); + XMLEvent event = pom.nextEvent(); + if ( event.isStartElement() ) + { + String currentElementName = event.asStartElement().getName().getLocalPart(); + + // here, we will only mark the beginning of the child or the parent element + if ( currentPath.equals( parentPath ) && elementName.equals( currentElementName ) ) + { + pom.mark( MARK_CHILD_BEGIN ); + } + else if ( currentPath.equals( superParentPath ) && currentElementName.equals( parentName ) ) + { + pom.mark( PARENT_BEGIN ); + } + // process child element + replacementMade = process( currentPath + "/" + currentElementName ); + } + else if ( event.isEndElement() ) + { + // here we're doing the replacement + if ( currentPath.equals( parentPath + "/" + elementName ) ) + { + // end of the child + replaceValueInChild(); + replacementMade = true; + } + else if ( shouldCreate && currentPath.equals( parentPath ) ) + { + // end of the parent + replaceValueInParent(); + replacementMade = true; + } + else + { + return false; + } + } } + return replacementMade; } - if ( event.isEndElement() ) + + private void replaceValueInChild() { - if ( matchScopeRegex.matcher( path ).matches() ) + pom.mark( MARK_OPTION ); + if ( pom.getBetween( MARK_CHILD_BEGIN, MARK_OPTION ).length() > 0 ) { - pom.mark( 1 ); - if ( pom.hasMark( 0 ) && pom.hasMark( 1 ) ) + pom.replaceBetween( 0, 1, value ); + } + else + { + pom.replace( String.format( "<%1$s>%2$s", elementName, value ) ); + } + } + + private void replaceValueInParent() + { + pom.mark( MARK_OPTION ); + if ( pom.hasMark( PARENT_BEGIN ) ) + { + if ( pom.getBetween( PARENT_BEGIN, MARK_OPTION ).length() > 0 ) { - pom.replaceBetween( 0, 1, value ); - madeReplacement = true; + pom.replace( String.format( "<%2$s>%3$s", + parentName, elementName, value ) ); + } + else + { + pom.replace( String.format( "<%1$s><%2$s>%3$s", + parentName, elementName, value ) ); } - pom.clearMark( 0 ); - pom.clearMark( 1 ); } - path = stack.pop(); + else + { + pom.replace( String.format( "<%1$s><%2$s>%3$s", + parentName, elementName, value ) ); + } } } - return madeReplacement; + + try + { + pom.rewind(); + return new ElementValueInternal().process( "" ); + } + finally + { + range( 0, 3 ).forEach( pom::clearMark ); + } } /** diff --git a/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java new file mode 100644 index 0000000000..db8fae6aef --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java @@ -0,0 +1,57 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * Basic tests for {@linkplain SetPropertyMojoTest}. + * + * @author Andrzej Jarmoniuk + */ +public class SetScmTagMojoTest extends BaseMojoTestCase +{ + @Test + public void testNewScmValues() throws Exception + { + Path pomFile = Paths.get( "target/test-classes/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml" ); + createMojo( "set-scm-tag", pomFile.toString() ) + .execute(); + String output = String.join( "", Files.readAllLines( pomFile ) ) + .replaceAll( "\\s*", "" ); + assertThat( output, allOf( + matchesPattern( ".*.*\\s*newTag\\s*.*.*" ), + matchesPattern( ".*.*\\s*url\\s*.*.*" ), + matchesPattern( ".*.*\\s*connection\\s*.*.*" ), + matchesPattern( ".*.*\\s*" + + "developerConnection\\s*.*.*" ) + ) + ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index 653dc658d3..e447355b39 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -1,6 +1,7 @@ package org.codehaus.mojo.versions.api; import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; import java.io.File; import java.io.StringReader; @@ -12,8 +13,13 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.stax2.XMLInputFactory2; +import org.junit.BeforeClass; import org.junit.Test; +import static org.codehaus.mojo.versions.utils.ModifiedPomXMLEventReaderUtils.matches; +import static org.codehaus.stax2.XMLInputFactory2.P_PRESERVE_LOCATION; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -25,6 +31,14 @@ */ public class PomHelperTest { + private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory2.newInstance(); + + @BeforeClass + public static void setUp() + { + INPUT_FACTORY.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); + } + /** * Tests if imported POMs are properly read from dependency management section. Such logic is required to resolve * bug #134 @@ -36,11 +50,12 @@ public void testImportedPOMsRetrievedFromDependencyManagement() throws Exception { URL url = getClass().getResource( "PomHelperTest.dependencyManagementBOMs.pom.xml" ); + assert url != null; File file = new File( url.getPath() ); StringBuilder input = PomHelper.readXmlFile( file ); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); + inputFactory.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); ModifiedPomXMLEventReader pom = new ModifiedPomXMLEventReader( input, inputFactory, file.getAbsolutePath() ); @@ -68,11 +83,12 @@ public void testLongProperties() throws Exception { URL url = getClass().getResource( "PomHelperTest.testLongProperties.pom.xml" ); + assert url != null; File file = new File( url.getPath() ); StringBuilder input = PomHelper.readXmlFile( file ); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); + inputFactory.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); ModifiedPomXMLEventReader pom = new ModifiedPomXMLEventReader( input, inputFactory, file.getAbsolutePath() ); @@ -92,6 +108,7 @@ public void testGroupIdNotOnChildPom() throws Exception { URL url = getClass().getResource( "PomHelperTest.noGroupIdOnChild.pom.xml" ); + assert url != null; StringBuilder input = PomHelper.readXmlFile( new File( url.getPath() ) ); MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read( new StringReader( input.toString() ) ); @@ -187,4 +204,65 @@ public void testRangeVersionIntersect() } + @Test + public void testSetElementValueExistingValue() throws XMLStreamException + { + ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( + new StringBuilder( "test" ), + INPUT_FACTORY, null ); + + assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", + "child", "value" ), is( true ) ); + assertThat( xmlEventReader, + matches( "value" ) ); + } + + @Test + public void testSetElementValueEmptyChild() throws XMLStreamException + { + ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( + new StringBuilder( "" ), INPUT_FACTORY, null ); + + assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", + "child", "value" ), is( true ) ); + assertThat( xmlEventReader, + matches( "value" ) ); + } + + @Test + public void testSetElementValueNewValueEmptyParent() throws XMLStreamException + { + ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( + new StringBuilder( "" ), INPUT_FACTORY, null ); + + assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", + "child", "value" ), is( true ) ); + assertThat( xmlEventReader, + matches( "value" ) ); + } + + @Test + public void testSetElementValueNewValueNoChild() throws XMLStreamException + { + ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( + new StringBuilder( "" ), INPUT_FACTORY, null ); + + assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", + "child", "value" ), is( true ) ); + assertThat( xmlEventReader, + matches( "value" ) ); + } + + @Test + public void testSetProjectValueNewValueNonEmptyParent() throws XMLStreamException + { + ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( + new StringBuilder( "test" ), INPUT_FACTORY, + null ); + + assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", + "child", "value" ), is( true ) ); + assertThat( xmlEventReader, + matches( "value" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java new file mode 100644 index 0000000000..fb8a37a3b3 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java @@ -0,0 +1,62 @@ +package org.codehaus.mojo.versions.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +/** + *

Utilities for the {@link ModifiedPomXMLEventReader} class

+ * + * @author Andrzej Jarmoniuk + */ +public class ModifiedPomXMLEventReaderUtils +{ + public static

Matcher

matches( String pattern ) + { + return new TypeSafeMatcher

() + { + @Override + public void describeTo( Description description ) + { + description.appendText( pattern ); + } + + @Override + protected void describeMismatchSafely( P pom, Description description ) + { + description.appendText( asString( pom ) ); + } + + @Override + protected boolean matchesSafely( P pom ) + { + return pattern.matches( asString( pom ) ); + } + + private String asString( P pom ) + { + return pom.asStringBuilder().toString().replaceAll( "\\s", "" ); + } + }; + } +} diff --git a/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml b/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml new file mode 100644 index 0000000000..681851f29a --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + + + + + versions-maven-plugin + + newTag + connection + developerConnection + url + + + + + \ No newline at end of file diff --git a/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml b/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml new file mode 100644 index 0000000000..681851f29a --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + + + + + versions-maven-plugin + + newTag + connection + developerConnection + url + + + + + \ No newline at end of file From 0e1d456f7894f7d349fbcdcf58294e4223b4d17d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 16 Sep 2022 14:21:01 +0200 Subject: [PATCH 124/441] Fixed #676: Removing BaseMojoTestCase -- not needed --- .../codehaus/mojo/versions/SetMojoTest.java | 14 +- .../mojo/versions/SetPropertyMojoTest.java | 77 +++++++--- .../mojo/versions/UseDepVersionMojoTest.java | 15 +- .../mojo/versions/utils/BaseMojoTestCase.java | 137 ------------------ .../set-property/null-new-version/pom.xml | 32 ++++ .../set-property/{ => null-property}/pom.xml | 3 +- .../codehaus/mojo/set/versionless-01/pom.xml | 5 +- .../{issue-637-pom.xml => issue-637/pom.xml} | 3 +- 8 files changed, 119 insertions(+), 167 deletions(-) delete mode 100644 src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java create mode 100644 src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml rename src/test/resources/org/codehaus/mojo/set-property/{ => null-property}/pom.xml (93%) rename src/test/resources/org/codehaus/mojo/use-dep-version/{issue-637-pom.xml => issue-637/pom.xml} (93%) diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index fb674768a8..a9b8916b40 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -1,18 +1,25 @@ package org.codehaus.mojo.versions; +import java.io.File; + import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.project.MavenProject; -import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.junit.Rule; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; -public class SetMojoTest extends BaseMojoTestCase +public class SetMojoTest extends AbstractMojoTestCase { + @Rule + MojoRule mojoRule = new MojoRule( this ); + @Test public void testGetIncrementedVersion() throws MojoExecutionException { @@ -95,7 +102,8 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti @Test public void testVersionlessDependency() throws Exception { - SetMojo myMojo = createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" ); + SetMojo myMojo = (SetMojo) mojoRule.lookupConfiguredMojo( + new File( "target/test-classes/org/codehaus/mojo/set/versionless-01" ), "set" ); myMojo.execute(); } } diff --git a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java index f96d35e4b8..4f1ecf436e 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -19,15 +19,25 @@ * under the License. */ +import java.io.File; import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Objects; import org.apache.maven.plugin.MojoExecutionException; -import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.matchesPattern; /** @@ -35,17 +45,45 @@ * * @author Andrzej Jarmoniuk */ -public class SetPropertyMojoTest extends BaseMojoTestCase +public class SetPropertyMojoTest extends AbstractMojoTestCase { - @Test + @Rule + MojoRule mojoRule = new MojoRule( this ); + + private Path pomDir; + + @Before + public void setUp() throws Exception + { + super.setUp(); + pomDir = Files.createTempDirectory( "set-property-" ); + } + + @After + public void tearDown() throws Exception + { + try + { + if ( pomDir != null && pomDir.toFile().exists() ) + { + Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); + pomDir.toFile().delete(); + } + } + finally + { + super.tearDown(); + } + } + @Test public void testNullNewVersion() throws Exception { - SetPropertyMojo mojo = createMojo( "set-property", - "target/test-classes/org/codehaus/mojo/set-property/pom.xml" ); - assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); - - setVariableValueToObject( mojo, "property", "dummy-api-version" ); + Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml" ), + Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), + "set-property" ); + mojo.localRepository = new StubArtifactRepository( pomDir.toString() ); setVariableValueToObject( mojo, "newVersion", null ); mojo.execute(); @@ -60,11 +98,11 @@ public void testNullNewVersion() public void testNewVersionEmpty() throws Exception { - SetPropertyMojo mojo = createMojo( "set-property", - "target/test-classes/org/codehaus/mojo/set-property/pom.xml" ); - assertThat( mojo.getProject().getProperties(), is( mojo.getProject().getModel().getProperties() ) ); - - setVariableValueToObject( mojo, "property", "dummy-api-version" ); + Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml" ), + Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), + "set-property" ); + mojo.localRepository = new StubArtifactRepository( pomDir.toString() ); setVariableValueToObject( mojo, "newVersion", "" ); mojo.execute(); @@ -79,15 +117,14 @@ public void testNewVersionEmpty() public void testNullProperty() throws Exception { - SetPropertyMojo mojo = createMojo( "set-property", - "src/test/resources/org/codehaus/mojo/set-property/pom.xml" ); + Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml" ), + Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), + "set-property" ); - setVariableValueToObject( mojo, "property", null ); - setVariableValueToObject( mojo, "propertiesVersionsFile", null ); - setVariableValueToObject( mojo, "newVersion", "2.0.0" ); try { - mojo.execute(); + mojo.update( null ); fail(); } catch ( MojoExecutionException e ) diff --git a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java index be965fd487..d00e6ced5c 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java @@ -19,9 +19,12 @@ * under the License. */ +import java.io.File; import java.util.Collections; -import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.junit.Rule; import org.junit.Test; /** @@ -29,13 +32,17 @@ * * @author Andrzej Jarmoniuk */ -public class UseDepVersionMojoTest extends BaseMojoTestCase +public class UseDepVersionMojoTest extends AbstractMojoTestCase { + @Rule + MojoRule mojoRule = new MojoRule( this ); + @Test public void testIssue673() throws Exception { - UseDepVersionMojo mojo = createMojo( "use-dep-version", - "src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml" ); + UseDepVersionMojo mojo = (UseDepVersionMojo) mojoRule.lookupConfiguredMojo( + new File( "target/test-classes/org/codehaus/mojo/use-dep-version/issue-637" ), + "use-dep-version" ); setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "processDependencyManagement", true ); setVariableValueToObject( mojo, "excludeReactor", true ); diff --git a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java b/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java deleted file mode 100644 index 1bdb484d57..0000000000 --- a/src/test/java/org/codehaus/mojo/versions/utils/BaseMojoTestCase.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.codehaus.mojo.versions.utils; - -import java.io.File; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Model; -import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.plugin.Mojo; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - *

Extension of the {@link AbstractMojoTestCase} class, providing support - * for loading projects specified by POM file path (instead of - * using stubs with implementation hint).

- * - *

Example usage:

- * - *
- *     // provide the path to the POM containing the tested project
- *     SetMojo myMojo = createMojo( "set", "src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml" );
- *     assertNotNull( myMojo );
- *     myMojo.execute();
- * 
- * @author Andrzej Jarmoniuk - */ -public abstract class BaseMojoTestCase extends AbstractMojoTestCase -{ - /** - * Lookup the mojo leveraging the actual subprojects pom - * and injects the project using the given pom file path. - * - * @param target Mojo subclass - * @param goal to execute on the plugin - * @param pomFilePath path to the pom project to inject - * @return a Mojo instance - * @throws Exception thrown if mojo lookup fails - */ - @SuppressWarnings( "unchecked" ) - protected T createMojo( String goal, String pomFilePath ) throws Exception - { - File pomFile = new File( pomFilePath ); - T mojo = (T) lookupMojo( goal, pomFile ); - setVariableValueToObject( mojo, "project", new TestProjectStub( pomFile ) ); - return mojo; - } - - private static class TestProjectStub extends MavenProjectStub - { - private final File pomFile; - - /** - * Default constructor - */ - private TestProjectStub( File pomFile ) throws IOException, XmlPullParserException - { - this.pomFile = pomFile; - MavenXpp3Reader pomReader = new MavenXpp3Reader(); - Model model = pomReader.read( ReaderFactory.newXmlReader( pomFile ) ); - model.setPomFile( pomFile ); - - setModel( model ); - setOriginalModel( model.clone() ); - setGroupId( model.getGroupId() ); - setArtifactId( model.getArtifactId() ); - setVersion( model.getVersion() ); - setName( model.getName() ); - setUrl( model.getUrl() ); - setPackaging( model.getPackaging() ); - setFile( model.getPomFile() ); - - setBuild( new Build() - {{ - setFinalName( model.getArtifactId() ); - setDirectory( getBasedir() + "/target" ); - setSourceDirectory( getBasedir() + "/src/main/java" ); - setOutputDirectory( getBasedir() + "/target/classes" ); - setTestSourceDirectory( getBasedir() + "/src/test/java" ); - setTestOutputDirectory( getBasedir() + "/target/test-classes" ); - }} ); - - setCompileSourceRoots( Collections.singletonList( getBasedir() + "/src/main/java" ) ); - setTestCompileSourceRoots( Collections.singletonList( getBasedir() + "/src/test/java" ) ); - } - - @Override - public File getBasedir() - { - return pomFile.getParentFile(); - } - - @Override - public Properties getProperties() - { - return getModel().getProperties(); - } - - @Override - public List getDependencies() - { - return getModel().getDependencies(); - } - - @Override - public DependencyManagement getDependencyManagement() - { - return getModel().getDependencyManagement(); - } - } -} diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml b/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml new file mode 100644 index 0000000000..b8fe197bb4 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + 1.0.0 + + + + + localhost + dummy-api + ${dummy-api-version} + + + + + + + org.codehaus.mojo + versions-maven-plugin + + dummy-api-version + + + + + diff --git a/src/test/resources/org/codehaus/mojo/set-property/pom.xml b/src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml similarity index 93% rename from src/test/resources/org/codehaus/mojo/set-property/pom.xml rename to src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml index 303db45ef6..b593863de9 100644 --- a/src/test/resources/org/codehaus/mojo/set-property/pom.xml +++ b/src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml @@ -21,9 +21,10 @@ + org.codehaus.mojo versions-maven-plugin -
\ No newline at end of file + diff --git a/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml b/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml index 22956c5178..ff646d28bd 100644 --- a/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml +++ b/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml @@ -26,9 +26,12 @@ + org.codehaus.mojo versions-maven-plugin + + set + - onchange dummy-api 2.0 diff --git a/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml b/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml similarity index 93% rename from src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml rename to src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml index 5f2edfe99f..6d602a4b62 100644 --- a/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637-pom.xml +++ b/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml @@ -17,6 +17,7 @@ + org.codehaus.mojo versions-maven-plugin DEVELOP-SNAPSHOT @@ -26,4 +27,4 @@ - \ No newline at end of file + From 4b8166a3b4ec48821ddc46edefecccbaf56d5557 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 16 Sep 2022 13:20:28 +0000 Subject: [PATCH 125/441] Bump maven-common-artifact-filters from 3.3.0 to 3.3.2 Bumps [maven-common-artifact-filters](https://github.com/apache/maven-common-artifact-filters) from 3.3.0 to 3.3.2. - [Release notes](https://github.com/apache/maven-common-artifact-filters/releases) - [Commits](https://github.com/apache/maven-common-artifact-filters/compare/maven-common-artifact-filters-3.3.0...maven-common-artifact-filters-3.3.2) --- updated-dependencies: - dependency-name: org.apache.maven.shared:maven-common-artifact-filters dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ae22aee30d..616d9abc72 100644 --- a/pom.xml +++ b/pom.xml @@ -186,7 +186,7 @@ org.apache.maven.shared maven-common-artifact-filters - 3.3.0 + 3.3.2 org.apache.maven.wagon From 815c82dd21a068a477ca5a5750b51fbe768d3d3e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 17 Sep 2022 14:08:57 +0200 Subject: [PATCH 126/441] Fixing #700 --- .../mojo/versions/SetScmTagMojoTest.java | 13 ++++++---- .../mojo/set-scm-tag/issue-342-pom.xml | 24 ------------------- .../org/codehaus/mojo/set-scm-tag/pom.xml | 21 ++++++++++++++++ 3 files changed, 30 insertions(+), 28 deletions(-) delete mode 100644 src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml diff --git a/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java index db8fae6aef..ebe2d50833 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java @@ -23,7 +23,9 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.codehaus.mojo.versions.utils.BaseMojoTestCase; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.junit.Rule; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -35,13 +37,16 @@ * * @author Andrzej Jarmoniuk */ -public class SetScmTagMojoTest extends BaseMojoTestCase +public class SetScmTagMojoTest extends AbstractMojoTestCase { + @Rule + public MojoRule mojoRule = new MojoRule( this ); + @Test public void testNewScmValues() throws Exception { - Path pomFile = Paths.get( "target/test-classes/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml" ); - createMojo( "set-scm-tag", pomFile.toString() ) + Path pomFile = Paths.get( "target/test-classes/org/codehaus/mojo/set-scm-tag/pom.xml" ); + mojoRule.lookupConfiguredMojo( pomFile.toFile().getParentFile(), "set-scm-tag" ) .execute(); String output = String.join( "", Files.readAllLines( pomFile ) ) .replaceAll( "\\s*", "" ); diff --git a/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml b/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml deleted file mode 100644 index 681851f29a..0000000000 --- a/src/test/resources/org/codehaus/mojo/set-scm-tag/issue-342-pom.xml +++ /dev/null @@ -1,24 +0,0 @@ - - 4.0.0 - default-group - default-artifact - 1.0 - pom - - - - - - - versions-maven-plugin - - newTag - connection - developerConnection - url - - - - - \ No newline at end of file diff --git a/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml b/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml index 681851f29a..b09f6b1e34 100644 --- a/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml +++ b/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml @@ -1,3 +1,22 @@ + + 4.0.0 @@ -11,7 +30,9 @@ + org.codehaus.mojo versions-maven-plugin + ${project.version} newTag connection From 484a581bdc8898656c85deb23eac49b292faae10 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 17 Sep 2022 14:00:25 +0200 Subject: [PATCH 127/441] Removing UpdateScope + refactoring VersionsHelper --- .../AbstractVersionsReportRenderer.java | 128 ++-- .../versions/DependencyUpdatesRenderer.java | 15 +- .../DependencyUpdatesXmlRenderer.java | 30 +- .../DisplayDependencyUpdatesMojo.java | 39 +- .../mojo/versions/PluginUpdatesDetails.java | 7 +- .../mojo/versions/PluginUpdatesRenderer.java | 74 +- .../versions/PropertyUpdatesRenderer.java | 15 +- .../versions/api/AbstractVersionDetails.java | 162 ++--- .../versions/api/DefaultVersionsHelper.java | 12 - .../codehaus/mojo/versions/api/Segment.java | 53 ++ .../mojo/versions/api/UpdateScope.java | 656 ------------------ .../mojo/versions/api/VersionDetails.java | 204 +----- .../mojo/versions/api/VersionsHelper.java | 12 - .../versions/ordering/VersionComparator.java | 1 + 14 files changed, 288 insertions(+), 1120 deletions(-) create mode 100644 src/main/java/org/codehaus/mojo/versions/api/Segment.java delete mode 100644 src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index 470f9c4a1f..e79d29b6f6 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -36,10 +36,16 @@ import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.util.StringUtils; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * Base class for report renderers. * @@ -122,7 +128,7 @@ protected void renderDependencySummaryTableRow( Dependency dependency, ArtifactV { sink.tableRow(); sink.tableCell(); - ArtifactVersion[] allUpdates = details.getAllUpdates( UpdateScope.ANY ); + ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); if ( allUpdates == null || allUpdates.length == 0 ) { renderSuccessIcon(); @@ -161,37 +167,37 @@ protected void renderDependencySummaryTableRow( Dependency dependency, ArtifactV } sink.tableCell(); - if ( details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( details.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( details.getNewestUpdate( of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( UpdateScope.MINOR ) != null ) + if ( details.getNewestUpdate( of( MINOR ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( details.getNewestUpdate( of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( UpdateScope.MAJOR ) != null ) + if ( details.getNewestUpdate( of( MAJOR ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( details.getNewestUpdate( of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -323,26 +329,26 @@ protected void renderDependencyDetailTable( Dependency dependency, ArtifactVersi sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = details.getAllUpdates( UpdateScope.ANY ); - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + ArtifactVersion[] versions = details.getAllUpdates( empty() ); + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -426,14 +432,14 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) { sink.lineBreak(); } - boolean bold = equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) ) - || equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) ) - || equals( versions[i], details.getOldestUpdate( UpdateScope.MAJOR ) ) - || equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) ); + boolean bold = equals( versions[i], details.getOldestUpdate( of( SUBINCREMENTAL ) ) ) + || equals( versions[i], details.getNewestUpdate( of( SUBINCREMENTAL ) ) ) + || equals( versions[i], details.getOldestUpdate( of( INCREMENTAL ) ) ) + || equals( versions[i], details.getNewestUpdate( of( INCREMENTAL ) ) ) + || equals( versions[i], details.getOldestUpdate( of( MINOR ) ) ) + || equals( versions[i], details.getNewestUpdate( of( MINOR ) ) ) + || equals( versions[i], details.getOldestUpdate( of( MAJOR ) ) ) + || equals( versions[i], details.getNewestUpdate( of( MAJOR ) ) ); if ( bold ) { safeBold(); @@ -444,35 +450,35 @@ else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) safeBold_(); sink.nonBreakingSpace(); safeItalic(); - if ( equals( versions[i], details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + if ( equals( versions[i], details.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.nextVersion" ) ); } - else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + else if ( equals( versions[i], details.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.latestSubIncremental" ) ); } - else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) + else if ( equals( versions[i], details.getOldestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.nextIncremental" ) ); } - else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.INCREMENTAL ) ) ) + else if ( equals( versions[i], details.getNewestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.latestIncremental" ) ); } - else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.MINOR ) ) ) + else if ( equals( versions[i], details.getOldestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.nextMinor" ) ); } - else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MINOR ) ) ) + else if ( equals( versions[i], details.getNewestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.latestMinor" ) ); } - else if ( equals( versions[i], details.getOldestUpdate( UpdateScope.MAJOR ) ) ) + else if ( equals( versions[i], details.getOldestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.nextMajor" ) ); } - else if ( equals( versions[i], details.getNewestUpdate( UpdateScope.MAJOR ) ) ) + else if ( equals( versions[i], details.getNewestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.latestMajor" ) ); } @@ -522,7 +528,7 @@ protected void renderPropertySummaryTableRow( Property property, PropertyVersion { sink.tableRow(); sink.tableCell(); - if ( versions.getAllUpdates( UpdateScope.ANY ).length == 0 ) + if ( versions.getAllUpdates( empty() ).length == 0 ) { renderSuccessIcon(); } @@ -539,37 +545,37 @@ protected void renderPropertySummaryTableRow( Property property, PropertyVersion sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( versions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( versions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( versions.getNewestUpdate( of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( versions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( UpdateScope.MINOR ) != null ) + if ( versions.getNewestUpdate( of( MINOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( versions.getNewestUpdate( of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( UpdateScope.MAJOR ) != null ) + if ( versions.getNewestUpdate( of( MAJOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( versions.getNewestUpdate( of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -618,27 +624,27 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions ve sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] artifactVersions = versions.getAllUpdates( UpdateScope.ANY ); + ArtifactVersion[] artifactVersions = versions.getAllUpdates( empty() ); Set rangeVersions = getVersionsInRange( property, versions, artifactVersions ); - if ( versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( versions.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( versions.getOldestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( versions.getOldestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -701,14 +707,14 @@ else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) sink.lineBreak(); } boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); - boolean bold = equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.MINOR ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.MINOR ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.MAJOR ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.MAJOR ) ); + boolean bold = equals( artifactVersions[i], versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) + || equals( artifactVersions[i], versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) + || equals( artifactVersions[i], versions.getOldestUpdate( of( INCREMENTAL ) ) ) + || equals( artifactVersions[i], versions.getNewestUpdate( of( INCREMENTAL ) ) ) + || equals( artifactVersions[i], versions.getOldestUpdate( of( MINOR ) ) ) + || equals( artifactVersions[i], versions.getNewestUpdate( of( MINOR ) ) ) + || equals( artifactVersions[i], versions.getOldestUpdate( of( MAJOR ) ) ) + || equals( artifactVersions[i], versions.getNewestUpdate( of( MAJOR ) ) ); if ( !allowed ) { sink.text( "* " ); @@ -727,35 +733,35 @@ else if ( versions.getOldestUpdate( UpdateScope.MAJOR ) != null ) } sink.nonBreakingSpace(); safeItalic(); - if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + if ( equals( artifactVersions[i], versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.nextVersion" ) ); } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.latestSubIncremental" ) ); } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) + else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.nextIncremental" ) ); } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.INCREMENTAL ) ) ) + else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.latestIncremental" ) ); } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.MINOR ) ) ) + else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.nextMinor" ) ); } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.MINOR ) ) ) + else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.latestMinor" ) ); } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( UpdateScope.MAJOR ) ) ) + else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.nextMajor" ) ); } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( UpdateScope.MAJOR ) ) ) + else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.latestMajor" ) ); } diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java index 3295b1a8c8..647b865873 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java @@ -27,10 +27,15 @@ import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.i18n.I18N; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * @since 1.0-beta-1 */ @@ -118,19 +123,19 @@ private void renderSummaryTotalsTable( Map allUpda int numCur = 0; for ( ArtifactVersions details : allUpdates.values() ) { - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { numAny++; } - else if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { numInc++; } - else if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { numMin++; } - else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { numMaj++; } diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java index eb89ee036f..ec9aa2db38 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java @@ -24,15 +24,23 @@ import java.util.Collection; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.TreeMap; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.reporting.MavenReportException; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.UpdateScope; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.utils.DependencyComparator; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available * dependency/dependency management updates. @@ -145,19 +153,19 @@ public static String getSummaryBlock( Collection allUpdates ) int numCur = 0; for ( ArtifactVersions details : allUpdates ) { - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { numAny++; } - else if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { numInc++; } - else if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { numMin++; } - else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { numMaj++; } @@ -190,17 +198,17 @@ public static String getVersionsBlocks( ArtifactVersions versions ) sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( versions.isCurrentVersionDefined() ? versions.getCurrentVersion().toString() : versions.getArtifact().getVersionRange().toString(), CURRENT_VERSION ) ).append( NL ); - ArtifactVersion nextVersion = versions.getOldestUpdate( UpdateScope.ANY ); + ArtifactVersion nextVersion = versions.getOldestUpdate( empty() ); if ( nextVersion != null ) { sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( nextVersion.toString(), NEXT_VERSION ) ).append( NL ); - String incrementalsBlock = getVersionsInScopeBlock( versions, UpdateScope.INCREMENTAL ); + String incrementalsBlock = getVersionsInScopeBlock( versions, of( INCREMENTAL ) ); sBuilder.append( incrementalsBlock ); - String minorsBlock = getVersionsInScopeBlock( versions, UpdateScope.MINOR ); + String minorsBlock = getVersionsInScopeBlock( versions, of( MINOR ) ); sBuilder.append( minorsBlock ); - String majorsBlock = getVersionsInScopeBlock( versions, UpdateScope.MAJOR ); + String majorsBlock = getVersionsInScopeBlock( versions, of( MAJOR ) ); sBuilder.append( majorsBlock ); String status = null; @@ -259,9 +267,9 @@ private static String getDependencyInfoBlock( Map return sBuilder.toString(); } - private static String getVersionsInScopeBlock( ArtifactVersions av, UpdateScope scope ) + private static String getVersionsInScopeBlock( ArtifactVersions av, Optional scope ) { - String versionsTag = scope.toString().toLowerCase() + "s"; + String versionsTag = scope.map( s -> s.name().toLowerCase() + "s" ).orElse( "any" ); StringBuilder sBuilder = new StringBuilder(); ArtifactVersion nextVersion = av.getOldestUpdate( scope ); diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 73a4f353a1..fc98c1d1d6 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; @@ -43,14 +44,19 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.UpdateScope; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.filtering.DependencyFilter; import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.util.StringUtils; +import static java.util.Optional.empty; +import static java.util.Optional.of; import static org.apache.commons.lang3.StringUtils.countMatches; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; /** * Displays all dependencies that have newer versions available. @@ -669,31 +675,14 @@ private DependencyManagement getProjectDependencyManagement( MavenProject projec } } - private UpdateScope calculateUpdateScope() + private Optional calculateUpdateScope() { - UpdateScope result = UpdateScope.ANY; - if ( !allowAnyUpdates ) - { - if ( allowMajorUpdates ) - { - result = UpdateScope.MAJOR; - } - else - { - if ( allowMinorUpdates ) - { - result = UpdateScope.MINOR; - } - else - { - if ( allowIncrementalUpdates ) - { - result = UpdateScope.INCREMENTAL; - } - } - } - } - return result; + return !allowAnyUpdates + ? allowMajorUpdates ? of( MAJOR ) + : allowMinorUpdates ? of( MINOR ) + : allowIncrementalUpdates ? of( INCREMENTAL ) + : empty() + : empty(); } private void logUpdates( Map updates, String section ) diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java index f8f7af3285..a4fd2db234 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java @@ -25,7 +25,8 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.UpdateScope; + +import static java.util.Optional.empty; /** * Details of a plugin's updates. @@ -65,7 +66,7 @@ public Map getDependencyVersions() */ public boolean isArtifactUpdateAvailable() { - return artifactVersions.getAllUpdates( UpdateScope.ANY, includeSnapshots ).length > 0; + return artifactVersions.getAllUpdates( empty(), includeSnapshots ).length > 0; } /** @@ -77,7 +78,7 @@ public boolean isDependencyUpdateAvailable() { for ( ArtifactVersions versions : dependencyVersions.values() ) { - ArtifactVersion[] dependencyUpdates = versions.getAllUpdates( UpdateScope.ANY, includeSnapshots ); + ArtifactVersion[] dependencyUpdates = versions.getAllUpdates( empty(), includeSnapshots ); if ( dependencyUpdates != null && dependencyUpdates.length > 0 ) { return true; diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index 2154e53bf6..bf887b8a67 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -32,10 +32,16 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.mojo.versions.utils.PluginComparator; import org.codehaus.plexus.i18n.I18N; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * @since 1.0-beta-1 */ @@ -105,19 +111,19 @@ private void renderSummaryTotalsTable( Map allUpda for ( PluginUpdatesDetails pluginDetails : allUpdates.values() ) { ArtifactVersions details = pluginDetails.getArtifactVersions(); - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { numAny++; } - else if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { numInc++; } - else if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { numMin++; } - else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { numMaj++; } @@ -292,37 +298,37 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ) != null ) + if ( details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ).toString() ); + sink.text( details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -360,26 +366,26 @@ private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = details.getArtifactVersions().getAllUpdates( UpdateScope.ANY ); - if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + ArtifactVersion[] versions = details.getArtifactVersions().getAllUpdates( empty() ); + if ( details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -431,15 +437,15 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != sink.lineBreak(); } boolean bold = equals( - versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) + versions[i], details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) ) || equals( versions[i], - details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ) ); + details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) ) + || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) ) + || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) ) + || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) ) + || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) ) + || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) ) + || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) ); if ( bold ) { safeBold(); @@ -451,42 +457,42 @@ else if ( details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) != sink.nonBreakingSpace(); safeItalic(); if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.nextVersion" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( UpdateScope.SUBINCREMENTAL ) ) ) + details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) { sink.text( getText( "report.latestSubIncremental" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( UpdateScope.INCREMENTAL ) ) ) + details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.nextIncremental" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( UpdateScope.INCREMENTAL ) ) ) + details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) ) ) { sink.text( getText( "report.latestIncremental" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( UpdateScope.MINOR ) ) ) + details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.nextMinor" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( UpdateScope.MINOR ) ) ) + details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) ) ) { sink.text( getText( "report.latestMinor" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( UpdateScope.MAJOR ) ) ) + details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.nextMajor" ) ); } else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( UpdateScope.MAJOR ) ) ) + details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) ) ) { sink.text( getText( "report.latestMajor" ) ); } diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java index e46530d2fb..b3d4686bb6 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java @@ -25,10 +25,15 @@ import org.apache.maven.doxia.sink.Sink; import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.api.UpdateScope; import org.codehaus.mojo.versions.utils.PropertyComparator; import org.codehaus.plexus.i18n.I18N; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * @since 1.0-beta-1 */ @@ -108,19 +113,19 @@ private void renderSummaryTotalsTable( Map allUpdate int numCur = 0; for ( PropertyVersions details : allUpdates.values() ) { - if ( details.getOldestUpdate( UpdateScope.SUBINCREMENTAL ) != null ) + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { numAny++; } - else if ( details.getOldestUpdate( UpdateScope.INCREMENTAL ) != null ) + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { numInc++; } - else if ( details.getOldestUpdate( UpdateScope.MINOR ) != null ) + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { numMin++; } - else if ( details.getOldestUpdate( UpdateScope.MAJOR ) != null ) + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { numMaj++; } diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 1f5a9b71e0..2bab33c80a 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -73,12 +73,6 @@ protected AbstractVersionDetails() { } - protected AbstractVersionDetails( ArtifactVersion currentVersion, boolean includeSnapshots ) - { - this.currentVersion = currentVersion; - this.includeSnapshots = includeSnapshots; - } - public final boolean isCurrentVersionDefined() { return getCurrentVersion() != null; @@ -273,23 +267,11 @@ public final ArtifactVersion[] getNewerVersions( String versionString, int upper return getVersions( restriction, includeSnapshots ); } - public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) - { - return getOldestVersion( lowerBound, upperBound, true ); - } - public final ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ) { return getOldestVersion( versionRange, null, includeSnapshots ); } - public final ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - return getOldestVersion( restriction, includeSnapshots ); - } - public final ArtifactVersion getOldestVersion( Restriction restriction, boolean includeSnapshots ) { @@ -356,88 +338,61 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, Restricti return result.toArray( new ArtifactVersion[0] ); } - public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - { - return getOldestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); - } - - public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - { - return getNewestUpdate( currentVersion, updateScope, isIncludeSnapshots() ); - } - - public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ) - { - return getAllUpdates( currentVersion, updateScope, isIncludeSnapshots() ); - } - - public ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, VersionRange versionRange ) - { - return getOldestUpdate( currentVersion, versionRange, isIncludeSnapshots() ); - } - - public ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, VersionRange versionRange ) - { - return getNewestUpdate( currentVersion, versionRange, isIncludeSnapshots() ); - } - - public ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange versionRange ) - { - return getAllUpdates( currentVersion, versionRange, isIncludeSnapshots() ); - } - - public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, + public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { - return updateScope.getOldestUpdate( this, currentVersion, includeSnapshots ); + try + { + return getOldestVersion( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + } + catch ( InvalidSegmentException e ) + { + return null; + } } - public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, + public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { - return updateScope.getNewestUpdate( this, currentVersion, includeSnapshots ); + try + { + return getNewestVersion( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + } + catch ( InvalidSegmentException e ) + { + return null; + } } - public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope, + public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { - return updateScope.getAllUpdates( this, currentVersion, includeSnapshots ); - } - - public ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ) - { - return getOldestVersion( versionRange, includeSnapshots ); - } - - public ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ) - { - return getNewestVersion( versionRange, includeSnapshots ); - } - - public ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ) - { - return new ArtifactVersion[0]; // To change body of implemented methods use File | Settings | File Templates. + try + { + return getVersions( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + } + catch ( InvalidSegmentException e ) + { + return null; + } } - public final ArtifactVersion getOldestUpdate( UpdateScope updateScope ) + public final ArtifactVersion getOldestUpdate( Optional updateScope ) { return getOldestUpdate( updateScope, isIncludeSnapshots() ); } - public final ArtifactVersion getNewestUpdate( UpdateScope updateScope ) + public final ArtifactVersion getNewestUpdate( Optional updateScope ) { return getNewestUpdate( updateScope, isIncludeSnapshots() ); } - public final ArtifactVersion[] getAllUpdates( UpdateScope updateScope ) + public final ArtifactVersion[] getAllUpdates( Optional updateScope ) { return getAllUpdates( updateScope, isIncludeSnapshots() ); } - public final ArtifactVersion getOldestUpdate( UpdateScope updateScope, boolean includeSnapshots ) + public final ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) { @@ -446,7 +401,7 @@ public final ArtifactVersion getOldestUpdate( UpdateScope updateScope, boolean i return null; } - public final ArtifactVersion getNewestUpdate( UpdateScope updateScope, boolean includeSnapshots ) + public final ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) { @@ -455,7 +410,7 @@ public final ArtifactVersion getNewestUpdate( UpdateScope updateScope, boolean i return null; } - public final ArtifactVersion[] getAllUpdates( UpdateScope updateScope, boolean includeSnapshots ) + public final ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) { @@ -464,33 +419,11 @@ public final ArtifactVersion[] getAllUpdates( UpdateScope updateScope, boolean i return null; } - public final ArtifactVersion getOldestUpdate( VersionRange versionRange ) - { - return getOldestUpdate( versionRange, isIncludeSnapshots() ); - } - - public final ArtifactVersion getNewestUpdate( VersionRange versionRange ) - { - return getNewestUpdate( versionRange, isIncludeSnapshots() ); - } - public final ArtifactVersion[] getAllUpdates( VersionRange versionRange ) { return getAllUpdates( versionRange, isIncludeSnapshots() ); } - public ArtifactVersion getOldestUpdate( VersionRange versionRange, boolean includeSnapshots ) - { - Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); - return getOldestVersion( versionRange, restriction, includeSnapshots ); - } - - public ArtifactVersion getNewestUpdate( VersionRange versionRange, boolean includeSnapshots ) - { - Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); - return getNewestVersion( versionRange, restriction, includeSnapshots ); - } - public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ) { Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); @@ -573,7 +506,7 @@ protected Optional getLowerBound( ArtifactVersion version, int unchanged * Checks if the candidate version is in the range of the restriction. * a custom comparator is/can be used to have milestones and rcs before final releases, * which is not yet possible with {@link Restriction#containsVersion(ArtifactVersion)}. - * @param restriction the range to check against. + * @PARAM RESTRICTION THE RANGE TO CHECK AGAINST. * @param candidate the version to check. * @return true if the candidate version is within the range of the restriction parameter. */ @@ -590,11 +523,28 @@ private boolean isVersionInRestriction( Restriction restriction, ArtifactVersion { return false; } - if ( ( !includeLower && lower == 0 ) || ( !includeUpper && upper == 0 ) ) - { - return false; - } - return true; + return ( includeLower || lower != 0 ) && ( includeUpper || upper != 0 ); } + /** + * Helper method to get the artifact boundaries for computing updates + * + * @param currentVersion The current version. + * @param scope scope of the restriction or Optional.empty() for no restriction + * @return {@linkplain Restriction} object based on the arguments + * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) + */ + protected Restriction restrictionFor( ArtifactVersion currentVersion, Optional scope ) + throws InvalidSegmentException + { + VersionComparator versionComparator = getVersionComparator(); + ArtifactVersion lowerBound = scope.isPresent() && scope.get().value() < Segment.SUBINCREMENTAL.value() + ? versionComparator.incrementSegment( currentVersion, scope.get().value() ) + : currentVersion; + ArtifactVersion upperBound = scope.isPresent() && scope.get().value() > Segment.MAJOR.value() + ? versionComparator.incrementSegment( currentVersion, scope.get().value() - 1 ) + : null; + return new Restriction( lowerBound, lowerBound != currentVersion, + upperBound, false ); + } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 3251311d6e..7331d857c8 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -671,18 +671,6 @@ public ArtifactVersion createArtifactVersion( String version ) return new DefaultArtifactVersion( version ); } - @Override - public ArtifactVersions lookupArtifactUpdates( Artifact artifact, boolean allowSnapshots, - boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException - { - ArtifactVersions artifactVersions = lookupArtifactVersions( artifact, usePluginRepositories ); - - artifactVersions.setIncludeSnapshots( allowSnapshots ); - - return artifactVersions; - } - @Override public Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) diff --git a/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/src/main/java/org/codehaus/mojo/versions/api/Segment.java new file mode 100644 index 0000000000..b64e8abc20 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/api/Segment.java @@ -0,0 +1,53 @@ +package org.codehaus.mojo.versions.api; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Indicates the segment along with its 0-based index + * + * @author Andrzej Jarmoniuk + */ +public enum Segment implements Comparable +{ + MAJOR( 0 ), MINOR( 1 ), INCREMENTAL( 2 ), SUBINCREMENTAL( 3 ); + + private final int index; + + Segment( int index ) + { + this.index = index; + } + + /** + * Returns the 0-based sendex index + * + * @return 0-based sendex index + */ + public int value() + { + return index; + } + + @Override + public String toString() + { + return name(); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java b/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java deleted file mode 100644 index 5dbdb2eb3f..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/api/UpdateScope.java +++ /dev/null @@ -1,656 +0,0 @@ -package org.codehaus.mojo.versions.api; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.io.StreamCorruptedException; -import java.util.HashMap; -import java.util.Map; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.ordering.VersionComparator; - -/** - * Scopes of version updates. - * - * @author Stephen Connolly - * todo: convert this class to a Java 1.5 enum once we move to Java 1.5 - * @since 1.0-beta-1 - */ -public abstract class UpdateScope - implements Comparable, Serializable -{ - - /** - * Versions which are less than an incremental update. - * - * @since 1.0-beta-1 - */ - public static final UpdateScope SUBINCREMENTAL = new UpdateScope( "SUBINCREMENTAL", 0 ) - { - /** {@inheritDoc} */ - public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); - Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); - return versionDetails.getOldestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); - Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); - return versionDetails.getNewestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 2 ); - Restriction restriction = new Restriction( currentVersion, false, upperBound, false ); - return versionDetails.getVersions( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - }; - - /** - * Incremental version updates, that is the third segment of the version number, for example 1.0.0.15 - * to 1.0.1.0. - * - * @since 1.0-beta-1 - */ - public static final UpdateScope INCREMENTAL = new UpdateScope( "INCREMENTAL", 1 ) - { - /** {@inheritDoc} */ - public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getOldestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getNewestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 3 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 2 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 1 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getVersions( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - }; - - /** - * Minor version updates, that is the second segment of the version number, for example 1.0.0.15 to - * 1.1.0.0. - * - * @since 1.0-beta-1 - */ - public static final UpdateScope MINOR = new UpdateScope( "MINOR", 2 ) - { - /** {@inheritDoc} */ - public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getOldestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getNewestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 2 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 1 ); - ArtifactVersion upperBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, upperBound, false ); - return versionDetails.getVersions( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - }; - - /** - * Major version updates, that is the first segment of the version number, for example 1.0.0.15 to - * 2.0.0.0. - * - * @since 1.0-beta-1 - */ - public static final UpdateScope MAJOR = new UpdateScope( "MAJOR", 3 ) - { - /** {@inheritDoc} */ - public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, null, false ); - return versionDetails.getOldestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, null, false ); - return versionDetails.getNewestVersion( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - /** {@inheritDoc} */ - public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - VersionComparator versionComparator = versionDetails.getVersionComparator(); - try - { - if ( versionComparator.getSegmentCount( currentVersion ) < 1 ) - { - return null; - } - ArtifactVersion lowerBound = versionComparator.incrementSegment( currentVersion, 0 ); - Restriction restriction = new Restriction( lowerBound, true, null, false ); - return versionDetails.getVersions( restriction, includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - throw new RuntimeException( e ); - } - } - - }; - - /** - * Any version updates. - * - * @since 1.0-beta-1 - */ - public static final UpdateScope ANY = new UpdateScope( "ANY", 4 ) - { - /** {@inheritDoc} */ - public ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( currentVersion, false, null, false ); - return versionDetails.getOldestVersion( restriction, includeSnapshots ); - } - - /** {@inheritDoc} */ - public ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( currentVersion, false, null, false ); - return versionDetails.getNewestVersion( restriction, includeSnapshots ); - } - - /** {@inheritDoc} */ - public ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( currentVersion, false, null, false ); - return versionDetails.getVersions( restriction, includeSnapshots ); - } - - }; - - /** - * Returns the next version after the specified current version within this scope. - * - * @param versionDetails The versions to select from. - * @param currentVersion The current version. - * @param includeSnapshots Whether to include snapshots. - * @return The next version within this scope or null if there is no version within this scope. - */ - public abstract ArtifactVersion getOldestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ); - - /** - * Returns the newest version after the specified current version within this scope. - * - * @param versionDetails The versions to select from. - * @param currentVersion The current version. - * @param includeSnapshots Whether to include snapshots. - * @return The newest version within this scope or null if there is no version within this scope. - */ - public abstract ArtifactVersion getNewestUpdate( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ); - - /** - * Returns all versions newer than the specified current version within this scope. - * - * @param versionDetails The versions to select from. - * @param currentVersion The current version. - * @param includeSnapshots Whether to include snapshots. - * @return All newer versions within this scope. - */ - public abstract ArtifactVersion[] getAllUpdates( VersionDetails versionDetails, ArtifactVersion currentVersion, - boolean includeSnapshots ); - - /** - * The name of this constant, as declared in the declaration. Most programmers should use the {@link #toString} - * method rather than accessing this field. - */ - private final String name; - - /** - * Returns the name of this enum constant, exactly as declared in its enum declaration. - *

- * Most programmers should use the {@link #toString} method in preference to this one, as the toString method may - * return a more user-friendly name. This method is designed primarily for use in specialized situations where - * correctness depends on getting the exact name, which will not vary from release to release. - *

- * - * @return the name of this enum constant - */ - public final String name() - { - return name; - } - - /** - * The ordinal of this enumeration constant (its position in the enum declaration, where the initial constant is - * assigned an ordinal of zero). - *

- * Most programmers will have no use for this field. - *

- */ - private final int ordinal; - - /** - * Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial - * constant is assigned an ordinal of zero). - *

- * Most programmers will have no use for this method. - *

- * - * @return the ordinal of this enumeration constant - */ - public final int ordinal() - { - return ordinal; - } - - /** - * Sole constructor. Programmers cannot invoke this constructor. - * - * @param name - The name of this enum constant, which is the identifier used to declare it. - * @param ordinal - The ordinal of this enumeration constant (its position in the enum declaration, where the - * initial constant is assigned an ordinal of zero). - */ - private UpdateScope( String name, int ordinal ) - { - this.name = name; - this.ordinal = ordinal; - } - - /** - * {@inheritDoc} - */ - public String toString() - { - return name; - } - - /** - * {@inheritDoc} - */ - public boolean equals( Object o ) - { - return this == o; - } - - /** - * {@inheritDoc} - */ - public int hashCode() - { - return super.hashCode(); - } - - /** - * Throws CloneNotSupportedException. This guarantees that levels are never cloned, which is necessary to preserve - * their "singleton" status. - * - * @return (neverreturns) - */ - protected final Object clone() - throws CloneNotSupportedException - { - throw new CloneNotSupportedException(); - } - - /** - * Compares this enum with the specified object for order. Returns a negative integer, zero, or a positive integer - * as this object is less than, equal to, or greater than the specified object. - *

- * Enum constants are only comparable to other enum constants of the same enum type. The natural order implemented - * by this method is the order in which the constants are declared. - *

- */ - public final int compareTo( UpdateScope other ) - { - UpdateScope self = this; - if ( self.getClass() != other.getClass() ) - { - throw new ClassCastException(); - } - return self.ordinal - other.ordinal; - } - - /** - * Returns the Class object corresponding to this enum constant's enum type. Two enum constants e1 and e2 are of the - * same enum type if and only if e1.getDeclaringClass() == e2.getDeclaringClass(). (The value returned by this - * method may differ from the one returned by the {@link Object#getClass} method for enum constants with - * constant-specific class bodies.) - * - * @return the Class object corresponding to this enum constant's enum type - */ - public final Class getDeclaringClass() - { - return getClass(); - } - - /** - * Returns the enum constant of the specified enum type with the specified name. The name must match exactly an - * identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) - * - * @param name the name of the constant to return - * @return the enum constant of the specified enum type with the specified name - * @throws IllegalArgumentException if the specified enum type has no constant with the specified name, or the - * specified class object does not represent an enum type - * @throws NullPointerException if name is null - */ - public static UpdateScope valueOf( String name ) - { - UpdateScope result = LEVEL_CONSTANTS.get( name ); - if ( result != null ) - { - return result; - } - if ( name == null ) - { - throw new NullPointerException( "Name is null" ); - } - throw new IllegalArgumentException( "No enum const " + UpdateScope.class.getName() + "." + name ); - } - - public static UpdateScope[] values() - { - return new UpdateScope[] { SUBINCREMENTAL, INCREMENTAL, MINOR, MAJOR, ANY }; - } - - /** - * Classifies the type of update. - * - * @param comparator The version comparator to use for classifying. - * @param from The first version. - * @param to The second version. - * @return The update classification. - */ - public static UpdateScope classifyUpdate( VersionComparator comparator, ArtifactVersion from, ArtifactVersion to ) - throws InvalidSegmentException - { - if ( comparator.compare( from, to ) >= 0 ) - { - throw new IllegalArgumentException( "From version must be less than to version" ); - } - // the trick here is that incrementing from twice and to once, should give the same version - int matchSegment = 0; - for ( int segment = - Math.min( comparator.getSegmentCount( from ), comparator.getSegmentCount( to ) ); segment > 0; segment-- ) - { - ArtifactVersion f = comparator.incrementSegment( from, segment - 1 ); - f = comparator.incrementSegment( f, segment - 1 ); - ArtifactVersion t = comparator.incrementSegment( to, segment - 1 ); - if ( f.toString().equals( t.toString() ) ) - { - matchSegment = segment; - break; - } - } - switch ( matchSegment ) - { - case 0: - return MAJOR; - case 1: - return MINOR; - case 2: - return INCREMENTAL; - default: - return SUBINCREMENTAL; - } - } - - private static final Map LEVEL_CONSTANTS; - - static - { - Map map = new HashMap<>( 5 ); - map.put( SUBINCREMENTAL.name(), SUBINCREMENTAL ); - map.put( INCREMENTAL.name(), INCREMENTAL ); - map.put( MINOR.name(), MINOR ); - map.put( MAJOR.name(), MAJOR ); - map.put( ANY.name(), ANY ); - LEVEL_CONSTANTS = map; - } - - /** - * enum classes cannot have finalize methods. - */ - protected final void finalize() - throws Throwable - { - super.finalize(); - } - - /** - * We need to ensure that the singleton is used when deserializing. - * - * @return The correct singleton instance. - * @throws java.io.ObjectStreamException when things go wrong. - */ - private Object readResolve() - throws ObjectStreamException - { - if ( ordinal == SUBINCREMENTAL.ordinal ) - { - return SUBINCREMENTAL; - } - if ( ordinal == INCREMENTAL.ordinal ) - { - return INCREMENTAL; - } - if ( ordinal == MINOR.ordinal ) - { - return MINOR; - } - if ( ordinal == MAJOR.ordinal ) - { - return MAJOR; - } - if ( ordinal == ANY.ordinal ) - { - return ANY; - } - throw new StreamCorruptedException(); - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 399efbedaa..b7aa11b9fe 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -19,6 +19,8 @@ * under the License. */ +import java.util.Optional; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; @@ -178,17 +180,6 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up */ ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ); - /** - * Returns the oldest version after the specified lowerBound, but less than the specified upper bound or - * null if no such version exists. - * - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. - * @return the next version between lowerBound and upperBound or null if no version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ); - /** * Returns the oldest version within the specified version range or null if no such version exists. * @@ -199,19 +190,6 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up */ ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ); - /** - * Returns the oldest version newer than the specified lower bound, but less than the specified upper bound or - * null if no such version exists. - * - * @param lowerBound the lower bound or null if the lower limit is unbounded. - * @param upperBound the upper bound or null if the upper limit is unbounded. - * @param includeSnapshots true if snapshots are to be included. - * @return the latest version between currentVersion and upperBound or null if no version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots ); - /** * Returns the oldest version within the specified bounds or null if no such version exists. * @@ -234,43 +212,6 @@ ArtifactVersion getOldestVersion( ArtifactVersion lowerBound, ArtifactVersion up */ ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); - /** - * Returns the oldest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param updateScope the update scope to include. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException; - - /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param updateScope the update scope to include. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException; - - /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param updateScope the update scope to include. - * @return the all versions after currentVersion within the specified update scope. - * @since 1.0-beta-1 - */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope ) - throws InvalidSegmentException; - /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or * null if no such version exists. @@ -282,7 +223,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope upd * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, + ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; /** @@ -296,7 +237,7 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, UpdateScope upd * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope updateScope, + ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; /** @@ -308,83 +249,9 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, UpdateScope upd * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, UpdateScope updateScope, + ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; - /** - * Returns the oldest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, VersionRange versionRange ); - - /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, VersionRange versionRange ); - - /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @return the all versions after currentVersion within the specified update scope. - * @since 1.0-beta-1 - */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange versionRange ); - - /** - * Returns the oldest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ); - - /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ); - - /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param versionRange the version range to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the all versions after currentVersion within the specified update scope. - * @since 1.0-beta-1 - */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange versionRange, - boolean includeSnapshots ); - /** * Returns true if and only if getCurrentVersion() != null. * @@ -430,7 +297,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( UpdateScope updateScope ) throws InvalidSegmentException; + ArtifactVersion getOldestUpdate( Optional updateScope ) throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -441,7 +308,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( UpdateScope updateScope ) throws InvalidSegmentException; + ArtifactVersion getNewestUpdate( Optional updateScope ) throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -450,7 +317,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( UpdateScope updateScope ) throws InvalidSegmentException; + ArtifactVersion[] getAllUpdates( Optional updateScope ) throws InvalidSegmentException; /** * Returns the oldest version newer than the specified current version, but within the the specified update scope or @@ -462,7 +329,8 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getOldestUpdate( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; + ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) + throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the the specified update scope or @@ -474,7 +342,8 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * version is available. * @since 1.0-beta-1 */ - ArtifactVersion getNewestUpdate( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; + ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) + throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -484,29 +353,8 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( UpdateScope updateScope, boolean includeSnapshots ) throws InvalidSegmentException; - - /** - * Returns the oldest version newer than the current version, but within the the specified update scope or - * null if no such version exists. - * - * @param versionRange the version range to include. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( VersionRange versionRange ); - - /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param versionRange the version range to include. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( VersionRange versionRange ); + ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) + throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the the specified update scope. @@ -517,30 +365,6 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, VersionRange ve */ ArtifactVersion[] getAllUpdates( VersionRange versionRange ); - /** - * Returns the oldest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param versionRange the version range to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( VersionRange versionRange, boolean includeSnapshots ); - - /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or - * null if no such version exists. - * - * @param versionRange the version range to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( VersionRange versionRange, boolean includeSnapshots ); - /** * Returns the all versions newer than the specified current version, but within the the specified update scope. * diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 9cd8fa8269..3d57779676 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -158,18 +158,6 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException; - /** - * Looks up the updates of an artifact. - * - * @param artifact The artifact to look up - * @param allowSnapshots Include snapshots in the list of updates. - * @param usePluginRepositories Search the plugin repositories. - * @return The artifact update details. - * @throws ArtifactMetadataRetrievalException When things go wrong. - */ - ArtifactVersions lookupArtifactUpdates( Artifact artifact, boolean allowSnapshots, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException; - /** * Looks up the updates for a set of dependencies. * diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index fbf6fb14e6..11f2af07f3 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -45,6 +45,7 @@ public interface VersionComparator * @param segment The segment number to increment. * @return An artifact version with the specified segment incremented. * @since 1.0-beta-1 + * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) */ ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, int segment ) throws InvalidSegmentException; } From a54e87fac6597d58eee14ec33c17590524836f48 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 16 Sep 2022 19:11:49 +0200 Subject: [PATCH 128/441] Migrate to JSR330 Closes #698 #697 --- ...AbstractVersionsDependencyUpdaterMojo.java | 17 ++++++++ .../versions/AbstractVersionsDisplayMojo.java | 17 ++++++++ .../mojo/versions/AbstractVersionsReport.java | 30 ++++++------- .../versions/AbstractVersionsUpdaterMojo.java | 29 +++++++------ .../versions/CompareDependenciesMojo.java | 19 ++++++++- .../versions/DependencyUpdatesReport.java | 14 +++++++ .../DisplayDependencyUpdatesMojo.java | 16 +++++++ .../versions/DisplayParentUpdatesMojo.java | 16 +++++++ .../versions/DisplayPluginUpdatesMojo.java | 30 ++++++++++--- .../versions/DisplayPropertyUpdatesMojo.java | 16 +++++++ .../mojo/versions/ForceReleasesMojo.java | 16 +++++++ .../mojo/versions/LockSnapshotsMojo.java | 20 ++++++++- .../mojo/versions/PluginUpdatesReport.java | 14 +++++++ .../mojo/versions/PropertyUpdatesReport.java | 14 +++++++ .../mojo/versions/ResolveRangesMojo.java | 16 +++++++ .../org/codehaus/mojo/versions/SetMojo.java | 22 ++++++++-- .../mojo/versions/SetPropertyMojo.java | 16 +++++++ .../codehaus/mojo/versions/SetScmTagMojo.java | 16 +++++++ .../mojo/versions/UnlockSnapshotsMojo.java | 16 +++++++ .../mojo/versions/UpdateChildModulesMojo.java | 16 +++++++ .../mojo/versions/UpdateParentMojo.java | 16 +++++++ .../mojo/versions/UpdatePropertiesMojo.java | 16 +++++++ .../mojo/versions/UpdatePropertyMojo.java | 16 +++++++ .../mojo/versions/UseDepVersionMojo.java | 16 +++++++ .../mojo/versions/UseLatestReleasesMojo.java | 16 +++++++ .../mojo/versions/UseLatestSnapshotsMojo.java | 16 +++++++ .../mojo/versions/UseLatestVersionsMojo.java | 15 +++++++ .../mojo/versions/UseNextReleasesMojo.java | 16 +++++++ .../mojo/versions/UseNextSnapshotsMojo.java | 16 +++++++ .../mojo/versions/UseNextVersionsMojo.java | 16 +++++++ .../mojo/versions/UseReactorMojo.java | 16 +++++++ .../mojo/versions/UseReleasesMojo.java | 16 +++++++ .../versions/DependencyUpdatesReportTest.java | 42 ++++--------------- .../versions/PluginUpdatesReportTest.java | 40 ++++-------------- ...ratePatternsForIncludesAnExcludesTest.java | 2 +- .../codehaus/mojo/versions/SetMojoTest.java | 8 ++-- .../mojo/versions/UpdateParentMojoTest.java | 10 ++--- .../versions/UseLatestVersionsMojoTest.java | 8 ++-- .../mojo/versions/utils/MockUtils.java | 28 +++++++++++++ 39 files changed, 575 insertions(+), 124 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 6ebbdb09d8..41ced6e9a8 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.inject.Inject; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -26,12 +28,17 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -137,6 +144,16 @@ public abstract class AbstractVersionsDependencyUpdaterMojo @Parameter( property = "excludeReactor", defaultValue = "true" ) private boolean excludeReactor; + @Inject + protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * Should the project/dependencies section of the pom be processed. * diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index bab4092b22..396e6ea7ac 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.inject.Inject; + import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -27,7 +29,12 @@ import java.util.Set; import org.apache.commons.lang3.StringUtils; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; /** * Abstract base class for the Display___ mojos. @@ -76,6 +83,16 @@ public abstract class AbstractVersionsDisplayMojo private boolean outputFileError = false; + @Inject + protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + protected void logInit() { if ( outputFile != null && !outputFileError ) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 8e093ccc3d..5fa98541ab 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.inject.Inject; + import java.io.File; import java.util.List; import java.util.Locale; @@ -37,7 +39,6 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; @@ -64,18 +65,10 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-3 */ - @Component protected I18N i18n; - @Component protected RepositorySystem repositorySystem; - /** - * @since 1.0-alpha-3 - */ - @Component - private ArtifactResolver resolver; - /** * Skip entire check. * @@ -89,7 +82,6 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-1 */ - @Component protected ArtifactMetadataSource artifactMetadataSource; /** @@ -107,7 +99,6 @@ public abstract class AbstractVersionsReport /** * @since 1.0-alpha-3 */ - @Component private WagonManager wagonManager; /** @@ -168,7 +159,6 @@ public abstract class AbstractVersionsReport @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) private MojoExecution mojoExecution; - @Component protected ArtifactResolver artifactResolver; /** @@ -200,6 +190,17 @@ public abstract class AbstractVersionsReport // --------------------- GETTER / SETTER METHODS --------------------- + @Inject + protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + { + this.i18n = i18n; + this.repositorySystem = repositorySystem; + this.artifactResolver = artifactResolver; + this.artifactMetadataSource = artifactMetadataSource; + this.wagonManager = wagonManager; + } + public VersionsHelper getHelper() throws MavenReportException { @@ -359,11 +360,6 @@ public String getComparisonMethod() return comparisonMethod; } - public ArtifactResolver getResolver() - { - return resolver; - } - public I18N getI18n() { return i18n; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index b2a45dbd5d..14fc8aa333 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -45,7 +46,6 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; @@ -86,19 +86,11 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; - @Component protected RepositorySystem repositorySystem; /** * @since 1.0-alpha-1 */ - @Component - protected org.apache.maven.artifact.resolver.ArtifactResolver resolver; - - /** - * @since 1.0-alpha-1 - */ - @Component protected MavenProjectBuilder projectBuilder; /** @@ -112,7 +104,6 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-1 */ - @Component protected ArtifactMetadataSource artifactMetadataSource; /** @@ -136,7 +127,6 @@ public abstract class AbstractVersionsUpdaterMojo /** * @since 1.0-alpha-3 */ - @Component private WagonManager wagonManager; /** @@ -195,7 +185,6 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) private MojoExecution mojoExecution; - @Component protected ArtifactResolver artifactResolver; /** * The format used to record changes. If "none" is specified, no changes are recorded. @@ -247,6 +236,20 @@ public abstract class AbstractVersionsUpdaterMojo // --------------------- GETTER / SETTER METHODS --------------------- + @Inject + protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + this.repositorySystem = repositorySystem; + this.projectBuilder = projectBuilder; + this.artifactMetadataSource = artifactMetadataSource; + this.wagonManager = wagonManager; + this.artifactResolver = artifactResolver; + } + public VersionsHelper getHelper() throws MojoExecutionException { if ( helper == null ) @@ -526,7 +529,7 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A artifact.setVersion( updateVersion.toString() ); try { - resolver.resolveAlways( artifact, remoteArtifactRepositories, localRepository ); + artifactResolver.resolveAlways( artifact, remoteArtifactRepositories, localRepository ); } catch ( ArtifactResolutionException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 4b2371769c..0ba886afdc 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.File; @@ -31,15 +32,18 @@ import java.util.Map; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -112,11 +116,22 @@ public class CompareDependenciesMojo /** * The project builder used to initialize the remote project. */ - @Component protected MavenProjectBuilder mavenProjectBuilder; // ------------------------------ METHODS -------------------------- + @Inject + public CompareDependenciesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + MavenProjectBuilder mavenProjectBuilder ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + this.mavenProjectBuilder = mavenProjectBuilder; + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException Something wrong with the plugin itself diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index c3ed203827..b5c5960373 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -19,21 +19,28 @@ * under the License. */ +import javax.inject.Inject; + import java.io.File; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.utils.DependencyComparator; +import org.codehaus.plexus.i18n.I18N; import static java.util.Collections.EMPTY_MAP; import static org.codehaus.mojo.versions.utils.MiscUtils.filter; @@ -93,6 +100,13 @@ public class DependencyUpdatesReport extends AbstractVersionsReport @Parameter( property = "onlyUpgradable", defaultValue = "false" ) protected boolean onlyUpgradable; + @Inject + protected DependencyUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + { + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index fc98c1d1d6..8f515b70fc 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.ArrayList; @@ -32,7 +33,10 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; @@ -43,6 +47,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.filtering.DependencyFilter; @@ -339,6 +345,16 @@ public class DisplayDependencyUpdatesMojo // --------------------- GETTER / SETTER METHODS --------------------- + @Inject + public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) { Set result = new TreeSet<>( new DependencyComparator() ); diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 7ef2a9167f..03363e5dbb 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -19,16 +19,22 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -45,6 +51,16 @@ public class DisplayParentUpdatesMojo public static final int MESSAGE_LENGTH = 68; + @Inject + public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + @Override public void execute() throws MojoExecutionException, MojoFailureException diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index f7cd5e8e4d..668fa3cef6 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; @@ -48,10 +49,13 @@ import org.apache.maven.BuildFailureException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -81,11 +85,12 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -135,13 +140,11 @@ public class DisplayPluginUpdatesMojo /** * @since 1.0-alpha-1 */ - @Component private LifecycleExecutor lifecycleExecutor; /** * @since 1.0-alpha-3 */ - @Component private ModelInterpolator modelInterpolator; /** @@ -149,17 +152,34 @@ public class DisplayPluginUpdatesMojo * * @since 1.0-alpha-1 */ - @Component private PluginManager pluginManager; /** * @since 1.3 */ - @Component private RuntimeInformation runtimeInformation; // --------------------- GETTER / SETTER METHODS --------------------- + @Inject + @SuppressWarnings( "checkstyle:ParameterNumber" ) + public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + LifecycleExecutor lifecycleExecutor, + ModelInterpolator modelInterpolator, + PluginManager pluginManager, + RuntimeInformation runtimeInformation ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + this.lifecycleExecutor = lifecycleExecutor; + this.modelInterpolator = modelInterpolator; + this.pluginManager = pluginManager; + this.runtimeInformation = runtimeInformation; + } + /** * Returns the pluginManagement section of the super-pom. * diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 4344a6da05..46d29094fd 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.ArrayList; @@ -26,13 +27,18 @@ import java.util.Map; import java.util.TreeSet; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -118,6 +124,16 @@ public class DisplayPropertyUpdatesMojo // -------------------------- OTHER METHODS -------------------------- + @Inject + public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + public void execute() throws MojoExecutionException, MojoFailureException { diff --git a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 0edc0bfa51..566cf6bd82 100644 --- a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; @@ -26,12 +27,17 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -56,6 +62,16 @@ public class ForceReleasesMojo // ------------------------------ METHODS -------------------------- + @Inject + public ForceReleasesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 42830207af..5e88809cee 100644 --- a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; @@ -26,11 +27,16 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -57,6 +63,16 @@ public class LockSnapshotsMojo // ------------------------------ METHODS -------------------------- + @Inject + public LockSnapshotsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong @@ -167,7 +183,7 @@ private String resolveSnapshotVersion( Artifact artifact ) try { - resolver.resolve( artifact, getProject().getRemoteArtifactRepositories(), localRepository ); + artifactResolver.resolve( artifact, getProject().getRemoteArtifactRepositories(), localRepository ); lockedVersion = artifact.getVersion(); } @@ -193,7 +209,7 @@ private String resolveSnapshotVersion( Dependency dep ) try { Artifact depArtifact = getHelper().createDependencyArtifact( dep ); - resolver.resolve( depArtifact, getProject().getRemoteArtifactRepositories(), localRepository ); + artifactResolver.resolve( depArtifact, getProject().getRemoteArtifactRepositories(), localRepository ); lockedVersion = depArtifact.getVersion(); } diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java index 5ced4f1903..01c6409218 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java @@ -19,20 +19,27 @@ * under the License. */ +import javax.inject.Inject; + import java.io.File; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.utils.PluginComparator; +import org.codehaus.plexus.i18n.I18N; import static org.codehaus.mojo.versions.utils.MiscUtils.filter; @@ -70,6 +77,13 @@ public class PluginUpdatesReport extends AbstractVersionsReport @Parameter( property = "onlyUpgradable", defaultValue = "false" ) protected boolean onlyUpgradable; + @Inject + protected PluginUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + { + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java index 5668ae9ffa..b3fb648101 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java @@ -19,18 +19,25 @@ * under the License. */ +import javax.inject.Inject; + import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.utils.PropertyComparator; +import org.codehaus.plexus.i18n.I18N; /** * Generates a report of available updates for properties of a project which are linked to the dependencies and/or @@ -77,6 +84,13 @@ public class PropertyUpdatesReport @Parameter( property = "autoLinkItems", defaultValue = "true" ) private boolean autoLinkItems; + @Inject + protected PropertyUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + { + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 937b68d170..9e1eaa7766 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; @@ -28,7 +29,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; @@ -36,6 +40,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -110,6 +116,16 @@ public class ResolveRangesMojo // ------------------------------ METHODS -------------------------- + @Inject + public ResolveRangesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 9aae5bd90a..d925175494 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.File; @@ -39,14 +40,18 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.change.VersionChange; import org.codehaus.mojo.versions.change.VersionChanger; @@ -162,10 +167,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo /** * Component used to prompt for input - * - * @component */ - @Component private Prompter prompter; /** @@ -240,6 +242,18 @@ public class SetMojo extends AbstractVersionsUpdaterMojo */ private final transient List sourceChanges = new ArrayList<>(); + @Inject + public SetMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Prompter prompter ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + this.prompter = prompter; + } + private synchronized void addChange( String groupId, String artifactId, String oldVersion, String newVersion ) { if ( !newVersion.equals( oldVersion ) ) diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index a84b1b62ad..18ac4743e4 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -19,16 +19,22 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.IOException; import java.util.Arrays; import java.util.Map; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -82,6 +88,16 @@ public class SetPropertyMojo @Parameter( property = "propertiesVersionsFile" ) private String propertiesVersionsFile; + @Inject + public SetPropertyMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 46d5cbdd0e..ca54ef0136 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -1,17 +1,23 @@ package org.codehaus.mojo.versions; +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -60,6 +66,16 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo @Parameter( property = "url" ) private String url; + @Inject + public SetScmTagMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * Called when this mojo is executed. * diff --git a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 1a21bb176c..fe4c1ce01f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.List; @@ -26,11 +27,16 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -59,6 +65,16 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo // ------------------------------ METHODS -------------------------- + @Inject + public UnlockSnapshotsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index bd0f0e88d5..2de5878a03 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.File; @@ -28,11 +29,16 @@ import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -63,6 +69,16 @@ public class UpdateChildModulesMojo */ private transient String sourceVersion = null; + @Inject + public UpdateChildModulesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * Called when this mojo is executed. * diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index bd1e789816..2c3add8798 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -19,10 +19,14 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -31,6 +35,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -94,6 +100,16 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo // -------------------------- OTHER METHODS -------------------------- + @Inject + public UpdateParentMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index c53e6eca0c..c9b3ab9781 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -19,16 +19,22 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Map; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -123,6 +129,16 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo // -------------------------- OTHER METHODS -------------------------- + @Inject + public UpdatePropertiesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 5426698a06..ca427f9418 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -19,16 +19,22 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Map; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -120,6 +126,16 @@ public class UpdatePropertyMojo // -------------------------- OTHER METHODS -------------------------- + @Inject + public UpdatePropertyMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 0a9169c0c7..f9426c56bd 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -19,17 +19,23 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -63,6 +69,16 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo defaultValue = "false" ) protected boolean forceVersion; + @Inject + public UseDepVersionMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + @Override protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 501e622edf..e61fdfa103 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.ArrayList; @@ -30,7 +31,10 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; @@ -39,6 +43,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -92,6 +98,16 @@ public class UseLatestReleasesMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseLatestReleasesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 16e9d87558..7d65fe0349 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.ArrayList; @@ -28,7 +29,10 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; @@ -37,6 +41,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -91,6 +97,16 @@ public class UseLatestSnapshotsMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 25380e4d3e..aafeafcf6c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -19,13 +19,17 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.io.IOException; import java.util.Collection; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; @@ -34,6 +38,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -90,6 +96,15 @@ public class UseLatestVersionsMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseLatestVersionsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } /** * {@inheritDoc} diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 153f8e89c3..c58bd1e6ae 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; @@ -26,12 +27,17 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -56,6 +62,16 @@ public class UseNextReleasesMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseNextReleasesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index b13960609f..255db131e0 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Arrays; @@ -27,7 +28,10 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; @@ -36,6 +40,8 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -86,6 +92,16 @@ public class UseNextSnapshotsMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseNextSnapshotsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 9d22973400..6b46fd8e61 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -19,17 +19,23 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -47,6 +53,16 @@ public class UseNextVersionsMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseNextVersionsMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index f887a29c42..e0ebc85ca3 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -19,18 +19,24 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -47,6 +53,16 @@ public class UseReactorMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseReactorMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 0cb8c751c9..514472d64c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -19,6 +19,7 @@ * under the License. */ +import javax.inject.Inject; import javax.xml.stream.XMLStreamException; import java.util.Collection; @@ -27,7 +28,10 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -35,6 +39,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -76,6 +82,16 @@ public class UseReleasesMojo // ------------------------------ METHODS -------------------------- + @Inject + public UseReleasesMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + /** * @param pom the pom to update. * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index 02bd99b3e0..ed0b789267 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -27,12 +27,9 @@ import java.util.Locale; import java.util.Set; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; -import org.apache.maven.doxia.tools.SiteTool; -import org.apache.maven.doxia.tools.SiteToolException; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; @@ -41,18 +38,18 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.model.RuleSet; -import org.codehaus.plexus.i18n.I18N; +import org.codehaus.mojo.versions.utils.MockUtils; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -68,14 +65,13 @@ private static class TestDependencyUpdatesReport extends DependencyUpdatesReport @SuppressWarnings( "deprecation" ) TestDependencyUpdatesReport() { - mockPlexusComponents(); + super( mockI18N(), mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); + siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); project.setOriginalModel( new Model() ); project.getOriginalModel().setDependencyManagement( new DependencyManagement() ); project.getModel().setDependencyManagement( new DependencyManagement() ); - - artifactMetadataSource = mockArtifactMetadataSource(); } public TestDependencyUpdatesReport withDependencies( Dependency... dependencies ) @@ -138,22 +134,9 @@ public TestDependencyUpdatesReport withIgnoredVersions( return this; } - /** - *

Mocks some Plexus components to speed up test execution.

- *

Note: these components could just as well be injected using - * org.codehaus.plexus.PlexusTestCase.lookup, - * but that method greatly slows down test execution.

- * - * @see - * Testing Plexus Components - */ - private void mockPlexusComponents() + private static RepositorySystem mockRepositorySystem() { - i18n = mock( I18N.class ); - when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( - invocation -> invocation.getArgument( 2 ) ); - - repositorySystem = mock( RepositorySystem.class ); + RepositorySystem repositorySystem = mock( RepositorySystem.class ); when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> { @@ -162,18 +145,7 @@ private void mockPlexusComponents() dependency.getVersion(), dependency.getScope(), dependency.getType(), dependency.getClassifier(), null ); } ); - - Artifact skinArtifact = mock( Artifact.class ); - when( skinArtifact.getId() ).thenReturn( "" ); - siteTool = mock( SiteTool.class ); - try - { - when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); - } - catch ( SiteToolException e ) - { - throw new RuntimeException( e ); - } + return repositorySystem; } } diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java index ddc3baa753..a8fad70d7f 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java @@ -27,12 +27,9 @@ import java.util.Locale; import java.util.Set; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; -import org.apache.maven.doxia.tools.SiteTool; -import org.apache.maven.doxia.tools.SiteToolException; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; @@ -40,11 +37,12 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.model.RuleSet; -import org.codehaus.plexus.i18n.I18N; +import org.codehaus.mojo.versions.utils.MockUtils; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; @@ -52,7 +50,6 @@ import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.matchesPattern; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -67,7 +64,8 @@ private static class TestPluginUpdatesReport extends PluginUpdatesReport { TestPluginUpdatesReport() { - mockPlexusComponents(); + super( mockI18N(), mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); + siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); project.setBuild( new Build() ); @@ -114,22 +112,9 @@ public TestPluginUpdatesReport withIgnoredVersions( return this; } - /** - *

Mocks some Plexus components to speed up test execution.

- *

Note: these components could just as well be injected using - * org.codehaus.plexus.PlexusTestCase.lookup, - * but that method greatly slows down test execution.

- * - * @see - * Testing Plexus Components - */ - private void mockPlexusComponents() + private static RepositorySystem mockRepositorySystem() { - i18n = mock( I18N.class ); - when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( - invocation -> invocation.getArgument( 2 ) ); - - repositorySystem = mock( RepositorySystem.class ); + RepositorySystem repositorySystem = mock( RepositorySystem.class ); when( repositorySystem.createPluginArtifact( any( Plugin.class ) ) ).thenAnswer( invocation -> { @@ -137,18 +122,7 @@ private void mockPlexusComponents() return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), SCOPE_RUNTIME, "maven-plugin", "jar", null ); } ); - - Artifact skinArtifact = mock( Artifact.class ); - when( skinArtifact.getId() ).thenReturn( "" ); - siteTool = mock( SiteTool.class ); - try - { - when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); - } - catch ( SiteToolException e ) - { - throw new RuntimeException( e ); - } + return repositorySystem; } } diff --git a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index 82fa5b718d..b238079b80 100644 --- a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -21,7 +21,7 @@ public class SeparatePatternsForIncludesAnExcludesTest public void setUp() throws Exception { - mojo = new AbstractVersionsDependencyUpdaterMojo() + mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null ) { protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index a9b8916b40..8318120414 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -23,7 +23,7 @@ public class SetMojoTest extends AbstractMojoTestCase @Test public void testGetIncrementedVersion() throws MojoExecutionException { - new SetMojo() + new SetMojo( null, null, null, null, null, null ) { { assertThat( getIncrementedVersion( "1.0.0", null ), is( "1.0.1-SNAPSHOT" ) ); @@ -38,7 +38,7 @@ public void testGetIncrementedVersion() throws MojoExecutionException @Test public void testNextSnapshotIndexLowerBound() { - new SetMojo() + new SetMojo( null, null, null, null, null, null ) { { try @@ -58,7 +58,7 @@ public void testNextSnapshotIndexLowerBound() @Test public void testNextSnapshotIndexUpperBound() { - new SetMojo() + new SetMojo( null, null, null, null, null, null ) { { try @@ -80,7 +80,7 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti { try { - new SetMojo() + new SetMojo( null, null, null, null, null, null ) { { project = new MavenProject(); diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 76d9191f81..d265d46ebd 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -70,14 +70,14 @@ public void setUp() throws IllegalAccessException changeRecorder = new TestChangeRecorder(); artifactResolver = mock( ArtifactResolver.class ); - mojo = new UpdateParentMojo() + mojo = new UpdateParentMojo( repositorySystem, + null, + artifactMetadataSource, + null, + artifactResolver ) {{ setProject( createProject() ); reactorProjects = Collections.emptyList(); - repositorySystem = UpdateParentMojoTest.repositorySystem; - artifactMetadataSource = UpdateParentMojoTest.artifactMetadataSource; - resolver = UpdateParentMojoTest.this.artifactResolver; - setVariableValueToObject( this, "changeRecorder", changeRecorder ); }}; } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 6072d925ee..47e0ed3393 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -62,7 +62,11 @@ public void setUp() throws Exception "1.0.0.0-SNAPSHOT", "0.9.0.0"} ); }} ); - mojo = new UseLatestVersionsMojo() + mojo = new UseLatestVersionsMojo( repositorySystemMock, + null, + artifactMetadataSourceMock, + null, + null ) {{ MavenProject project = new MavenProject() {{ @@ -83,8 +87,6 @@ public void setUp() throws Exception }} ); }}; setProject( project ); - repositorySystem = repositorySystemMock; - artifactMetadataSource = artifactMetadataSourceMock; changeRecorder = new TestChangeRecorder(); setVariableValueToObject( this, "changeRecorder", changeRecorder ); diff --git a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java index 0d9ea6234e..71e885f889 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -28,8 +28,12 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.doxia.tools.SiteTool; +import org.apache.maven.doxia.tools.SiteToolException; +import org.codehaus.plexus.i18n.I18N; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -83,4 +87,28 @@ public static ArtifactMetadataSource mockArtifactMetadataSource( Map invocation.getArgument( 2 ) ); + return i18n; + } + + public static SiteTool mockSiteTool() + { + Artifact skinArtifact = mock( Artifact.class ); + when( skinArtifact.getId() ).thenReturn( "" ); + SiteTool siteTool = mock( SiteTool.class ); + try + { + when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); + } + catch ( SiteToolException e ) + { + throw new RuntimeException( e ); + } + return siteTool; + } } From 9d9991e4fa7cf0ca59c6ed282fdfaf425e22b005 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 18 Sep 2022 10:58:18 +0200 Subject: [PATCH 129/441] (doc) remove unused and deprecated Mojo annotation requiresProject. Also requiresProject = true is default --- src/main/java/org/codehaus/mojo/versions/CommitMojo.java | 2 +- .../org/codehaus/mojo/versions/CompareDependenciesMojo.java | 2 +- .../codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java | 3 +-- .../org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java | 2 +- .../org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java | 2 +- .../codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java | 2 +- .../java/org/codehaus/mojo/versions/ForceReleasesMojo.java | 2 +- .../java/org/codehaus/mojo/versions/LockSnapshotsMojo.java | 2 +- .../org/codehaus/mojo/versions/PropertyUpdatesReport.java | 2 +- .../java/org/codehaus/mojo/versions/ResolveRangesMojo.java | 2 +- src/main/java/org/codehaus/mojo/versions/RevertMojo.java | 2 +- src/main/java/org/codehaus/mojo/versions/SetMojo.java | 2 +- .../java/org/codehaus/mojo/versions/SetPropertyMojo.java | 2 +- src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java | 5 +---- .../org/codehaus/mojo/versions/UpdateChildModulesMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UpdateParentMojo.java | 5 +---- .../org/codehaus/mojo/versions/UpdatePropertiesMojo.java | 5 +---- .../java/org/codehaus/mojo/versions/UpdatePropertyMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UseDepVersionMojo.java | 4 +--- .../org/codehaus/mojo/versions/UseLatestReleasesMojo.java | 2 +- .../org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java | 2 +- .../org/codehaus/mojo/versions/UseLatestVersionsMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UseNextReleasesMojo.java | 2 +- .../org/codehaus/mojo/versions/UseNextSnapshotsMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UseNextVersionsMojo.java | 2 +- src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java | 2 +- .../java/org/codehaus/mojo/versions/UseReleasesMojo.java | 2 +- 28 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/CommitMojo.java b/src/main/java/org/codehaus/mojo/versions/CommitMojo.java index 3a715cff70..b1bf396613 100644 --- a/src/main/java/org/codehaus/mojo/versions/CommitMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CommitMojo.java @@ -36,7 +36,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "commit", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "commit", threadSafe = true ) public class CommitMojo extends AbstractMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 0ba886afdc..8e802ae118 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -57,7 +57,7 @@ * @author Paul Gier * @since 1.3 */ -@Mojo( name = "compare-dependencies", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "compare-dependencies", threadSafe = true ) public class CompareDependenciesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 8f515b70fc..bf3a2ac185 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -72,8 +72,7 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "display-dependency-updates", requiresProject = true, requiresDirectInvocation = false, - threadSafe = true ) +@Mojo( name = "display-dependency-updates", threadSafe = true ) public class DisplayDependencyUpdatesMojo extends AbstractVersionsDisplayMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 03363e5dbb..066aab7e2b 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -44,7 +44,7 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "display-parent-updates", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "display-parent-updates", threadSafe = true ) public class DisplayParentUpdatesMojo extends AbstractVersionsDisplayMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 668fa3cef6..09f035fe29 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -109,7 +109,7 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "display-plugin-updates", requiresProject = true, requiresDirectInvocation = false, threadSafe = true ) +@Mojo( name = "display-plugin-updates", threadSafe = true ) public class DisplayPluginUpdatesMojo extends AbstractVersionsDisplayMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 46d29094fd..238077de9b 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -49,7 +49,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "display-property-updates", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "display-property-updates", threadSafe = true ) public class DisplayPropertyUpdatesMojo extends AbstractVersionsDisplayMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 566cf6bd82..56c9812643 100644 --- a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -48,7 +48,7 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "force-releases", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "force-releases", threadSafe = true ) public class ForceReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 5e88809cee..9e17a35942 100644 --- a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -49,7 +49,7 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "lock-snapshots", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "lock-snapshots", threadSafe = true ) public class LockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java index b3fb648101..4093b70c3e 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java @@ -46,7 +46,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "property-updates-report", requiresProject = true, requiresDependencyResolution = ResolutionScope.RUNTIME, +@Mojo( name = "property-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) public class PropertyUpdatesReport extends AbstractVersionsReport diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 9e1eaa7766..14bf5c73b5 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -54,7 +54,7 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "resolve-ranges", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "resolve-ranges", threadSafe = true ) public class ResolveRangesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/src/main/java/org/codehaus/mojo/versions/RevertMojo.java index dd5f289bd6..a85092f420 100644 --- a/src/main/java/org/codehaus/mojo/versions/RevertMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/RevertMojo.java @@ -36,7 +36,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "revert", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "revert", threadSafe = true ) public class RevertMojo extends AbstractMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index d925175494..9fee67c5d2 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -72,7 +72,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "set", requiresProject = true, requiresDirectInvocation = true, aggregator = true, threadSafe = true ) +@Mojo( name = "set", aggregator = true, threadSafe = true ) public class SetMojo extends AbstractVersionsUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 18ac4743e4..6ab5915347 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -52,7 +52,7 @@ * @author Karl Heinz Marbaise * @since 2.5 */ -@Mojo( name = "set-property", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "set-property", threadSafe = true ) public class SetPropertyMojo extends AbstractVersionsUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index ca54ef0136..addeab5dce 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -30,7 +30,7 @@ * @author Anton Johansson * @since 2.5 */ -@Mojo( name = "set-scm-tag", requiresDirectInvocation = true, aggregator = true, threadSafe = true ) +@Mojo( name = "set-scm-tag", aggregator = true, threadSafe = true ) public class SetScmTagMojo extends AbstractVersionsUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index fe4c1ce01f..d338a53d34 100644 --- a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -49,10 +49,7 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "unlock-snapshots", - requiresProject = true, - requiresDirectInvocation = true, - threadSafe = true ) +@Mojo( name = "unlock-snapshots", threadSafe = true ) public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index 2de5878a03..be50bbeb08 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -49,7 +49,7 @@ * @author Stephen Connolly * @since 1.0-alpha-2 */ -@Mojo( name = "update-child-modules", requiresProject = true, requiresDirectInvocation = true, aggregator = true, +@Mojo( name = "update-child-modules", aggregator = true, threadSafe = true ) public class UpdateChildModulesMojo extends AbstractVersionsUpdaterMojo diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 2c3add8798..b3ee61b8ab 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -49,10 +49,7 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-parent", - requiresProject = true, - requiresDirectInvocation = true, - threadSafe = true ) +@Mojo( name = "update-parent", threadSafe = true ) public class UpdateParentMojo extends AbstractVersionsUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index c9b3ab9781..910eff7439 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -46,10 +46,7 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-properties", - requiresProject = true, - requiresDirectInvocation = true, - threadSafe = true ) +@Mojo( name = "update-properties", threadSafe = true ) public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index ca427f9418..0101e5ebdc 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -46,7 +46,7 @@ * @author Eric Pabst * @since 1.3 */ -@Mojo( name = "update-property", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "update-property", threadSafe = true ) public class UpdatePropertyMojo extends AbstractVersionsUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index f9426c56bd..ccd389e0ad 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -48,9 +48,7 @@ * @author Dan Arcari * @since 2.3 */ -@Mojo( name = "use-dep-version", - requiresProject = true, - threadSafe = true ) +@Mojo( name = "use-dep-version", threadSafe = true ) public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index e61fdfa103..c48197b2c6 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -60,7 +60,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-latest-releases", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-latest-releases", threadSafe = true ) public class UseLatestReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 7d65fe0349..fb8cea2d7f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -59,7 +59,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "use-latest-snapshots", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-latest-snapshots", threadSafe = true ) public class UseLatestSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index aafeafcf6c..e93b7d5a3c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -55,7 +55,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-latest-versions", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-latest-versions", threadSafe = true ) public class UseLatestVersionsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index c58bd1e6ae..149cc23f0f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -48,7 +48,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-next-releases", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-next-releases", threadSafe = true ) public class UseNextReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 255db131e0..be11af6fa4 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -54,7 +54,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "use-next-snapshots", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-next-snapshots", threadSafe = true ) public class UseNextSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 6b46fd8e61..ba0223cf98 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -46,7 +46,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-next-versions", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-next-versions", threadSafe = true ) public class UseNextVersionsMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index e0ebc85ca3..467a2d747a 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -46,7 +46,7 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "use-reactor", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-reactor", threadSafe = true ) public class UseReactorMojo extends AbstractVersionsDependencyUpdaterMojo { diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 514472d64c..6e71ff0aaa 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -52,7 +52,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-releases", requiresProject = true, requiresDirectInvocation = true, threadSafe = true ) +@Mojo( name = "use-releases", threadSafe = true ) public class UseReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { From fc5f0928d3922c9089363663ef8391e38e482e5e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 18 Sep 2022 12:25:32 +0200 Subject: [PATCH 130/441] #690: Adding a unit test testing the issue --- .../mojo/versions/UpdateParentMojoTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index d265d46ebd..bb39a26728 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -325,4 +325,25 @@ private void testSkipResolution( String version ) assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", "parent-artifact", "1.0.0", version ) ) ); } + + @Test + public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "0.9.0" ); + }} ); + mojo.allowSnapshots = true; + mojo.parentVersion = "[0,1.0.1-SNAPSHOT]"; + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "parent-artifact", "0.9.0", + "1.0.1-SNAPSHOT" ) ) ); + } } From 29394d946189c373a5b9565c08ab20e01211ff2e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 18 Sep 2022 09:22:44 +0200 Subject: [PATCH 131/441] Further refactoring: replacing segment index with the Segment enum --- .../versions/AbstractVersionsUpdaterMojo.java | 49 +++++++++-------- .../versions/DisplayPropertyUpdatesMojo.java | 7 ++- .../mojo/versions/ResolveRangesMojo.java | 7 ++- .../mojo/versions/UpdatePropertiesMojo.java | 6 ++- .../mojo/versions/UpdatePropertyMojo.java | 7 ++- .../mojo/versions/UseLatestReleasesMojo.java | 7 ++- .../mojo/versions/UseLatestSnapshotsMojo.java | 15 ++++-- .../mojo/versions/UseLatestVersionsMojo.java | 4 +- .../mojo/versions/UseNextSnapshotsMojo.java | 17 ++++-- .../versions/api/AbstractVersionDetails.java | 53 ++++++++++--------- .../mojo/versions/api/PropertyVersions.java | 23 ++++---- .../codehaus/mojo/versions/api/Segment.java | 13 +++++ .../ordering/AbstractVersionComparator.java | 10 +++- .../ordering/InvalidSegmentException.java | 9 ++-- .../ordering/MajorMinorIncrementalFilter.java | 3 +- .../ordering/MavenVersionComparator.java | 21 +++----- .../ordering/MercuryVersionComparator.java | 14 ++--- .../ordering/NumericVersionComparator.java | 13 ++--- .../versions/ordering/VersionComparator.java | 3 +- .../ordering/MavenVersionComparatorTest.java | 30 ++++++----- .../MercuryVersionComparatorTest.java | 23 ++++---- .../NumericVersionComparatorTest.java | 20 ++++--- .../ordering/VersionComparatorsTest.java | 3 +- 23 files changed, 206 insertions(+), 151 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 14fc8aa333..9b9b4dca77 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -28,8 +28,10 @@ import java.io.IOException; import java.io.Writer; import java.util.List; +import java.util.Optional; import java.util.Set; +import org.apache.commons.text.CaseUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -55,6 +57,7 @@ import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -67,6 +70,12 @@ import org.codehaus.plexus.util.WriterFactory; import org.codehaus.stax2.XMLInputFactory2; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; + /** * Abstract base class for Versions Mojos. * @@ -568,43 +577,33 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * @param allowIncrementalUpdates Allow incremental updates * @return Returns the segment (0-based) that is unchangable. If any segment can change, returns -1. */ - protected int determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, - boolean allowIncrementalUpdates ) + protected Optional determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, + boolean allowIncrementalUpdates ) { - int segment; - if ( allowMajorUpdates ) - { - segment = -1; - getLog().info( "Major version changes allowed" ); - } - else if ( allowMinorUpdates ) - { - segment = 0; - getLog().info( "Minor version changes allowed" ); - } - else if ( allowIncrementalUpdates ) - { - segment = 1; - getLog().info( "Incremental version changes allowed" ); - } - else + Optional unchangedSegment = allowMajorUpdates ? empty() + : allowMinorUpdates ? of( MAJOR ) + : allowIncrementalUpdates ? of( MINOR ) + : of( INCREMENTAL ); + if ( getLog().isInfoEnabled() ) { - segment = 2; - getLog().info( "Subincremental version changes allowed" ); + getLog().info( + unchangedSegment.map( s -> + CaseUtils.toCamelCase( Segment.of( s.value() + 1 ).toString(), true ) ) + .orElse( "All" ) + " version changes allowed" ); } - - return segment; + return unchangedSegment; } protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, PropertyVersions version, String currentVersion, - boolean allowDowngrade, int segment ) + boolean allowDowngrade, + Optional unchangedSegment ) throws XMLStreamException, InvalidVersionSpecificationException, InvalidSegmentException, MojoExecutionException { ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, this.reactorProjects, - this.getHelper(), allowDowngrade, segment ); + this.getHelper(), allowDowngrade, unchangedSegment ); if ( winner == null || currentVersion.equals( winner.toString() ) ) { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 238077de9b..97c15dc585 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.TreeSet; import org.apache.maven.artifact.manager.WagonManager; @@ -40,6 +41,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -155,11 +157,12 @@ public void execute() continue; } - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = + determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); try { ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, - this.reactorProjects, this.getHelper(), false, segment ); + this.reactorProjects, this.getHelper(), false, unchangedSegment ); if ( winner != null && !currentVersion.equals( winner.toString() ) ) { StringBuilder buf = new StringBuilder(); diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 14bf5c73b5..0ed8fe5b68 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Map; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -44,6 +45,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -310,11 +312,12 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom ) property.setVersion( currentVersion ); - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); // TODO: Check if we could add allowDowngrade ? try { - updatePropertyToNewestVersion( pom, property, version, currentVersion, false, segment ); + updatePropertyToNewestVersion( pom, property, version, currentVersion, false, unchangedSegment ); } catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 910eff7439..9cb0e812e0 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -23,6 +23,7 @@ import javax.xml.stream.XMLStreamException; import java.util.Map; +import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -37,6 +38,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -179,13 +181,13 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( canUpdateProperty ) { - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); try { ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); + allowDowngrade, unchangedSegment ); if ( targetVersion != null ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 0101e5ebdc..ea7e4c002c 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -23,6 +23,7 @@ import javax.xml.stream.XMLStreamException; import java.util.Map; +import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; @@ -37,6 +38,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -163,11 +165,12 @@ protected void update( ModifiedPomXMLEventReader pom ) continue; } - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = + determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); try { ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, segment ); + allowDowngrade, unchangedSegment ); if ( targetVersion != null ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index c48197b2c6..ba1ad991e4 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,6 +48,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -147,7 +149,8 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); MajorMinorIncrementalFilter majorMinorIncfilter = new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); @@ -182,7 +185,7 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); MajorMinorIncrementalFilter majorMinorIncfilter = new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); @@ -180,15 +184,18 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection versionComparator.getSegmentCount( lowerBound ) ) + if ( unchangedSegment.isPresent() + && unchangedSegment.get().value() >= versionComparator.getSegmentCount( lowerBound ) ) { getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); continue; } try { - ArtifactVersion upperBound = - segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; + ArtifactVersion upperBound = unchangedSegment.isPresent() + && unchangedSegment.get().value() >= MAJOR.value() + ? versionComparator.incrementSegment( lowerBound, unchangedSegment.get() ) + : null; getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); ArtifactVersion[] newer = versions.getVersions( restriction, true ); diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index e93b7d5a3c..172da4e174 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Optional; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -42,6 +43,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -163,7 +165,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - int unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); MajorMinorIncrementalFilter majorMinorIncfilter = new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index be11af6fa4..3050b2ce9a 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -44,10 +45,13 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; + /** * Replaces any release versions with the next snapshot version (if it has been deployed). * @@ -132,7 +136,9 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional + unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); for ( Dependency dep : dependencies ) { @@ -162,15 +168,18 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection versionComparator.getSegmentCount( lowerBound ) ) + if ( unchangedSegment.isPresent() + && unchangedSegment.get().value() >= versionComparator.getSegmentCount( lowerBound ) ) { getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); continue; } try { - ArtifactVersion upperBound = - segment >= 0 ? versionComparator.incrementSegment( lowerBound, segment ) : null; + ArtifactVersion upperBound = unchangedSegment.isPresent() + && unchangedSegment.get().value() >= MAJOR.value() + ? versionComparator.incrementSegment( lowerBound, unchangedSegment.get() ) + : null; getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); ArtifactVersion[] newer = versions.getVersions( restriction, true ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 2bab33c80a..e846a20914 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -225,16 +225,18 @@ public final ArtifactVersion[] getNewerVersions( String version, boolean include * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots * should be included. * - * @param version current version - * @param upperBoundSegment the upper bound segment - * @param includeSnapshots whether snapshot versions should be included - * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, int, boolean, boolean)} instead + * @param version current version + * @param upperBoundSegment the upper bound segment; empty() means no upper bound + * @param includeSnapshots whether snapshot versions should be included * @return array of newer versions fulfilling the criteria * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than - * the segment count) + * the segment count) + * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, Optional, boolean, boolean)}, + * boolean, boolean)} instead */ @Deprecated - public final ArtifactVersion[] getNewerVersions( String version, int upperBoundSegment, boolean includeSnapshots ) + public final ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, + boolean includeSnapshots ) throws InvalidSegmentException { return getNewerVersions( version, upperBoundSegment, includeSnapshots, false ); @@ -245,7 +247,7 @@ public final ArtifactVersion[] getNewerVersions( String version, int upperBoundS * should be included. * * @param versionString current version - * @param upperBoundSegment the upper bound segment + * @param upperBoundSegment the upper bound segment; empty() means no upper bound * @param includeSnapshots whether snapshot versions should be included * @param allowDowngrade whether to allow downgrading if the current version is a snapshots and snapshots * are disallowed @@ -253,15 +255,15 @@ public final ArtifactVersion[] getNewerVersions( String version, int upperBoundS * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than * the segment count) */ - public final ArtifactVersion[] getNewerVersions( String versionString, int upperBoundSegment, + public final ArtifactVersion[] getNewerVersions( String versionString, Optional upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade ) throws InvalidSegmentException { ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); ArtifactVersion lowerBound = allowDowngrade ? getLowerBoundArtifactVersion( currentVersion, upperBoundSegment ) : currentVersion; - ArtifactVersion upperBound = upperBoundSegment == -1 ? null - : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment ); + ArtifactVersion upperBound = !upperBoundSegment.isPresent() ? null + : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment.get() ); Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); return getVersions( restriction, includeSnapshots ); @@ -436,13 +438,14 @@ public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean inclu * implying that there is also no string designation of the lower bound version. * * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed - * @param unchangedSegment 0-based index of the first segment not to be changed; -1 means everything can change + * @param unchangedSegment first segment not to be changed; empty() means any segment can change * @return {@link ArtifactVersion} the lowest artifact version with the given segment held or null if no such * version can be found * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than * the segment count) */ - protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, int unchangedSegment ) + protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, + Optional unchangedSegment ) throws InvalidSegmentException { Optional lowerBound = getLowerBound( version, unchangedSegment ); @@ -455,48 +458,46 @@ protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, * implying that there is also no string designation of the lower bound version. * * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed - * @param unchangedSegment 0-based index of the first segment not to be changed; -1 means everything can change + * @param unchangedSegment first segment not to be changed; empty() means anything can change * @return {@link Optional} string containing the lowest artifact version with the given segment held * @throws InvalidSegmentException if the requested segment is outside of the bounds (less than 1 or greater than * the segment count) */ - protected Optional getLowerBound( ArtifactVersion version, int unchangedSegment ) + protected Optional getLowerBound( ArtifactVersion version, Optional unchangedSegment ) throws InvalidSegmentException { - if ( unchangedSegment < 0 ) + if ( !unchangedSegment.isPresent() ) { return empty(); } int segmentCount = getVersionComparator().getSegmentCount( version ); - if ( unchangedSegment > segmentCount ) + if ( unchangedSegment.get().value() > segmentCount ) { - throw new InvalidSegmentException( unchangedSegment, segmentCount, version ); + throw new InvalidSegmentException( unchangedSegment.get(), segmentCount, version ); } StringBuilder newVersion = new StringBuilder(); newVersion.append( version.getMajorVersion() ); + if ( segmentCount > 0 ) { - newVersion.append( "." ) - .append( unchangedSegment >= 1 ? version.getMinorVersion() : 0 ); + newVersion.append( "." ).append( unchangedSegment.get().value() >= 1 ? version.getMinorVersion() : 0 ); } if ( segmentCount > 1 ) { newVersion.append( "." ) - .append( unchangedSegment >= 2 ? version.getIncrementalVersion() : 0 ); + .append( unchangedSegment.get().value() >= 2 ? version.getIncrementalVersion() : 0 ); } if ( segmentCount > 2 ) { if ( version.getQualifier() != null ) { - newVersion.append( "-" ) - .append( unchangedSegment >= 3 ? version.getQualifier() : "0" ); + newVersion.append( "-" ).append( unchangedSegment.get().value() >= 3 ? version.getQualifier() : "0" ); } else { - newVersion.append( "-" ) - .append( unchangedSegment >= 3 ? version.getBuildNumber() : "0" ); + newVersion.append( "-" ).append( unchangedSegment.get().value() >= 3 ? version.getBuildNumber() : "0" ); } } return of( newVersion.toString() ); @@ -539,10 +540,10 @@ protected Restriction restrictionFor( ArtifactVersion currentVersion, Optional Segment.MAJOR.value() - ? versionComparator.incrementSegment( currentVersion, scope.get().value() - 1 ) + ? versionComparator.incrementSegment( currentVersion, Segment.of( scope.get().value() - 1 ) ) : null; return new Restriction( lowerBound, lowerBound != currentVersion, upperBound, false ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 6292349644..6cfc260f21 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -43,6 +43,8 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; +import static java.util.Optional.empty; + /** * Manages a property that is associated with one or more artifacts. * @@ -310,7 +312,8 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert List reactorProjects, VersionsHelper helper ) throws InvalidVersionSpecificationException, InvalidSegmentException { - return getNewestVersion( currentVersion, property, allowSnapshots, reactorProjects, helper, false, -1 ); + return getNewestVersion( currentVersion, property, allowSnapshots, reactorProjects, helper, + false, empty() ); } /** @@ -332,7 +335,7 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert */ public ArtifactVersion getNewestVersion( String currentVersion, Property property, boolean allowSnapshots, Collection reactorProjects, VersionsHelper helper, - boolean allowDowngrade, int unchangedSegment ) + boolean allowDowngrade, Optional unchangedSegment ) throws InvalidSegmentException, InvalidVersionSpecificationException { final boolean includeSnapshots = !property.isBanSnapshots() && allowSnapshots; @@ -355,9 +358,9 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert } ArtifactVersion upperBound = null; - if ( unchangedSegment != -1 ) + if ( unchangedSegment.isPresent() ) { - upperBound = getVersionComparator().incrementSegment( lowerBound, unchangedSegment ); + upperBound = getVersionComparator().incrementSegment( lowerBound, unchangedSegment.get() ); helper.getLog().debug( "Property ${" + property.getName() + "}: upperBound is: " + upperBound ); } Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); @@ -418,22 +421,22 @@ else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) return result; } - private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper helper, int segment, + private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper helper, + Optional unchangedSegment, boolean includeSnapshots, VersionRange range ) throws InvalidSegmentException { ArtifactVersion lowerBound = helper.createArtifactVersion( currentVersion ); ArtifactVersion upperBound = null; - if ( segment != -1 ) + if ( unchangedSegment.isPresent() ) { - upperBound = getVersionComparator().incrementSegment( lowerBound, segment ); + upperBound = getVersionComparator().incrementSegment( lowerBound, unchangedSegment.get() ); } Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); return getNewestVersion( range, restriction, includeSnapshots ); } - private final class PropertyVersionComparator - implements VersionComparator + private final class PropertyVersionComparator implements VersionComparator { public int compare( ArtifactVersion v1, ArtifactVersion v2 ) { @@ -494,7 +497,7 @@ public int getSegmentCount( ArtifactVersion v ) return result; } - public ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException + public ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { if ( !isAssociated() ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/src/main/java/org/codehaus/mojo/versions/api/Segment.java index b64e8abc20..c329898914 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/Segment.java +++ b/src/main/java/org/codehaus/mojo/versions/api/Segment.java @@ -45,6 +45,19 @@ public int value() return index; } + public static Segment of( int index ) + { + switch ( index ) + { + case 0: return MAJOR; + case 1: return MINOR; + case 2: return INCREMENTAL; + case 3: return SUBINCREMENTAL; + default: + throw new IllegalArgumentException( "Wrong segment index: " + index ); + } + } + @Override public String toString() { diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index afed874df2..1108ac3494 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -20,6 +20,7 @@ */ import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; /** * Base class for version comparators. @@ -56,17 +57,22 @@ public final int getSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ - public final ArtifactVersion incrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException + public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { if ( VersionComparators.isSnapshot( v ) ) { return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), segment ) ); } + int segmentCount = getSegmentCount( v ); + if ( segment.value() >= segmentCount ) + { + throw new InvalidSegmentException( segment, segmentCount, v ); + } return innerIncrementSegment( v, segment ); } - protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) + protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException; /** diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java b/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java index ce704ff423..ad656cfe63 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java @@ -20,13 +20,14 @@ */ import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; /** * Represents an invalid segment being identified within a version. */ public class InvalidSegmentException extends Exception { - private final int segment; + private final Segment segment; private final int segmentCount; @@ -39,9 +40,9 @@ public class InvalidSegmentException extends Exception * @param segmentCount the number of segments. * @param version the version object. */ - public InvalidSegmentException( int segment, int segmentCount, ArtifactVersion version ) + public InvalidSegmentException( Segment segment, int segmentCount, ArtifactVersion version ) { - super( String.format( "Invalid segment, %d, for the %d segment version: '%s'", segment, segmentCount, + super( String.format( "Invalid segment %s for the %d segment version: '%s'", segment.toString(), segmentCount, version.toString() ) ); this.segment = segment; this.segmentCount = segmentCount; @@ -51,7 +52,7 @@ public InvalidSegmentException( int segment, int segmentCount, ArtifactVersion v /** * @return segment */ - public int getSegment() + public Segment getSegment() { return segment; } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java b/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java index a88311698a..39b7cba69d 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java @@ -21,6 +21,7 @@ import java.util.LinkedList; import java.util.List; +import java.util.Optional; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.codehaus.mojo.versions.api.AbstractVersionDetails; @@ -39,7 +40,7 @@ *
  • 3.1.0
  • *
  • 3.3.0
  • * - * The {@link AbstractVersionDetails#getNewerVersions(String, int, boolean)} will use an upper version of + * The {@link AbstractVersionDetails#getNewerVersions(String, Optional, boolean, boolean)} will use an upper version of * 2.1.0 to limit the versions to use. The result of this would be using 2.1.0-M1 which * contradicts the wish of the user of not updating the minor version. The root cause of this is the comparison of Maven * versions which will defined 2.1.0-M1 as less than 2.1.0. The method diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index b0ee00c9cc..db6444ff49 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -21,6 +21,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; import org.codehaus.plexus.util.StringUtils; /** @@ -29,8 +30,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class MavenVersionComparator - extends AbstractVersionComparator +public class MavenVersionComparator extends AbstractVersionComparator { /** @@ -92,15 +92,10 @@ protected int innerGetSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - int segmentCount = innerGetSegmentCount( v ); - if ( segment < 0 || segment >= segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } String version = v.toString(); - if ( segmentCount == 1 ) + if ( innerGetSegmentCount( v ) == 1 ) { // only the qualifier version = VersionComparators.alphaNumIncrement( version ); @@ -124,14 +119,14 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment switch ( segment ) { - case 0: + case MAJOR: major++; minor = 0; incremental = 0; build = 0; qualifier = null; break; - case 1: + case MINOR: minor++; incremental = 0; build = 0; @@ -140,12 +135,12 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment qualifier = "SNAPSHOT"; } break; - case 2: + case INCREMENTAL: incremental++; build = 0; qualifier = null; break; - case 3: + case SUBINCREMENTAL: if ( haveQualifier ) { qualifier = qualifierIncrement( qualifier ); diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java index 335538a0c7..d633e39b24 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; /** * A comparator which uses Mercury's version rules. @@ -52,18 +53,13 @@ protected int innerGetSegmentCount( ArtifactVersion v ) return tok.countTokens(); } - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - final int segmentCount = getSegmentCount( v ); - if ( segment < 0 || segment > segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } final String version = v.toString(); StringBuilder result = new StringBuilder( version.length() + 10 ); StringTokenizer tok = new StringTokenizer( version, ".-" ); int index = 0; - while ( tok.hasMoreTokens() && segment > 0 ) + while ( tok.hasMoreTokens() && segment.value() > 0 ) { String token = tok.nextToken(); result.append( token ); @@ -74,9 +70,9 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment result.append( version.substring( index, index + 1 ) ); index++; } - segment--; + segment = Segment.of( segment.value() - 1 ); } - if ( segment == 0 ) + if ( segment.value() == 0 ) { if ( tok.hasMoreTokens() ) { diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java index 85443c2767..70a38f3011 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java @@ -24,6 +24,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; /** * A comparator which will compare all segments of a dot separated version string as numbers if possible, i.e. 1.3.34 @@ -163,18 +164,13 @@ protected int innerGetSegmentCount( ArtifactVersion v ) * {@inheritDoc} */ @SuppressWarnings( "checkstyle:MethodLength" ) - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment ) throws InvalidSegmentException + protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - final int segmentCount = innerGetSegmentCount( v ); - if ( segment < 0 || segment > segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } final String version = v.toString(); StringBuilder buf = new StringBuilder(); StringTokenizer tok = new StringTokenizer( version, "." ); boolean first = true; - while ( segment >= 0 && tok.hasMoreTokens() ) + for ( int segmentIdx = segment.value(); segmentIdx >= 0 && tok.hasMoreTokens(); --segmentIdx ) { if ( first ) { @@ -193,7 +189,7 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, int segment p = p.substring( 0, index ); } - if ( segment == 0 ) + if ( segmentIdx == 0 ) { try { @@ -317,7 +313,6 @@ else if ( "ga".equalsIgnoreCase( p ) || "final".equalsIgnoreCase( p ) ) buf.append( '-' ); buf.append( q ); } - segment--; } while ( tok.hasMoreTokens() ) { diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 11f2af07f3..08d3973a78 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -22,6 +22,7 @@ import java.util.Comparator; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; /** * A rule for comparing and manipulating versions. @@ -47,5 +48,5 @@ public interface VersionComparator * @since 1.0-beta-1 * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) */ - ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, int segment ) throws InvalidSegmentException; + ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, Segment segment ) throws InvalidSegmentException; } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index d691557152..4aed2cf78b 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -20,8 +20,12 @@ */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; import static org.junit.Assert.assertEquals; public class MavenVersionComparatorTest @@ -44,21 +48,21 @@ public void testSegmentCounting() public void testSegmentIncrementing() throws InvalidSegmentException { - assertIncrement( "6", "5", 0 ); - assertIncrement( "6.0", "5.0", 0 ); - assertIncrement( "5.1", "5.0", 1 ); - assertIncrement( "5.1.0", "5.0.1", 1 ); - assertIncrement( "5.alpha.2", "5.alpha.1", 0 ); - assertIncrement( "5.alpha-1.2", "5.alpha-1.1", 0 ); - assertIncrement( "5.alpha-1.ba", "5.alpha-1.az", 0 ); - assertIncrement( "5.alpha-wins.2", "5.alpha-wins.1", 0 ); - assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", 3 ); - assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", 3 ); - assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", 3 ); - assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", 3 ); + assertIncrement( "6", "5", MAJOR ); + assertIncrement( "6.0", "5.0", MAJOR ); + assertIncrement( "5.1", "5.0", MINOR ); + assertIncrement( "5.1.0", "5.0.1", MINOR ); + assertIncrement( "5.alpha.2", "5.alpha.1", MAJOR ); + assertIncrement( "5.alpha-1.2", "5.alpha-1.1", MAJOR ); + assertIncrement( "5.alpha-1.ba", "5.alpha-1.az", MAJOR ); + assertIncrement( "5.alpha-wins.2", "5.alpha-wins.1", MAJOR ); + assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); } - private void assertIncrement( String expected, String initial, int segment ) throws InvalidSegmentException + private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException { assertEquals( expected, instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index deeb70c8ea..a9dcfe8680 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -22,6 +22,9 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.junit.Assert.assertEquals; public class MercuryVersionComparatorTest @@ -30,7 +33,7 @@ public class MercuryVersionComparatorTest @Test public void testSegmentCounting() - throws Exception + throws Exception { assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); @@ -42,23 +45,23 @@ public void testSegmentCounting() @Test public void testSegmentIncrementing() - throws Exception + throws Exception { assertEquals( new DefaultArtifactVersion( "6" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), 0 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), 0 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), 2 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ).toString() ); assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } \ No newline at end of file diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index fc0ac1498d..e7a58949be 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -22,6 +22,9 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -104,20 +107,21 @@ public void testSegmentIncrementing() throws Exception { assertEquals( new DefaultArtifactVersion( "6" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), 0 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), 0 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); assertEquals( new DefaultArtifactVersion( "5.alpha-1.2" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), 2 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ) + .toString() ); assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), 1 ).toString() ); + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java index 06bdbf7f3d..d433d7fc0e 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java @@ -21,6 +21,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.junit.Assert.assertTrue; @@ -70,7 +71,7 @@ public void assertLater( String version, VersionComparator instance ) throws Inv int count = instance.getSegmentCount( v1 ); for ( int i = 0; i < count; i++ ) { - ArtifactVersion v2 = instance.incrementSegment( v1, i ); + ArtifactVersion v2 = instance.incrementSegment( v1, Segment.of( i ) ); assertTrue( v1 + " < " + v2, instance.compare( v1, v2 ) < 0 ); } } From 1510c1807418d6a6b81298ee653137fb870829c6 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 18 Sep 2022 11:33:15 +0200 Subject: [PATCH 132/441] Quick fix reported by IDE improvements --- ...AbstractVersionsDependencyUpdaterMojo.java | 12 ++-------- .../versions/CompareDependenciesMojo.java | 2 +- .../versions/DependencyUpdatesReport.java | 4 ++-- .../DisplayDependencyUpdatesMojo.java | 23 ++++++++----------- .../versions/DisplayPluginUpdatesMojo.java | 20 ++++++++-------- .../mojo/versions/PluginUpdatesRenderer.java | 16 ++++++------- .../org/codehaus/mojo/versions/SetMojo.java | 4 ++-- .../mojo/versions/UpdateParentMojo.java | 2 +- .../mojo/versions/UseLatestReleasesMojo.java | 11 ++++----- .../mojo/versions/UseReactorMojo.java | 7 +++--- .../versions/api/DefaultVersionsHelper.java | 13 ++++------- .../codehaus/mojo/versions/api/PomHelper.java | 4 +--- .../mojo/versions/api/PropertyVersions.java | 2 +- .../ordering/MercuryVersionComparator.java | 6 ++--- .../utils/PropertiesVersionsFileReader.java | 5 ++-- .../DisplayDependencyUpdatesMojoTest.java | 2 +- .../mojo/versions/RewriteWithStAXTest.java | 11 +++++---- ...ratePatternsForIncludesAnExcludesTest.java | 13 ++++++----- .../codehaus/mojo/versions/SetMojoTest.java | 2 +- .../mojo/versions/SetPropertyMojoTest.java | 2 +- .../mojo/versions/UseDepVersionMojoTest.java | 2 +- .../api/DefaultVersionsHelperTest.java | 2 +- .../filtering/DependencyFilterTest.java | 21 ++++++++++------- .../ordering/VersionComparatorsTest.java | 6 ++--- .../PropertiesVersionsFileReaderTest.java | 4 ++-- 25 files changed, 92 insertions(+), 104 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 41ced6e9a8..8d1ddbc3a3 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -320,16 +320,8 @@ protected String toString( Dependency d ) */ protected boolean isProducedByReactor( Dependency dependency ) { - for ( Object reactorProject : reactorProjects ) - { - MavenProject project = (MavenProject) reactorProject; - if ( compare( project, dependency ) ) - { - return true; - } - } - return false; - + return reactorProjects.stream() + .anyMatch( reactorProject -> compare( reactorProject, dependency ) ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 8e802ae118..74f56ae78d 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -177,7 +177,7 @@ protected void update( ModifiedPomXMLEventReader pom ) throw new MojoExecutionException( "Unable to build remote project " + remoteArtifact, e ); } - Map remoteDepsMap = new HashMap(); + Map remoteDepsMap = new HashMap<>(); if ( !ignoreRemoteDependencyManagement ) { List remoteProjectDepMgmtDeps = ( remoteMavenProject.getDependencyManagement() == null ) ? null diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index b5c5960373..4f16f7a43c 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -42,7 +42,7 @@ import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.i18n.I18N; -import static java.util.Collections.EMPTY_MAP; +import static java.util.Collections.emptyMap; import static org.codehaus.mojo.versions.utils.MiscUtils.filter; /** @@ -190,7 +190,7 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! Map dependencyManagementUpdates = processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) - : EMPTY_MAP; + : emptyMap(); if ( onlyUpgradable ) { diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index bf3a2ac185..22439e28c8 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -23,7 +23,6 @@ import javax.xml.stream.XMLStreamException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; @@ -704,10 +703,8 @@ private void logUpdates( Map updates, String secti { List withUpdates = new ArrayList<>(); List usingCurrent = new ArrayList<>(); - Iterator i = updates.values().iterator(); - while ( i.hasNext() ) + for ( ArtifactVersions versions : updates.values() ) { - ArtifactVersions versions = (ArtifactVersions) i.next(); String left = " " + ArtifactUtils.versionlessKey( versions.getArtifact() ) + " "; final String current; ArtifactVersion latest; @@ -719,12 +716,12 @@ private void logUpdates( Map updates, String secti else { ArtifactVersion newestVersion = - versions.getNewestVersion( versions.getArtifact().getVersionRange(), allowSnapshots ); + versions.getNewestVersion( versions.getArtifact().getVersionRange(), allowSnapshots ); current = versions.getArtifact().getVersionRange().toString(); latest = newestVersion == null ? null - : versions.getNewestUpdate( newestVersion, calculateUpdateScope(), allowSnapshots ); + : versions.getNewestUpdate( newestVersion, calculateUpdateScope(), allowSnapshots ); if ( latest != null - && ArtifactVersions.isVersionInRange( latest, versions.getArtifact().getVersionRange() ) ) + && ArtifactVersions.isVersionInRange( latest, versions.getArtifact().getVersionRange() ) ) { latest = null; } @@ -740,7 +737,7 @@ private void logUpdates( Map updates, String secti else { t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), "." ) - + right ); + + right ); } } @@ -757,10 +754,9 @@ private void logUpdates( Map updates, String secti else { logLine( false, "The following dependencies in " + section + " are using the newest version:" ); - i = usingCurrent.iterator(); - while ( i.hasNext() ) + for ( String s : usingCurrent ) { - logLine( false, (String) i.next() ); + logLine( false, s ); } logLine( false, "" ); } @@ -778,10 +774,9 @@ private void logUpdates( Map updates, String secti else { logLine( false, "The following dependencies in " + section + " have newer versions:" ); - i = withUpdates.iterator(); - while ( i.hasNext() ) + for ( String withUpdate : withUpdates ) { - logLine( false, (String) i.next() ); + logLine( false, withUpdate ); } logLine( false, "" ); } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 09f035fe29..78c08f721c 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -196,7 +196,7 @@ private Map getSuperPomPluginManagement() { Method getPluginsBoundByDefaultToAllLifecycles = LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - new Class[] {String.class} ); + String.class ); Set plugins = (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { getProject().getPackaging()} ); @@ -1102,7 +1102,7 @@ private Set getBoundPlugins( MavenProject project, String thePhases ) { Method getPluginsBoundByDefaultToAllLifecycles = LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - new Class[] {String.class} ); + String.class ); Set plugins = (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { project.getPackaging() == null ? "jar" : project.getPackaging()} ); @@ -1127,7 +1127,7 @@ private Set getBoundPlugins( MavenProject project, String thePhases ) getLog().debug( "Using Maven 2.0.10+ strategy to determine lifecycle defined plugins" ); try { - Method getLifecycles = LifecycleExecutor.class.getMethod( "getLifecycles", new Class[0] ); + Method getLifecycles = LifecycleExecutor.class.getMethod( "getLifecycles" ); lifecycles = (List) getLifecycles.invoke( lifecycleExecutor, new Object[0] ); } catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e1 ) @@ -1221,7 +1221,7 @@ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) plugins.add( plugin ); } - plugins.addAll( (List) project.getBuildPlugins() ); + plugins.addAll( project.getBuildPlugins() ); return plugins; } @@ -1261,8 +1261,8 @@ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) { if ( defaultMappings == null ) { - throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging - + "\'.", e ); + throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: '" + packaging + + "'.", e ); } } } @@ -1271,8 +1271,8 @@ private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) { if ( defaultMappings == null ) { - throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging - + "\', and there is no default" ); + throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: '" + packaging + + "', and there is no default" ); } else { @@ -1446,7 +1446,7 @@ public Map getPhaseToLifecycleMap( List lifecycles for ( Lifecycle lifecycle : lifecycles ) { - for ( String phase : (List) lifecycle.getPhases() ) + for ( String phase : lifecycle.getPhases() ) { if ( phaseToLifecycleMap.containsKey( phase ) ) { @@ -1507,7 +1507,7 @@ private Set getProjectPlugins( Map superPomPluginManagem debugVersionMap( "super-pom version map", superPomPluginManagement ); debugVersionMap( "parent version map", parentPluginManagement ); - Map excludePluginManagement = new HashMap( superPomPluginManagement ); + Map excludePluginManagement = new HashMap<>( superPomPluginManagement ); excludePluginManagement.putAll( parentPluginManagement ); debugVersionMap( "aggregate version map", excludePluginManagement ); diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index bf887b8a67..86a9123f16 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -356,8 +356,8 @@ private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); sink.section2(); sink.sectionTitle2(); - sink.text( MessageFormat.format( getText( "report.plugin" ), new Object[] { - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() )} ) ); + sink.text( MessageFormat.format( getText( "report.plugin" ), + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); sink.sectionTitle2_(); sink.table(); sink.tableRows( new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false ); @@ -510,16 +510,16 @@ else if ( equals( versions[i], { sink.section3(); sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), new Object[] { - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() )} ) ); + sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); sink.sectionTitle3_(); renderDependencySummaryTable( details.getDependencyVersions(), false, true, true ); sink.section3_(); - details.getDependencyVersions().entrySet() - .forEach( entry -> renderDependencyDetail( entry.getKey(), entry.getValue() ) ); + details.getDependencyVersions() + .forEach( this::renderDependencyDetail ); } sink.section2_(); } @@ -528,8 +528,8 @@ private void renderDependencyDetail( Dependency dependency, ArtifactVersions det { sink.section3(); sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependency" ), new Object[] { - ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() )} ) ); + sink.text( MessageFormat.format( getText( "report.pluginDependency" ), + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) ) ); sink.sectionTitle3_(); renderDependencyDetailTable( dependency, details, false, true, true ); sink.section3_(); diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 9fee67c5d2..206417570b 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -348,11 +348,11 @@ public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "Local aggregation root: " + project.getBasedir() ); Map reactorModels = PomHelper.getReactorModels( project, getLog() ); final SortedMap reactor = - new TreeMap( new ReactorDepthComparator( reactorModels ) ); + new TreeMap<>( new ReactorDepthComparator( reactorModels ) ); reactor.putAll( reactorModels ); // set of files to update - final Set files = new LinkedHashSet(); + final Set files = new LinkedHashSet<>(); getLog().info( "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index b3ee61b8ab..f7e62c01e6 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -143,7 +143,7 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( artifactVersion != null ) { getLog().info( "Updating parent from " + getProject().getParent().getVersion() - + " to " + artifactVersion.toString() ); + + " to " + artifactVersion ); if ( PomHelper.setProjectParentVersion( pom, artifactVersion.toString() ) ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index ba1ad991e4..7afa71d298 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -225,19 +225,18 @@ && isProcessingParent() ) private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact ) { List filteredNewer = new ArrayList<>( newer.length ); - for ( int j = 0; j < newer.length; j++ ) + for ( ArtifactVersion artifactVersion : newer ) { - ArtifactVersion artifactVersion = newer[j]; Artifact artefactWithNewVersion = - new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), - VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(), - artifact.getType(), null, new DefaultArtifactHandler(), false ); + new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), + VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(), + artifact.getType(), null, new DefaultArtifactHandler(), false ); if ( isIncluded( artefactWithNewVersion ) ) { filteredNewer.add( artifactVersion ); } } - return filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] ); + return filteredNewer.toArray( new ArtifactVersion[0] ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index 467a2d747a..b4d2b91f81 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -106,9 +106,9 @@ private void useReactor( ModifiedPomXMLEventReader pom, Collection d continue; } - for ( Object reactorProject : reactorProjects ) + for ( MavenProject reactorProject : reactorProjects ) { - MavenProject project = (MavenProject) reactorProject; + MavenProject project = reactorProject; if ( StringUtils.equals( project.getGroupId(), dep.getGroupId() ) && StringUtils.equals( project.getArtifactId(), dep.getArtifactId() ) && !StringUtils.equals( project.getVersion(), dep.getVersion() ) ) @@ -127,9 +127,8 @@ private void useReactor( ModifiedPomXMLEventReader pom, Collection d private void useReactor( ModifiedPomXMLEventReader pom, MavenProject parent ) throws XMLStreamException, ArtifactMetadataRetrievalException { - for ( Object reactorProject : reactorProjects ) + for ( MavenProject project : reactorProjects ) { - MavenProject project = (MavenProject) reactorProject; if ( StringUtils.equals( project.getGroupId(), parent.getGroupId() ) && StringUtils.equals( project.getArtifactId(), parent.getArtifactId() ) && !StringUtils.equals( project.getVersion(), parent.getVersion() ) ) diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 7331d857c8..a7685eeccf 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -21,10 +21,10 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -192,7 +192,7 @@ private static RuleSet getRuleSet( Wagon wagon, String remoteURI ) try { wagon.get( remoteURI, tempFile ); - try ( InputStream is = new FileInputStream( tempFile ) ) + try ( InputStream is = Files.newInputStream( tempFile.toPath() ) ) { return readRulesFromStream( is ); } @@ -356,7 +356,7 @@ private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String ser { throw new MojoExecutionException( "Authorization failure trying to load rules from " + rulesUri, e ); } - catch ( ResourceDoesNotExistException e ) + catch ( ResourceDoesNotExistException | IOException e ) { throw new MojoExecutionException( "Could not load specified rules from " + rulesUri, e ); } @@ -372,10 +372,6 @@ private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String ser { throw new MojoExecutionException( "Could not establish connection to " + rulesUri, e ); } - catch ( IOException e ) - { - throw new MojoExecutionException( "Could not load specified rules from " + rulesUri, e ); - } return loadedRules; } @@ -395,7 +391,8 @@ public Log getLog() public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException { - List remoteRepositories = usePluginRepositories ? remotePluginRepositories : remoteArtifactRepositories; + List remoteRepositories = usePluginRepositories + ? remotePluginRepositories : remoteArtifactRepositories; final List versions = artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository, remoteRepositories ); final List ignoredVersions = getIgnoredVersions( artifact ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index b7dde0e88b..74a344b169 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -1300,9 +1299,8 @@ private static void addProperties( VersionsHelper helper, Map j = (Enumeration) properties.propertyNames(); j.hasMoreElements(); ) + for ( String propertyName : properties.stringPropertyNames() ) { - String propertyName = j.nextElement(); if ( !result.containsKey( propertyName ) ) { result.put( propertyName, new PropertyVersionsBuilder( profileId, propertyName, helper ) ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 6cfc260f21..7d4621e630 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -309,7 +309,7 @@ public String toString() } public ArtifactVersion getNewestVersion( String currentVersion, Property property, boolean allowSnapshots, - List reactorProjects, VersionsHelper helper ) + List reactorProjects, VersionsHelper helper ) throws InvalidVersionSpecificationException, InvalidSegmentException { return getNewestVersion( currentVersion, property, allowSnapshots, reactorProjects, helper, diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java index d633e39b24..bccc150462 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java @@ -67,7 +67,7 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segm if ( tok.hasMoreTokens() ) { // grab the token separator - result.append( version.substring( index, index + 1 ) ); + result.append( version.charAt( index ) ); index++; } segment = Segment.of( segment.value() - 1 ); @@ -118,7 +118,7 @@ else if ( "final".equalsIgnoreCase( token ) || "ga".equalsIgnoreCase( token ) if ( tok.hasMoreTokens() ) { // grab the token separator - result.append( version.substring( index, index + 1 ) ); + result.append( version.charAt( index ) ); index++; } @@ -137,7 +137,7 @@ else if ( "final".equalsIgnoreCase( token ) || "ga".equalsIgnoreCase( token ) if ( tok.hasMoreTokens() ) { // grab the token separator - result.append( version.substring( index, index + 1 ) ); + result.append( version.charAt( index ) ); index++; } } diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java index 5a4f7f5658..98fcaa40a9 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java @@ -1,8 +1,9 @@ package org.codehaus.mojo.versions.utils; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -29,7 +30,7 @@ public PropertiesVersionsFileReader( String filePath ) public void read() throws IOException { - try ( InputStream input = new FileInputStream( propertyFilePath ) ) + try ( InputStream input = Files.newInputStream( Paths.get( propertyFilePath ) ) ) { Properties prop = new Properties(); diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 3b113f7f58..e7ec9d8633 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -70,7 +70,7 @@ public void testValidateGAVListFailed() "group:artifact:version:type" ), 3, "" ); fail( "Method should have thrown a MojoExecutionException" ); } - catch ( MojoExecutionException e ) + catch ( MojoExecutionException ignored ) { } } diff --git a/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java b/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java index f8cd2700ca..76a70b1471 100644 --- a/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java +++ b/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java @@ -29,6 +29,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.Stack; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -36,7 +37,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; /** * Basic tests for rewriting XML with a StAX (JSR-173) implementation. @@ -54,7 +55,7 @@ public void testBasic() + " mojo-&sandbox-parent\n" + " 5-SNAPSHOT\r" + " \r" + "
    "; - byte[] rawInput = input.getBytes( "utf-8" ); + byte[] rawInput = input.getBytes( StandardCharsets.UTF_8 ); ByteArrayInputStream source = new ByteArrayInputStream( rawInput ); ByteArrayOutputStream dest = new ByteArrayOutputStream(); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); @@ -67,9 +68,9 @@ public void testBasic() eventWriter.add( eventReader.nextEvent() ); } - String output = new String( dest.toByteArray(), "utf-8" ); + String output = dest.toString( "utf-8" ); - assertFalse( "StAX implementation is not good enough", input.equals( output ) ); + assertNotEquals( "StAX implementation is not good enough", input, output ); } @Test @@ -212,7 +213,7 @@ public void testReplaceFancy() inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); ModifiedPomXMLEventReader eventReader = new ModifiedPomXMLEventReader( output, inputFactory, null ); - Stack stack = new Stack(); + Stack stack = new Stack<>(); String path = ""; while ( eventReader.hasNext() ) diff --git a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index b238079b80..f17e63817c 100644 --- a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -33,14 +33,14 @@ protected void update( ModifiedPomXMLEventReader pom ) @Test public void testSeparatePatternsWithNull() { - List patterns = mojo.separatePatterns( null ); + List patterns = mojo.separatePatterns( null ); assertEquals( 0, patterns.size() ); } @Test public void testSeparatePatternsWithSinglePattern() { - List patterns = mojo.separatePatterns( "group:artifact:type:version" ); + List patterns = mojo.separatePatterns( "group:artifact:type:version" ); assertEquals( 1, patterns.size() ); assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); } @@ -48,7 +48,7 @@ public void testSeparatePatternsWithSinglePattern() @Test public void testSeparatePatternWithSingleRange() { - List patterns = mojo.separatePatterns( "group:artifact:type:[1.0.2,2.0.0]" ); + List patterns = mojo.separatePatterns( "group:artifact:type:[1.0.2,2.0.0]" ); assertEquals( 1, patterns.size() ); assertEquals( "group:artifact:type:[1.0.2,2.0.0]", patterns.get( 0 ) ); @@ -60,7 +60,8 @@ public void testSeparatePatternWithSingleRange() @Test public void testSeparatePatternWithSeveralPatternsAndRanges() { - List patterns = mojo.separatePatterns( "group:artifact:type:[1.0.2,2.0.0),group2:artifact:type:(1.0.2,2.0.0]" ); + List patterns = mojo.separatePatterns( + "group:artifact:type:[1.0.2,2.0.0),group2:artifact:type:(1.0.2,2.0.0]" ); assertEquals( 2, patterns.size() ); assertEquals( "group:artifact:type:[1.0.2,2.0.0)", patterns.get( 0 ) ); assertEquals( "group2:artifact:type:(1.0.2,2.0.0]", patterns.get( 1 ) ); @@ -69,7 +70,7 @@ public void testSeparatePatternWithSeveralPatternsAndRanges() @Test public void testSeparatePatternsWithTwoCommaSeparatedPatterns() { - List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2" ); + List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2" ); assertEquals( 2, patterns.size() ); assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); assertEquals( "group:artifact:type:version2", patterns.get( 1 ) ); @@ -78,7 +79,7 @@ public void testSeparatePatternsWithTwoCommaSeparatedPatterns() @Test public void testSeparatePatternsWithSeveralCommaSeparatedPatterns() { - List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2," + List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2," + "group:artifact:type:version3,group:artifact:type:version4" ); assertEquals( 4, patterns.size() ); assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index 8318120414..b8d5ff77ad 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -18,7 +18,7 @@ public class SetMojoTest extends AbstractMojoTestCase { @Rule - MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule( this ); @Test public void testGetIncrementedVersion() throws MojoExecutionException diff --git a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java index 4f1ecf436e..1005ade873 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -48,7 +48,7 @@ public class SetPropertyMojoTest extends AbstractMojoTestCase { @Rule - MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule( this ); private Path pomDir; diff --git a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java index d00e6ced5c..290a021942 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java @@ -35,7 +35,7 @@ public class UseDepVersionMojoTest extends AbstractMojoTestCase { @Rule - MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule( this ); @Test public void testIssue673() throws Exception diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 625a115dd9..ada1bf7294 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -181,7 +181,7 @@ public void testMVERSIONS159ExcludedAndNotIncluded() new Property( "bar.version" ) }; // should not throw an IllegalStateException - Map result = + Map result = helper.getVersionPropertiesMap( project, propertyDefinitions, "foo.version", "bar.version", false ); assertTrue( result.isEmpty() ); } diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java index 9458df0b20..956facfb62 100644 --- a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java +++ b/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -1,5 +1,6 @@ package org.codehaus.mojo.versions.filtering; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -29,7 +30,8 @@ class RemoveFromTest @Test void removesExcludedDepsWithExactMatch() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( + Collections.singletonList( "localhost:my-impl:3" ) ); Set actual = exclusions.removingFrom( input ); @@ -45,7 +47,8 @@ void removesExcludedDepsWithExactMatch() @Test void removesExcludedDepsWithWildcardInVersion() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( + Collections.singletonList( "localhost:my-impl:*" ) ); Set actual = exclusions.removingFrom( input ); @@ -61,7 +64,7 @@ void removesExcludedDepsWithWildcardInVersion() @Test void removesExcludedDepsWithWildcardInGroupId() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:*:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "localhost:*:*" ) ); Set actual = exclusions.removingFrom( input ); @@ -76,7 +79,7 @@ void removesExcludedDepsWithWildcardInGroupId() @Test void removesExcludedDepsWithAllWildcards() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "*:*:*" ) ); Set actual = exclusions.removingFrom( input ); @@ -118,7 +121,8 @@ class RetainingInTest @Test void retainsOnlyDepsWithExactMatch() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-impl:3" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( + Collections.singletonList( "localhost:my-impl:3" ) ); Set actual = exclusions.retainingIn( input ); @@ -133,7 +137,8 @@ void retainsOnlyDepsWithExactMatch() @Test void retainsOnlyDepsMatchingWildcardInVersion() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-api:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( + Collections.singletonList( "localhost:my-api:*" ) ); Set actual = exclusions.retainingIn( input ); @@ -148,7 +153,7 @@ void retainsOnlyDepsMatchingWildcardInVersion() @Test void retainsOnlyDepsWithMultipleWildcards() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "localhost:my-*:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "localhost:my-*:*" ) ); Set actual = exclusions.retainingIn( input ); @@ -164,7 +169,7 @@ void retainsOnlyDepsWithMultipleWildcards() @Test void retainsAllOnAllWildcards() { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( "*:*:*" ) ); + DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "*:*:*" ) ); Set actual = exclusions.retainingIn( input ); diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java index d433d7fc0e..c33852d23e 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java @@ -58,10 +58,10 @@ public void testNumericVersionComparator() throws InvalidSegmentException public void assertVersions( VersionComparator instance ) throws InvalidSegmentException { - for ( int i = 0; i < versionDataset.length; i++ ) + for ( String s : versionDataset ) { - assertLater( versionDataset[i], instance ); - assertLater( versionDataset[i] + "-SNAPSHOT", instance ); + assertLater( s, instance ); + assertLater( s + "-SNAPSHOT", instance ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java index 7b2e05ce39..cc0e880cc5 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java @@ -35,8 +35,8 @@ private boolean equalsCvsUnordered( String csvExpected, String csvActual ) { return false; } - Set listExpected = new HashSet( Arrays.asList( csvExpected.split( "," ) ) ); - Set listActual = new HashSet( Arrays.asList( csvActual.split( "," ) ) ); + Set listExpected = new HashSet<>( Arrays.asList( csvExpected.split( "," ) ) ); + Set listActual = new HashSet<>( Arrays.asList( csvActual.split( "," ) ) ); return listExpected.equals( listActual ); } } From f0dc7152be253dda95331acbd9c9f5f93893fb0e Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:17:29 +0200 Subject: [PATCH 133/441] #632 Fixed lower and upper bounds to keep milestones and rcs in the right majors. --- .../verify.bsh | 2 +- .../it-plugin-updates-report-001/verify.bsh | 2 +- .../AbstractVersionsReportRenderer.java | 133 +++++++----------- .../mojo/versions/PluginUpdatesRenderer.java | 57 +------- .../versions/api/AbstractVersionDetails.java | 2 +- .../mojo/versions/api/VersionDetails.java | 22 +-- .../ordering/AbstractVersionComparator.java | 13 +- .../versions/ordering/ComparableVersion.java | 8 +- .../ordering/MavenVersionComparator.java | 2 +- .../ordering/MavenVersionComparatorTest.java | 15 +- .../MercuryVersionComparatorTest.java | 39 +++-- .../NumericVersionComparatorTest.java | 35 +++-- 12 files changed, 114 insertions(+), 216 deletions(-) diff --git a/src/it/it-dependency-updates-report-001/verify.bsh b/src/it/it-dependency-updates-report-001/verify.bsh index cb1a4a8c77..289ca69b24 100644 --- a/src/it/it-dependency-updates-report-001/verify.bsh +++ b/src/it/it-dependency-updates-report-001/verify.bsh @@ -17,7 +17,7 @@ try System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "1.1.0-2 Next Version" ) < 0) + if ( result.indexOf( "1.1.0-2 Latest Subincremental" ) < 0) { System.out.println( "Did not identify next version" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-001/verify.bsh b/src/it/it-plugin-updates-report-001/verify.bsh index 67a272ca2f..003f5155ce 100644 --- a/src/it/it-plugin-updates-report-001/verify.bsh +++ b/src/it/it-plugin-updates-report-001/verify.bsh @@ -39,7 +39,7 @@ try return false; } if ( result.indexOf( "Group Id localhost Artifact Id dummy-api Current Version 1.1 Classifier Type jar Newer " - + "versions 1.1.0-2 Next Version 1.1.1 Next Incremental 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 Next " + + "versions 1.1.0-2 Latest Subincremental 1.1.1 Next Incremental 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 Next " + "Minor 1.2.1 1.2.2 1.3 Latest Minor 2.0 Next Major 2.1 3.0 Latest Major" ) < 0) { System.out.println( "Did not identify dependency next versions" ); diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index e79d29b6f6..7769801caf 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -33,6 +33,7 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -432,57 +433,18 @@ else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { sink.lineBreak(); } - boolean bold = equals( versions[i], details.getOldestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( versions[i], details.getNewestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( versions[i], details.getOldestUpdate( of( INCREMENTAL ) ) ) - || equals( versions[i], details.getNewestUpdate( of( INCREMENTAL ) ) ) - || equals( versions[i], details.getOldestUpdate( of( MINOR ) ) ) - || equals( versions[i], details.getNewestUpdate( of( MINOR ) ) ) - || equals( versions[i], details.getOldestUpdate( of( MAJOR ) ) ) - || equals( versions[i], details.getNewestUpdate( of( MAJOR ) ) ); - if ( bold ) + String label = getLabel( versions[i], details ); + if ( label != null ) { safeBold(); } sink.text( versions[i].toString() ); - if ( bold ) + if ( label != null ) { safeBold_(); sink.nonBreakingSpace(); safeItalic(); - if ( equals( versions[i], details.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextVersion" ) ); - } - else if ( equals( versions[i], details.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestSubIncremental" ) ); - } - else if ( equals( versions[i], details.getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextIncremental" ) ); - } - else if ( equals( versions[i], details.getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestIncremental" ) ); - } - else if ( equals( versions[i], details.getOldestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.nextMinor" ) ); - } - else if ( equals( versions[i], details.getNewestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.latestMinor" ) ); - } - else if ( equals( versions[i], details.getOldestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.nextMajor" ) ); - } - else if ( equals( versions[i], details.getNewestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.latestMajor" ) ); - } - + sink.text( label ); safeItalic_(); } } @@ -707,25 +669,18 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.lineBreak(); } boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); - boolean bold = equals( artifactVersions[i], versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( of( INCREMENTAL ) ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( of( INCREMENTAL ) ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( of( MINOR ) ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( of( MINOR ) ) ) - || equals( artifactVersions[i], versions.getOldestUpdate( of( MAJOR ) ) ) - || equals( artifactVersions[i], versions.getNewestUpdate( of( MAJOR ) ) ); + String label = getLabel( artifactVersions[i], versions ); if ( !allowed ) { sink.text( "* " ); someNotAllowed = true; } - if ( allowed && bold ) + if ( allowed && label != null ) { safeBold(); } sink.text( artifactVersions[i].toString() ); - if ( bold ) + if ( label != null ) { if ( allowed ) { @@ -733,39 +688,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) } sink.nonBreakingSpace(); safeItalic(); - if ( equals( artifactVersions[i], versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextVersion" ) ); - } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestSubIncremental" ) ); - } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextIncremental" ) ); - } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestIncremental" ) ); - } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.nextMinor" ) ); - } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.latestMinor" ) ); - } - else if ( equals( artifactVersions[i], versions.getOldestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.nextMajor" ) ); - } - else if ( equals( artifactVersions[i], versions.getNewestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.latestMajor" ) ); - } - + sink.text( label ); safeItalic_(); } } @@ -855,4 +778,42 @@ private Set getVersionsInRange( Property property, PropertyVersions vers return rangeVersions; } + protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) + { + String label = null; + if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) + { + label = getText( "report.latestMajor" ); + } + else if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) + { + label = getText( "report.nextMajor" ); + } + else if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) + { + label = getText( "report.latestMinor" ); + } + else if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) + { + label = getText( "report.nextMinor" ); + } + else if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) + { + label = getText( "report.latestIncremental" ); + } + else if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) + { + label = getText( "report.nextIncremental" ); + } + else if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) + { + label = getText( "report.latestSubIncremental" ); + } + else if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) + { + label = getText( "report.nextVersion" ); + } + return label; + } + } diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java index 86a9123f16..de7b3677d7 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java @@ -436,67 +436,18 @@ else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) { sink.lineBreak(); } - boolean bold = equals( - versions[i], details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( versions[i], - details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) ) - || equals( versions[i], details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) ) - || equals( versions[i], details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) ); - if ( bold ) + String label = getLabel( versions[i], details.getArtifactVersions() ); + if ( label != null ) { safeBold(); } sink.text( versions[i].toString() ); - if ( bold ) + if ( label != null ) { safeBold_(); sink.nonBreakingSpace(); safeItalic(); - if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextVersion" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestSubIncremental" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.nextIncremental" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - sink.text( getText( "report.latestIncremental" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.nextMinor" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) ) ) - { - sink.text( getText( "report.latestMinor" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.nextMajor" ) ); - } - else if ( equals( versions[i], - details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) ) ) - { - sink.text( getText( "report.latestMajor" ) ); - } - + sink.text( label ); safeItalic_(); } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index e846a20914..8f0fff4f1f 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -507,7 +507,7 @@ protected Optional getLowerBound( ArtifactVersion version, Optionalnull
    if no such version exists. * * @param currentVersion the lower bound or null if the lower limit is unbounded. @@ -227,7 +227,7 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optionalnull
    if no such version exists. * * @param currentVersion the lower bound or null if the lower limit is unbounded. @@ -241,7 +241,7 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optionalnull if the lower limit is unbounded. * @param updateScope the update scope to include. @@ -289,7 +289,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optionalnull if no such version exists. * * @param updateScope the update scope to include. @@ -300,7 +300,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or + * Returns the newest version newer than the specified current version, but within the specified update scope or * null if no such version exists. * * @param updateScope the update scope to include. @@ -311,7 +311,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. + * Returns the all versions newer than the specified current version, but within the specified update scope. * * @param updateScope the update scope to include. * @return the all versions after currentVersion within the specified update scope. @@ -320,7 +320,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; /** - * Returns the oldest version newer than the specified current version, but within the the specified update scope or + * Returns the oldest version newer than the specified current version, but within the specified update scope or * null if no such version exists. * * @param updateScope the update scope to include. @@ -333,7 +333,7 @@ ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeS throws InvalidSegmentException; /** - * Returns the newest version newer than the specified current version, but within the the specified update scope or + * Returns the newest version newer than the specified current version, but within the specified update scope or * null if no such version exists. * * @param updateScope the update scope to include. @@ -346,7 +346,7 @@ ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeS throws InvalidSegmentException; /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. + * Returns the all versions newer than the specified current version, but within the specified update scope. * * @param updateScope the update scope to include. * @param includeSnapshots true if snapshots are to be included. @@ -357,7 +357,7 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS throws InvalidSegmentException; /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. + * Returns the all versions newer than the specified current version, but within the specified update scope. * * @param versionRange the version range to include. * @return the all versions after currentVersion within the specified update scope. @@ -366,7 +366,7 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS ArtifactVersion[] getAllUpdates( VersionRange versionRange ); /** - * Returns the all versions newer than the specified current version, but within the the specified update scope. + * Returns the all versions newer than the specified current version, but within the specified update scope. * * @param versionRange the version range to include. * @param includeSnapshots true if snapshots are to be included. diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 1108ac3494..773914180a 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -59,17 +59,8 @@ public final int getSegmentCount( ArtifactVersion v ) */ public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - if ( VersionComparators.isSnapshot( v ) ) - { - return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), - segment ) ); - } - int segmentCount = getSegmentCount( v ); - if ( segment.value() >= segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } - return innerIncrementSegment( v, segment ); + return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), + segment ) ); } protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java index 6b944ce9af..9cb107f6a3 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java @@ -127,7 +127,8 @@ public String toString() private static class StringItem implements Item { - private static final String[] QUALIFIERS = {"snapshot", "alpha", "beta", "milestone", "rc", "", "sp"}; + private static final String[] QUALIFIERS = { + "snapshot", "alpha", "beta", "milestone", "preview", "rc", "", "sp" }; private static final List QUALIFIERS_LIST = Arrays.asList( QUALIFIERS ); @@ -135,9 +136,10 @@ private static class StringItem static { - ALIASES.put( "ga", "" ); - ALIASES.put( "final", "" ); + ALIASES.put( "mr", "milestone" ); ALIASES.put( "cr", "rc" ); + ALIASES.put( "final", "" ); + ALIASES.put( "ga", "" ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index db6444ff49..c0bc1c2682 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -38,7 +38,7 @@ public class MavenVersionComparator extends AbstractVersionComparator */ public int compare( ArtifactVersion o1, ArtifactVersion o2 ) { - return o1.compareTo( o2 ); + return new ComparableVersion( o1.toString() ).compareTo( new ComparableVersion( o2.toString() ) ); } /** diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index 4aed2cf78b..4b520f7c28 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -45,8 +45,7 @@ public void testSegmentCounting() } @Test - public void testSegmentIncrementing() - throws InvalidSegmentException + public void testSegmentIncrementing() throws InvalidSegmentException { assertIncrement( "6", "5", MAJOR ); assertIncrement( "6.0", "5.0", MAJOR ); @@ -56,15 +55,15 @@ public void testSegmentIncrementing() assertIncrement( "5.alpha-1.2", "5.alpha-1.1", MAJOR ); assertIncrement( "5.alpha-1.ba", "5.alpha-1.az", MAJOR ); assertIncrement( "5.alpha-wins.2", "5.alpha-wins.1", MAJOR ); - assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-alpha-3", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-alpha-90", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-za", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-z90", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); } private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException { - assertEquals( expected, + assertEquals( expected + "-SNAPSHOT", instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); } -} \ No newline at end of file +} diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index a9dcfe8680..4d64da3a24 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -20,6 +20,7 @@ */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; @@ -32,8 +33,7 @@ public class MercuryVersionComparatorTest private MercuryVersionComparator instance = new MercuryVersionComparator(); @Test - public void testSegmentCounting() - throws Exception + public void testSegmentCounting() throws Exception { assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); @@ -44,24 +44,21 @@ public void testSegmentCounting() } @Test - public void testSegmentIncrementing() - throws Exception + public void testSegmentIncrementing() throws Exception { - assertEquals( new DefaultArtifactVersion( "6" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); + assertIncrement( "6", "5", MAJOR ); + assertIncrement( "6.0", "5.0", MAJOR ); + assertIncrement( "5.1", "5.0", MINOR ); + assertIncrement( "5.1.0", "5.0.1", MINOR ); + assertIncrement( "5.beta.0", "5.alpha.1", MINOR ); + assertIncrement( "5.beta-0.0", "5.alpha-1.1", MINOR ); + assertIncrement( "5.alpha-2.0", "5.alpha-1.1", INCREMENTAL ); + assertIncrement( "5.beta-0.0", "5.alpha-wins.1", MINOR ); } -} \ No newline at end of file + + private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException + { + assertEquals( expected + "-SNAPSHOT", + instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index e7a58949be..d437aa62ca 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -20,6 +20,7 @@ */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; @@ -103,25 +104,21 @@ public void testSegmentCounting() } @Test - public void testSegmentIncrementing() - throws Exception + public void testSegmentIncrementing() throws Exception + { + assertIncrement( "6", "5", MAJOR ); + assertIncrement( "6.0", "5.0", MAJOR ); + assertIncrement( "5.1", "5.0", MINOR ); + assertIncrement( "5.1.0", "5.0.1", MINOR ); + assertIncrement( "5.beta.0", "5.alpha.1", MINOR ); + assertIncrement( "5.alpha-2.0", "5.alpha-1.1", MINOR ); + assertIncrement( "5.alpha-1.2", "5.alpha-1.1", INCREMENTAL ); + assertIncrement( "5.beta.0", "5.alpha-wins.1", MINOR ); + } + + private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException { - assertEquals( new DefaultArtifactVersion( "6" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-1.2" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ) - .toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); + assertEquals( expected + "-SNAPSHOT", + instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); } } From 3e983983c7e2eb148079bc5cf622a0f55e6e63e2 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 19 Sep 2022 18:24:26 +0200 Subject: [PATCH 134/441] Implementing #709: Remove snapshot idempotency --- .../org/codehaus/mojo/versions/SetMojo.java | 17 ++++---- .../codehaus/mojo/versions/SetMojoTest.java | 41 +++++++++++++++++++ .../codehaus/mojo/set/remove-snapshot/pom.xml | 23 +++++++++++ 3 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 206417570b..56205ecf8f 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -65,6 +65,8 @@ import org.codehaus.plexus.components.interactivity.PrompterException; import org.codehaus.plexus.util.StringUtils; +import static org.codehaus.plexus.util.StringUtils.isEmpty; + /** * Sets the current project's version and based on that change propagates that change onto any child modules as * necessary. @@ -298,8 +300,13 @@ public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion ); } - if ( StringUtils.isEmpty( newVersion ) ) + if ( isEmpty( newVersion ) ) { + if ( removeSnapshot ) + { + getLog().info( "removeSnapshot enabled whilst the version is not a snapshot: nothing to do." ); + return; + } if ( settings.isInteractiveMode() ) { try @@ -319,12 +326,6 @@ public void execute() throws MojoExecutionException, MojoFailureException + "or run in interactive mode" ); } } - if ( StringUtils.isEmpty( newVersion ) ) - { - throw new MojoExecutionException( "You must specify the new version, either by using the newVersion " - + "property (that is -DnewVersion=... on the command line) " - + "or run in interactive mode" ); - } if ( !"onchange".equals( updateBuildOutputTimestampPolicy ) && !"always".equals( updateBuildOutputTimestampPolicy ) && !"never".equals( updateBuildOutputTimestampPolicy ) ) @@ -614,7 +615,7 @@ private void updateBuildOutputTimestamp( ModifiedPomXMLEventReader pom, Model mo { String buildOutputTimestamp = model.getProperties().getProperty( "project.build.outputTimestamp" ); - if ( buildOutputTimestamp == null || StringUtils.isEmpty( buildOutputTimestamp ) ) + if ( buildOutputTimestamp == null || isEmpty( buildOutputTimestamp ) ) { // no Reproducible Builds output timestamp defined return; diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index b8d5ff77ad..162679afd5 100644 --- a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -1,7 +1,13 @@ package org.codehaus.mojo.versions; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Objects; +import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -11,6 +17,7 @@ import org.junit.Rule; import org.junit.Test; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; @@ -106,4 +113,38 @@ public void testVersionlessDependency() throws Exception new File( "target/test-classes/org/codehaus/mojo/set/versionless-01" ), "set" ); myMojo.execute(); } + + @Test + public void testRemoveSnapshotIdempotency() + throws Exception + { + Path pomDir = Files.createTempDirectory( "set-" ); + try + { + Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml" ), + Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + + SetMojo firstRun = (SetMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set" ); + firstRun.execute(); + assertThat( String.join( "", Files.readAllLines( Paths.get( pomDir.toString(), "pom.xml" ) ) ), + containsString( "1.0" ) ); + + // no exception should be thrown, the file should stay with version "1.0" + SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set" ); + MavenExecutionRequest request = + (MavenExecutionRequest) getVariableValueFromObject( secondRun.settings, "request" ); + setVariableValueToObject( request, "interactiveMode", false ); + secondRun.execute(); + assertThat( String.join( "", Files.readAllLines( Paths.get( pomDir.toString(), "pom.xml" ) ) ), + containsString( "1.0" ) ); + } + finally + { + if ( pomDir != null && pomDir.toFile().exists() ) + { + Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); + pomDir.toFile().delete(); + } + } + } } diff --git a/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml b/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml new file mode 100644 index 0000000000..3bfaf049a7 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + default-group + default-artifact + 1.0-SNAPSHOT + + + + + org.codehaus.mojo + versions-maven-plugin + + set + + + true + false + + + + + From e6ca37256f2b533c031db0d236f93e63112a7d07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Sep 2022 13:54:22 +0000 Subject: [PATCH 135/441] Bump actions/stale from 5 to 6 Bumps [actions/stale](https://github.com/actions/stale) from 5 to 6. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b0639af2a9..e0962037cc 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v5 + - uses: actions/stale@v6 with: stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 30 days.' days-before-pr-stale: 365 From 8ac4923bf38a8010fd52023a1384fd1c8bc6c9bb Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 22 Sep 2022 21:16:07 +0200 Subject: [PATCH 136/441] #343 Parent updates report --- .../invoker.properties | 1 + .../module/pom.xml | 54 +++++++ src/it/it-parent-updates-report-001/pom.xml | 60 ++++++++ .../src/site/site.xml | 7 + .../verify.groovy | 13 ++ .../versions/DependencyUpdatesRenderer.java | 22 ++- .../mojo/versions/ParentUpdatesReport.java | 145 ++++++++++++++++++ .../parent-updates-report.properties | 58 +++++++ src/site/apt/index.apt | 3 + .../versions/DependencyUpdatesReportTest.java | 23 +-- .../versions/ParentUpdatesReportTest.java | 87 +++++++++++ .../mojo/versions/utils/MockUtils.java | 17 ++ 12 files changed, 463 insertions(+), 27 deletions(-) create mode 100644 src/it/it-parent-updates-report-001/invoker.properties create mode 100644 src/it/it-parent-updates-report-001/module/pom.xml create mode 100644 src/it/it-parent-updates-report-001/pom.xml create mode 100644 src/it/it-parent-updates-report-001/src/site/site.xml create mode 100644 src/it/it-parent-updates-report-001/verify.groovy create mode 100644 src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java create mode 100644 src/main/resources/parent-updates-report.properties create mode 100644 src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java diff --git a/src/it/it-parent-updates-report-001/invoker.properties b/src/it/it-parent-updates-report-001/invoker.properties new file mode 100644 index 0000000000..c01f7db0e4 --- /dev/null +++ b/src/it/it-parent-updates-report-001/invoker.properties @@ -0,0 +1 @@ +invoker.goals=site diff --git a/src/it/it-parent-updates-report-001/module/pom.xml b/src/it/it-parent-updates-report-001/module/pom.xml new file mode 100644 index 0000000000..0d6ffd7577 --- /dev/null +++ b/src/it/it-parent-updates-report-001/module/pom.xml @@ -0,0 +1,54 @@ + + 4.0.0 + + + localhost + dummy-parent3 + 1.0.0 + + + module + 1.0.0 + + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + @sitePluginVersion@ + + + + + + + true + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + parent-updates-report + + + + + + + + \ No newline at end of file diff --git a/src/it/it-parent-updates-report-001/pom.xml b/src/it/it-parent-updates-report-001/pom.xml new file mode 100644 index 0000000000..8afff30386 --- /dev/null +++ b/src/it/it-parent-updates-report-001/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + + + localhost + dummy-parent2 + 1.0 + + + it-parent-updates-report-001 + 1.0.0 + pom + + + module + + + + + + + maven-clean-plugin + 2.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-site-plugin + @sitePluginVersion@ + + + + + + + true + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + + parent-updates-report + + + + + + + + diff --git a/src/it/it-parent-updates-report-001/src/site/site.xml b/src/it/it-parent-updates-report-001/src/site/site.xml new file mode 100644 index 0000000000..e955148484 --- /dev/null +++ b/src/it/it-parent-updates-report-001/src/site/site.xml @@ -0,0 +1,7 @@ + + + org.apache.maven.skins + maven-default-skin + 1.0 + + diff --git a/src/it/it-parent-updates-report-001/verify.groovy b/src/it/it-parent-updates-report-001/verify.groovy new file mode 100644 index 0000000000..130ccd01f0 --- /dev/null +++ b/src/it/it-parent-updates-report-001/verify.groovy @@ -0,0 +1,13 @@ +report = new File( basedir, "target/site/parent-updates-report.html" ).text + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ) + +assert report =~ /dummy-parent2 +1.0 +pom +3.1/ + +report = new File( basedir, "module/target/site/parent-updates-report.html" ).text + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ) + +assert report =~ /dummy-parent3 +1.0.0 +pom/ \ No newline at end of file diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java index 647b865873..d1d6b807af 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java @@ -72,10 +72,9 @@ protected void renderBody() renderSummaryTotalsTable( allUpdates ); - renderSummaryTable( "report.overview.dependencyManagement", dependencyManagementUpdates, - "report.overview.noDependencyManagement" ); + renderDependencyManagementSummary(); - renderSummaryTable( "report.overview.dependency", dependencyUpdates, "report.overview.noDependency" ); + renderDependencySummary(); sink.section1_(); @@ -94,7 +93,18 @@ protected void renderBody() sink.section1_(); } - private void renderSummaryTable( String titleKey, Map contents, String emptyKey ) + protected void renderDependencySummary() + { + renderSummaryTable( "report.overview.dependency", dependencyUpdates, "report.overview.noDependency" ); + } + + protected void renderDependencyManagementSummary() + { + renderSummaryTable( "report.overview.dependencyManagement", dependencyManagementUpdates, + "report.overview.noDependencyManagement" ); + } + + protected void renderSummaryTable( String titleKey, Map contents, String emptyKey ) { sink.section2(); sink.sectionTitle2(); @@ -114,7 +124,7 @@ private void renderSummaryTable( String titleKey, Map allUpdates ) + protected void renderSummaryTotalsTable( Map allUpdates ) { int numInc = 0; int numMin = 0; @@ -203,7 +213,7 @@ else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) sink.table_(); } - private void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) + protected void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) { sink.section2(); sink.sectionTitle2(); diff --git a/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java new file mode 100644 index 0000000000..cbc99740f3 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java @@ -0,0 +1,145 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import javax.inject.Inject; + +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.plexus.i18n.I18N; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; + +/** + * Generates a report on available updates for parent artifacts + * + * @author Andrzej Jarmoniuk + * @since 2.13.0 + */ +@Mojo( name = "parent-updates-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = false ) +public class ParentUpdatesReport extends AbstractVersionsReport +{ + @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) + protected List reactorProjects; + + @Inject + protected ParentUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + { + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + } + + /** + * {@inheritDoc} + */ + public boolean isExternalReport() + { + return false; + } + + /** + * {@inheritDoc} + */ + public boolean canGenerateReport() + { + if ( getProject().getParent() == null ) + { + getLog().warn( "Project does not have a parent." ); + return false; + } + + if ( reactorProjects.contains( getProject().getParent() ) ) + { + getLog().warn( "Parent project is part of the reactor." ); + return false; + } + + return true; + } + + /** + * generates an empty report in case there are no sources to generate a report with + * + * @param locale the locale to generate the report for. + * @param sink the report formatting tool + */ + @SuppressWarnings( "deprecation" ) + protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException + { + try + { + ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( project.getParentArtifact(), + false ); + artifactVersions.setIncludeSnapshots( allowSnapshots ); + Dependency parent = DependencyBuilder.newBuilder() + .withGroupId( artifactVersions.getGroupId() ) + .withArtifactId( artifactVersions.getArtifactId() ) + .withVersion( artifactVersions.getArtifact().getVersion() ) + .withScope( artifactVersions.getArtifact().getScope() ) + .withType( artifactVersions.getArtifact().getType() ) + .withClassifier( artifactVersions.getArtifact().getClassifier() ) + .build(); + new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, + singletonMap( parent, artifactVersions ), emptyMap() ) + { + @Override + protected void renderSummaryTotalsTable( Map allUpdates ) + { + } + + @Override + protected void renderDependencyManagementSummary() + { + } + } + .renderBody(); + } + catch ( ArtifactMetadataRetrievalException e ) + { + throw new MavenReportException( e.getMessage(), e ); + } + } + + /** + * {@inheritDoc} + */ + public String getOutputName() + { + return "parent-updates-report"; + } +} diff --git a/src/main/resources/parent-updates-report.properties b/src/main/resources/parent-updates-report.properties new file mode 100644 index 0000000000..632d111778 --- /dev/null +++ b/src/main/resources/parent-updates-report.properties @@ -0,0 +1,58 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.title=Parent Updates Report +report.description=Provides information on parent artifact updates +report.overview.title=Overview +report.overview.text=This report summarizes newer versions that may be available for your project's parent artifacts +report.overview.dependency=Parent artifact +report.overview.noDependency=This project does not declare a parent artifact +report.overview.numUpToDate=# of parent artifacts using the latest version available +report.overview.numNewerMajorAvailable=# of parent artifacts where the next version available is a major version update +report.overview.numNewerMinorAvailable=# of parent artifacts where the next version available is a minor version update +report.overview.numNewerIncrementalAvailable=# of parent artifacts where the next version available is an incremental \ + version update +report.overview.numNewerVersionAvailable=# of parent artifacts where the next version available is smaller than an \ + incremental version update +report.overview.property=Summary of parent artifacts associated with artifact versions +report.overview.noProperty=No properties associated with artifacts have been defined. +report.detail.title=Parent Update +report.detail.text= +report.status=Status +report.groupId=Group Id +report.artifactId=Artifact Id +report.currentVersion=Current Version +report.scope=Scope +report.classifier=Classifier +report.type=Type +report.nextVersion=Next Version +report.latestSubIncremental=Latest Subincremental +report.nextIncremental=Next Incremental +report.latestIncremental=Latest Incremental +report.nextMinor=Next Minor +report.latestMinor=Latest Minor +report.nextMajor=Next Major +report.latestMajor=Latest Major +report.updateVersions=Newer versions +report.noUpdatesAvailable=No newer versions available. +report.otherUpdatesAvailable=There is at least one newer version available. +report.incrementalUpdatesAvailable=There is at least one newer incremental version available. \ + Incremental updates are typically passive. +report.minorUpdatesAvailable=There is at least one newer minor version available. \ + Minor updates are sometimes passive. +report.majorUpdatesAvailable=There is at least one newer major version available. \ + Major updates are rarely passive. diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt index 66d643fe39..e95618a672 100644 --- a/src/site/apt/index.apt +++ b/src/site/apt/index.apt @@ -116,6 +116,9 @@ Versions Maven Plugin * {{{./property-updates-report-mojo.html}versions:property-updates-report}} produces a report of those properties which are used to control artifact versions and which properties have newer versions available. + * {{{./parent-updates-report-mojo.html}versions:parent-updates-report}} produces a report on possible parent artifact + upgrades. + * Usage General instructions on how to use the Versions Plugin can be found on the {{{./usage.html}usage page}}. Some more diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index ed0b789267..12c149f223 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -27,7 +27,6 @@ import java.util.Locale; import java.util.Set; -import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Dependency; @@ -35,9 +34,8 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.model.RuleSet; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.MockUtils; import org.junit.Test; @@ -49,9 +47,6 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Basic tests for {@linkplain DependencyUpdatesReport}. @@ -65,7 +60,7 @@ private static class TestDependencyUpdatesReport extends DependencyUpdatesReport @SuppressWarnings( "deprecation" ) TestDependencyUpdatesReport() { - super( mockI18N(), mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); + super( mockI18N(), MockUtils.mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); @@ -133,20 +128,6 @@ public TestDependencyUpdatesReport withIgnoredVersions( this.ignoredVersions = ignoredVersions; return this; } - - private static RepositorySystem mockRepositorySystem() - { - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( - invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier(), null ); - } ); - return repositorySystem; - } } private static Dependency dependencyOf( String artifactId ) diff --git a/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java new file mode 100644 index 0000000000..95c81c19be --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java @@ -0,0 +1,87 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Locale; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; +import org.apache.maven.doxia.sink.SinkFactory; +import org.apache.maven.model.Model; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.junit.Test; + +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.allOf; + +/** + * Basic tests for {@linkplain ParentUpdatesReport}. + * + * @author Andrzej Jarmoniuk + */ +public class ParentUpdatesReportTest +{ + @Test + public void testAllowSnapshots() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new ParentUpdatesReport( mockI18N(), mockRepositorySystem(), null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"} ); + }} ), null ) + {{ + allowSnapshots = true; + project = new MavenProject( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "child-artifact" ); + setVersion( "1.0.0" ); + }} ); + project.setParent( new MavenProject( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "default-artifact" ); + setVersion( "1.0.0" ); + }} ) ); + reactorProjects = new ArrayList<>(); + project.setParentArtifact( new DefaultArtifact( project.getParent().getGroupId(), + project.getParent().getArtifactId(), project.getParent().getVersion(), + Artifact.SCOPE_COMPILE, "pom", "default", null ) ); + }}.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, allOf( containsString( "1.0.0" ), + containsString( "1.0.1" ), containsString( "1.1.0" ), + containsString( "2.0.0" ), containsString( "2.0.1-SNAPSHOT" ) ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java index 71e885f889..efc108dd25 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -25,11 +25,14 @@ import java.util.Map; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.doxia.tools.SiteToolException; +import org.apache.maven.model.Dependency; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.i18n.I18N; import static org.mockito.ArgumentMatchers.any; @@ -111,4 +114,18 @@ public static SiteTool mockSiteTool() } return siteTool; } + + public static RepositorySystem mockRepositorySystem() + { + RepositorySystem repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( + invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion(), dependency.getScope(), dependency.getType(), + dependency.getClassifier(), null ); + } ); + return repositorySystem; + } } From 05f243dc98de6f385637b2f92fa7a5549dd9246b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20=C5=BBygie=C5=82o?= Date: Sat, 4 Jul 2020 09:56:36 +0200 Subject: [PATCH 137/441] Add missing space in exception message --- .../org/codehaus/mojo/versions/CompareDependenciesMojo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 74f56ae78d..1c015fd82c 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -144,7 +144,7 @@ protected void update( ModifiedPomXMLEventReader pom ) { if ( this.ignoreRemoteDependencies && this.ignoreRemoteDependencyManagement ) { - throw new MojoFailureException( " ignoreRemoteDependencies and ignoreRemoteDependencyManagement" + throw new MojoFailureException( " ignoreRemoteDependencies and ignoreRemoteDependencyManagement " + "are both set to true. At least one of these needs to be false " ); } From b5edfe07742cc743566cf45dda4c2f639c323025 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Sep 2022 13:37:31 +0000 Subject: [PATCH 138/441] Bump junit-bom from 5.9.0 to 5.9.1 Bumps [junit-bom](https://github.com/junit-team/junit5) from 5.9.0 to 5.9.1. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.0...r5.9.1) --- updated-dependencies: - dependency-name: org.junit:junit-bom dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 616d9abc72..741d55aac1 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ 1.8 ${mojo.java.target} - 5.9.0 + 5.9.1 3.2.5 3.5.2 1.11.1 From 63f9bd97240672bd41f4b45658ea59ab137ad5f8 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:36:35 +0200 Subject: [PATCH 139/441] Second batch of maintenance following PR #672 --- .../mojo/versions/UseLatestReleasesMojo.java | 10 +++------- .../mojo/versions/UseLatestSnapshotsMojo.java | 13 +++---------- .../mojo/versions/UseLatestVersionsMojo.java | 9 +++------ .../mojo/versions/api/AbstractVersionDetails.java | 1 + 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 7afa71d298..3613f131dd 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -50,7 +50,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -151,8 +150,6 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - MajorMinorIncrementalFilter majorMinorIncfilter = - new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); for ( Dependency dep : dependencies ) { @@ -185,10 +182,9 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection 0 ) { String newVersion = filteredVersions[filteredVersions.length - 1].toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 023265a752..50ee454d9f 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -48,7 +48,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -151,8 +150,6 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - MajorMinorIncrementalFilter majorMinorIncfilter = - new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); for ( Dependency dep : dependencies ) { @@ -201,6 +198,7 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection snapshotsOnly = new ArrayList<>(); @@ -212,13 +210,8 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection 0 ) { latestVersion = filteredVersions[filteredVersions.length - 1].toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 172da4e174..fd10d8a537 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -45,7 +45,6 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -167,8 +166,6 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); - MajorMinorIncrementalFilter majorMinorIncfilter = - new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); for ( Dependency dep : dependencies ) { @@ -199,10 +196,10 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection 0 ) { String newVersion = filteredVersions[filteredVersions.length - 1].toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 8f0fff4f1f..1d03bcdc2c 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -266,6 +266,7 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional< : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment.get() ); Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); + // TODO shouldn't allowDowngrade boolean be passed to this call ? return getVersions( restriction, includeSnapshots ); } From 37e8947baa484a04cd393dc35f6e323aa1ee3fa1 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Wed, 28 Sep 2022 17:49:59 +0200 Subject: [PATCH 140/441] Second batch of maintenance following PR #672 --- .../org/codehaus/mojo/versions/UseLatestVersionsMojo.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index fd10d8a537..da31fd138d 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -45,6 +45,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -166,6 +167,8 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + MajorMinorIncrementalFilter majorMinorIncfilter = + new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); for ( Dependency dep : dependencies ) { @@ -197,9 +200,10 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection 0 ) { String newVersion = filteredVersions[filteredVersions.length - 1].toString(); From e7aa4066b240b905228924675f9e88f9c46e7b61 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 21 Sep 2022 21:53:13 +0200 Subject: [PATCH 141/441] #265: Processing all child modules instead of relying on default maven processing --- src/it/it-revert-isssue-265/aggregate/pom.xml | 21 +++++ .../it-revert-isssue-265/invoker.properties | 4 + src/it/it-revert-isssue-265/module-a/pom.xml | 15 +++ src/it/it-revert-isssue-265/module-b/pom.xml | 17 ++++ src/it/it-revert-isssue-265/verify.groovy | 8 ++ .../codehaus/mojo/versions/RevertMojo.java | 82 ++++++++++++---- .../mojo/versions/RevertMojoTest.java | 93 +++++++++++++++++++ .../mojo/revert/issue-265/aggregate/pom.xml | 52 +++++++++++ .../aggregate/pom.xml.versionsBackup | 21 +++++ .../mojo/revert/issue-265/module-a/pom.xml | 15 +++ .../issue-265/module-a/pom.xml.versionsBackup | 15 +++ .../mojo/revert/issue-265/module-b/pom.xml | 17 ++++ .../issue-265/module-b/pom.xml.versionsBackup | 17 ++++ 13 files changed, 359 insertions(+), 18 deletions(-) create mode 100644 src/it/it-revert-isssue-265/aggregate/pom.xml create mode 100644 src/it/it-revert-isssue-265/invoker.properties create mode 100644 src/it/it-revert-isssue-265/module-a/pom.xml create mode 100644 src/it/it-revert-isssue-265/module-b/pom.xml create mode 100644 src/it/it-revert-isssue-265/verify.groovy create mode 100644 src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup diff --git a/src/it/it-revert-isssue-265/aggregate/pom.xml b/src/it/it-revert-isssue-265/aggregate/pom.xml new file mode 100644 index 0000000000..ef00bd7e19 --- /dev/null +++ b/src/it/it-revert-isssue-265/aggregate/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + localhost + dummy-artifact + OLD + pom + + + ../module-a + + + + + module-b + + + ../module-b + + + + diff --git a/src/it/it-revert-isssue-265/invoker.properties b/src/it/it-revert-isssue-265/invoker.properties new file mode 100644 index 0000000000..ca423c70cc --- /dev/null +++ b/src/it/it-revert-isssue-265/invoker.properties @@ -0,0 +1,4 @@ +invoker.goals.1 = ${project.groupId}:${project.artifactId}:${project.version}:set -f aggregate/pom.xml +invoker.mavenOpts.1 = -DnewVersion=1.2.3 -DprocessAllModules + +invoker.goals.2 = ${project.groupId}:${project.artifactId}:${project.version}:revert -f aggregate/pom.xml \ No newline at end of file diff --git a/src/it/it-revert-isssue-265/module-a/pom.xml b/src/it/it-revert-isssue-265/module-a/pom.xml new file mode 100644 index 0000000000..c0c8c088ca --- /dev/null +++ b/src/it/it-revert-isssue-265/module-a/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + localhost + dummy-artifact-a + 1.0.0 + pom + + + + localhost + dummy-artifact + OLD + + + diff --git a/src/it/it-revert-isssue-265/module-b/pom.xml b/src/it/it-revert-isssue-265/module-b/pom.xml new file mode 100644 index 0000000000..6ea7173432 --- /dev/null +++ b/src/it/it-revert-isssue-265/module-b/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + localhost + dummy-artifact-b + 1.0.0 + pom + + + + + localhost + dummy-artifact + OLD + + + + diff --git a/src/it/it-revert-isssue-265/verify.groovy b/src/it/it-revert-isssue-265/verify.groovy new file mode 100644 index 0000000000..4fd909e1f8 --- /dev/null +++ b/src/it/it-revert-isssue-265/verify.groovy @@ -0,0 +1,8 @@ +assert new File( basedir, "aggregate/pom.xml" ).text =~ /OLD/ +assert !new File( basedir, "aggregate/pom.xml.versionsBackup" ).exists() + +assert new File( basedir, "module-a/pom.xml" ).text =~ /OLD/ +assert !new File( basedir, "module-a/pom.xml.versionsBackup" ).exists() + +assert new File( basedir, "module-b/pom.xml" ).text =~ /OLD/ +assert !new File( basedir, "module-b/pom.xml.versionsBackup" ).exists() diff --git a/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/src/main/java/org/codehaus/mojo/versions/RevertMojo.java index a85092f420..c2c294fcf2 100644 --- a/src/main/java/org/codehaus/mojo/versions/RevertMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/RevertMojo.java @@ -19,16 +19,25 @@ * under the License. */ -import java.io.File; +import javax.inject.Inject; + import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Set; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; +import org.apache.maven.project.MavenProjectBuilder; +import org.codehaus.mojo.versions.api.PomHelper; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; /** * Restores the pom from the initial backup. @@ -37,8 +46,7 @@ * @since 1.0-alpha-3 */ @Mojo( name = "revert", threadSafe = true ) -public class RevertMojo - extends AbstractMojo +public class RevertMojo extends AbstractMojo { /** * The Maven Project. @@ -48,24 +56,62 @@ public class RevertMojo @Parameter( defaultValue = "${project}", required = true, readonly = true ) private MavenProject project; - public void execute() - throws MojoExecutionException, MojoFailureException + /** + * Whether to start processing at the local aggregation root (which might be a parent module + * of that module where Maven is executed in, and the version change may affect parent and sibling modules). + * Setting to false makes sure only the module (and it's submodules) where Maven is executed for is affected. + * + * @since 2.13.0 + */ + @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) + private boolean processFromLocalAggregationRoot; + + protected MavenProjectBuilder projectBuilder; + + @Parameter( defaultValue = "${localRepository}", readonly = true ) + protected ArtifactRepository localRepository; + + @Inject + protected RevertMojo( MavenProjectBuilder projectBuilder ) + { + this.projectBuilder = projectBuilder; + } + + public void execute() throws MojoExecutionException, MojoFailureException { - File outFile = project.getFile(); - File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" ); + final MavenProject projectToProcess = !processFromLocalAggregationRoot + ? PomHelper.getLocalRoot( projectBuilder, this.project, localRepository, null, getLog() ) + : this.project; - if ( backupFile.exists() ) + getLog().info( "Local aggregation root: " + projectToProcess.getBasedir() ); + Set reactor = PomHelper.getAllChildModules( projectToProcess, getLog() ); + reactor.add( "." ); + + reactor.forEach( entry -> { - getLog().info( "Restoring " + outFile + " from " + backupFile ); - try - { - FileUtils.copyFile( backupFile, outFile ); - FileUtils.forceDelete( backupFile ); - } - catch ( IOException e ) + Path pomFile = projectToProcess.getBasedir().toPath().resolve( entry ).resolve( "pom.xml" ).normalize(); + getLog().debug( "Processing:" + pomFile ); + Path backupFile = Paths.get( pomFile + ".versionsBackup" ); + if ( Files.exists( backupFile ) ) { - throw new MojoExecutionException( e.getMessage(), e ); + getLog().info( "Restoring " + pomFile + " from " + backupFile ); + try + { + Files.copy( backupFile, pomFile, REPLACE_EXISTING ); + try + { + Files.delete( backupFile ); + } + catch ( IOException e ) + { + getLog().warn( "Error deleting " + backupFile ); + } + } + catch ( IOException e ) + { + getLog().warn( "Error copying " + backupFile + " onto " + pomFile ); + } } - } + } ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java b/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java new file mode 100644 index 0000000000..ceb31ea1e6 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java @@ -0,0 +1,93 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Objects; + +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; + +import static java.lang.String.join; +import static org.apache.commons.io.FileUtils.copyDirectory; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.core.Is.is; + +/** + * Unit tests for {@link RevertMojo} + * + * @author Andrzej Jarmoniuk + */ +public class RevertMojoTest extends AbstractMojoTestCase +{ + @Rule + public MojoRule mojoRule = new MojoRule( this ); + private Path pomDir; + + @Before + public void setUp() throws Exception + { + super.setUp(); + pomDir = Files.createTempDirectory( "revert-" ); + } + + @After + public void tearDown() throws Exception + { + try + { + if ( pomDir != null && pomDir.toFile().exists() ) + { + Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); + pomDir.toFile().delete(); + } + } + finally + { + super.tearDown(); + } + } + + public void testRevert() throws Exception + { + copyDirectory( new File( getBasedir(), + "target/test-classes/org/codehaus/mojo/revert/issue-265" ), pomDir.toFile() ); + RevertMojo myMojo = (RevertMojo) mojoRule.lookupConfiguredMojo( + new File( pomDir.toString(), "aggregate" ), "revert" ); + myMojo.execute(); + + assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "aggregate/pom.xml" ) ) ), + containsString( "OLD" ) ); + assertThat( Files.exists( pomDir.resolve( "aggregate/pom.xml.versionsBackup" ) ), is( false ) ); + assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-a/pom.xml" ) ) ), + containsString( "OLD" ) ); + assertThat( Files.exists( pomDir.resolve( "module-a/pom.xml.versionsBackup" ) ), is( false ) ); + assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-b/pom.xml" ) ) ), + containsString( "OLD" ) ); + assertThat( Files.exists( pomDir.resolve( "module-b/pom.xml.versionsBackup" ) ), is( false ) ); + } +} diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml b/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml new file mode 100644 index 0000000000..2dbb4eb56a --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + localhost + dummy-artifact + NEW + pom + + + ../module-a + + + + + module-b + + + ../module-b + + + + + + + + org.codehaus.mojo + versions-maven-plugin + + revert + + + + + diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup b/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup new file mode 100644 index 0000000000..ef00bd7e19 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup @@ -0,0 +1,21 @@ + + 4.0.0 + localhost + dummy-artifact + OLD + pom + + + ../module-a + + + + + module-b + + + ../module-b + + + + diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml new file mode 100644 index 0000000000..a5782a4807 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + localhost + dummy-artifact-a + 1.0.0 + pom + + + + localhost + dummy-artifact + NEW + + + diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup new file mode 100644 index 0000000000..c0c8c088ca --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup @@ -0,0 +1,15 @@ + + 4.0.0 + localhost + dummy-artifact-a + 1.0.0 + pom + + + + localhost + dummy-artifact + OLD + + + diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml new file mode 100644 index 0000000000..9bf6bd5e83 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + localhost + dummy-artifact-b + NEW + pom + + + + + localhost + dummy-artifact + VERSION + + + + diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup new file mode 100644 index 0000000000..6ea7173432 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup @@ -0,0 +1,17 @@ + + 4.0.0 + localhost + dummy-artifact-b + 1.0.0 + pom + + + + + localhost + dummy-artifact + OLD + + + + From f7c728ab0ca25d98708803fab4fe63672a810ff6 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 30 Sep 2022 07:14:22 +0200 Subject: [PATCH 142/441] #454: Introducing "infinity-like" calculus for dependency range computation --- ...AbstractVersionsDependencyUpdaterMojo.java | 4 +- .../AbstractVersionsReportRenderer.java | 43 ++++--- .../versions/AbstractVersionsUpdaterMojo.java | 4 +- .../versions/DependencyUpdatesReport.java | 2 +- .../DisplayDependencyUpdatesMojo.java | 30 +++-- .../org/codehaus/mojo/versions/SetMojo.java | 3 +- .../versions/api/AbstractVersionDetails.java | 75 ++++------- .../codehaus/mojo/versions/api/PomHelper.java | 3 +- .../codehaus/mojo/versions/api/Segment.java | 31 +++-- .../mojo/versions/api/VersionDetails.java | 9 ++ .../ordering/AbstractVersionComparator.java | 13 +- .../ordering/BoundArtifactVersion.java | 93 ++++++++++++++ .../versions/ordering/ComparableVersion.java | 14 +-- .../ordering/MavenVersionComparator.java | 4 + .../versions/ordering/VersionComparator.java | 31 +++++ .../advancing-dependency-versions.apt.vm | 6 +- .../apt/examples/display-plugin-updates.apt | 2 +- .../versions/DependencyUpdatesReportTest.java | 48 ++++++++ .../DisplayDependencyUpdatesMojoTest.java | 116 ++++++++++++++++++ .../versions/UseLatestReleasesMojoTest.java | 106 ++++++++++++++++ .../versions/api/ArtifactVersionsTest.java | 23 +++- .../ordering/MavenVersionComparatorTest.java | 64 ++++++++-- .../MercuryVersionComparatorTest.java | 31 ++--- .../NumericVersionComparatorTest.java | 32 ++--- .../mojo/versions/utils/MockUtils.java | 3 +- 25 files changed, 633 insertions(+), 157 deletions(-) create mode 100644 src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java create mode 100644 src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 8d1ddbc3a3..89fa4fc2dd 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -60,7 +60,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo /** * A comma separated list of artifact patterns to include. Follows the pattern - * "groupId:artifactId:type:classifier:version". Designed to allow specifing the set of includes from the command + * "groupId:artifactId:type:classifier:version". Designed to allow specifying the set of includes from the command * line. When specifying includes from the pom, use the {@link #includes} configuration instead. If this property is * specified then the {@link # include} configuration is ignored. * @@ -71,7 +71,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo /** * A comma separated list of artifact patterns to exclude. Follows the pattern - * "groupId:artifactId:type:classifier:version". Designed to allow specifing the set of excludes from the command + * "groupId:artifactId:type:classifier:version". Designed to allow specifying the set of excludes from the command * line. When specifying excludes from the pom, use the {@link #excludes} configuration instead. If this property is * specified then the {@link # exclude} configuration is ignored. * diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java index 7769801caf..b61ffa0e36 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java @@ -780,40 +780,47 @@ private Set getVersionsInRange( Property property, PropertyVersions vers protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) { - String label = null; - if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) + if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) { - label = getText( "report.latestMajor" ); + return getText( "report.latestSubIncremental" ); } - else if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) + + if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) { - label = getText( "report.nextMajor" ); + return getText( "report.nextVersion" ); } - else if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) + + if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) { - label = getText( "report.latestMinor" ); + return getText( "report.nextIncremental" ); } - else if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) + + if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) { - label = getText( "report.nextMinor" ); + return getText( "report.latestIncremental" ); } - else if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) + + if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) { - label = getText( "report.latestIncremental" ); + return getText( "report.nextMinor" ); } - else if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) + + if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) { - label = getText( "report.nextIncremental" ); + return getText( "report.latestMinor" ); } - else if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) + + if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) { - label = getText( "report.latestSubIncremental" ); + return getText( "report.nextMajor" ); } - else if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) + + if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) { - label = getText( "report.nextVersion" ); + return getText( "report.latestMajor" ); } - return label; + + return ""; } } diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 9b9b4dca77..15e7449670 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -356,6 +356,7 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver * @param versionRange The version range. * @param allowingSnapshots null for no override, otherwise the local override to apply. * @param usePluginRepositories Use plugin repositories + * @param allowDowngrade whether downgrades should be allowed * @return The latest version of the specified artifact that matches the specified version range or * null if no matching version could be found. * @throws ArtifactMetadataRetrievalException If the artifact metadata could not be found. @@ -515,6 +516,7 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * @param artifact The artifact. * @param currentVersion The current version of the artifact. * @param updateVersion The proposed new version of the artifact. + * @param forceUpdate if true, LATEST and RELEASE versions will be overwritten with the real version * @return true if the update should be applied to the pom. * @since 2.9 */ @@ -575,7 +577,7 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * @param allowMajorUpdates Allow major updates * @param allowMinorUpdates Allow minor updates * @param allowIncrementalUpdates Allow incremental updates - * @return Returns the segment (0-based) that is unchangable. If any segment can change, returns -1. + * @return Returns the segment (0-based) that is unchangeable. If any segment can change, returns -1. */ protected Optional determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, boolean allowIncrementalUpdates ) diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java index 4f16f7a43c..80b66a0607 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java @@ -65,7 +65,7 @@ public class DependencyUpdatesReport extends AbstractVersionsReport protected boolean processDependencyManagement; /** - * Whether to process the depdendencyManagement part transitive or not. + * Whether to process the dependencyManagement part transitive or not. * In case of <type>pom</type>and * <scope>import</scope> this means * by default to report also the imported dependencies. diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 22439e28c8..a34235cfa5 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -94,7 +94,7 @@ public class DisplayDependencyUpdatesMojo private boolean processDependencyManagement; /** - * Whether to process the depdendencyManagement part transitive or not. + * Whether to process the dependencyManagement part transitive or not. * In case of <type>pom</type>and * <scope>import</scope> this means * by default to report also the imported dependencies. @@ -691,12 +691,28 @@ private DependencyManagement getProjectDependencyManagement( MavenProject projec private Optional calculateUpdateScope() { - return !allowAnyUpdates - ? allowMajorUpdates ? of( MAJOR ) - : allowMinorUpdates ? of( MINOR ) - : allowIncrementalUpdates ? of( INCREMENTAL ) - : empty() - : empty(); + if ( !allowIncrementalUpdates && !allowMinorUpdates && !allowMajorUpdates && !allowAnyUpdates ) + { + throw new IllegalArgumentException( "One of: allowAnyUpdates, allowMajorUpdates, allowMinorUpdates, " + + "allowIncrementalUpdates must be true" ); + } + + if ( allowAnyUpdates && allowMajorUpdates && allowMinorUpdates ) + { + return empty(); + } + + if ( allowMajorUpdates && allowMinorUpdates ) + { + return of( MAJOR ); + } + + if ( allowMinorUpdates ) + { + return of( MINOR ); + } + + return of( INCREMENTAL ); } private void logUpdates( Map updates, String section ) diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 56205ecf8f..0305a2968c 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -402,9 +402,10 @@ public void execute() throws MojoExecutionException, MojoFailureException /** * Returns the incremented version, with the nextSnapshotIndexToIncrement indicating the 1-based index, - * conunting from the left, or the most major version component, of the version string. + * from the left, or the most major version component, of the version string. * * @param version input version + * @param nextSnapshotIndexToIncrement 1-based segment number to be incremented * @return version with the incremented index specified by nextSnapshotIndexToIncrement or last index * @throws MojoExecutionException thrown if the input parameters are invalid */ diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 1d03bcdc2c..2eac6fe7db 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -31,11 +31,13 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; +import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; import static java.util.Optional.empty; import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; /** * Base class for {@link org.codehaus.mojo.versions.api.VersionDetails}. @@ -171,7 +173,6 @@ private static Iterable reverse( T[] array ) public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots, boolean allowDowngrade ) { - final VersionComparator versionComparator = getVersionComparator(); // reverse( getVersions( ... ) ) will contain versions sorted from latest to oldest, // so we only need to find the first candidate fulfilling the criteria for ( ArtifactVersion candidate : reverse( getVersions( includeSnapshots ) ) ) @@ -260,13 +261,22 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional< throws InvalidSegmentException { ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); - ArtifactVersion lowerBound = - allowDowngrade ? getLowerBoundArtifactVersion( currentVersion, upperBoundSegment ) : currentVersion; - ArtifactVersion upperBound = !upperBoundSegment.isPresent() ? null - : getVersionComparator().incrementSegment( lowerBound, upperBoundSegment.get() ); + ArtifactVersion lowerBound = allowDowngrade + ? getLowerBound( currentVersion, upperBoundSegment ) + .map( DefaultArtifactVersion::new ) + .orElse( null ) + : currentVersion; + ArtifactVersion upperBound = + !upperBoundSegment.isPresent() + ? null + : upperBoundSegment + .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, + s.isMajorTo( SUBINCREMENTAL ) + ? Segment.of( s.value() + 1 ) + : s ) ) + .orElse( null ); Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); - // TODO shouldn't allowDowngrade boolean be passed to this call ? return getVersions( restriction, includeSnapshots ); } @@ -346,7 +356,8 @@ public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Op { try { - return getOldestVersion( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + return getOldestVersion( getVersionComparator().restrictionFor( currentVersion, updateScope ), + includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -359,7 +370,8 @@ public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Op { try { - return getNewestVersion( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + return getNewestVersion( getVersionComparator().restrictionFor( currentVersion, updateScope ), + includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -372,7 +384,8 @@ public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Op { try { - return getVersions( restrictionFor( currentVersion, updateScope ), includeSnapshots ); + return getVersions( getVersionComparator().restrictionFor( currentVersion, updateScope ), + includeSnapshots ); } catch ( InvalidSegmentException e ) { @@ -433,32 +446,12 @@ public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean inclu return getVersions( versionRange, restriction, includeSnapshots ); } - /** - * Returns the lower bound version based on the given artifact version - * and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, - * implying that there is also no string designation of the lower bound version. - * - * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed - * @param unchangedSegment first segment not to be changed; empty() means any segment can change - * @return {@link ArtifactVersion} the lowest artifact version with the given segment held or null if no such - * version can be found - * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than - * the segment count) - */ - protected ArtifactVersion getLowerBoundArtifactVersion( ArtifactVersion version, - Optional unchangedSegment ) - throws InvalidSegmentException - { - Optional lowerBound = getLowerBound( version, unchangedSegment ); - return lowerBound.map( DefaultArtifactVersion::new ).orElse( null ); - } - /** * Returns the string designation of the lower bound version based on the given artifact version * and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, * implying that there is also no string designation of the lower bound version. * - * @param version {@link ArtifactVersion} object specyfing the verion for which the lower bound is being computed + * @param version {@link ArtifactVersion} object specifying the version for which the lower bound is being computed * @param unchangedSegment first segment not to be changed; empty() means anything can change * @return {@link Optional} string containing the lowest artifact version with the given segment held * @throws InvalidSegmentException if the requested segment is outside of the bounds (less than 1 or greater than @@ -527,26 +520,4 @@ private boolean isVersionInRestriction( Restriction restriction, ArtifactVersion } return ( includeLower || lower != 0 ) && ( includeUpper || upper != 0 ); } - - /** - * Helper method to get the artifact boundaries for computing updates - * - * @param currentVersion The current version. - * @param scope scope of the restriction or Optional.empty() for no restriction - * @return {@linkplain Restriction} object based on the arguments - * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) - */ - protected Restriction restrictionFor( ArtifactVersion currentVersion, Optional scope ) - throws InvalidSegmentException - { - VersionComparator versionComparator = getVersionComparator(); - ArtifactVersion lowerBound = scope.isPresent() && scope.get().value() < Segment.SUBINCREMENTAL.value() - ? versionComparator.incrementSegment( currentVersion, scope.get() ) - : currentVersion; - ArtifactVersion upperBound = scope.isPresent() && scope.get().value() > Segment.MAJOR.value() - ? versionComparator.incrementSegment( currentVersion, Segment.of( scope.get().value() - 1 ) ) - : null; - return new Restriction( lowerBound, lowerBound != currentVersion, - upperBound, false ); - } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 74a344b169..8c66929c67 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -1476,9 +1476,10 @@ public static String getGroupId( Model model ) * Finds the local root of the specified project. * * @param project The project to find the local root for. + * @param builder {@linkplain MavenProjectBuilder} object * @param localRepository the local repo. * @param globalProfileManager the global profile manager. - * @param logger The logger to log to. + * @param logger The logger to log tog * @return The local root (note this may be the project passed as an argument). */ public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project, diff --git a/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/src/main/java/org/codehaus/mojo/versions/api/Segment.java index c329898914..f72acdf223 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/Segment.java +++ b/src/main/java/org/codehaus/mojo/versions/api/Segment.java @@ -26,14 +26,7 @@ */ public enum Segment implements Comparable { - MAJOR( 0 ), MINOR( 1 ), INCREMENTAL( 2 ), SUBINCREMENTAL( 3 ); - - private final int index; - - Segment( int index ) - { - this.index = index; - } + MAJOR, MINOR, INCREMENTAL, SUBINCREMENTAL; /** * Returns the 0-based sendex index @@ -42,20 +35,26 @@ public enum Segment implements Comparable */ public int value() { - return index; + return ordinal(); } public static Segment of( int index ) { - switch ( index ) + if ( index < 0 || index > 3 ) { - case 0: return MAJOR; - case 1: return MINOR; - case 2: return INCREMENTAL; - case 3: return SUBINCREMENTAL; - default: - throw new IllegalArgumentException( "Wrong segment index: " + index ); + throw new IllegalArgumentException( "Wrong segment index: " + index ); } + return values()[index]; + } + + /** + * Returns true if the given segment is more major than the other + * @param other other segment to compare + * @return true if the given segment is more major + */ + public boolean isMajorTo( Segment other ) + { + return value() < other.value(); } @Override diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 26e63e4fc1..60b48fe1a9 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -221,6 +221,7 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * @param includeSnapshots true if snapshots are to be included. * @return the oldest version after currentVersion within the specified update scope or null if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, @@ -235,6 +236,7 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optionaltrue if snapshots are to be included. * @return the newest version after currentVersion within the specified update scope or null if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, @@ -247,6 +249,7 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optionaltrue if snapshots are to be included. * @return the all versions after currentVersion within the specified update scope. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, @@ -295,6 +298,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optionalnull if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getOldestUpdate( Optional updateScope ) throws InvalidSegmentException; @@ -306,6 +310,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optionalnull if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getNewestUpdate( Optional updateScope ) throws InvalidSegmentException; @@ -315,6 +320,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; @@ -327,6 +333,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optionaltrue if snapshots are to be included. * @return the oldest version after currentVersion within the specified update scope or null if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) @@ -340,6 +347,7 @@ ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeS * @param includeSnapshots true if snapshots are to be included. * @return the newest version after currentVersion within the specified update scope or null if no * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) @@ -351,6 +359,7 @@ ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeS * @param updateScope the update scope to include. * @param includeSnapshots true if snapshots are to be included. * @return the all versions after currentVersion within the specified update scope. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 773914180a..1baeea0a35 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -59,8 +59,17 @@ public final int getSegmentCount( ArtifactVersion v ) */ public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), - segment ) ); + if ( VersionComparators.isSnapshot( v ) ) + { + return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), + segment ) ); + } + int segmentCount = getSegmentCount( v ); + if ( segment.value() >= segmentCount ) + { + throw new InvalidSegmentException( segment, segmentCount, v ); + } + return innerIncrementSegment( v, segment ); } protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java b/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java new file mode 100644 index 0000000000..2f923668e6 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java @@ -0,0 +1,93 @@ +package org.codehaus.mojo.versions.ordering; + +import java.util.Iterator; +import java.util.List; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; + +import static org.codehaus.mojo.versions.ordering.ComparableVersion.IntegerItem.ZERO; + +/** + *

    Represents an artifact version with all segments more major or equal to a given segment + * held in place. It can be thought of as an artifact having +∞ as its upper bound + * on all segments less major than the held segment.

    + *

    When compared with another artifact versions, this results with the other object + * with the segment versions up to the held segment being equal, + * always comparing lower than this object.

    + *

    This is particularly helpful for -SNAPSHOT and other versions with qualifiers, which + * are lower than version 0 in the Maven versioning system.

    + */ +public class BoundArtifactVersion extends DefaultArtifactVersion +{ + /** + * Most major segment that can change, i.e. not held in place. + * All segments that are more major than this one are held in place. + */ + private final Segment segment; + + private final BoundComparableVersion comparator; + + /** + * Constructs the instance + * @param artifactVersion artifact version containing the segment version values + * @param segment most major segment that can change, i.e. not held in place + */ + public BoundArtifactVersion( ArtifactVersion artifactVersion, Segment segment ) + { + super( artifactVersion.toString() ); + this.segment = segment; + this.comparator = new BoundComparableVersion( this ); + } + + /** + * Returns the most major segment that can change. + * All segments that are more major than this one are held in place. + * @return segment that can change + */ + public Segment getSegment() + { + return segment; + } + + @Override + public int compareTo( ArtifactVersion other ) + { + if ( other == null ) + { + return -1; + } + + return comparator.compareTo( new ComparableVersion( other.toString() ) ); + } + + protected static class BoundComparableVersion extends ComparableVersion + { + private BoundArtifactVersion artifactVersion; + protected BoundComparableVersion( BoundArtifactVersion artifactVersion ) + { + super( artifactVersion.toString() ); + this.artifactVersion = artifactVersion; + } + + @Override + public int compareTo( ComparableVersion o ) + { + return compareTo( ( (List) items ).iterator(), + ( (Iterable) o.items ).iterator(), artifactVersion.segment.value() ); + + } + + @SuppressWarnings( "checkstyle:InnerAssignment" ) + private int compareTo( Iterator left, Iterator right, int comparisonLimit ) + { + int r; + return !( comparisonLimit > 0 && right.hasNext() ) + ? 1 + : ( r = -( right.next().compareTo( left.hasNext() ? left.next() : ZERO ) ) ) != 0 + ? r + : compareTo( left, right, comparisonLimit - 1 ); + } + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java index 9cb107f6a3..55327cfaf3 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java @@ -43,9 +43,9 @@ public class ComparableVersion private String canonical; - private ListItem items; + protected ListItem items; - private interface Item + protected interface Item { int INTEGER_ITEM = 0; @@ -63,10 +63,10 @@ private interface Item /** * Represents a numeric item in the version item list. */ - private static class IntegerItem + protected static class IntegerItem implements Item { - private static final BigInteger BIG_INTEGEGER_ZERO = new BigInteger( "0" ); + private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" ); private final BigInteger value; @@ -74,7 +74,7 @@ private static class IntegerItem private IntegerItem() { - this.value = BIG_INTEGEGER_ZERO; + this.value = BIG_INTEGER_ZERO; } IntegerItem( String str ) @@ -89,14 +89,14 @@ public int getType() public boolean isNull() { - return BIG_INTEGEGER_ZERO.equals( value ); + return BIG_INTEGER_ZERO.equals( value ); } public int compareTo( Item item ) { if ( item == null ) { - return BIG_INTEGEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 + return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } switch ( item.getType() ) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index c0bc1c2682..c4f5332ed9 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -38,6 +38,10 @@ public class MavenVersionComparator extends AbstractVersionComparator */ public int compare( ArtifactVersion o1, ArtifactVersion o2 ) { + if ( o1 instanceof BoundArtifactVersion ) + { + return o1.compareTo( o2 ); + } return new ComparableVersion( o1.toString() ).compareTo( new ComparableVersion( o2.toString() ) ); } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 08d3973a78..50edfe7e89 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -20,10 +20,15 @@ */ import java.util.Comparator; +import java.util.Optional; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.codehaus.mojo.versions.api.Segment; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * A rule for comparing and manipulating versions. */ @@ -49,4 +54,30 @@ public interface VersionComparator * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) */ ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, Segment segment ) throws InvalidSegmentException; + + /** + *

    Returns a {@linkplain Restriction} object for computing version upgrades + * with the given segment allowing updates, with all more major segments locked in place.

    + *

    The resulting restriction could be thought of as one + * retaining the versions on positions up to the held position, + * the position right after the position held in place will be incremented by one, + * and on all positions which are more minor than that, the range would contain -∞ + * for the bottom bound and +∞ for the above bound.

    + *

    This will allow matching the required versions while not matching versions which are considered + * inferior than the zeroth version, i.e. versions with a qualifier.

    + * + * @param currentVersion The current version. + * @param scope most major segment where updates are allowed Optional.empty() for no restriction + * @return {@linkplain Restriction} object based on the arguments + */ + default Restriction restrictionFor( ArtifactVersion currentVersion, Optional scope ) + throws InvalidSegmentException + { + ArtifactVersion nextVersion = scope.isPresent() && scope.get().isMajorTo( SUBINCREMENTAL ) + ? incrementSegment( currentVersion, scope.get() ) + : currentVersion; + return new Restriction( nextVersion, nextVersion != currentVersion, scope.filter( MAJOR::isMajorTo ) + .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ).orElse( null ), + false ); + } } diff --git a/src/site/apt/examples/advancing-dependency-versions.apt.vm b/src/site/apt/examples/advancing-dependency-versions.apt.vm index 2db59aba9b..cf9eeb4f9f 100644 --- a/src/site/apt/examples/advancing-dependency-versions.apt.vm +++ b/src/site/apt/examples/advancing-dependency-versions.apt.vm @@ -72,13 +72,13 @@ Goal Matrix The columns in the above goal matrix are as follows: - * when scanning the <<>> for depenendency to update, include those dependencies which + * when scanning the <<>> for dependency to update, include those dependencies which are for release versions (i.e. non-SNAPSHOT versions). - * when scanning the <<>> for depenendency to update, include those dependencies which + * when scanning the <<>> for dependency to update, include those dependencies which are for -SNAPSHOT versions. - * when building the list of newer versions of a dependency, include release versions (i.e. non-SNAPSHOT + * when building the list of newer versions of a dependency, include release versions (i.e. non-SNAPSHOT versions) in the list. * when building the list of newer versions of a dependency, include -SNAPSHOT versions in the list. diff --git a/src/site/apt/examples/display-plugin-updates.apt b/src/site/apt/examples/display-plugin-updates.apt index fbecd09ddd..2ad794cf6b 100644 --- a/src/site/apt/examples/display-plugin-updates.apt +++ b/src/site/apt/examples/display-plugin-updates.apt @@ -88,7 +88,7 @@ mvn versions:display-plugin-updates The plugin will also warn if you have not specified the versions of any plugins that you are using and tell you what version you are currently using. Best practice in Maven is to always specify the plugin versions in order to - ensure that builds are reproducable. + ensure that builds are reproducible. For example the following <<>>: diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java index 12c149f223..cd99c1d250 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java @@ -24,9 +24,11 @@ import java.io.OutputStream; import java.util.Arrays; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.Locale; import java.util.Set; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Dependency; @@ -55,6 +57,7 @@ */ public class DependencyUpdatesReportTest { + private static class TestDependencyUpdatesReport extends DependencyUpdatesReport { @SuppressWarnings( "deprecation" ) @@ -128,6 +131,12 @@ public TestDependencyUpdatesReport withIgnoredVersions( this.ignoredVersions = ignoredVersions; return this; } + + public TestDependencyUpdatesReport withArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource ) + { + this.artifactMetadataSource = artifactMetadataSource; + return this; + } } private static Dependency dependencyOf( String artifactId ) @@ -223,4 +232,43 @@ public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, String output = os.toString().replaceAll( "\n", "" ); assertThat( output, containsString( "report.noUpdatesAvailable" ) ); } + + + @Test + public void testSubincrementalUpdates() + throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReport() + .withDependencies( DependencyBuilder.newBuilder() + .withGroupId( "localhost" ) + .withArtifactId( "dummy-api" ) + .withVersion( "1.1" ) + .withScope( SCOPE_COMPILE ) + .withType( "jar" ) + .build() ) + .withArtifactMetadataSource( mockArtifactMetadataSource( new LinkedHashMap() + {{ + put( "dummy-api", new String[] { "1.0.1", "1.0", "1.1.0-2", "1.1.1", "1.1.1-2", "1.1.2", + "1.1.2-SNAPSHOT", "1.1.3", "1.1", "1.1-SNAPSHOT", "1.2.1", "1.2.2", "1.2", "1.3", + "1.9.1-SNAPSHOT", "2.0", "2.1.1-SNAPSHOT", "2.1", "3.0", "3.1.1-SNAPSHOT", + "3.1.5-SNAPSHOT", "3.4.0-SNAPSHOT"} ); + }} ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString() + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ); + assertThat( output, containsString( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.3 1.3 3.0" ) ); + assertThat( output, containsString( "1.1.0-2 report.latestSubIncremental" ) ); + assertThat( output, containsString( "1.1.1 report.nextIncremental" ) ); + assertThat( output, containsString( "1.1.3 report.latestIncremental" ) ); + assertThat( output, containsString( "1.2 report.nextMinor" ) ); + assertThat( output, containsString( "1.3 report.latestMinor" ) ); + assertThat( output, containsString( "2.0 report.nextMajor" ) ); + assertThat( output, containsString( "3.0 report.latestMajor" ) ); + } + } diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index e7ec9d8633..6fe8c5b82d 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -20,24 +20,37 @@ */ import java.io.File; +import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.HashMap; import java.util.List; +import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.plugin.testing.MojoRule; +import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; +import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.model.TestIgnoreVersions; +import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; import static org.codehaus.mojo.versions.model.TestIgnoreVersions.TYPE_REGEX; import static org.codehaus.mojo.versions.model.TestIgnoreVersions.matches; import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItem; @@ -114,4 +127,107 @@ public void testRuleSetPresentAndWorking() throws Exception assert outputFile == null || !outputFile.exists() || outputFile.delete(); } } + + private MavenProject createProject() + { + return new MavenProject( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "default-artifact" ); + setVersion( "1.0.0-SNAPSHOT" ); + + setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "default-dependency" ) + .withVersion( "1.0.0" ) + .build() ) ); + }} ) + {{ + setOriginalModel( getModel() ); + }}; + } + + @Test + public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException + { + Path tempPath = null; + try + { + tempPath = Files.createTempFile( "display-dependency-updates", "" ); + final File tempFile = tempPath.toFile(); + new DisplayDependencyUpdatesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", + "2.0.0-rc1"} ); + }} ), null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + {{ + setProject( createProject() ); + setVariableValueToObject( this, "allowMinorUpdates", true ); + setVariableValueToObject( this, "processDependencies", true ); + setVariableValueToObject( this, "dependencyIncludes", + singletonList( WildcardMatcher.WILDCARD ) ); + setVariableValueToObject( this, "dependencyExcludes", emptyList() ); + this.allowSnapshots = true; + this.outputFile = tempFile; + setPluginContext( new HashMap<>() ); + }}.execute(); + + assertThat( String.join( "", Files.readAllLines( tempPath ) ), + not( anyOf( containsString( "2.0.0-SNAPSHOT" ), + containsString( "2.0.0-beta" ), + containsString( "2.0.0-rc1" ) ) ) ); + } + finally + { + if ( tempPath != null && Files.exists( tempPath ) ) + { + Files.delete( tempPath ); + } + } + } + + @Test + public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException + { + Path tempPath = null; + try + { + tempPath = Files.createTempFile( "display-dependency-updates", "" ); + final File tempFile = tempPath.toFile(); + new DisplayDependencyUpdatesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", + "1.9.0-rc1"} ); + }} ), null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + {{ + setProject( createProject() ); + setVariableValueToObject( this, "allowIncrementalUpdates", true ); + setVariableValueToObject( this, "processDependencies", true ); + setVariableValueToObject( this, "dependencyIncludes", + singletonList( WildcardMatcher.WILDCARD ) ); + setVariableValueToObject( this, "dependencyExcludes", emptyList() ); + this.allowSnapshots = true; + this.outputFile = tempFile; + setPluginContext( new HashMap<>() ); + }}.execute(); + + assertThat( String.join( "", Files.readAllLines( tempPath ) ), + not( anyOf( containsString( "1.9.0-SNAPSHOT" ), + containsString( "1.9.0-beta" ), + containsString( "1.9.0-rc1" ) ) ) ); + } + finally + { + if ( tempPath != null && Files.exists( tempPath ) ) + { + Files.delete( tempPath ); + } + } + } } diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java new file mode 100644 index 0000000000..beb93a2b89 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -0,0 +1,106 @@ +package org.codehaus.mojo.versions; + +import javax.xml.stream.XMLStreamException; + +import java.util.HashMap; + +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.hamcrest.Matchers; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; + +import static java.util.Collections.singletonList; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.when; + +@SuppressWarnings( "deprecation" ) +public class UseLatestReleasesMojoTest +{ + private UseLatestReleasesMojo mojo; + private TestChangeRecorder changeRecorder; + + @Before + public void setUp() throws Exception + { + RepositorySystem repositorySystemMock = mock( RepositorySystem.class ); + when( repositorySystemMock.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), + dependency.getScope(), dependency.getType(), + dependency.getClassifier() != null ? dependency.getClassifier() : "default", null ); + } ); + + ArtifactMetadataSource artifactMetadataSourceMock = mockArtifactMetadataSource( new HashMap() + {{ + put( "dependency-artifact", new String[] {"0.9.0", "1.0.0-beta"} ); + }} ); + + mojo = new UseLatestReleasesMojo( repositorySystemMock, + null, + artifactMetadataSourceMock, + null, + null ) + {{ + MavenProject project = new MavenProject() + {{ + setModel( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "project-artifact" ); + setVersion( "1.0.0-SNAPSHOT" ); + + setDependencies( singletonList( + DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "dependency-artifact" ) + .withVersion( "0.9.0" ) + .withScope( SCOPE_COMPILE ) + .withType( "jar" ) + .withClassifier( "default" ) + .build() ) ); + }} ); + }}; + setProject( project ); + + changeRecorder = new TestChangeRecorder(); + setVariableValueToObject( this, "changeRecorder", changeRecorder ); + }}; + } + + @Test + public void testDontUpgradeToBeta() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "allowSnapshots", false ); + setVariableValueToObject( mojo, "allowMajorUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), Matchers.empty() ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index ac72d98996..1cc1d974d2 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -31,10 +31,14 @@ import org.hamcrest.Matchers; import org.junit.Test; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; public class ArtifactVersionsTest { @@ -105,4 +109,21 @@ private ArtifactVersion[] versions( String... versions ) } return artifactVersions; } + + @Test + public void testReportLabels() + { + ArtifactVersion[] versions = versions( "1.0.1", "1.0", "1.1.0-2", "1.1.1", "1.1.1-2", "1.1.2", + "1.1.2-SNAPSHOT", "1.1.3", "1.1", "1.1-SNAPSHOT", "1.2.1", "1.2.2", "1.2", "1.3", + "1.9.1-SNAPSHOT", "2.0", "2.1.1-SNAPSHOT", "2.1", "3.0", "3.1.1-SNAPSHOT", + "3.1.5-SNAPSHOT", "3.4.0-SNAPSHOT" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.1", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + + assertThat( instance.getNewestUpdate( of( SUBINCREMENTAL ) ).toString(), is( "1.1.0-2" ) ); + assertThat( instance.getOldestUpdate( of( INCREMENTAL ) ).toString(), is( "1.1.1" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index 4b520f7c28..8edc29b3d1 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -19,14 +19,19 @@ * under the License. */ +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; import static org.codehaus.mojo.versions.api.Segment.MAJOR; import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.lessThan; +import static org.hamcrest.core.Is.is; public class MavenVersionComparatorTest { @@ -36,12 +41,12 @@ public class MavenVersionComparatorTest public void testSegmentCounting() throws Exception { - assertEquals( 3, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); - assertEquals( 3, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); - assertEquals( 4, instance.getSegmentCount( new DefaultArtifactVersion( "5-0" ) ) ); - assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5.3.a" ) ) ); - assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5.0.a.1.4.5" ) ) ); - assertEquals( 3, instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ); + assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ) ); + assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ) ); + assertThat( 4, is( instance.getSegmentCount( new DefaultArtifactVersion( "5-0" ) ) ) ); + assertThat( 1, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.3.a" ) ) ) ); + assertThat( 1, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.0.a.1.4.5" ) ) ) ); + assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ) ); } @Test @@ -55,15 +60,48 @@ public void testSegmentIncrementing() throws InvalidSegmentException assertIncrement( "5.alpha-1.2", "5.alpha-1.1", MAJOR ); assertIncrement( "5.alpha-1.ba", "5.alpha-1.az", MAJOR ); assertIncrement( "5.alpha-wins.2", "5.alpha-wins.1", MAJOR ); - assertIncrement( "1.0-alpha-3", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-alpha-90", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-za", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-z90", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); + assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); } private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException { - assertEquals( expected + "-SNAPSHOT", - instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); + assertThat( instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString(), + is( expected ) ); + } + + @Test + public void testUpperBoundaryCustom() + { + assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3" ), + INCREMENTAL ), new DefaultArtifactVersion( "1.2.3-ANDRZEJ" ) ), greaterThan( 0 ) ); + } + + @Test + public void testUpperBoundaryRelease() + { + assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.1.0" ), + INCREMENTAL ), new DefaultArtifactVersion( "1.1.0" ) ), greaterThan( 0 ) ); + } + + @Test + public void testUpperBoundarySnapshot() + { + assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.1.0" ), + INCREMENTAL ), new DefaultArtifactVersion( "1.1.0-SNAPSHOT" ) ), greaterThan( 0 ) ); + } + + @Test + public void testScopeLessThanNumSegmentsUpper() + { + ArtifactVersion artifactVersion = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + SUBINCREMENTAL ); + assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.0.1" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1.0-2" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1.1-2" ) ), lessThan( 0 ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index 4d64da3a24..27d75f4d17 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; @@ -46,19 +45,21 @@ public void testSegmentCounting() throws Exception @Test public void testSegmentIncrementing() throws Exception { - assertIncrement( "6", "5", MAJOR ); - assertIncrement( "6.0", "5.0", MAJOR ); - assertIncrement( "5.1", "5.0", MINOR ); - assertIncrement( "5.1.0", "5.0.1", MINOR ); - assertIncrement( "5.beta.0", "5.alpha.1", MINOR ); - assertIncrement( "5.beta-0.0", "5.alpha-1.1", MINOR ); - assertIncrement( "5.alpha-2.0", "5.alpha-1.1", INCREMENTAL ); - assertIncrement( "5.beta-0.0", "5.alpha-wins.1", MINOR ); - } - - private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException - { - assertEquals( expected + "-SNAPSHOT", - instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); + assertEquals( new DefaultArtifactVersion( "6" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index d437aa62ca..58fb889516 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; @@ -106,19 +105,22 @@ public void testSegmentCounting() @Test public void testSegmentIncrementing() throws Exception { - assertIncrement( "6", "5", MAJOR ); - assertIncrement( "6.0", "5.0", MAJOR ); - assertIncrement( "5.1", "5.0", MINOR ); - assertIncrement( "5.1.0", "5.0.1", MINOR ); - assertIncrement( "5.beta.0", "5.alpha.1", MINOR ); - assertIncrement( "5.alpha-2.0", "5.alpha-1.1", MINOR ); - assertIncrement( "5.alpha-1.2", "5.alpha-1.1", INCREMENTAL ); - assertIncrement( "5.beta.0", "5.alpha-wins.1", MINOR ); - } - - private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException - { - assertEquals( expected + "-SNAPSHOT", - instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString() ); + assertEquals( new DefaultArtifactVersion( "6" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); + assertEquals( new DefaultArtifactVersion( "5.alpha-1.2" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ) + .toString() ); + assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java index efc108dd25..991a944098 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -32,6 +32,7 @@ import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.doxia.tools.SiteToolException; import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.i18n.I18N; @@ -124,7 +125,7 @@ public static RepositorySystem mockRepositorySystem() Dependency dependency = invocation.getArgument( 0 ); return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier(), null ); + dependency.getClassifier(), new DefaultArtifactHandlerStub( "default" ) ); } ); return repositorySystem; } From 720ff9e5e925e1eb0722065b3eae5713e7a0a135 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 3 Oct 2022 17:44:49 +0200 Subject: [PATCH 143/441] #729: Ignoring the flipper. This test should be used for profiling and not as part of integration testing --- pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pom.xml b/pom.xml index 741d55aac1..cc32d2d4e2 100644 --- a/pom.xml +++ b/pom.xml @@ -368,6 +368,16 @@ */pom.xml + + + it-property-updates-report-002-slow/* + verify ${repository.proxy.url} From 3063fd0e9104ade489100898a3861fb2269717c3 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 3 Oct 2022 07:07:39 +0200 Subject: [PATCH 144/441] #725: Migrating index.apt to markdown --- src/site/apt/index.apt | 174 ------------------------------------- src/site/markdown/index.md | 125 ++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 174 deletions(-) delete mode 100644 src/site/apt/index.apt create mode 100644 src/site/markdown/index.md diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt deleted file mode 100644 index e95618a672..0000000000 --- a/src/site/apt/index.apt +++ /dev/null @@ -1,174 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ------ - Introduction - ------ - Stephen Connolly - ------ - 2009-04-21 - ------ - - -Versions Maven Plugin - - The Versions Plugin is used when you want to manage the versions of artifacts in a project's POM. - -* Goals Overview - - The Versions Plugin has the following goals. - - * {{{./compare-dependencies-mojo.html}versions:compare-dependencies}} compares the dependency versions of the current - project to the dependency management section of a remote project. - - * {{{./display-dependency-updates-mojo.html}versions:display-dependency-updates}} scans a project's dependencies and - produces a report of those dependencies which have newer versions available. - - * {{{./display-plugin-updates-mojo.html}versions:display-plugin-updates}} scans a project's plugins and produces a - report of those plugins which have newer versions available, taking care of Maven version prerequisites. - - * {{{./display-property-updates-mojo.html}versions:display-property-updates}} scans a project and produces a report of - those properties which are used to control artifact versions and which properties have newer versions available. - - * {{{./update-parent-mojo.html}versions:update-parent}} updates the parent section of a project so that it references the - newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need - to ensure you are using the latest version of the corporate root POM. - - * {{{./update-properties-mojo.html}versions:update-properties}} updates properties defined in a project so that they - correspond to the latest available version of specific dependencies. This can be useful if a suite of dependencies - must all be locked to one version. - - * {{{./update-property-mojo.html}versions:update-property}} Sets a property to the latest version in a given range of - associated artifacts. - - * {{{./update-child-modules-mojo.html}versions:update-child-modules}} updates the parent section of the child modules - of a project so the version matches the version of the current project. For example, if you have an aggregator pom - that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this - mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to - run this goal if your project is broken so badly that it cannot build because of the version mis-match). - - * {{{./lock-snapshots-mojo.html}versions:lock-snapshots}} searches the pom for all -SNAPSHOT versions and replaces them - with the current timestamp version of that -SNAPSHOT, e.g. -20090327.172306-4 - - * {{{./unlock-snapshots-mojo.html}versions:unlock-snapshots}} searches the pom for all timestamp locked snapshot versions - and replaces them with -SNAPSHOT. - - * {{{./resolve-ranges-mojo.html}versions:resolve-ranges}} finds dependencies using version ranges and resolves the range - to the specific version being used. - - * {{{./set-mojo.html}versions:set}} can be used to set the project version from the command line. - - * {{{./set-property-mojo.html}versions:set-property}} can be used to set one or multiple properties to a given version from the command line. - - * {{{./use-releases-mojo.html}versions:use-releases}} searches the pom for all -SNAPSHOT versions which have been - released and replaces them with the corresponding release version. - - * {{{./use-next-releases-mojo.html}versions:use-next-releases}} searches the pom for all non-SNAPSHOT versions which - have been a newer release and replaces them with the next release version. - - * {{{./use-latest-releases-mojo.html}versions:use-latest-releases}} searches the pom for all non-SNAPSHOT versions which - have been a newer release and replaces them with the latest release version. - - * {{{./use-next-snapshots-mojo.html}versions:use-next-snapshots}} searches the pom for all non-SNAPSHOT versions which - have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version. - - * {{{./use-latest-snapshots-mojo.html}versions:use-latest-snapshots}} searches the pom for all non-SNAPSHOT versions - which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version. - - * {{{./use-next-versions-mojo.html}versions:use-next-versions}} searches the pom for all versions which - have been a newer version and replaces them with the next version. - - * {{{./use-latest-versions-mojo.html}versions:use-latest-versions}} searches the pom for all versions which - have been a newer version and replaces them with the latest version. - - * {{{./use-dep-version-mojo.html}versions:use-dep-version}} updates a dependency to a specific version. - - * {{{./commit-mojo.html}versions:commit}} removes the <<>> files. Forms one half of the - built-in "Poor Man's SCM". - - * {{{./revert-mojo.html}versions:revert}} restores the <<>> files from the <<>> files. - Forms one half of the built-in "Poor Man's SCM". - -* Reporting goals overview - - The Versions Plugin has the following reporting goals. - - * {{{./dependency-updates-report-mojo.html}versions:dependency-updates-report}} produces a report of those - project dependencies which have newer versions available. - - * {{{./plugin-updates-report-mojo.html}versions:plugin-updates-report}} produces a report of those plugins which have - newer versions available. - - * {{{./property-updates-report-mojo.html}versions:property-updates-report}} produces a report of - those properties which are used to control artifact versions and which properties have newer versions available. - - * {{{./parent-updates-report-mojo.html}versions:parent-updates-report}} produces a report on possible parent artifact - upgrades. - -* Usage - - General instructions on how to use the Versions Plugin can be found on the {{{./usage.html}usage page}}. Some more - specific use cases are described in the examples given below. Last but not least, users occasionally contribute - additional examples, tips or errata to the - {{{http://docs.codehaus.org/display/MAVENUSER/Versions+Plugin}plugin's wiki page}}. - - In case you still have questions regarding the plugin's usage, please have a look at the {{{./faq.html}FAQ}} and feel - free to contact the {{{./mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could - already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching - the {{{./mail-lists.html}mail archive}}. - - If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our - {{{./issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your - concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, - entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. - Of course, patches are welcome, too. Contributors can check out the project from our - {{{./source-repository.html}source repository}} and will find supplementary information in the - {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. - -* Examples - - To provide you with better understanding of some usages of the Plugin Name, - you can take a look into the following examples: - - * {{{./examples/advancing-dependency-versions.html}Advancing dependency versions}} - - * {{{./examples/compare-dependencies.html}Compare project dependencies to a remote project}} - - * {{{./examples/display-dependency-updates.html}Checking for new dependency updates}} - - * {{{./examples/display-plugin-updates.html}Checking for new plugin updates}} - - * {{{./examples/display-property-updates.html}Checking for new property-linked updates}} - - * {{{./examples/update-parent.html}Updating the Parent version}} - - * {{{./examples/update-properties.html}Updating a version specified in a property}} - - * {{{./examples/update-child-modules.html}Fixing a multi-module build}} - - * {{{./examples/resolve-ranges.html}Resolve version ranges}} - - * {{{./examples/lock-snapshots.html}Locking snapshot dependencies}} - - * {{{./examples/unlock-snapshots.html}Unlocking snapshot dependencies}} - - * {{{./examples/use-releases.html}Replacing -SNAPSHOT versions with their corresponding releases}} - - * {{{./examples/set.html}Changing the project version}} - - * {{{./examples/recording-changes.html}Recording version changes}} - diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md new file mode 100644 index 0000000000..f3d14bada3 --- /dev/null +++ b/src/site/markdown/index.md @@ -0,0 +1,125 @@ +title: Introduction +autor: Stephen Connolly +date: 2009-04-21 + + + +# Versions Maven Plugin + +The Versions Plugin is used when you want to manage the versions of artifacts in a project's POM. + +## Goals Overview + +The Versions Plugin has the following goals. +* [versions:compare-dependencies](./compare-dependencies-mojo.html) compares the dependency versions of the current + project to the dependency management section of a remote project. +* [versions:display-dependency-updates](./display-dependency-updates-mojo.html) scans a project's dependencies and + produces a report of those dependencies which have newer versions available. +* [versions:display-plugin-updates](./display-plugin-updates-mojo.html) scans a project's plugins and produces a + report of those plugins which have newer versions available, taking care of Maven version prerequisites. +* [versions:display-property-updates](./display-property-updates-mojo.html) scans a project and produces a report of + those properties which are used to control artifact versions and which properties have newer versions available. +* [versions:update-parent](./update-parent-mojo.html) updates the parent section of a project so that it references the + newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need + to ensure you are using the latest version of the corporate root POM. +* [versions:update-properties](./update-properties-mojo.html) updates properties defined in a project so that they + correspond to the latest available version of specific dependencies. This can be useful if a suite of dependencies + must all be locked to one version. +* [versions:update-property](./update-property-mojo.html) Sets a property to the latest version in a given range of + associated artifacts. +* [versions:update-child-modules](./update-child-modules-mojo.html) updates the parent section of the child modules + of a project so the version matches the version of the current project. For example, if you have an aggregator pom + that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this + mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to + run this goal if your project is broken so badly that it cannot build because of the version mis-match). +* [versions:lock-snapshots](./lock-snapshots-mojo.html) searches the pom for all -SNAPSHOT versions and replaces them + with the current timestamp version of that -SNAPSHOT, e.g. -20090327.172306-4 +* [versions:unlock-snapshots](./unlock-snapshots-mojo.html) searches the pom for all timestamp locked snapshot versions + and replaces them with -SNAPSHOT. +* [versions:resolve-ranges](./resolve-ranges-mojo.html) finds dependencies using version ranges and resolves the range + to the specific version being used. +* [versions:set](./set-mojo.html) can be used to set the project version from the command line. +* [versions:set-property](./set-property-mojo.html) can be used to set one or multiple properties to a given version from the command line. +* [versions:use-releases](./use-releases-mojo.html) searches the pom for all -SNAPSHOT versions which have been + released and replaces them with the corresponding release version. +* [versions:use-next-releases](./use-next-releases-mojo.html) searches the pom for all non-SNAPSHOT versions which + have been a newer release and replaces them with the next release version. +* [versions:use-latest-releases](./use-latest-releases-mojo.html) searches the pom for all non-SNAPSHOT versions which + have been a newer release and replaces them with the latest release version. +* [versions:use-next-snapshots](./use-next-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions which + have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version. +* [versions:use-latest-snapshots](./use-latest-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions + which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version. +* [versions:use-next-versions](./use-next-versions-mojo.html) searches the pom for all versions which + have been a newer version and replaces them with the next version. +* [versions:use-latest-versions](./use-latest-versions-mojo.html) searches the pom for all versions which + have been a newer version and replaces them with the latest version. +* [versions:use-dep-version](./use-dep-version-mojo.html) updates a dependency to a specific version. +* [versions:commit](./commit-mojo.html) removes the `pom.xml.versionsBackup` files. Forms one half of the + built-in "Poor Man's SCM". +* [versions:revert](./revert-mojo.html) restores the `pom.xml` files from the `pom.xml.versionsBackup` files. + Forms one half of the built-in "Poor Man's SCM". + +## Reporting goals overview + +The Versions Plugin has the following reporting goals. +* [versions:dependency-updates-report](./dependency-updates-report-mojo.html) produces a report of those + project dependencies which have newer versions available. +* [versions:plugin-updates-report](./plugin-updates-report-mojo.html) produces a report of those plugins which have + newer versions available. +* [versions:property-updates-report](./property-updates-report-mojo.html) produces a report of + those properties which are used to control artifact versions and which properties have newer versions available. +* [versions:parent-updates-report](./parent-updates-report-mojo.html) produces a report on possible parent artifact + upgrades. + +## Usage + +General instructions on how to use the Versions Plugin can be found on the [usage page](./usage.html). Some more +specific use cases are described in the examples given below. + +In case you still have questions regarding the plugin's usage, please have a look at the [FAQ](./faq.html) and feel +free to contact the [user mailing list](./mail-lists.html). The posts to the mailing list are archived and could +already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching +the [mail archive](./mail-lists.html). + +If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our +[issue tracker](./issue-tracking.html). When creating a new issue, please provide a comprehensive description of your +concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, +entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. +Of course, patches are welcome, too. Contributors can check out the project from our +[source repository](./source-repository.html) and will find supplementary information in the +[guide to helping with Maven](https://maven.apache.org/guides/development/guide-helping.html). + +## Examples + +To provide you with better understanding of some usages of the Plugin Name, +you can take a look into the following examples: +* [Advancing dependency versions](./examples/advancing-dependency-versions.html) +* [Compare project dependencies to a remote project](./examples/compare-dependencies.html) +* [Checking for new dependency updates](./examples/display-dependency-updates.html) +* [Checking for new plugin updates](./examples/display-plugin-updates.html) +* [Checking for new property-linked updates](./examples/display-property-updates.html) +* [Updating the Parent version](./examples/update-parent.html) +* [Updating a version specified in a property](./examples/update-properties.html) +* [Fixing a multi-module build](./examples/update-child-modules.html) +* [Resolve version ranges](./examples/resolve-ranges.html) +* [Locking snapshot dependencies](./examples/lock-snapshots.html) +* [Unlocking snapshot dependencies](./examples/unlock-snapshots.html) +* [Replacing -SNAPSHOT versions with their corresponding releases](./examples/use-releases.html) +* [Changing the project version](./examples/set.html) +* [Recording version changes](./examples/recording-changes.html) From c50ecd6c6dd747ddcbbc9bb43346ff704b7d088c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 29 Sep 2022 23:03:24 +0200 Subject: [PATCH 145/441] Deploy project snapshots to OSS --- .github/workflows/maven.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 218d4832bd..4a11acbbd5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -26,3 +26,9 @@ jobs: with: ff-maven: "3.8.6" # Maven version for fail-fast-build maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds + + deploy: + name: Deploy + needs: build + uses: mojohaus/.github/.github/workflows/maven-deploy.yml@master + secrets: inherit From 3b57415f5501c888e74a1e7890f5dc7a25a57e08 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 7 Oct 2022 06:33:10 +0200 Subject: [PATCH 146/441] #725: Migrating FAQ to markdown --- src/site/fml/faq.fml | 116 --------------------------------------- src/site/markdown/faq.md | 66 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 116 deletions(-) delete mode 100644 src/site/fml/faq.fml create mode 100644 src/site/markdown/faq.md diff --git a/src/site/fml/faq.fml b/src/site/fml/faq.fml deleted file mode 100644 index 3b54898517..0000000000 --- a/src/site/fml/faq.fml +++ /dev/null @@ -1,116 +0,0 @@ - - - - General - - - What does the Versions Maven Plugin do? - -

    The Versions Maven Plugin provides a means to update version information in a Maven project

    -
    -
    - - - Why is this plugin reporting version 1.0.0.9 of foo:bar as the latest version when I can see - version 1.0.0.23? - - -

    The current implementation of - - DefaultArtifactVersion - - in the core of Maven expects that version numbers will have a very - specific format: -

    -

    - MajorVersion [ - . - MinorVersion [ - . - IncrementalVersion ] ] [ - - - BuildNumber | Qualifier ] -

    -

    WhereMajorVersion,MinorVersion,IncrementalVersion, and - BuildNumber - are all - numeric and - Qualifier - is a string. If your version number does not match this format, then the entire - version number is treated as being theQualifier. -

    -

    Version numbers in maven are compared using the individual components, soMajorVersion, - MinorVersion,IncrementalVersion, and - BuildNumber - are all compared asIntegers - while - Qualifier - is compared as aString. -

    -

    From the above you may have guessed neither - 1.0.0.9 - nor - 1.0.0.23 - match the exact - format that Maven expects, and as a result they are mapped as being just aQualifier. - String comparison will sort - 1.0.0.9 - >1.0.0.23. -

    -

    If you need version numbers to be sorted "correctly" you will need to define some - - version number comparison rules - . -

    -
    -
    - - Why is foo:bar version x.y.z not being detected? - -

    - In order to determine what versions of an artifact are present, Maven relies on the presence of - meta-data files in the repository. If the meta-data files are missing or contain invalid information - then Maven will not know about versions that are available in your repositories. -

    -

    - Here are some common reasons why your metadata can be invalid: -

    -
      -
    • - You are using a local repository as a remote repository. Stop, don't do this. The local repository - uses a separate set of metadata files from those used by a remote repository. There are tools available - to convert a local repository into a remote repository, but you're really better off using a repository - manager. -
    • -
    • - Artifacts have been deployed by non-maven metadata aware tools. -
    • -
    • - Tools that claim to be maven meta-data aware have clobbered the metadata files. -
    • -
    -

    - In most cases, using a repository manager will solve these issues as the repository managers usually - rebuild the metadata files based on the artifacts that are present. -

    -
    -
    -
    -
    diff --git a/src/site/markdown/faq.md b/src/site/markdown/faq.md new file mode 100644 index 0000000000..b7872d5d7c --- /dev/null +++ b/src/site/markdown/faq.md @@ -0,0 +1,66 @@ +title: FAQ +autor: Stephen Connolly + + + +# Frequently Asked Questions + +## General + +### What does the Versions Maven Plugin do? + +The Versions Maven Plugin provides a means to update version information in a Maven project + +### Why is this plugin reporting version 1.0.0.9 of foo:bar as the latest version when I can see version 1.0.0.23? + +The current implementation of +[DefaultArtifactVersion](https://maven.apache.org/ref/current/maven-artifact/xref/org/apache/maven/artifact/versioning/DefaultArtifactVersion.html) +in the core of Maven expects that version numbers will have a very specific format: + +` . . - ` + +Where *MajorVersion*, *MinorVersion*, *IncrementalVersion* and *BuildNumber* are all numeric and *Qualifier* +is a string. If your version number does not match this format, then the entire version number is treated as being +the *Qualifier*. + +Version numbers in maven are compared using the individual components, so *MajorVersion*, *MinorVersion*, +*IncrementalVersion*, and *BuildNumber* are all compared as `Integer`s while *Qualifier* is compared as a `String`. + +From the above you may have guessed neither `1.0.0.9` nor `1.0.0.23` match the exact format that Maven expects, +and as a result they are mapped as being just a *Qualifier*. String comparison will sort `1.0.0.9` > `1.0.0.23`. + +If you need version numbers to be sorted "correctly" you will need to define some +[version number comparison rules](./version-rules.html). + +### Why is foo:bar version x.y.z not being detected? + +In order to determine what versions of an artifact are present, Maven relies on the presence of +meta-data files in the repository. If the meta-data files are missing or contain invalid information +then Maven will not know about versions that are available in your repositories. + +Here are some common reasons why your metadata can be invalid: + +- You are using a local repository as a remote repository. Stop, don't do this. The local repository +uses a separate set of metadata files from those used by a remote repository. There are tools available +to convert a local repository into a remote repository, but you're really better off using a repository +manager. +- Artifacts have been deployed by non-maven metadata aware tools. +- Tools that claim to be maven meta-data aware have clobbered the metadata files. + +In most cases, using a repository manager will solve these issues as the repository managers usually +rebuild the metadata files based on the artifacts that are present. From 736f87b8002d159115edc60ed90a5493e6a50692 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 3 Oct 2022 07:07:39 +0200 Subject: [PATCH 147/441] #725: Migrating Version Rules to markdown --- src/site/apt/version-rules.apt.vm | 253 -------------------------- src/site/markdown/version-rules.md.vm | 249 +++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 253 deletions(-) delete mode 100644 src/site/apt/version-rules.apt.vm create mode 100644 src/site/markdown/version-rules.md.vm diff --git a/src/site/apt/version-rules.apt.vm b/src/site/apt/version-rules.apt.vm deleted file mode 100644 index eb28a0adf9..0000000000 --- a/src/site/apt/version-rules.apt.vm +++ /dev/null @@ -1,253 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Version number rules - ----- - Stephen Connolly - ------ - 2012-11-14 - ------ - -Version number rules - -* Introduction - - <> The limitations explained in this paragraph were true in Maven 2.x, but have been <> in Maven 3.x (see - {{{https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning}Maven Versioning Wiki page}} for more details) - - The current implementation of - {{{http://maven.apache.org/ref/current/maven-artifact/xref/org/apache/maven/artifact/versioning/DefaultArtifactVersion.html}<<>>}} - in the core of Maven expects that version numbers will have a very specific format: - - <<< . . - >>> - - Where , , and are all numeric and - is a string. If your version number does not match this format, then the entire version number is treated as being - the . - - If your version numbers do not match this scheme, you may face issues with - - * version ranges (unfortunately there is nothing that the <<>> can do to help you with - your problems with version ranges and your version numbering scheme... well you could replace your - version ranges with properties and use the update-properties goal) - - * goals in this plugin that sort versions, for example update-properties (you can do things to help with these - kinds of problems) - - The <<>> knows three rules for comparing version numbers: - - [<<>>] The standard Maven 2.x version numbering scheme. - - [<<>>] An alternative version numbering scheme with no "special" qualifiers. - - The <<>> will assume that all version numbers follow the <<>> scheme unless you tell - it otherwise. - -* Rules.xml - - To specify the version schemes to use, you may define a {{{./rule.html}rule-set xml file}}, use the <<>> - element in the <<>> plugin configuration, or specify ignored versions via - the <<>> property. - -** Using the <<>> file - - The <<>> file should conform to the xsd specified in the example below. - ---- - - - - - - - - ---- - - The rule-set files must match the {{{./xsd/rule-2.0.0.xsd}XSD schema}}. - - You can then use the <<>> parameter to specify the rule-set to be used by the - <<>>. - - Note: the <<>> attribute in the <<>> elements has a lazy <<<.*>>> at the end, such that - <<>> will match <<>>, <<>>, <<>>, etc. - -** Using the <<>> element in the POM - - As an alternative to providing a separate <<>> file, starting with version <<<2.13.0>>> it is possible - to provide the <<>> element directly in the POM. The structure is somewhat simpler to - the <<>> file: - ---- - - ... - - ... - - ... - - org.codehaus.mojo - versions-maven-plugin - ${pluginVersion} - - - - - - - 1.0.0 - - - - regex - (.+-SNAPSHOT|.+-M\d) - - - regex - .+-(alpha|beta) - - - - - - - - - org.codehaus.mojo - - - - ... - - - - maven - - - ---- - -** Using the <<>> property - - The <<>> property can list *comma-separated* list of global version **regex** patterns, which - will be ignored when considering available versions. - - Examples: - - * <<<1.0.0>>> - - * <<<.+-SNAPSHOT>>> - - * <<<(.+-SNAPSHOT|.+-M\d),.+-(alpha|beta),3.0.0>>> - -** Ignoring certain versions - - It is possible to ignore versions on a global and on a per-rule basis. - - The other methods (via the <<<>>> element and via the <<>>) property have been - explained above. The described - ---- - - - .*-beta - - - - - .*-RELEASE - 2.1.0 - - - - ---- - - Note: it is possible to ignore versions using regular expressions. - - If you have your ruleset xml file hosted at, for example, http://www.mycompany.com/maven-version-rules.xml - then the following configuration in your corporate pom would ensure that all projects use this rule set. - ---- - - ... - - ... - - ... - - org.codehaus.mojo - versions-maven-plugin - ${pluginVersion} - - ... - http://www.mycompany.com/maven-version-rules.xml - ... - - - ... - - ... - - ... - ---- - - You can provide your ruleset xml file also within a jar, if you want to distribute - your ruleset xml as Maven artifact. Therefore you have to declare the containing - jar as direct dependency of the <> and to use classpath - as protocol. - ---- - - ... - - ... - - ... - - org.codehaus.mojo - versions-maven-plugin - ${pluginVersion} - - ... - classpath:///package/foo/bar/rules.xml - ... - - - - com.mycompany - version-rules - 1.0 - - - - ... - - ... - - ... - ---- \ No newline at end of file diff --git a/src/site/markdown/version-rules.md.vm b/src/site/markdown/version-rules.md.vm new file mode 100644 index 0000000000..2c7c8fb13b --- /dev/null +++ b/src/site/markdown/version-rules.md.vm @@ -0,0 +1,249 @@ +title: Version Rules +autor: Stephen Connolly +date: 2012-11-14 + + + +## Velocity uses # as a prefix for macros and ## as a prefix for comments +#set($h1 = '#') +#set($h2 = '##') +#set($h3 = '###') +#set($h4 = '####') + +$h1 Version number rules + +$h2 Introduction + +**Notice:** The limitations explained in this paragraph were true in Maven 2.x, but have been **fixed** in Maven 3.x (see +[Maven Versioning Wiki page](https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning) for more details) + +The current implementation of +[DefaultArtifactVersion](https://maven.apache.org/ref/current/maven-artifact/xref/org/apache/maven/artifact/versioning/DefaultArtifactVersion.html) +in the core of Maven expects that version numbers will have a very specific format: + +` . . - ` + +Where *MajorVersion*, *MinorVersion*, *IncrementalVersion* and *BuildNumber* are all numeric and *Qualifier* +is a string. If your version number does not match this format, then the entire version number is treated as being +the *Qualifier*. + +If your version numbers do not match this scheme, you may face issues with +- version ranges (unfortunately there is nothing that the `versions-maven-plugin` can do to help you with + your problems with version ranges and your version numbering scheme... well you could replace your + version ranges with properties and use the update-properties goal) +- goals in this plugin that sort versions, for example update-properties (you can do things to help with these + kinds of problems) + +The `versions-maven-plugin` knows three rules for comparing version numbers: +- *maven*, The standard Maven 2.x and 3.x version numbering scheme. +- *numeric*, An alternative version numbering scheme with no "special" qualifiers. +- *mercury*, An alternative version numbering scheme, now defunct. + +The `versions-maven-plugin` will assume that all version numbers follow the `maven` scheme unless you tell +it otherwise. + +$h2 Rules.xml + +To specify the version schemes to use, you may define a [rule-set xml file](./rule.html), use the `ruleSet` +element in the `versions-maven-plugin` plugin configuration, or specify ignored versions via +the `maven.version.ignore` property. + +$h3 Using the `Rules.xml` file + +The `rules.xml` file should conform to the xsd specified in the example below. + +```xml + + + + + + + + +``` + +The rule-set files must match the [XSD schema](./xsd/rule-2.0.0.xsd). + +You can then use the `rulesUri` parameter to specify the rule-set to be used by the +`versions-maven-plugin`. + +Note: the `groupId` attribute in the `rule` elements has a lazy `.*` at the end, such that +`com.mycompany` will match `com.mycompany`, `com.mycompany.foo`, `com.mycompany.foo.bar`, etc. + +$h3 Using the `ruleSet` element in the POM + +As an alternative to providing a separate `rules.xml` file, starting with version `2.13.0` it is possible +to provide the `ruleSet` element directly in the POM. The structure is somewhat simpler to +the `rules.xml` file: + +```xml + + ... + + ... + + ... + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + + + + + + 1.0.0 + + + + regex + (.+-SNAPSHOT|.+-M\d) + + + regex + .+-(alpha|beta) + + + + + + + + + org.codehaus.mojo + + + + ... + + + + maven + + + +``` + +$h3 Using the `maven.version.ignore` property + +The `maven.version.ignore` property can list *comma-separated* list of global version **regex** patterns, which +will be ignored when considering available versions. + +Examples: +- `1.0.0` +- `.+-SNAPSHOT` +- `(.+-SNAPSHOT|.+-M\d),.+-(alpha|beta),3.0.0` + +$h3 Ignoring certain versions + +It is possible to ignore versions on a global and on a per-rule basis. + +The other methods (via the `` element and via the `maven.version.ignore`) property have been +explained above. The described + +```xml + + + .*-beta + + + + + .*-RELEASE + 2.1.0 + + + + +``` + +Note: it is possible to ignore versions using regular expressions. + +If you have your ruleset xml file hosted at, for example, http://www.mycompany.com/maven-version-rules.xml +then the following configuration in your corporate pom would ensure that all projects use this rule set. + +```xml + + ... + + ... + + ... + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + ... + http://www.mycompany.com/maven-version-rules.xml + ... + + + ... + + ... + + ... + +``` + +You can provide your ruleset xml file also within a jar, if you want to distribute +your ruleset xml as Maven artifact. Therefore you have to declare the containing +jar as direct dependency of the **versions-maven-plugin** and to use classpath +as protocol. + +```xml + + ... + + ... + + ... + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + ... + classpath:///package/foo/bar/rules.xml + ... + + + + com.mycompany + version-rules + 1.0 + + + + ... + + ... + + ... + +``` From 97c6333719edf43724bfbf8ab30dc02d6280c854 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 5 Oct 2022 08:35:23 +0200 Subject: [PATCH 148/441] #499: Add segment selection to update parent --- .../it-update-parent-002/invoker.properties | 1 - src/it/it-update-parent-002/pom.xml | 50 ------ src/it/it-update-parent-002/verify.bsh | 33 ---- .../it-update-parent-003/invoker.properties | 1 - src/it/it-update-parent-003/pom.xml | 50 ------ src/it/it-update-parent-003/verify.bsh | 32 ---- .../versions/AbstractVersionsUpdaterMojo.java | 24 +-- .../mojo/versions/UpdateParentMojo.java | 83 ++++++++-- .../versions/api/AbstractVersionDetails.java | 23 ++- .../mojo/versions/UpdateParentMojoTest.java | 148 ++++++++++++------ 10 files changed, 188 insertions(+), 257 deletions(-) delete mode 100644 src/it/it-update-parent-002/invoker.properties delete mode 100644 src/it/it-update-parent-002/pom.xml delete mode 100644 src/it/it-update-parent-002/verify.bsh delete mode 100644 src/it/it-update-parent-003/invoker.properties delete mode 100644 src/it/it-update-parent-003/pom.xml delete mode 100644 src/it/it-update-parent-003/verify.bsh diff --git a/src/it/it-update-parent-002/invoker.properties b/src/it/it-update-parent-002/invoker.properties deleted file mode 100644 index be7a896ce6..0000000000 --- a/src/it/it-update-parent-002/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:update-parent diff --git a/src/it/it-update-parent-002/pom.xml b/src/it/it-update-parent-002/pom.xml deleted file mode 100644 index c82d7a938c..0000000000 --- a/src/it/it-update-parent-002/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - 4.0.0 - - - localhost - dummy-parent - 1.0 - - - localhost - it-201 - 1.0 - pom - update-parent within range - - - - - - maven-clean-plugin - 2.2 - - - maven-deploy-plugin - 2.3 - - - maven-install-plugin - 2.2 - - - maven-site-plugin - 2.0 - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - - [,3.0-!) - - - - - - diff --git a/src/it/it-update-parent-002/verify.bsh b/src/it/it-update-parent-002/verify.bsh deleted file mode 100644 index 7c158490d8..0000000000 --- a/src/it/it-update-parent-002/verify.bsh +++ /dev/null @@ -1,33 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E.*\\Q\\E\\s*2\\.0\\s*\\Q\\E.*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not update parent to version 2.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/it/it-update-parent-003/invoker.properties b/src/it/it-update-parent-003/invoker.properties deleted file mode 100644 index be7a896ce6..0000000000 --- a/src/it/it-update-parent-003/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:update-parent diff --git a/src/it/it-update-parent-003/pom.xml b/src/it/it-update-parent-003/pom.xml deleted file mode 100644 index 03ca6fd7e2..0000000000 --- a/src/it/it-update-parent-003/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - 4.0.0 - - - localhost - dummy-parent - 2.0 - - - localhost - it-201 - 1.0 - pom - update-parent within range - - - - - - maven-clean-plugin - 2.2 - - - maven-deploy-plugin - 2.3 - - - maven-install-plugin - 2.2 - - - maven-site-plugin - 2.0 - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - - [,3.0-!) - - - - - - diff --git a/src/it/it-update-parent-003/verify.bsh b/src/it/it-update-parent-003/verify.bsh deleted file mode 100644 index d38f93b00c..0000000000 --- a/src/it/it-update-parent-003/verify.bsh +++ /dev/null @@ -1,32 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E.*\\Q\\E\\s*2\\.0\\s*\\Q\\E.*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Updated parent" ); - return false; - } -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 15e7449670..d374a9cc1d 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -345,32 +345,10 @@ public void execute() protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException, MojoExecutionException - { - return findLatestVersion( artifact, versionRange, allowingSnapshots, usePluginRepositories, false ); - } - - /** - * Finds the latest version of the specified artifact that matches the version range. - * - * @param artifact The artifact. - * @param versionRange The version range. - * @param allowingSnapshots null for no override, otherwise the local override to apply. - * @param usePluginRepositories Use plugin repositories - * @param allowDowngrade whether downgrades should be allowed - * @return The latest version of the specified artifact that matches the specified version range or - * null if no matching version could be found. - * @throws ArtifactMetadataRetrievalException If the artifact metadata could not be found. - * @throws MojoExecutionException if something goes wrong. - * @since 1.0-alpha-1 - */ - protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, - Boolean allowingSnapshots, boolean usePluginRepositories, - boolean allowDowngrade ) - throws ArtifactMetadataRetrievalException, MojoExecutionException { boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); - return artifactVersions.getNewestVersion( versionRange, null, includeSnapshots, allowDowngrade ); + return artifactVersions.getNewestVersion( versionRange, null, includeSnapshots, false ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index f7e62c01e6..bece00a032 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -22,6 +22,11 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.util.Arrays; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -37,7 +42,10 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -95,6 +103,30 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo defaultValue = "false" ) protected boolean allowDowngrade; + /** + * Whether to allow the major version number to be changed. + * + * @since 2.13.0 + */ + @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + protected boolean allowMajorUpdates = true; + + /** + * Whether to allow the minor version number to be changed. + * + * @since 2.13.0 + */ + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + protected boolean allowMinorUpdates = true; + + /** + * Whether to allow the incremental version number to be changed. + * + * @since 2.13.0 + */ + @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + protected boolean allowIncrementalUpdates = true; + // -------------------------- OTHER METHODS -------------------------- @Inject @@ -135,10 +167,13 @@ protected void update( ModifiedPomXMLEventReader pom ) throw new MojoExecutionException( "skipResolution is only valid if parentVersion is set" ); } - String initialVersion = parentVersion == null ? getProject().getParent().getVersion() : parentVersion; + String initialVersion = parentVersion == null + ? getProject().getParent().getVersion() + : parentVersion; try { - ArtifactVersion artifactVersion = skipResolution ? new DefaultArtifactVersion( parentVersion ) + ArtifactVersion artifactVersion = skipResolution + ? new DefaultArtifactVersion( parentVersion ) : resolveTargetVersion( initialVersion ); if ( artifactVersion != null ) { @@ -166,10 +201,15 @@ protected void update( ModifiedPomXMLEventReader pom ) { throw new MojoExecutionException( e.getMessage(), e ); } + catch ( InvalidSegmentException e ) + { + throw new MojoExecutionException( "Invalid segment specification for version " + initialVersion, e ); + } } - private ArtifactVersion resolveTargetVersion( String initialVersion ) - throws MojoExecutionException, ArtifactMetadataRetrievalException, InvalidVersionSpecificationException + protected ArtifactVersion resolveTargetVersion( String initialVersion ) + throws MojoExecutionException, ArtifactMetadataRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder .newBuilder() @@ -186,14 +226,37 @@ private ArtifactVersion resolveTargetVersion( String initialVersion ) VersionRange.createFromVersionSpec( "[" + targetVersionRange.getRecommendedVersion() + ",)" ) ); } - ArtifactVersion artifactVersion = findLatestVersion( artifact, targetVersionRange, null, - false, allowDowngrade ); - if ( !shouldApplyUpdate( artifact, getProject().getParent().getVersion(), artifactVersion, forceUpdate ) ) + final ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates ); + + // currentVersion (set to parentVersion here) is not included in the version range for searching upgrades + // unless we set allowDowngrade to true + for ( ArtifactVersion candidate : reverse( versions.getNewerVersions( initialVersion, unchangedSegment, + allowSnapshots, !isBlank( parentVersion ) || allowDowngrade ) ) ) { - getLog().debug( "Update not applied. Exiting." ); - return null; + if ( allowDowngrade + || targetVersionRange == null + || ArtifactVersions.isVersionInRange( candidate, targetVersionRange ) ) + { + if ( shouldApplyUpdate( artifact, getProject().getParent().getVersion(), candidate, forceUpdate ) ) + { + return candidate; + } + else + { + getLog().debug( "Update not applied. Exiting." ); + return null; + } + } } - return artifactVersion; + + getLog().info( "No versions found" ); + return null; } + private static Iterable reverse( T[] array ) + { + return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); + } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 2eac6fe7db..747a448e47 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -177,20 +177,19 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restri // so we only need to find the first candidate fulfilling the criteria for ( ArtifactVersion candidate : reverse( getVersions( includeSnapshots ) ) ) { - if ( !allowDowngrade && versionRange != null - && !ArtifactVersions.isVersionInRange( candidate, versionRange ) ) + if ( allowDowngrade || versionRange == null + || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) { - continue; - } - if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) - { - continue; - } - if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) ) - { - continue; + if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) + { + continue; + } + if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) ) + { + continue; + } + return candidate; } - return candidate; } return null; } diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index bb39a26728..43ca78b36f 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -10,6 +10,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -20,6 +21,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; import org.junit.BeforeClass; @@ -34,6 +36,7 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; @@ -60,6 +63,8 @@ public static void setUpStatic() {{ put( "parent-artifact", new String[] { "0.9.0", "1.0.0", "1.0.1-SNAPSHOT" } ); put( "issue-670-artifact", new String[] { "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" } ); + put( "dummy-parent2", new String[] { "1.0", "2.0", "3.0", "3.0-alpha-1", "3.0-beta-1" } ); + put( "test-incremental", new String[] { "1.0.0", "1.1.0", "1.1.1", "2.0.0" } ); put( "unknown-artifact", new String[0] ); }} ); } @@ -174,69 +179,46 @@ public void testParentDowngradeForbidden() @Test public void testParentDowngradeAllowedWithRange() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, ArtifactMetadataRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowDowngrade = true; mojo.getProject().setParent( new MavenProject() {{ setGroupId( "default-group" ); setArtifactId( "parent-artifact" ); - setVersion( "[1.0.1-SNAPSHOT,)" ); }} ); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); - } - assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "parent-artifact", "[1.0.1-SNAPSHOT,)", - "1.0.0" ) ) ); + ArtifactVersion newVersion = mojo.resolveTargetVersion( "[1.0.1-SNAPSHOT,)" ); + assertThat( newVersion, notNullValue() ); + assertThat( newVersion.toString(), is( "1.0.0" ) ); } @Test public void testParentDowngradeForbiddenWithRange() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, ArtifactMetadataRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowDowngrade = false; - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - setVersion( "[1.0.1-SNAPSHOT,)" ); - }} ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); - } - assertThat( changeRecorder.getChanges(), is( empty() ) ); + ArtifactVersion newVersion = mojo.resolveTargetVersion( "[1.0.1-SNAPSHOT,)" ); + assertThat( newVersion, nullValue() ); } @Test public void testAllowSnapshots() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, ArtifactMetadataRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowSnapshots = true; mojo.getProject().setParent( new MavenProject() {{ setGroupId( "default-group" ); setArtifactId( "issue-670-artifact" ); - setVersion( "0.0.1-1" ); }} ); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); - } - assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", - "issue-670-artifact", "0.0.1-1", - "0.0.1-1-impl-SNAPSHOT" ) ) ); + ArtifactVersion newVersion = mojo.resolveTargetVersion( "0.0.1-1" ); + assertThat( newVersion, notNullValue() ); + assertThat( newVersion.toString(), is( "0.0.1-1-impl-SNAPSHOT" ) ); } @Test @@ -265,21 +247,16 @@ public void testAllowSnapshotsWithParentVersion() @Test public void testIgnoredVersions() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, IllegalAccessException, + ArtifactMetadataRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.getProject().setParent( new MavenProject() {{ setGroupId( "default-group" ); setArtifactId( "parent-artifact" ); - setVersion( "0.9.0" ); }} ); setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.0.0" ) ); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); - mojo.update( null ); - } - assertThat( changeRecorder.getChanges(), is( empty() ) ); + assertThat( mojo.resolveTargetVersion( "0.9.0" ), nullValue() ); } @Test @@ -346,4 +323,85 @@ public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStre hasItem( new VersionChange( "default-group", "parent-artifact", "0.9.0", "1.0.1-SNAPSHOT" ) ) ); } + + @Test + public void testAllowMinorUpdates() + throws MojoExecutionException, ArtifactMetadataRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "parent-artifact" ); + setVersion( "0.8.0" ); + }} ); + mojo.allowMajorUpdates = false; + mojo.allowMinorUpdates = true; + mojo.allowIncrementalUpdates = false; + + ArtifactVersion newVersion = mojo.resolveTargetVersion( "0.8.0" ); + + assertThat( newVersion, notNullValue() ); + assertThat( newVersion.toString(), is( "0.9.0" ) ); + } + + @Test + public void testAllowIncrementalUpdates() + throws MojoExecutionException, ArtifactMetadataRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "test-incremental" ); + }} ); + mojo.allowMajorUpdates = false; + mojo.allowMinorUpdates = false; + mojo.allowIncrementalUpdates = true; + + ArtifactVersion newVersion = mojo.resolveTargetVersion( "1.1.0" ); + + assertThat( newVersion, notNullValue() ); + assertThat( newVersion.toString(), is( "1.1.1" ) ); + } + + @Test + public void testParentVersionRange() throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "dummy-parent2" ); + setVersion( "1.0" ); + }} ); + mojo.allowSnapshots = true; + mojo.parentVersion = "[,3.0-!)"; + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "dummy-parent2", "1.0", + "2.0" ) ) ); + } + + @Test + public void testParentVersionRange2() throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setParent( new MavenProject() + {{ + setGroupId( "default-group" ); + setArtifactId( "dummy-parent2" ); + setVersion( "2.0" ); + }} ); + mojo.allowSnapshots = true; + mojo.parentVersion = "[,3.0-!)"; + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), empty() ); + } } From b9d24c0dfbc68fcff64342d4e5370d807a2e39c8 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Tue, 27 Sep 2022 18:13:33 +0200 Subject: [PATCH 149/441] #637: Refactoring report renderers --- pom.xml | 6 +- .../verify.groovy | 22 +- .../invoker.properties | 2 +- .../mojo/versions/AbstractVersionsReport.java | 20 +- .../AbstractVersionsReportRenderer.java | 826 ------------------ .../versions/DependencyUpdatesRenderer.java | 226 ----- ....java => DependencyUpdatesReportMojo.java} | 27 +- .../DisplayDependencyUpdatesMojo.java | 14 +- .../versions/DisplayPluginUpdatesMojo.java | 4 +- ...port.java => ParentUpdatesReportMojo.java} | 50 +- .../mojo/versions/PluginUpdatesDetails.java | 25 +- ...port.java => PluginUpdatesReportMojo.java} | 31 +- .../versions/PropertyUpdatesRenderer.java | 206 ----- ...rt.java => PropertyUpdatesReportMojo.java} | 22 +- .../mojo/versions/api/ArtifactVersions.java | 49 +- .../api/DefaultArtifactAssociation.java | 1 + .../versions/api/DefaultVersionsHelper.java | 12 +- .../mojo/versions/api/ReportRenderer.java | 31 + .../versions/filtering/DependencyFilter.java | 2 +- .../AbstractVersionsReportRenderer.java | 457 ++++++++++ .../DependencyUpdatesReportRenderer.java | 131 +++ .../versions/reporting/OverviewStats.java | 89 ++ .../ParentUpdatesReportRenderer.java | 48 + .../PluginUpdatesReportRenderer.java} | 348 +++----- .../PropertyUpdatesReportRenderer.java | 431 +++++++++ .../reporting/ReportRendererFactory.java | 45 + .../reporting/ReportRendererFactoryImpl.java | 85 ++ .../reporting/VersionsReportRendererBase.java | 196 +++++ .../reporting/model/AbstractUpdatesModel.java | 72 ++ .../model/DependencyUpdatesModel.java | 37 + .../reporting/model/ParentUpdatesModel.java | 37 + .../reporting/model/PluginUpdatesModel.java | 42 + .../reporting/model/PropertyUpdatesModel.java | 46 + .../versions/utils/DependencyComparator.java | 39 +- .../mojo/versions/utils/PluginComparator.java | 4 +- .../versions/utils/PropertyComparator.java | 14 +- .../DependencyUpdatesXmlRenderer.java | 34 +- .../{ => xml}/PluginUpdatesXmlRenderer.java | 33 +- .../parent-updates-report.properties | 2 +- ...a => DependencyUpdatesReportMojoTest.java} | 144 +-- .../DependencyUpdatesXmlRendererTest.java | 1 + ....java => ParentUpdatesReportMojoTest.java} | 11 +- ....java => PluginUpdatesReportMojoTest.java} | 34 +- .../api/DefaultVersionsHelperTest.java | 1 + 44 files changed, 2220 insertions(+), 1737 deletions(-) delete mode 100644 src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java delete mode 100644 src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java rename src/main/java/org/codehaus/mojo/versions/{DependencyUpdatesReport.java => DependencyUpdatesReportMojo.java} (89%) rename src/main/java/org/codehaus/mojo/versions/{ParentUpdatesReport.java => ParentUpdatesReportMojo.java} (69%) rename src/main/java/org/codehaus/mojo/versions/{PluginUpdatesReport.java => PluginUpdatesReportMojo.java} (85%) delete mode 100644 src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java rename src/main/java/org/codehaus/mojo/versions/{PropertyUpdatesReport.java => PropertyUpdatesReportMojo.java} (82%) create mode 100644 src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java rename src/main/java/org/codehaus/mojo/versions/{PluginUpdatesRenderer.java => reporting/PluginUpdatesReportRenderer.java} (51%) create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java create mode 100644 src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java rename src/main/java/org/codehaus/mojo/versions/{ => xml}/DependencyUpdatesXmlRenderer.java (92%) rename src/main/java/org/codehaus/mojo/versions/{ => xml}/PluginUpdatesXmlRenderer.java (81%) rename src/test/java/org/codehaus/mojo/versions/{DependencyUpdatesReportTest.java => DependencyUpdatesReportMojoTest.java} (63%) rename src/test/java/org/codehaus/mojo/versions/{ParentUpdatesReportTest.java => ParentUpdatesReportMojoTest.java} (89%) rename src/test/java/org/codehaus/mojo/versions/{PluginUpdatesReportTest.java => PluginUpdatesReportMojoTest.java} (86%) diff --git a/pom.xml b/pom.xml index cc32d2d4e2..ea6fff7958 100644 --- a/pom.xml +++ b/pom.xml @@ -417,14 +417,16 @@ - org.codehaus.mojo - versions-maven-plugin + ${project.groupId} + ${project.artifactId} + ${project.version} dependency-updates-report plugin-updates-report property-updates-report + parent-updates-report diff --git a/src/it/it-abstract-versions-report-001/verify.groovy b/src/it/it-abstract-versions-report-001/verify.groovy index da937db0ce..c0633c5e32 100644 --- a/src/it/it-abstract-versions-report-001/verify.groovy +++ b/src/it/it-abstract-versions-report-001/verify.groovy @@ -1,15 +1,17 @@ -dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ) - -assert dependencyUpdatesReport.exists( ) +dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) // some basic (=not comprehensive) checks on the contents of the dependency report -assert dependencyUpdatesReport.text =~ /\b1\.1\.0-2\b/ // current version of the dependency -assert dependencyUpdatesReport.text =~ /\b3\.0\b/ // latest major available version - -pluginUpdatesReport = new File( basedir, "target/site/plugin-updates-report.html" ) +assert dependencyUpdatesReport =~ /\b1\.1\.0-2\b/ // current version of the dependency +assert dependencyUpdatesReport =~ /\b3\.0\b/ // latest major available version -assert pluginUpdatesReport.exists( ) +pluginUpdatesReport = new File( basedir, "target/site/plugin-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) // some basic (=not comprehensive) checks on the contents of the plugin report -assert pluginUpdatesReport.text =~ /\b1\.0\b/ // current version of the plugin -assert pluginUpdatesReport.text =~ /\b3\.1\b/ // latest major available version \ No newline at end of file +assert pluginUpdatesReport =~ /\b1\.0\b/ // current version of the plugin +assert pluginUpdatesReport =~ /\b3\.1\b/ // latest major available version \ No newline at end of file diff --git a/src/it/it-parent-updates-report-001/invoker.properties b/src/it/it-parent-updates-report-001/invoker.properties index c01f7db0e4..d89b80b302 100644 --- a/src/it/it-parent-updates-report-001/invoker.properties +++ b/src/it/it-parent-updates-report-001/invoker.properties @@ -1 +1 @@ -invoker.goals=site +invoker.goals = site diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 5fa98541ab..336febe831 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -19,8 +19,6 @@ * under the License. */ -import javax.inject.Inject; - import java.io.File; import java.util.List; import java.util.Locale; @@ -49,15 +47,17 @@ import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.model.RuleSet; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.plexus.i18n.I18N; /** * Base class for all versions reports. * + * @param modelled report object * @author Stephen Connolly * @since 1.0-alpha-3 */ -public abstract class AbstractVersionsReport +public abstract class AbstractVersionsReport extends AbstractMavenReport { /** @@ -99,7 +99,7 @@ public abstract class AbstractVersionsReport /** * @since 1.0-alpha-3 */ - private WagonManager wagonManager; + private final WagonManager wagonManager; /** * @since 1.0-alpha-3 @@ -188,17 +188,25 @@ public abstract class AbstractVersionsReport @Parameter( property = "maven.version.ignore" ) protected Set ignoredVersions; + /** + * Renderer factory + * + * @since 2.13.0 + */ + protected ReportRendererFactory rendererFactory; + // --------------------- GETTER / SETTER METHODS --------------------- - @Inject protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + ReportRendererFactory rendererFactory ) { this.i18n = i18n; this.repositorySystem = repositorySystem; this.artifactResolver = artifactResolver; this.artifactMetadataSource = artifactMetadataSource; this.wagonManager = wagonManager; + this.rendererFactory = rendererFactory; } public VersionsHelper getHelper() diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java deleted file mode 100644 index b61ffa0e36..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReportRenderer.java +++ /dev/null @@ -1,826 +0,0 @@ -package org.codehaus.mojo.versions; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.HashSet; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkEventAttributes; -import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; -import org.apache.maven.model.Dependency; -import org.apache.maven.reporting.AbstractMavenReportRenderer; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; -import org.codehaus.mojo.versions.api.ArtifactAssociation; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.plexus.i18n.I18N; -import org.codehaus.plexus.util.StringUtils; - -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - -/** - * Base class for report renderers. - * - * @author Stephen Connolly - * @since 1.0-beta-1 - */ -public abstract class AbstractVersionsReportRenderer - extends AbstractMavenReportRenderer -{ - /** - * Internationalization component. - * - * @since 1.0-beta-1 - */ - protected final I18N i18n; - - /** - * The locale we are rendering for. - * - * @since 1.0-beta-1 - */ - protected final Locale locale; - - /** - * The name of the bundle containing our I18n resources. - * - * @since 1.0-beta-1 - */ - protected final String bundleName; - - public AbstractVersionsReportRenderer( org.apache.maven.doxia.sink.Sink sink, String bundleName, I18N i18n, - Locale locale ) - { - super( sink ); - this.bundleName = bundleName; - this.i18n = i18n; - this.locale = locale; - } - - public String getTitle() - { - return getText( "report.title" ); - } - - /** - * Gets the localized message for this report. - * - * @param key the message key. - * @return the message. - */ - public String getText( String key ) - { - return i18n.getString( bundleName, locale, key ); - } - - protected void renderWarningIcon() - { - sink.figureGraphics( "images/icon_warning_sml.gif" ); - } - - protected void renderSuccessIcon() - { - sink.figureGraphics( "images/icon_success_sml.gif" ); - } - - protected boolean equals( ArtifactVersion v1, ArtifactVersion v2 ) - { - return v1 == v2 || ( v1 != null && v1.equals( v2 ) ) - || ( v1 != null && v2 != null && v1.toString().equals( v2.toString() ) ); - } - - protected void renderDependencySummaryTableRow( Dependency dependency, ArtifactVersions details ) - { - renderDependencySummaryTableRow( dependency, details, true, true, true ); - } - - protected void renderDependencySummaryTableRow( Dependency dependency, ArtifactVersions details, - boolean includeScope, boolean includeClassifier, - boolean includeType ) - { - sink.tableRow(); - sink.tableCell(); - ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); - if ( allUpdates == null || allUpdates.length == 0 ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } - sink.tableCell_(); - sink.tableCell(); - sink.text( dependency.getGroupId() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( dependency.getArtifactId() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( dependency.getVersion() ); - sink.tableCell_(); - if ( includeScope ) - { - sink.tableCell(); - sink.text( dependency.getScope() ); - sink.tableCell_(); - } - if ( includeClassifier ) - { - sink.tableCell(); - sink.text( dependency.getClassifier() ); - sink.tableCell_(); - } - if ( includeType ) - { - sink.tableCell(); - sink.text( dependency.getType() ); - sink.tableCell_(); - } - - sink.tableCell(); - if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( details.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( details.getNewestUpdate( of( INCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( details.getNewestUpdate( of( MINOR ) ) != null ) - { - safeBold(); - sink.text( details.getNewestUpdate( of( MINOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( details.getNewestUpdate( of( MAJOR ) ) != null ) - { - safeBold(); - sink.text( details.getNewestUpdate( of( MAJOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableRow_(); - } - - protected void safeBold() - { - try - { - sink.bold(); - } - catch ( NoSuchMethodError e ) - { - // ignore Maven 2.1.0 - } - } - - @SuppressWarnings( "checkstyle:MethodName" ) - protected void safeBold_() - { - try - { - sink.bold_(); - } - catch ( NoSuchMethodError e ) - { - // ignore Maven 2.1.0 - } - } - - protected void safeItalic() - { - try - { - sink.italic(); - } - catch ( NoSuchMethodError e ) - { - // ignore Maven 2.1.0 - } - } - - @SuppressWarnings( "checkstyle:MethodName" ) - protected void safeItalic_() - { - try - { - sink.italic_(); - } - catch ( NoSuchMethodError e ) - { - // ignore Maven 2.1.0 - } - } - - protected void renderDependencySummaryTableHeader() - { - renderDependencySummaryTableHeader( true, true, true ); - } - - protected void renderDependencySummaryTableHeader( boolean includeScope, boolean includeClassifier, - boolean includeType ) - { - sink.tableRow(); - sink.tableHeaderCell(); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.groupId" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.artifactId" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - if ( includeScope ) - { - sink.tableHeaderCell(); - sink.text( getText( "report.scope" ) ); - sink.tableHeaderCell_(); - } - if ( includeClassifier ) - { - sink.tableHeaderCell(); - sink.text( getText( "report.classifier" ) ); - sink.tableHeaderCell_(); - } - if ( includeType ) - { - sink.tableHeaderCell(); - sink.text( getText( "report.type" ) ); - sink.tableHeaderCell_(); - } - sink.tableHeaderCell(); - sink.text( getText( "report.latestSubIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMinor" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMajor" ) ); - sink.tableHeaderCell_(); - sink.tableRow_(); - } - - protected void renderDependencyDetailTable( Dependency dependency, ArtifactVersions details ) - { - renderDependencyDetailTable( dependency, details, true, true, true ); - } - - @SuppressWarnings( "checkstyle:MethodLength" ) - protected void renderDependencyDetailTable( Dependency dependency, ArtifactVersions details, boolean includeScope, - boolean includeClassifier, boolean includeType ) - { - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); - sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = details.getAllUpdates( empty() ); - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.otherUpdatesAvailable" ) ); - } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.incrementalUpdatesAvailable" ) ); - } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.minorUpdatesAvailable" ) ); - } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.majorUpdatesAvailable" ) ); - } - else - { - renderSuccessIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.noUpdatesAvailable" ) ); - } - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.groupId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getGroupId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.artifactId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getArtifactId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getVersion() ); - sink.tableCell_(); - sink.tableRow_(); - if ( includeScope ) - { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.scope" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getScope() ); - sink.tableCell_(); - sink.tableRow_(); - } - if ( includeClassifier ) - { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.classifier" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getClassifier() ); - sink.tableCell_(); - sink.tableRow_(); - } - if ( includeType ) - { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.type" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( dependency.getType() ); - sink.tableCell_(); - sink.tableRow_(); - } - if ( versions != null && versions.length > 0 ) - { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.updateVersions" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - for ( int i = 0; i < versions.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - String label = getLabel( versions[i], details ); - if ( label != null ) - { - safeBold(); - } - sink.text( versions[i].toString() ); - if ( label != null ) - { - safeBold_(); - sink.nonBreakingSpace(); - safeItalic(); - sink.text( label ); - safeItalic_(); - } - } - sink.tableCell_(); - sink.tableRow_(); - } - sink.tableRows_(); - sink.table_(); - } - - protected void renderDependencySummaryTable( Map map ) - { - renderDependencySummaryTable( map, true, true, true ); - } - - protected void renderDependencySummaryTable( Map map, boolean includeScope, - boolean includeClassifier, boolean includeType ) - { - sink.table(); - renderDependencySummaryTableHeader( includeScope, includeClassifier, includeType ); - for ( Map.Entry entry : map.entrySet() ) - { - renderDependencySummaryTableRow( entry.getKey(), entry.getValue(), includeScope, includeClassifier, - includeType ); - } - renderDependencySummaryTableHeader( includeScope, includeClassifier, includeType ); - sink.table_(); - } - - protected void renderPropertySummaryTable( Map map ) - { - sink.table(); - renderPropertySummaryTableHeader(); - for ( Map.Entry entry : map.entrySet() ) - { - renderPropertySummaryTableRow( entry.getKey(), entry.getValue() ); - } - renderPropertySummaryTableHeader(); - sink.table_(); - } - - protected void renderPropertySummaryTableRow( Property property, PropertyVersions versions ) - { - sink.tableRow(); - sink.tableCell(); - if ( versions.getAllUpdates( empty() ).length == 0 ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } - sink.tableCell_(); - sink.tableCell(); - sink.text( "${" + property.getName() + "}" ); - sink.tableCell_(); - sink.tableCell(); - sink.text( versions.getCurrentVersion().toString() ); - sink.tableCell_(); - - sink.tableCell(); - if ( versions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( versions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( versions.getNewestUpdate( of( INCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( versions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( versions.getNewestUpdate( of( MINOR ) ) != null ) - { - safeBold(); - sink.text( versions.getNewestUpdate( of( MINOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( versions.getNewestUpdate( of( MAJOR ) ) != null ) - { - safeBold(); - sink.text( versions.getNewestUpdate( of( MAJOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableRow_(); - } - - protected void renderPropertySummaryTableHeader() - { - sink.tableRow(); - sink.tableHeaderCell(); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.property" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestSubIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMinor" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMajor" ) ); - sink.tableHeaderCell_(); - sink.tableRow_(); - } - - @SuppressWarnings( "checkstyle:MethodLength" ) - protected void renderPropertyDetailTable( Property property, PropertyVersions versions ) - { - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); - sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - ArtifactVersion[] artifactVersions = versions.getAllUpdates( empty() ); - Set rangeVersions = getVersionsInRange( property, versions, artifactVersions ); - if ( versions.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.otherUpdatesAvailable" ) ); - } - else if ( versions.getOldestUpdate( of( INCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.incrementalUpdatesAvailable" ) ); - } - else if ( versions.getOldestUpdate( of( MINOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.minorUpdatesAvailable" ) ); - } - else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.majorUpdatesAvailable" ) ); - } - else - { - renderSuccessIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.noUpdatesAvailable" ) ); - } - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.property" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( "${" + property.getName() + "}" ); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.associations" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - ArtifactAssociation[] associations = versions.getAssociations(); - for ( int i = 0; i < associations.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - sink.text( ArtifactUtils.versionlessKey( associations[i].getArtifact() ) ); - } - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( versions.getCurrentVersion().toString() ); - sink.tableCell_(); - sink.tableRow_(); - if ( artifactVersions.length > 0 ) - { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.updateVersions" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - boolean someNotAllowed = false; - for ( int i = 0; i < artifactVersions.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); - String label = getLabel( artifactVersions[i], versions ); - if ( !allowed ) - { - sink.text( "* " ); - someNotAllowed = true; - } - if ( allowed && label != null ) - { - safeBold(); - } - sink.text( artifactVersions[i].toString() ); - if ( label != null ) - { - if ( allowed ) - { - safeBold_(); - } - sink.nonBreakingSpace(); - safeItalic(); - sink.text( label ); - safeItalic_(); - } - } - if ( someNotAllowed ) - { - sink.lineBreak(); - sink.lineBreak(); - sink.text( "* " ); - safeItalic(); - sink.text( getText( "report.excludedVersion" ) ); - safeItalic_(); - } - sink.tableCell_(); - sink.tableRow_(); - } - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.versionRange" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( StringUtils.isEmpty( property.getVersion() ) ? "[,)" : property.getVersion() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.autoLinkDependencies" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isAutoLinkDependencies() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.banSnapshots" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isBanSnapshots() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.searchReactor" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isSearchReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.preferReactor" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isPreferReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRows_(); - sink.table_(); - } - - private Set getVersionsInRange( Property property, PropertyVersions versions, - ArtifactVersion[] artifactVersions ) - { - VersionRange range; - Set rangeVersions = new HashSet<>(); - ArtifactVersion[] tmp; - if ( property.getVersion() != null ) - { - try - { - range = VersionRange.createFromVersionSpec( property.getVersion() ); - tmp = versions.getAllUpdates( range ); - } - catch ( InvalidVersionSpecificationException e ) - { - tmp = artifactVersions; - } - } - else - { - tmp = artifactVersions; - } - for ( ArtifactVersion artifactVersion : tmp ) - { - rangeVersions.add( artifactVersion.toString() ); - } - return rangeVersions; - } - - protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) - { - if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.latestSubIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.nextVersion" ); - } - - if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.nextIncremental" ); - } - - if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.latestIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.nextMinor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.latestMinor" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.nextMajor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.latestMajor" ); - } - - return ""; - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java deleted file mode 100644 index d1d6b807af..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesRenderer.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.codehaus.mojo.versions; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.utils.DependencyComparator; -import org.codehaus.plexus.i18n.I18N; - -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - -/** - * @since 1.0-beta-1 - */ -public class DependencyUpdatesRenderer - extends AbstractVersionsReportRenderer -{ - - private final Map dependencyUpdates; - - private final Map dependencyManagementUpdates; - - public DependencyUpdatesRenderer( Sink sink, I18N i18n, String bundleName, Locale locale, - Map dependencyUpdates, - Map dependencyManagementUpdates ) - { - super( sink, bundleName, i18n, locale ); - this.dependencyUpdates = dependencyUpdates; - this.dependencyManagementUpdates = dependencyManagementUpdates; - } - - protected void renderBody() - { - Map allUpdates = new TreeMap<>( new DependencyComparator() ); - allUpdates.putAll( dependencyManagementUpdates ); - allUpdates.putAll( dependencyUpdates ); - - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.overview.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.overview.text" ) ); - sink.paragraph_(); - - renderSummaryTotalsTable( allUpdates ); - - renderDependencyManagementSummary(); - - renderDependencySummary(); - - sink.section1_(); - - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.detail.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.detail.text" ) ); - sink.paragraph_(); - - for ( Map.Entry entry : allUpdates.entrySet() ) - { - renderDependencyDetail( entry.getKey(), entry.getValue() ); - } - sink.section1_(); - } - - protected void renderDependencySummary() - { - renderSummaryTable( "report.overview.dependency", dependencyUpdates, "report.overview.noDependency" ); - } - - protected void renderDependencyManagementSummary() - { - renderSummaryTable( "report.overview.dependencyManagement", dependencyManagementUpdates, - "report.overview.noDependencyManagement" ); - } - - protected void renderSummaryTable( String titleKey, Map contents, String emptyKey ) - { - sink.section2(); - sink.sectionTitle2(); - sink.text( getText( titleKey ) ); - sink.sectionTitle2_(); - - if ( contents.isEmpty() ) - { - sink.paragraph(); - sink.text( getText( emptyKey ) ); - sink.paragraph_(); - } - else - { - renderDependencySummaryTable( contents ); - } - sink.section2_(); - } - - protected void renderSummaryTotalsTable( Map allUpdates ) - { - int numInc = 0; - int numMin = 0; - int numMaj = 0; - int numAny = 0; - int numCur = 0; - for ( ArtifactVersions details : allUpdates.values() ) - { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - numAny++; - } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) - { - numInc++; - } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) - { - numMin++; - } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) - { - numMaj++; - } - else - { - numCur++; - } - } - sink.table(); - sink.tableRow(); - sink.tableCell(); - renderSuccessIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numUpToDate" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numCur ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerVersionAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numAny ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numInc ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMinorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMin ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMajorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMaj ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.table_(); - } - - protected void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) - { - sink.section2(); - sink.sectionTitle2(); - sink.text( ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) ); - sink.sectionTitle2_(); - renderDependencyDetailTable( dependency, details ); - sink.section2_(); - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java similarity index 89% rename from src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java rename to src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 80b66a0607..8f40fa0f85 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -39,6 +39,9 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.plexus.i18n.I18N; @@ -53,7 +56,7 @@ */ @Mojo( name = "dependency-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class DependencyUpdatesReport extends AbstractVersionsReport +public class DependencyUpdatesReportMojo extends AbstractVersionsReport { /** @@ -101,10 +104,12 @@ public class DependencyUpdatesReport extends AbstractVersionsReport protected boolean onlyUpgradable; @Inject - protected DependencyUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + protected DependencyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, + ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager, rendererFactory ); } /** @@ -132,10 +137,10 @@ public boolean canGenerateReport() @SuppressWarnings( "deprecation" ) protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { - Set dependencies = new TreeSet<>( new DependencyComparator() ); + Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); dependencies.addAll( getProject().getDependencies() ); - Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); + Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); if ( processDependencyManagement ) { @@ -202,11 +207,9 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! { if ( "html".equals( format ) ) { - DependencyUpdatesRenderer renderer = - new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, dependencyUpdates, - dependencyManagementUpdates ); - renderer.render(); - + rendererFactory.createReportRenderer( getOutputName(), sink, locale, + new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ) ) + .render(); } else if ( "xml".equals( format ) ) { @@ -254,5 +257,5 @@ public String getOutputName() { return "dependency-updates-report"; } - } + diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index a34235cfa5..5227465810 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -355,7 +355,7 @@ public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) { - Set result = new TreeSet<>( new DependencyComparator() ); + Set result = new TreeSet<>( DependencyComparator.INSTANCE ); if ( build.getPluginManagement() != null ) { for ( Plugin plugin : build.getPluginManagement().getPlugins() ) @@ -371,7 +371,7 @@ private static Set extractPluginDependenciesFromPluginsInPluginManag private static Set extractDependenciesFromPlugins( List plugins ) { - Set result = new TreeSet<>( new DependencyComparator() ); + Set result = new TreeSet<>( DependencyComparator.INSTANCE ); for ( Plugin plugin : plugins ) { if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) @@ -395,7 +395,7 @@ private static Set extractDependenciesFromPlugins( List plug private static Set removeDependencyManagment( Set dependencies, Set dependencyManagement ) { - Set result = new TreeSet<>( new DependencyComparator() ); + Set result = new TreeSet<>( DependencyComparator.INSTANCE ); for ( Dependency dependency : dependencies ) { boolean matched = false; @@ -488,7 +488,7 @@ public void execute() validateInput(); - Set dependencyManagement = new TreeSet<>( new DependencyComparator() ); + Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); DependencyManagement projectDependencyManagement = getProjectDependencyManagement( getProject() ); if ( projectDependencyManagement != null ) { @@ -537,7 +537,7 @@ public void execute() } } - Set dependencies = new TreeSet<>( new DependencyComparator() ); + Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); dependencies.addAll( getProject().getDependencies() ); if ( isProcessingDependencyManagement() ) @@ -545,14 +545,14 @@ public void execute() dependencies = removeDependencyManagment( dependencies, dependencyManagement ); } - Set pluginDependencies = new TreeSet<>( new DependencyComparator() ); + Set pluginDependencies = new TreeSet<>( DependencyComparator.INSTANCE ); if ( isProcessingPluginDependencies() ) { pluginDependencies = extractDependenciesFromPlugins( getProject().getBuildPlugins() ); } - Set pluginDependenciesInPluginManagement = new TreeSet<>( new DependencyComparator() ); + Set pluginDependenciesInPluginManagement = new TreeSet<>( DependencyComparator.INSTANCE ); if ( isProcessPluginDependenciesInDependencyManagement() ) { pluginDependenciesInPluginManagement = diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 78c08f721c..fe15039f7c 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -1645,7 +1645,7 @@ private Set getProjectPlugins( Map superPomPluginManagem } debugPluginMap( "after adding reporting plugins for profile " + profile.getId(), plugins ); } - Set result = new TreeSet<>( new PluginComparator() ); + Set result = new TreeSet<>( PluginComparator.INSTANCE ); result.addAll( plugins.values() ); return result; } @@ -1702,7 +1702,7 @@ private void debugPluginMap( String description, Map plugins ) { if ( getLog().isDebugEnabled() ) { - Set sorted = new TreeSet<>( new PluginComparator() ); + Set sorted = new TreeSet<>( PluginComparator.INSTANCE ); sorted.addAll( plugins.values() ); StringBuilder buf = new StringBuilder( description ); for ( Plugin plugin : sorted ) diff --git a/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java similarity index 69% rename from src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java rename to src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index cbc99740f3..54adc31619 100644 --- a/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -23,14 +23,12 @@ import java.util.List; import java.util.Locale; -import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -38,12 +36,11 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.ParentUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.plexus.i18n.I18N; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; - /** * Generates a report on available updates for parent artifacts * @@ -51,17 +48,18 @@ * @since 2.13.0 */ @Mojo( name = "parent-updates-report", - requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = false ) -public class ParentUpdatesReport extends AbstractVersionsReport + requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) +public class ParentUpdatesReportMojo extends AbstractVersionsReport { @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) protected List reactorProjects; @Inject - protected ParentUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + protected ParentUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager, rendererFactory ); } /** @@ -106,28 +104,16 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( project.getParentArtifact(), false ); artifactVersions.setIncludeSnapshots( allowSnapshots ); - Dependency parent = DependencyBuilder.newBuilder() - .withGroupId( artifactVersions.getGroupId() ) - .withArtifactId( artifactVersions.getArtifactId() ) - .withVersion( artifactVersions.getArtifact().getVersion() ) - .withScope( artifactVersions.getArtifact().getScope() ) - .withType( artifactVersions.getArtifact().getType() ) - .withClassifier( artifactVersions.getArtifact().getClassifier() ) - .build(); - new DependencyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, - singletonMap( parent, artifactVersions ), emptyMap() ) - { - @Override - protected void renderSummaryTotalsTable( Map allUpdates ) - { - } - - @Override - protected void renderDependencyManagementSummary() - { - } - } - .renderBody(); + rendererFactory.createReportRenderer( getOutputName(), sink, locale, + new ParentUpdatesModel( DependencyBuilder.newBuilder() + .withGroupId( artifactVersions.getGroupId() ) + .withArtifactId( artifactVersions.getArtifactId() ) + .withVersion( artifactVersions.getArtifact().getVersion() ) + .withScope( artifactVersions.getArtifact().getScope() ) + .withType( artifactVersions.getArtifact().getType() ) + .withClassifier( artifactVersions.getArtifact().getClassifier() ) + .build(), artifactVersions ) ) + .render(); } catch ( ArtifactMetadataRetrievalException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java index a4fd2db234..84842b57ef 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java @@ -31,10 +31,8 @@ /** * Details of a plugin's updates. */ -public class PluginUpdatesDetails +public class PluginUpdatesDetails extends ArtifactVersions { - private final ArtifactVersions artifactVersions; - private final Map dependencyVersions; private final boolean includeSnapshots; @@ -42,18 +40,14 @@ public class PluginUpdatesDetails public PluginUpdatesDetails( ArtifactVersions artifactVersions, Map dependencyVersions, boolean includeSnapshots ) { + super( artifactVersions ); Objects.requireNonNull( artifactVersions ); Objects.requireNonNull( dependencyVersions ); - this.artifactVersions = artifactVersions; + this.dependencyVersions = dependencyVersions; this.includeSnapshots = includeSnapshots; } - public ArtifactVersions getArtifactVersions() - { - return artifactVersions; - } - public Map getDependencyVersions() { return dependencyVersions; @@ -66,7 +60,8 @@ public Map getDependencyVersions() */ public boolean isArtifactUpdateAvailable() { - return artifactVersions.getAllUpdates( empty(), includeSnapshots ).length > 0; + ArtifactVersion[] updates = getAllUpdates( empty(), includeSnapshots ); + return updates != null && updates.length > 0; } /** @@ -76,15 +71,11 @@ public boolean isArtifactUpdateAvailable() */ public boolean isDependencyUpdateAvailable() { - for ( ArtifactVersions versions : dependencyVersions.values() ) + return dependencyVersions.values().stream().anyMatch( versions -> { ArtifactVersion[] dependencyUpdates = versions.getAllUpdates( empty(), includeSnapshots ); - if ( dependencyUpdates != null && dependencyUpdates.length > 0 ) - { - return true; - } - } - return false; + return dependencyUpdates != null && dependencyUpdates.length > 0; + } ); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java similarity index 85% rename from src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java rename to src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 01c6409218..32503ec04a 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -38,6 +38,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.xml.PluginUpdatesXmlRenderer; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.mojo.versions.utils.PluginComparator; import org.codehaus.plexus.i18n.I18N; @@ -51,7 +54,7 @@ */ @Mojo( name = "plugin-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class PluginUpdatesReport extends AbstractVersionsReport +public class PluginUpdatesReportMojo extends AbstractVersionsReport { /** @@ -78,10 +81,11 @@ public class PluginUpdatesReport extends AbstractVersionsReport protected boolean onlyUpgradable; @Inject - protected PluginUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + protected PluginUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager, rendererFactory ); } /** @@ -121,19 +125,19 @@ private boolean haveBuildPlugins() */ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { - Set pluginManagement = new TreeSet<>( new PluginComparator() ); + Set pluginManagement = new TreeSet<>( PluginComparator.INSTANCE ); if ( haveBuildPluginManagementPlugins() ) { pluginManagement.addAll( getProject().getBuild().getPluginManagement().getPlugins() ); } - Set plugins = new TreeSet<>( new PluginComparator() ); + Set plugins = new TreeSet<>( PluginComparator.INSTANCE ); if ( haveBuildPlugins() ) { plugins.addAll( getProject().getBuild().getPlugins() ); } - PluginComparator comparator = new PluginComparator(); + PluginComparator comparator = PluginComparator.INSTANCE; if ( !onlyProjectPlugins ) { // Retains only plugins not present in pluginManagement @@ -157,19 +161,18 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx if ( onlyUpgradable ) { pluginUpdates = - filter( pluginUpdates, plugin -> plugin.getArtifactVersions().getVersions().length > 1 ); + filter( pluginUpdates, plugin -> plugin.getVersions().length > 1 ); pluginManagementUpdates = filter( pluginManagementUpdates, - plugin -> plugin.getArtifactVersions().getVersions().length > 1 ); + plugin -> plugin.getVersions().length > 1 ); } for ( String format : formats ) { if ( "html".equals( format ) ) { - PluginUpdatesRenderer renderer = - new PluginUpdatesRenderer( sink, getI18n(), getOutputName(), locale, pluginUpdates, - pluginManagementUpdates ); - renderer.render(); + rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, + new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ) ) + .render(); } else if ( "xml".equals( format ) ) { @@ -201,5 +204,5 @@ public String getOutputName() { return "plugin-updates-report"; } - } + diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java deleted file mode 100644 index b3d4686bb6..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesRenderer.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.codehaus.mojo.versions; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Locale; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.maven.doxia.sink.Sink; -import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.utils.PropertyComparator; -import org.codehaus.plexus.i18n.I18N; - -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - -/** - * @since 1.0-beta-1 - */ -public class PropertyUpdatesRenderer - extends AbstractVersionsReportRenderer -{ - - private final Map propertyUpdates; - - public PropertyUpdatesRenderer( Sink sink, I18N i18n, String bundleName, Locale locale, - Map propertyUpdates ) - { - super( sink, bundleName, i18n, locale ); - this.propertyUpdates = propertyUpdates; - } - - protected void renderBody() - { - Map allUpdates = new TreeMap<>( new PropertyComparator() ); - allUpdates.putAll( propertyUpdates ); - - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.overview.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.overview.text" ) ); - sink.paragraph_(); - - renderSummaryTotalsTable( allUpdates ); - - renderSummaryTable( "report.overview.property", propertyUpdates, "report.overview.noProperty" ); - - sink.section1_(); - - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.detail.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.detail.text" ) ); - sink.paragraph_(); - - for ( final Map.Entry entry : allUpdates.entrySet() ) - { - renderPropertyDetail( entry.getKey(), entry.getValue() ); - } - sink.section1_(); - } - - private void renderSummaryTable( String titleKey, Map contents, String emptyKey ) - { - sink.section2(); - sink.sectionTitle2(); - sink.text( getText( titleKey ) ); - sink.sectionTitle2_(); - - if ( contents.isEmpty() ) - { - sink.paragraph(); - sink.text( getText( emptyKey ) ); - sink.paragraph_(); - } - else - { - renderPropertySummaryTable( contents ); - } - sink.section2_(); - } - - private void renderSummaryTotalsTable( Map allUpdates ) - { - int numInc = 0; - int numMin = 0; - int numMaj = 0; - int numAny = 0; - int numCur = 0; - for ( PropertyVersions details : allUpdates.values() ) - { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - numAny++; - } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) - { - numInc++; - } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) - { - numMin++; - } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) - { - numMaj++; - } - else - { - numCur++; - } - } - sink.table(); - sink.tableRow(); - sink.tableCell(); - renderSuccessIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numUpToDate" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numCur ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerVersionAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numAny ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numInc ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMinorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMin ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMajorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMaj ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.table_(); - } - - private void renderPropertyDetail( Property property, PropertyVersions versions ) - { - sink.section2(); - sink.sectionTitle2(); - sink.text( "${" + property.getName() + "" ); - sink.sectionTitle2_(); - renderPropertyDetailTable( property, versions ); - sink.section2_(); - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java similarity index 82% rename from src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java rename to src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 4093b70c3e..3299d0e0ed 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReport.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -36,6 +36,8 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; import org.codehaus.mojo.versions.utils.PropertyComparator; import org.codehaus.plexus.i18n.I18N; @@ -48,10 +50,8 @@ */ @Mojo( name = "property-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class PropertyUpdatesReport - extends AbstractVersionsReport +public class PropertyUpdatesReportMojo extends AbstractVersionsReport { - /** * Any restrictions that apply to specific properties. * @@ -85,10 +85,12 @@ public class PropertyUpdatesReport private boolean autoLinkItems; @Inject - protected PropertyUpdatesReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager ) + protected PropertyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, + ArtifactResolver artifactResolver, + ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager ); + super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager, rendererFactory ); } /** @@ -115,7 +117,7 @@ private boolean haveBuildProperties() protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException { - final Map updateSet = new TreeMap<>( new PropertyComparator() ); + final Map updateSet = new TreeMap<>( PropertyComparator.INSTANCE ); try { updateSet.putAll( getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, @@ -125,9 +127,8 @@ protected void doGenerateReport( Locale locale, Sink sink ) { throw new MavenReportException( e.getMessage(), e ); } - PropertyUpdatesRenderer renderer = - new PropertyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, updateSet ); - renderer.render(); + rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, + new PropertyUpdatesModel( updateSet ) ).render(); } /** @@ -138,3 +139,4 @@ public String getOutputName() return "property-updates-report"; } } + diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index e5d9df192a..db28d1e990 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -30,6 +30,8 @@ import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.VersionComparator; +import static org.apache.commons.lang3.StringUtils.compare; + /** * Holds the results of a search for versions of an artifact. * @@ -37,7 +39,7 @@ * @since 1.0-alpha-3 */ public class ArtifactVersions - extends AbstractVersionDetails + extends AbstractVersionDetails implements Comparable { /** * The artifact that who's versions we hold details of. @@ -80,6 +82,36 @@ public ArtifactVersions( Artifact artifact, List versions, Vers } } + /** + * Creates a new {@link ArtifactVersions} instance as shallow copy of the other + * + * @param other other object to be linked to + * @since 2.13.0 + */ + public ArtifactVersions( ArtifactVersions other ) + { + artifact = other.artifact; + versionComparator = other.versionComparator; + versions = other.versions; + setCurrentVersion( other.getCurrentVersion() ); + setIncludeSnapshots( other.isIncludeSnapshots() ); + } + + @SuppressWarnings( "checkstyle:InnerAssignment" ) + public int compareTo( ArtifactVersions that ) + { + int rv; + return this == that + ? 0 + : that == null || getClass() != that.getClass() + ? 1 + : ( rv = compare( getGroupId(), that.getGroupId() ) ) != 0 + ? rv + : ( rv = compare( getArtifactId(), that.getArtifactId() ) ) != 0 + ? rv + : compare( getVersion(), that.getVersion() ); + } + /** * Checks if the version is in the range (and ensures that the range respects the -! syntax to rule out * any qualifiers from range boundaries). @@ -134,7 +166,7 @@ public Artifact getArtifact() } /** - * Returns the groupId of the artifact who's versions we are holding. + * Returns the groupId of the artifact which versions we are holding. * * @return the groupId. * @since 1.0-alpha-3 @@ -145,7 +177,7 @@ public String getGroupId() } /** - * Returns the artifactId of the artifact who's versions we are holding. + * Returns the artifactId of the artifact which versions we are holding. * * @return the artifactId. * @since 1.0-alpha-3 @@ -155,6 +187,17 @@ public String getArtifactId() return getArtifact().getArtifactId(); } + /** + * Returns the artifactId of the artifact which versions we are holding. + * + * @return current version + * @since 2.13.0 + */ + public String getVersion() + { + return getArtifact().getVersion(); + } + public ArtifactVersion[] getVersions( boolean includeSnapshots ) { return includeSnapshots diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java index f612462f07..e75ee3525b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java @@ -54,6 +54,7 @@ public String getArtifactId() return artifact.getArtifactId(); } + public Artifact getArtifact() { return artifact; diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index a7685eeccf..947333b60b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -311,7 +311,7 @@ private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String ser WagonManager wagonManager, Settings settings ) throws MojoExecutionException { - RuleSet loadedRules = new RuleSet(); + RuleSet loadedRules; int split = rulesUri.lastIndexOf( '/' ); String baseUri = rulesUri; @@ -681,7 +681,7 @@ public Map lookupDependenciesUpdates( Set dependencyUpdates = new TreeMap<>( new DependencyComparator() ); + final Map dependencyUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); // Lookup details in parallel... final ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); @@ -731,7 +731,7 @@ public Map lookupPluginsUpdates( Set plugi requestsForDetails.add( new PluginLookup( plugin, allowSnapshots ) ); } - Map pluginUpdates = new TreeMap<>( new PluginComparator() ); + Map pluginUpdates = new TreeMap<>( PluginComparator.INSTANCE ); // Lookup details in parallel... ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); @@ -768,13 +768,11 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) + " for updates newer than " + version ); - boolean includeSnapshots = allowSnapshots; - final ArtifactVersions pluginArtifactVersions = lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), version ), true ); - Set pluginDependencies = new TreeSet<>( new DependencyComparator() ); + Set pluginDependencies = new TreeSet<>( DependencyComparator.INSTANCE ); if ( plugin.getDependencies() != null ) { pluginDependencies.addAll( plugin.getDependencies() ); @@ -782,7 +780,7 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna Map pluginDependencyDetails = lookupDependenciesUpdates( pluginDependencies, false ); - return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, includeSnapshots ); + return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, allowSnapshots ); } @Override diff --git a/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java new file mode 100644 index 0000000000..376985ef93 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java @@ -0,0 +1,31 @@ +package org.codehaus.mojo.versions.api; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Common interface for reporting components + */ +public interface ReportRenderer +{ + /** + * Renders the report + */ + void render(); +} diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java index af021add5f..07bf61617e 100644 --- a/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java +++ b/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java @@ -62,6 +62,6 @@ private TreeSet filterBy( Set dependencies, Predicate new TreeSet<>( new DependencyComparator() ) ) ); + .collect( Collectors.toCollection( () -> new TreeSet<>( DependencyComparator.INSTANCE ) ) ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java new file mode 100644 index 0000000000..4f52245e53 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -0,0 +1,457 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Arrays; +import java.util.Locale; +import java.util.Map; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkEventAttributes; +import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ReportRenderer; +import org.codehaus.plexus.i18n.I18N; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + +/** + * Base class for report renderers. + * @param modelled report object + * + * @author Stephen Connolly + * @since 1.0-beta-1 + */ +public abstract class AbstractVersionsReportRenderer extends VersionsReportRendererBase implements ReportRenderer +{ + + /** + * Model of the object being rendered + * + * @since 2.13.0 + */ + protected T model; + + /** + * Constructor to be called by the dependency injection framework + * @param i18n i18n object to be injected + */ + protected AbstractVersionsReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, T model ) + { + super( sink, i18n, locale, bundleName ); + this.model = model; + } + + /** + * {@inheritDoc} + */ + protected void renderBody() + { + sink.section1(); + sink.sectionTitle1(); + sink.text( getText( "report.overview.title" ) ); + sink.sectionTitle1_(); + sink.paragraph(); + sink.text( getText( "report.overview.text" ) ); + sink.paragraph_(); + + renderOverview(); + + renderManagementSummaryTable(); + renderSummaryTable(); + + sink.section1_(); + + sink.section1(); + sink.sectionTitle1(); + sink.text( getText( "report.detail.title" ) ); + sink.sectionTitle1_(); + sink.paragraph(); + sink.text( getText( "report.detail.text" ) ); + sink.paragraph_(); + + renderDetails(); + + sink.section1_(); + } + + /** + * Renders the "Overview" table + */ + protected void renderOverview() + { + sink.table(); + sink.tableRow(); + renderOverviewTableRow( computeOverviewStats() ); + sink.tableRow_(); + sink.table_(); + } + + /** + * Renders the "management" (dependencyManagement, pluginManagement, etc.) summary table + */ + protected abstract void renderManagementSummaryTable(); + + /** + * Renders the regular ("dependencies", "plugins", etc.) summary table + */ + protected abstract void renderSummaryTable(); + + /** + * Renders the singular summary table row + * @param stats summary statistics object to render + * @param concrete {@linkplain OverviewStats} class + */ + protected void renderOverviewTableRow( Q stats ) + { + sink.tableCell(); + renderSuccessIcon(); + sink.tableCell_(); + sink.tableCell(); + sink.text( getText( "report.overview.numUpToDate" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( stats.getUpToDate() ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableCell(); + renderWarningIcon(); + sink.tableCell_(); + sink.tableCell(); + sink.text( getText( "report.overview.numNewerVersionAvailable" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( stats.getAny() ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableCell(); + renderWarningIcon(); + sink.tableCell_(); + sink.tableCell(); + sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( stats.getIncremental() ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableCell(); + renderWarningIcon(); + sink.tableCell_(); + sink.tableCell(); + sink.text( getText( "report.overview.numNewerMinorAvailable" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( stats.getMinor() ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableCell(); + renderWarningIcon(); + sink.tableCell_(); + sink.tableCell(); + sink.text( getText( "report.overview.numNewerMajorAvailable" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( stats.getMajor() ) ); + sink.tableCell_(); + } + + /** + * Computes the {@linkplain OverviewStats} object needed to render the summary table row + * @param concrete {@linkplain OverviewStats} class + * @return stats object + */ + protected abstract Q computeOverviewStats(); + + /** + * Renders the details table + */ + protected abstract void renderDetails(); + + protected void renderSummaryTable( Map contents, boolean hasScope ) + { + sink.table(); + + sink.tableRow(); + renderSummaryTableHeader( hasScope, true ); + sink.tableRow_(); + + contents.forEach( ( artifact, artifactVersions ) -> + renderSummaryTableRow( artifact, artifactVersions, hasScope ) ); + + sink.tableRow(); + renderSummaryTableHeader( hasScope, true ); + sink.tableRow_(); + + sink.table_(); + } + + protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) + { + renderTableHeaderCells( "report.status", "report.groupId", "report.artifactId", + "report.currentVersion" ); + if ( hasScope ) + { + renderTableHeaderCells( "report.scope" ); + } + if ( hasType ) + { + renderTableHeaderCells( "report.classifier", "report.type" ); + } + renderTableHeaderCells( "report.latestSubIncremental", + "report.latestIncremental", "report.latestMinor", "report.latestMajor" ); + } + + protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions artifactVersions, + boolean includeScope ) + { + sink.tableRow(); + sink.tableCell(); + ArtifactVersion[] allUpdates = artifactVersions.getAllUpdates( empty() ); + if ( allUpdates == null || allUpdates.length == 0 ) + { + renderSuccessIcon(); + } + else + { + renderWarningIcon(); + } + sink.tableCell_(); + sink.tableCell(); + sink.text( artifact.getGroupId() ); + sink.tableCell_(); + sink.tableCell(); + sink.text( artifact.getArtifactId() ); + sink.tableCell_(); + sink.tableCell(); + sink.text( artifact.getVersion() ); + sink.tableCell_(); + if ( includeScope ) + { + sink.tableCell(); + sink.text( artifact.getScope() ); + sink.tableCell_(); + } + sink.tableCell(); + sink.text( artifact.getClassifier() ); + sink.tableCell_(); + sink.tableCell(); + sink.text( artifact.getType() ); + sink.tableCell_(); + + sink.tableCell(); + if ( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + safeBold(); + sink.text( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + { + safeBold(); + sink.text( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( artifactVersions.getNewestUpdate( of( MINOR ) ) != null ) + { + safeBold(); + sink.text( artifactVersions.getNewestUpdate( of( MINOR ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( artifactVersions.getNewestUpdate( of( MAJOR ) ) != null ) + { + safeBold(); + sink.text( artifactVersions.getNewestUpdate( of( MAJOR ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableRow_(); + } + + @SuppressWarnings( "checkstyle:MethodLength" ) + protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope ) + { + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); + sink.table(); + sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.status" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + ArtifactVersion[] versions = details.getAllUpdates( empty() ); + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.otherUpdatesAvailable" ) ); + } + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.incrementalUpdatesAvailable" ) ); + } + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.minorUpdatesAvailable" ) ); + } + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.majorUpdatesAvailable" ) ); + } + else + { + renderSuccessIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.noUpdatesAvailable" ) ); + } + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.groupId" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getGroupId() ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.artifactId" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getArtifactId() ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.currentVersion" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getVersion() ); + sink.tableCell_(); + sink.tableRow_(); + if ( includeScope ) + { + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.scope" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getScope() ); + sink.tableCell_(); + sink.tableRow_(); + } + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.classifier" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getClassifier() ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.type" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( artifact.getType() ); + sink.tableCell_(); + sink.tableRow_(); + if ( versions != null && versions.length > 0 ) + { + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.updateVersions" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + for ( int i = 0; i < versions.length; i++ ) + { + if ( i > 0 ) + { + sink.lineBreak(); + } + String label = getLabel( versions[i], details ); + if ( label != null ) + { + safeBold(); + } + sink.text( versions[i].toString() ); + if ( label != null ) + { + safeBold_(); + sink.nonBreakingSpace(); + safeItalic(); + sink.text( label ); + safeItalic_(); + } + } + sink.tableCell_(); + sink.tableRow_(); + } + sink.tableRows_(); + sink.table_(); + } + + /** + * Renders a table header containing elements denoted by the given keys + * @param keys variable argument list containing keys of the property file to retrieve the + * headers from + */ + protected void renderTableHeaderCells( String... keys ) + { + Arrays.stream( keys ) + .map( this::getText ) + .forEachOrdered( str -> + { + sink.tableHeaderCell(); + sink.text( str ); + sink.tableHeaderCell_(); + } ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java new file mode 100644 index 0000000000..be5c140304 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -0,0 +1,131 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Locale; +import java.util.Map; + +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; +import org.codehaus.plexus.i18n.I18N; + +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + +/** + * @param type of the model + * @since 1.0-beta-1 + */ +public class DependencyUpdatesReportRenderer extends AbstractVersionsReportRenderer +{ + public DependencyUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, K model ) + { + super( i18n, sink, locale, bundleName, model ); + } + + /** + * {@inheritDoc} + */ + @Override + protected void renderDetails() + { + model.getAllUpdates().forEach( this::renderDependencyDetail ); + } + + @Override + protected void renderSummaryTable() + { + renderTable( "report.overview.dependency", model.getArtifactUpdates(), + "report.overview.noDependency" ); + } + + @Override + protected void renderManagementSummaryTable() + { + renderTable( "report.overview.dependencyManagement", + model.getArtifactManagementUpdates(), "report.overview.noDependencyManagement" ); + } + + protected void renderTable( String titleKey, Map contents, String emptyKey ) + { + sink.section2(); + sink.sectionTitle2(); + sink.text( getText( titleKey ) ); + sink.sectionTitle2_(); + + if ( contents.isEmpty() ) + { + sink.paragraph(); + sink.text( getText( emptyKey ) ); + sink.paragraph_(); + } + else + { + renderSummaryTable( contents, true ); + } + sink.section2_(); + } + + @Override + protected OverviewStats computeOverviewStats() + { + OverviewStats stats = new OverviewStats(); + model.getAllUpdates().values().forEach( details -> + { + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + stats.incrementAny(); + } + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + { + stats.incrementIncremental(); + } + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + { + stats.incrementMinor(); + } + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + { + stats.incrementMajor(); + } + else + { + stats.incrementUpToDate(); + } + } ); + return stats; + } + + protected void renderDependencyDetail( Dependency artifact, ArtifactVersions details ) + { + sink.section2(); + sink.sectionTitle2(); + sink.text( ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ) ); + sink.sectionTitle2_(); + renderDependencyDetailTable( artifact, details, true ); + sink.section2_(); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java new file mode 100644 index 0000000000..4cff6950a7 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java @@ -0,0 +1,89 @@ +package org.codehaus.mojo.versions.reporting; + + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Represents summary stats + * + * @author Andrzej Jarmoniuk + */ +class OverviewStats +{ + private int major; + + private int minor; + + private int incremental; + + private int any; + + private int upToDate; + + public int getMajor() + { + return major; + } + + public void incrementMajor() + { + major++; + } + + public int getMinor() + { + return minor; + } + + public void incrementMinor() + { + minor++; + } + + public int getIncremental() + { + return incremental; + } + + public void incrementIncremental() + { + incremental++; + } + + public int getAny() + { + return any; + } + + public void incrementAny() + { + any++; + } + + public int getUpToDate() + { + return upToDate; + } + + public void incrementUpToDate() + { + upToDate++; + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java new file mode 100644 index 0000000000..63ea6fc969 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java @@ -0,0 +1,48 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Locale; + +import org.apache.maven.doxia.sink.Sink; +import org.codehaus.mojo.versions.reporting.model.ParentUpdatesModel; +import org.codehaus.plexus.i18n.I18N; + +/** + * @since 1.0-beta-1 + */ +public class ParentUpdatesReportRenderer extends DependencyUpdatesReportRenderer +{ + public ParentUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, + ParentUpdatesModel model ) + { + super( i18n, sink, locale, bundleName, model ); + } + + @Override + protected void renderOverview() + { + } + + @Override + protected void renderManagementSummaryTable() + { + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java similarity index 51% rename from src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java rename to src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index de7b3677d7..869bcfd6e3 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -1,4 +1,4 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.reporting; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -22,7 +22,6 @@ import java.text.MessageFormat; import java.util.Locale; import java.util.Map; -import java.util.TreeMap; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -30,9 +29,9 @@ import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; -import org.apache.maven.model.Plugin; +import org.codehaus.mojo.versions.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.utils.PluginComparator; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.plexus.i18n.I18N; import static java.util.Optional.empty; @@ -45,228 +44,159 @@ /** * @since 1.0-beta-1 */ -public class PluginUpdatesRenderer - extends AbstractVersionsReportRenderer +public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer { - private final Map pluginUpdates; + public PluginUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, + PluginUpdatesModel model ) + { + super( i18n, sink, locale, bundleName, model ); + } - private final Map pluginManagementUpdates; + @Override + protected void renderSummaryTable() + { + renderTable( "report.overview.plugin", model.getArtifactUpdates(), + "report.overview.noPlugin" ); + } - public PluginUpdatesRenderer( Sink sink, I18N i18n, String bundleName, Locale locale, - Map pluginUpdates, - Map pluginManagementUpdates ) + protected void renderManagementSummaryTable() { - super( sink, bundleName, i18n, locale ); - this.pluginUpdates = pluginUpdates; - this.pluginManagementUpdates = pluginManagementUpdates; + renderTable( "report.overview.pluginManagement", model.getArtifactManagementUpdates(), + "report.overview.noPluginManagement" ); } - protected void renderBody() + /** + * {@inheritDoc} + */ + @Override + protected void renderDetails() { - Map allUpdates = new TreeMap<>( new PluginComparator() ); - allUpdates.putAll( pluginManagementUpdates ); - allUpdates.putAll( pluginUpdates ); + model.getAllUpdates().forEach( this::renderPluginDetail ); + } - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.overview.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.overview.text" ) ); - sink.paragraph_(); + private void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) + { + sink.section3(); + sink.sectionTitle3(); + sink.text( MessageFormat.format( getText( "report.pluginDependency" ), + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) ) ); + sink.sectionTitle3_(); + renderDependencyDetailTable( dependency, details, false ); + sink.section3_(); + } - renderSummaryTotalsTable( allUpdates ); + private void renderTable( String titleKey, Map contents, String emptyKey ) + { + sink.section2(); + sink.sectionTitle2(); + sink.text( getText( titleKey ) ); + sink.sectionTitle2_(); + + if ( contents.isEmpty() ) + { + sink.paragraph(); + sink.text( getText( emptyKey ) ); + sink.paragraph_(); + } + else + { + renderSummaryTable( contents ); + } + sink.section2_(); + } + + protected void renderSummaryTable( Map contents ) + { + sink.table(); + + sink.tableRow(); + renderSummaryTableHeader( false, false ); + sink.tableRow_(); - renderSummaryTable( "report.overview.pluginManagement", pluginManagementUpdates, - "report.overview.noPluginManagement" ); + contents.forEach( this::renderSummaryTableRow ); - renderSummaryTable( "report.overview.plugin", pluginUpdates, "report.overview.noPlugin" ); + sink.tableRow(); + renderSummaryTableHeader( false, false ); + sink.tableRow_(); - sink.section1_(); + sink.table_(); + } - sink.section1(); - sink.sectionTitle1(); - sink.text( getText( "report.detail.title" ) ); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text( getText( "report.detail.text" ) ); - sink.paragraph_(); + /** + * Extension of the {@linkplain OverviewStats} adding dependency stats + */ + static class PluginOverviewStats extends OverviewStats + { + private int dependencies; - for ( final Map.Entry entry : allUpdates.entrySet() ) + public int getDependencies() { - renderPluginDetail( entry.getKey(), entry.getValue() ); + return dependencies; } - sink.section1_(); + public void incrementDependencies() + { + dependencies++; + } } - private void renderSummaryTotalsTable( Map allUpdates ) + /** + * {@inheritDoc} + */ + @Override + protected PluginOverviewStats computeOverviewStats() { - int numInc = 0; - int numMin = 0; - int numMaj = 0; - int numAny = 0; - int numCur = 0; - int numDep = 0; - for ( PluginUpdatesDetails pluginDetails : allUpdates.values() ) + PluginOverviewStats stats = new PluginOverviewStats(); + model.getAllUpdates().values().forEach( details -> { - ArtifactVersions details = pluginDetails.getArtifactVersions(); if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { - numAny++; + stats.incrementAny(); } else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) { - numInc++; + stats.incrementIncremental(); } else if ( details.getOldestUpdate( of( MINOR ) ) != null ) { - numMin++; + stats.incrementMinor(); } else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) { - numMaj++; + stats.incrementMajor(); } else { - numCur++; + stats.incrementUpToDate(); } - if ( pluginDetails.isDependencyUpdateAvailable() ) + if ( details.isDependencyUpdateAvailable() ) { - numDep++; + stats.incrementDependencies(); } - } - sink.table(); - sink.tableRow(); - sink.tableCell(); - renderSuccessIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numUpToDate" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numCur ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerVersionAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numAny ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numInc ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMinorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMin ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMajorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numMaj ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerDependenciesAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( numDep ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.table_(); + } ); + return stats; } - private void renderSummaryTable( String titleKey, Map contents, String emptyKey ) + @Override + protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) { - sink.section2(); - sink.sectionTitle2(); - sink.text( getText( titleKey ) ); - sink.sectionTitle2_(); - - if ( contents.isEmpty() ) - { - sink.paragraph(); - sink.text( getText( emptyKey ) ); - sink.paragraph_(); - } - else - { - sink.table(); - renderSummaryTableHeader(); - for ( final Map.Entry entry : contents.entrySet() ) - { - renderPluginSummary( entry.getKey(), entry.getValue() ); - } - renderSummaryTableHeader(); - sink.table_(); - } - sink.section2_(); + super.renderSummaryTableHeader( hasScope, hasType ); + renderTableHeaderCells( "report.dependencyStatus" ); } - private void renderSummaryTableHeader() + @Override + protected void renderOverviewTableRow( T stats ) { - sink.tableRow(); - sink.tableHeaderCell(); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.groupId" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.artifactId" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestSubIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestIncremental" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMinor" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.latestMajor" ) ); - sink.tableHeaderCell_(); - sink.tableHeaderCell(); - sink.text( getText( "report.dependencyStatus" ) ); - sink.tableHeaderCell_(); - sink.tableRow_(); + super.renderOverviewTableRow( stats ); + sink.tableCell(); + sink.text( getText( "report.overview.numNewerDependenciesAvailable" ) ); + sink.tableCell_(); + sink.tableCell(); + sink.text( Integer.toString( ( (PluginOverviewStats) stats ).getDependencies() ) ); + sink.tableCell_(); } - private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) + protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details ) { sink.tableRow(); sink.tableCell(); @@ -280,17 +210,17 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) } sink.tableCell_(); sink.tableCell(); - sink.text( plugin.getGroupId() ); + sink.text( artifact.getGroupId() ); sink.tableCell_(); sink.tableCell(); - sink.text( plugin.getArtifactId() ); + sink.text( artifact.getArtifactId() ); sink.tableCell_(); sink.tableCell(); if ( !details.isArtifactUpdateAvailable() ) { safeBold(); } - sink.text( plugin.getVersion() ); + sink.text( artifact.getVersion() ); if ( !details.isArtifactUpdateAvailable() ) { safeBold_(); @@ -298,37 +228,37 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( details.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( details.getNewestUpdate( of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( of( MINOR ) ) != null ) + if ( details.getNewestUpdate( of( MINOR ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( details.getNewestUpdate( of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ) != null ) + if ( details.getNewestUpdate( of( MAJOR ) ) != null ) { safeBold(); - sink.text( details.getArtifactVersions().getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( details.getNewestUpdate( of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -348,7 +278,7 @@ private void renderPluginSummary( Plugin plugin, PluginUpdatesDetails details ) } @SuppressWarnings( "checkstyle:MethodLength" ) - private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) + private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails plugin ) { final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); @@ -366,26 +296,26 @@ private void renderPluginDetail( Plugin plugin, PluginUpdatesDetails details ) sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = details.getArtifactVersions().getAllUpdates( empty() ); - if ( details.getArtifactVersions().getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + ArtifactVersion[] versions = plugin.getAllUpdates( empty() ); + if ( plugin.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( plugin.getOldestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( of( MINOR ) ) != null ) + else if ( plugin.getOldestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) + else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -423,7 +353,7 @@ else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) sink.text( plugin.getVersion() ); sink.tableCell_(); sink.tableRow_(); - if ( versions.length > 0 ) + if ( versions != null && versions.length > 0 ) { sink.tableRow(); sink.tableHeaderCell( headerAttributes ); @@ -436,7 +366,7 @@ else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) { sink.lineBreak(); } - String label = getLabel( versions[i], details.getArtifactVersions() ); + String label = getLabel( versions[i], plugin ); if ( label != null ) { safeBold(); @@ -457,7 +387,7 @@ else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) sink.tableRows_(); sink.table_(); - if ( !details.getDependencyVersions().isEmpty() ) + if ( !plugin.getDependencyVersions().isEmpty() ) { sink.section3(); sink.sectionTitle3(); @@ -465,25 +395,13 @@ else if ( details.getArtifactVersions().getOldestUpdate( of( MAJOR ) ) != null ) ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); sink.sectionTitle3_(); - renderDependencySummaryTable( details.getDependencyVersions(), false, true, true ); + renderSummaryTable( plugin.getDependencyVersions(), false ); sink.section3_(); - details.getDependencyVersions() - .forEach( this::renderDependencyDetail ); + plugin.getDependencyVersions().forEach( this::renderDependencyDetail ); } sink.section2_(); } - - private void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) - { - sink.section3(); - sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependency" ), - ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) ) ); - sink.sectionTitle3_(); - renderDependencyDetailTable( dependency, details, false, true, true ); - sink.section3_(); - } - } + diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java new file mode 100644 index 0000000000..32ebe9246a --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -0,0 +1,431 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.HashSet; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkEventAttributes; +import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; +import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.ArtifactAssociation; +import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; +import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.util.StringUtils; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + +/** + * @since 1.0-beta-1 + */ +public class PropertyUpdatesReportRenderer extends AbstractVersionsReportRenderer +{ + public PropertyUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, + PropertyUpdatesModel model ) + { + super( i18n, sink, locale, bundleName, model ); + } + + @Override + protected void renderManagementSummaryTable() + { + } + + @Override + protected void renderSummaryTable() + { + renderTable( "report.overview.property", model.getAllUpdates(), + "report.overview.noProperty" ); + } + + /** + * {@inheritDoc} + */ + @Override + protected void renderDetails() + { + model.getAllUpdates().forEach( this::renderPropertyDetail ); + } + + protected void renderTable( String titleKey, Map contents, String emptyKey ) + { + sink.section2(); + sink.sectionTitle2(); + sink.text( getText( titleKey ) ); + sink.sectionTitle2_(); + + if ( contents.isEmpty() ) + { + sink.paragraph(); + sink.text( getText( emptyKey ) ); + sink.paragraph_(); + } + else + { + renderSummaryTable( contents ); + } + sink.section2_(); + } + + protected void renderSummaryTable( Map contents ) + { + sink.table(); + + sink.tableRow(); + renderSummaryTableHeader( false, false ); + sink.tableRow_(); + + contents.forEach( this::renderPropertySummaryTableRow ); + + sink.tableRow(); + renderSummaryTableHeader( false, false ); + sink.tableRow_(); + + sink.table_(); + } + + private void renderPropertySummaryTableRow( Property property, PropertyVersions versions ) + { + sink.tableRow(); + sink.tableCell(); + if ( versions.getAllUpdates( empty() ).length == 0 ) + { + renderSuccessIcon(); + } + else + { + renderWarningIcon(); + } + sink.tableCell_(); + sink.tableCell(); + sink.text( "${" + property.getName() + "}" ); + sink.tableCell_(); + sink.tableCell(); + sink.text( versions.getCurrentVersion().toString() ); + sink.tableCell_(); + + sink.tableCell(); + if ( versions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + safeBold(); + sink.text( versions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( versions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + { + safeBold(); + sink.text( versions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( versions.getNewestUpdate( of( MINOR ) ) != null ) + { + safeBold(); + sink.text( versions.getNewestUpdate( of( MINOR ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableCell(); + if ( versions.getNewestUpdate( of( MAJOR ) ) != null ) + { + safeBold(); + sink.text( versions.getNewestUpdate( of( MAJOR ) ).toString() ); + safeBold_(); + } + sink.tableCell_(); + + sink.tableRow_(); + } + + @SuppressWarnings( "checkstyle:MethodLength" ) + protected void renderPropertyDetailTable( Property property, PropertyVersions versions ) + { + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); + sink.table(); + sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.status" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + ArtifactVersion[] artifactVersions = versions.getAllUpdates( empty() ); + Set rangeVersions = getVersionsInRange( property, versions, artifactVersions ); + if ( versions.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.otherUpdatesAvailable" ) ); + } + else if ( versions.getOldestUpdate( of( INCREMENTAL ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.incrementalUpdatesAvailable" ) ); + } + else if ( versions.getOldestUpdate( of( MINOR ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.minorUpdatesAvailable" ) ); + } + else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) + { + renderWarningIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.majorUpdatesAvailable" ) ); + } + else + { + renderSuccessIcon(); + sink.nonBreakingSpace(); + sink.text( getText( "report.noUpdatesAvailable" ) ); + } + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.property" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( "${" + property.getName() + "}" ); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.associations" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + ArtifactAssociation[] associations = versions.getAssociations(); + for ( int i = 0; i < associations.length; i++ ) + { + if ( i > 0 ) + { + sink.lineBreak(); + } + sink.text( ArtifactUtils.versionlessKey( associations[i].getArtifact() ) ); + } + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.currentVersion" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( versions.getCurrentVersion().toString() ); + sink.tableCell_(); + sink.tableRow_(); + if ( artifactVersions.length > 0 ) + { + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.updateVersions" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + boolean someNotAllowed = false; + for ( int i = 0; i < artifactVersions.length; i++ ) + { + if ( i > 0 ) + { + sink.lineBreak(); + } + boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); + String label = getLabel( artifactVersions[i], versions ); + if ( !allowed ) + { + sink.text( "* " ); + someNotAllowed = true; + } + if ( allowed && label != null ) + { + safeBold(); + } + sink.text( artifactVersions[i].toString() ); + if ( label != null ) + { + if ( allowed ) + { + safeBold_(); + } + sink.nonBreakingSpace(); + safeItalic(); + sink.text( label ); + safeItalic_(); + } + } + if ( someNotAllowed ) + { + sink.lineBreak(); + sink.lineBreak(); + sink.text( "* " ); + safeItalic(); + sink.text( getText( "report.excludedVersion" ) ); + safeItalic_(); + } + sink.tableCell_(); + sink.tableRow_(); + } + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.versionRange" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( StringUtils.isEmpty( property.getVersion() ) ? "[,)" : property.getVersion() ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.autoLinkDependencies" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( property.isAutoLinkDependencies() ? getText( "report.yes" ) : getText( "report.no" ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.banSnapshots" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( property.isBanSnapshots() ? getText( "report.yes" ) : getText( "report.no" ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.searchReactor" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( property.isSearchReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); + sink.tableCell_(); + sink.tableRow_(); + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( "report.preferReactor" ) ); + sink.tableHeaderCell_(); + sink.tableCell( cellAttributes ); + sink.text( property.isPreferReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); + sink.tableCell_(); + sink.tableRow_(); + + sink.tableRows_(); + sink.table_(); + } + + @SuppressWarnings( "checkstyle:MethodLength" ) + protected Set getVersionsInRange( Property property, PropertyVersions versions, + ArtifactVersion[] artifactVersions ) + { + VersionRange range; + Set rangeVersions = new HashSet<>(); + ArtifactVersion[] tmp; + if ( property.getVersion() != null ) + { + try + { + range = VersionRange.createFromVersionSpec( property.getVersion() ); + tmp = versions.getAllUpdates( range ); + } + catch ( InvalidVersionSpecificationException e ) + { + tmp = artifactVersions; + } + } + else + { + tmp = artifactVersions; + } + for ( ArtifactVersion artifactVersion : tmp ) + { + rangeVersions.add( artifactVersion.toString() ); + } + return rangeVersions; + } + + @Override + protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) + { + renderTableHeaderCells( "report.status", "report.property", "report.currentVersion", + "report.latestSubIncremental", "report.latestIncremental", "report.latestMinor", + "report.latestMajor" ); + } + + @Override + protected OverviewStats computeOverviewStats() + { + OverviewStats stats = new OverviewStats(); + model.getAllUpdates().values().forEach( details -> + { + if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + { + stats.incrementAny(); + } + else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + { + stats.incrementIncremental(); + } + else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + { + stats.incrementMinor(); + } + else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + { + stats.incrementMajor(); + } + else + { + stats.incrementUpToDate(); + } + } ); + return stats; + } + + private void renderPropertyDetail( Property property, PropertyVersions versions ) + { + sink.section2(); + sink.sectionTitle2(); + sink.text( "${" + property.getName() + "}" ); + sink.sectionTitle2_(); + renderPropertyDetailTable( property, versions ); + sink.section2_(); + } + +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java b/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java new file mode 100644 index 0000000000..c762b2efb8 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java @@ -0,0 +1,45 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Locale; + +import org.apache.maven.doxia.sink.Sink; +import org.codehaus.mojo.versions.api.ReportRenderer; + +/** + * Factory for report renderers + */ +public interface ReportRendererFactory +{ + /** + * Creates a new {@linkplain ReportRenderer} instance for the given report renderer name. + * + * @param concrete class of the report renderer + * @param reportName name of the report to generate + * @param sink sink to use for rendering + * @param locale locale to use for rendering + * @param model data to render + * @return new report renderer + * @throws IllegalArgumentException thrown if the report with the given name could not be found + */ + T createReportRenderer( String reportName, Sink sink, Locale locale, U model ) + throws IllegalArgumentException; +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java b/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java new file mode 100644 index 0000000000..d1344a811c --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java @@ -0,0 +1,85 @@ +package org.codehaus.mojo.versions.reporting; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Locale; + +import org.apache.maven.doxia.sink.Sink; +import org.codehaus.mojo.versions.api.ReportRenderer; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; +import org.codehaus.mojo.versions.reporting.model.ParentUpdatesModel; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; +import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; +import org.codehaus.plexus.i18n.I18N; + +/** + * Factory for report renderers + */ +@Named +@Singleton +public class ReportRendererFactoryImpl implements ReportRendererFactory +{ + public static final String DEPENDENCY_UPDATES_REPORT = "dependency-updates-report"; + public static final String PLUGIN_UPDATES_REPORT = "plugin-updates-report"; + public static final String PROPERTY_UPDATES_REPORT = "property-updates-report"; + public static final String PARENT_UPDATES_REPORT = "parent-updates-report"; + private final I18N i18N; + + @Inject + public ReportRendererFactoryImpl( I18N i18N ) + { + this.i18N = i18N; + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings( "unchecked" ) + public T createReportRenderer( String reportName, Sink sink, Locale locale, U model ) + throws IllegalArgumentException + { + if ( DEPENDENCY_UPDATES_REPORT.equals( reportName ) ) + { + return (T) new DependencyUpdatesReportRenderer<>( i18N, sink, locale, reportName, + (DependencyUpdatesModel) model ); + } + if ( PLUGIN_UPDATES_REPORT.equals( reportName ) ) + { + return (T) new PluginUpdatesReportRenderer( i18N, sink, locale, reportName, + (PluginUpdatesModel) model ); + } + if ( PROPERTY_UPDATES_REPORT.equals( reportName ) ) + { + return (T) new PropertyUpdatesReportRenderer( i18N, sink, locale, reportName, + (PropertyUpdatesModel) model ); + } + if ( PARENT_UPDATES_REPORT.equals( reportName ) ) + { + return (T) new ParentUpdatesReportRenderer( i18N, sink, locale, reportName, + (ParentUpdatesModel) model ); + } + throw new IllegalArgumentException( "Invalid report name: " + reportName ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java new file mode 100644 index 0000000000..28640a78f8 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -0,0 +1,196 @@ +package org.codehaus.mojo.versions.reporting; + + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Locale; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.reporting.AbstractMavenReportRenderer; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; +import org.codehaus.plexus.i18n.I18N; + +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + +/** + * Base class over AbstractVersionsReportRenderer providing base + * utility methods + */ +public abstract class VersionsReportRendererBase extends AbstractMavenReportRenderer +{ + /** + * Internationalization component. + * + * @since 1.0-beta-1 + */ + protected final I18N i18n; + /** + * The locale we are rendering for. + * + * @since 1.0-beta-1 + */ + protected Locale locale; + /** + * The name of the bundle containing our I18n resources. + * + * @since 1.0-beta-1 + */ + protected String bundleName; + + public VersionsReportRendererBase( Sink sink, I18N i18n, Locale locale, String bundleName ) + { + super( sink ); + this.i18n = i18n; + this.locale = locale; + this.bundleName = bundleName; + } + + public String getTitle() + { + return getText( "report.title" ); + } + + /** + * Gets the localized message for this report. + * + * @param key the message key. + * @return the message. + */ + public String getText( String key ) + { + return i18n.getString( bundleName, locale, key ); + } + + protected void renderWarningIcon() + { + sink.figureGraphics( "images/icon_warning_sml.gif" ); + } + + protected void renderSuccessIcon() + { + sink.figureGraphics( "images/icon_success_sml.gif" ); + } + + protected boolean equals( ArtifactVersion v1, ArtifactVersion v2 ) + { + return v1 == v2 || ( v1 != null && v1.equals( v2 ) ) + || ( v1 != null && v2 != null && v1.toString().equals( v2.toString() ) ); + } + + protected void safeBold() + { + try + { + sink.bold(); + } + catch ( NoSuchMethodError e ) + { + // ignore Maven 2.1.0 + } + } + + @SuppressWarnings( "checkstyle:MethodName" ) + protected void safeBold_() + { + try + { + sink.bold_(); + } + catch ( NoSuchMethodError e ) + { + // ignore Maven 2.1.0 + } + } + + protected void safeItalic() + { + try + { + sink.italic(); + } + catch ( NoSuchMethodError e ) + { + // ignore Maven 2.1.0 + } + } + + @SuppressWarnings( "checkstyle:MethodName" ) + protected void safeItalic_() + { + try + { + sink.italic_(); + } + catch ( NoSuchMethodError e ) + { + // ignore Maven 2.1.0 + } + } + + protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) + { + if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) + { + return getText( "report.latestSubIncremental" ); + } + + if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) + { + return getText( "report.nextVersion" ); + } + + if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) + { + return getText( "report.nextIncremental" ); + } + + if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) + { + return getText( "report.latestIncremental" ); + } + + if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) + { + return getText( "report.nextMinor" ); + } + + if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) + { + return getText( "report.latestMinor" ); + } + + if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) + { + return getText( "report.nextMajor" ); + } + + if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) + { + return getText( "report.latestMajor" ); + } + + return ""; + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java b/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java new file mode 100644 index 0000000000..f3a6ba6365 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java @@ -0,0 +1,72 @@ +package org.codehaus.mojo.versions.reporting.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Map; +import java.util.TreeMap; +import java.util.function.Function; + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.utils.DependencyComparator; + +/** + * Base class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API + * @param class extending ArtifactVersion in the constructor + */ +public abstract class AbstractUpdatesModel +{ + private final Map artifactUpdates; + private final Map artifactManagementUpdates; + private final Map allUpdates; + + public AbstractUpdatesModel( Map artifactUpdates, + Map artifactManagementUpdates, + Function supplier ) + { + this.artifactUpdates = artifactUpdates.entrySet().stream().collect( + () -> new TreeMap<>( DependencyComparator.INSTANCE ), + ( map, entry ) -> map.put( supplier.apply( entry.getKey() ), entry.getValue() ), + Map::putAll ); + this.artifactManagementUpdates = artifactManagementUpdates.entrySet().stream().collect( + () -> new TreeMap<>( DependencyComparator.INSTANCE ), + ( map, entry ) -> map.put( supplier.apply( entry.getKey() ), entry.getValue() ), + Map::putAll ); + allUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); + // overriding entries from dependencyManagementUpdates with dependencyUpdates + allUpdates.putAll( this.artifactManagementUpdates ); + allUpdates.putAll( this.artifactUpdates ); + } + + public Map getArtifactUpdates() + { + return artifactUpdates; + } + + public Map getArtifactManagementUpdates() + { + return artifactManagementUpdates; + } + + public Map getAllUpdates() + { + return allUpdates; + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java b/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java new file mode 100644 index 0000000000..fd4ebadb85 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java @@ -0,0 +1,37 @@ +package org.codehaus.mojo.versions.reporting.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Map; + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.ArtifactVersions; + +/** + * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API + */ +public class DependencyUpdatesModel extends AbstractUpdatesModel +{ + public DependencyUpdatesModel( Map dependencyUpdates, + Map dependencyManagementUpdates ) + { + super( dependencyUpdates, dependencyManagementUpdates, id -> id ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java b/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java new file mode 100644 index 0000000000..9924a64154 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java @@ -0,0 +1,37 @@ +package org.codehaus.mojo.versions.reporting.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.ArtifactVersions; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; + +/** + * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API + */ +public class ParentUpdatesModel extends DependencyUpdatesModel +{ + public ParentUpdatesModel( Dependency parent, ArtifactVersions dependencyUpdates ) + { + super( singletonMap( parent, dependencyUpdates ), emptyMap() ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java b/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java new file mode 100644 index 0000000000..1846624a53 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java @@ -0,0 +1,42 @@ +package org.codehaus.mojo.versions.reporting.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Map; + +import org.apache.maven.model.Plugin; +import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.utils.DependencyBuilder; + +/** + * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API + */ +public class PluginUpdatesModel extends AbstractUpdatesModel +{ + public PluginUpdatesModel( Map pluginUpdates, + Map pluginManagementUpdates ) + { + super( pluginUpdates, pluginManagementUpdates, p -> DependencyBuilder.newBuilder() + .withGroupId( p.getGroupId() ) + .withArtifactId( p.getArtifactId() ) + .withVersion( p.getVersion() ) + .build() ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java b/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java new file mode 100644 index 0000000000..9a5d36cfc0 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java @@ -0,0 +1,46 @@ +package org.codehaus.mojo.versions.reporting.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Map; +import java.util.TreeMap; + +import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.utils.PropertyComparator; + +/** + * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API + */ +public class PropertyUpdatesModel +{ + private final Map allUpdates; + + public PropertyUpdatesModel( Map propertyUpdates ) + { + this.allUpdates = new TreeMap<>( PropertyComparator.INSTANCE ); + this.allUpdates.putAll( propertyUpdates ); + } + + public Map getAllUpdates() + { + return allUpdates; + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java index 20be1ad5f3..8330fc4b28 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java @@ -21,6 +21,7 @@ import java.util.Comparator; +import org.apache.commons.lang3.StringUtils; import org.apache.maven.model.Dependency; /** @@ -28,9 +29,9 @@ * * @since 1.0-alpha-1 */ -public class DependencyComparator - implements Comparator +public enum DependencyComparator implements Comparator { + INSTANCE; /** * @param d1 the first dependency @@ -39,29 +40,21 @@ public class DependencyComparator * @see java.util.Comparator#compare(Object, Object) * @since 1.0-alpha-1 */ + @SuppressWarnings( "checkstyle:InnerAssignment" ) public int compare( Dependency d1, Dependency d2 ) { - int r = d1.getGroupId().compareTo( d2.getGroupId() ); - if ( r == 0 ) - { - r = d1.getArtifactId().compareTo( d2.getArtifactId() ); - } - if ( r == 0 ) - { - String v1 = d1.getVersion(); - String v2 = d2.getVersion(); - if ( v1 == null ) - { - // hope I got the +1/-1 the right way around - return v2 == null ? 0 : -1; - } - if ( v2 == null ) - { - return 1; - } - r = v1.compareTo( v2 ); - } - return r; + int r; + return d1 == d2 + ? 0 + : d1 == null + ? 1 + : d2 == null + ? -1 + : ( r = StringUtils.compare( d1.getGroupId(), d2.getGroupId() ) ) != 0 + ? r + : ( r = StringUtils.compare( d1.getArtifactId(), d2.getArtifactId() ) ) != 0 + ? r + : StringUtils.compare( d1.getVersion(), d2.getVersion() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java index b62a06ec08..d4efe84646 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java @@ -29,9 +29,9 @@ * * @since 1.0-beta-1 */ -public class PluginComparator - implements Comparator +public enum PluginComparator implements Comparator { + INSTANCE; /** * Compares to {@link Plugin} or {@link ReportPlugin} instances. diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java index a00af7d2b0..676df82494 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java @@ -21,6 +21,7 @@ import java.util.Comparator; +import org.apache.commons.lang3.StringUtils; import org.codehaus.mojo.versions.Property; /** @@ -28,9 +29,10 @@ * * @since 1.0-beta-1 */ -public class PropertyComparator - implements Comparator +public enum PropertyComparator implements Comparator { + INSTANCE; + /** * Compares to {@link Property} instances. * @@ -42,6 +44,12 @@ public class PropertyComparator */ public int compare( Property p1, Property p2 ) { - return p1.getName().compareTo( p2.getName() ); + return p1 == p2 + ? 0 + : p1 == null + ? 1 + : p2 == null + ? -1 + : StringUtils.compare( p1.getName(), p2.getName() ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java similarity index 92% rename from src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java rename to src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java index ec9aa2db38..6b890c7b52 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java @@ -1,4 +1,4 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.xml; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -23,7 +23,6 @@ import java.io.PrintWriter; import java.util.Collection; import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; import java.util.TreeMap; @@ -77,11 +76,11 @@ public class DependencyUpdatesXmlRenderer private static final String TAB = "\t"; - private Map dependencyUpdates; + private final Map dependencyUpdates; - private Map dependencyManagementUpdates; + private final Map dependencyManagementUpdates; - private String outputFileName; + private final String outputFileName; public DependencyUpdatesXmlRenderer( Map dependencyUpdates, Map dependencyManagementUpdates, @@ -102,7 +101,7 @@ public void render() { StringBuilder sb = new StringBuilder(); sb.append( "" ).append( NL ); - Map allUpdates = new TreeMap<>( new DependencyComparator() ); + Map allUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); allUpdates.putAll( dependencyManagementUpdates ); allUpdates.putAll( dependencyUpdates ); sb.append( getSummaryBlock( allUpdates.values() ) ); @@ -144,7 +143,7 @@ public static String wrapElement( String value, String tag ) * @param allUpdates all dependencies versions * @return summary in xml format */ - public static String getSummaryBlock( Collection allUpdates ) + public static String getSummaryBlock( Collection allUpdates ) { int numInc = 0; int numMin = 0; @@ -241,28 +240,27 @@ private static String getDependencyInfoBlock( Map { StringBuilder sBuilder = new StringBuilder(); sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - for ( Entry entry : dependencyUpdates.entrySet() ) + dependencyUpdates.forEach( ( dep, value ) -> { sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); + .append( NL ); - Dependency dep = entry.getKey(); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getGroupId(), - GROUP_ID ) ).append( NL ); + GROUP_ID ) ).append( NL ); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getArtifactId(), - ARTIFACT_ID ) ).append( NL ); + ARTIFACT_ID ) ).append( NL ); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getScope(), - SCOPE ) ).append( NL ); + SCOPE ) ).append( NL ); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getClassifier(), - CLASSIFIER ) ).append( NL ); + CLASSIFIER ) ).append( NL ); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getType(), - TYPE ) ).append( NL ); + TYPE ) ).append( NL ); - sBuilder.append( getVersionsBlocks( entry.getValue() ) ); + sBuilder.append( getVersionsBlocks( value ) ); sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - } + .append( NL ); + } ); sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); return sBuilder.toString(); } diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java similarity index 81% rename from src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java rename to src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java index e19a98e3e6..7459323b31 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java @@ -1,4 +1,4 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.xml; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -21,19 +21,16 @@ import java.io.IOException; import java.io.PrintWriter; -import java.util.Collection; import java.util.Map; -import java.util.Map.Entry; import java.util.TreeMap; -import java.util.stream.Collectors; import org.apache.maven.model.Plugin; import org.apache.maven.reporting.MavenReportException; -import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.PluginUpdatesDetails; import org.codehaus.mojo.versions.utils.PluginComparator; -import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.getVersionsBlocks; -import static org.codehaus.mojo.versions.DependencyUpdatesXmlRenderer.wrapElement; +import static org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer.getVersionsBlocks; +import static org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer.wrapElement; /** * XML renderer for PluginUpdatesReport creates an xml file in target directory and writes report about available @@ -83,7 +80,7 @@ public void render() { StringBuilder sb = new StringBuilder(); sb.append( "" ).append( NL ); - Map allUpdates = new TreeMap<>( new PluginComparator() ); + Map allUpdates = new TreeMap<>( PluginComparator.INSTANCE ); allUpdates.putAll( pluginManagementUpdates ); allUpdates.putAll( pluginUpdates ); sb.append( getSummaryBlock( allUpdates ) ); @@ -105,10 +102,7 @@ public void render() private static String getSummaryBlock( Map allUpdates ) { - Collection allVersions = allUpdates.values().stream() - .map( PluginUpdatesDetails::getArtifactVersions ) - .collect( Collectors.toList() ); - return DependencyUpdatesXmlRenderer.getSummaryBlock( allVersions ); + return DependencyUpdatesXmlRenderer.getSummaryBlock( allUpdates.values() ); } private static String getPluginsInfoBlock( Map pluginUpdates, String blockName, @@ -116,22 +110,21 @@ private static String getPluginsInfoBlock( Map plu { StringBuilder sBuilder = new StringBuilder(); sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - for ( Entry entry : pluginUpdates.entrySet() ) + pluginUpdates.forEach( ( plugin, value ) -> { sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); + .append( NL ); - Plugin plugin = entry.getKey(); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( plugin.getGroupId(), - GROUP_ID ) ).append( NL ); + GROUP_ID ) ).append( NL ); sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( plugin.getArtifactId(), - ARTIFACT_ID ) ).append( NL ); + ARTIFACT_ID ) ).append( NL ); - sBuilder.append( getVersionsBlocks( entry.getValue().getArtifactVersions() ) ); + sBuilder.append( getVersionsBlocks( value ) ); sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - } + .append( NL ); + } ); sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); return sBuilder.toString(); } diff --git a/src/main/resources/parent-updates-report.properties b/src/main/resources/parent-updates-report.properties index 632d111778..2ddf8b1650 100644 --- a/src/main/resources/parent-updates-report.properties +++ b/src/main/resources/parent-updates-report.properties @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java similarity index 63% rename from src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java rename to src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index cd99c1d250..7403e2610f 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -24,10 +24,11 @@ import java.io.OutputStream; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.Locale; import java.util.Set; +import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; @@ -36,9 +37,13 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.model.RuleSet; +import org.codehaus.mojo.versions.reporting.ReportRendererFactoryImpl; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.MockUtils; +import org.codehaus.plexus.i18n.I18N; +import org.hamcrest.Matchers; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; @@ -49,21 +54,25 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** - * Basic tests for {@linkplain DependencyUpdatesReport}. + * Basic tests for {@linkplain DependencyUpdatesReportMojo}. * * @author Andrzej Jarmoniuk */ -public class DependencyUpdatesReportTest +public class DependencyUpdatesReportMojoTest { - - private static class TestDependencyUpdatesReport extends DependencyUpdatesReport + private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesReportMojo { - @SuppressWarnings( "deprecation" ) - TestDependencyUpdatesReport() + private static final I18N MOCK_I18N = mockI18N(); + + TestDependencyUpdatesReportMojo() { - super( mockI18N(), MockUtils.mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); + super( MOCK_I18N, mockRepositorySystem(), null, mockArtifactMetadataSource(), + null, new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); @@ -72,13 +81,20 @@ private static class TestDependencyUpdatesReport extends DependencyUpdatesReport project.getModel().setDependencyManagement( new DependencyManagement() ); } - public TestDependencyUpdatesReport withDependencies( Dependency... dependencies ) + public TestDependencyUpdatesReportMojo withDependencies( Dependency... dependencies ) { project.setDependencies( Arrays.asList( dependencies ) ); return this; } - public TestDependencyUpdatesReport withOriginalDependencyManagement( + public TestDependencyUpdatesReportMojo withArtifactMetadataSource( + ArtifactMetadataSource artifactMetadataSource ) + { + this.artifactMetadataSource = artifactMetadataSource; + return this; + } + + public TestDependencyUpdatesReportMojo withOriginalDependencyManagement( Dependency... originalDependencyManagement ) { project.getOriginalModel().getDependencyManagement() @@ -86,62 +102,77 @@ public TestDependencyUpdatesReport withOriginalDependencyManagement( return this; } - public TestDependencyUpdatesReport withDependencyManagement( Dependency... dependencyManagement ) + public TestDependencyUpdatesReportMojo withDependencyManagement( Dependency... dependencyManagement ) { project.getModel().getDependencyManagement().setDependencies( Arrays.asList( dependencyManagement ) ); return this; } - public TestDependencyUpdatesReport withOnlyUpgradable( boolean onlyUpgradable ) + public TestDependencyUpdatesReportMojo withOnlyUpgradable( boolean onlyUpgradable ) { this.onlyUpgradable = onlyUpgradable; return this; } - public TestDependencyUpdatesReport withProcessDependencyManagement( boolean processDependencyManagement ) + public TestDependencyUpdatesReportMojo withProcessDependencyManagement( boolean processDependencyManagement ) { this.processDependencyManagement = processDependencyManagement; return this; } - public TestDependencyUpdatesReport withProcessDependencyManagementTransitive( + public TestDependencyUpdatesReportMojo withProcessDependencyManagementTransitive( boolean processDependencyManagementTransitive ) { this.processDependencyManagementTransitive = processDependencyManagementTransitive; return this; } - public TestDependencyUpdatesReport withOnlyProjectDependencies( + public TestDependencyUpdatesReportMojo withOnlyProjectDependencies( boolean onlyProjectDependencies ) { this.onlyProjectDependencies = onlyProjectDependencies; return this; } - public TestDependencyUpdatesReport withRuleSet( + public TestDependencyUpdatesReportMojo withRuleSet( RuleSet ruleSet ) { this.ruleSet = ruleSet; return this; } - public TestDependencyUpdatesReport withIgnoredVersions( + public TestDependencyUpdatesReportMojo withIgnoredVersions( Set ignoredVersions ) { this.ignoredVersions = ignoredVersions; return this; } - public TestDependencyUpdatesReport withArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource ) + private static RepositorySystem mockRepositorySystem() { - this.artifactMetadataSource = artifactMetadataSource; - return this; + RepositorySystem repositorySystem = mock( RepositorySystem.class ); + when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( + invocation -> + { + Dependency dependency = invocation.getArgument( 0 ); + return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion(), dependency.getScope(), dependency.getType(), + dependency.getClassifier(), null ); + } ); + return repositorySystem; } } private static Dependency dependencyOf( String artifactId ) { - return DependencyBuilder.dependencyWith( "groupA", artifactId, "1.0.0", "default", "pom", SCOPE_COMPILE ); + return DependencyBuilder.dependencyWith( "groupA", artifactId, "1.0.0", + "default", "pom", SCOPE_COMPILE ); + } + + private static Dependency dependencyOf( String artifactId, String version ) + { + return DependencyBuilder.dependencyWith( "groupA", artifactId, version, + "default", "pom", SCOPE_COMPILE ); } @Test @@ -149,7 +180,7 @@ public void testOnlyUpgradableDependencies() throws IOException, MavenReportExce { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() + new TestDependencyUpdatesReportMojo() .withOnlyUpgradable( true ) .withDependencies( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), @@ -166,7 +197,7 @@ public void testOnlyUpgradableWithOriginalDependencyManagement() throws IOExcept { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() + new TestDependencyUpdatesReportMojo() .withOriginalDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), dependencyOf( "artifactC" ) ) .withProcessDependencyManagement( true ) @@ -183,7 +214,7 @@ public void testOnlyUpgradableWithTransitiveDependencyManagement() throws IOExce { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() + new TestDependencyUpdatesReportMojo() .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), dependencyOf( "artifactC" ) ) @@ -202,7 +233,7 @@ public void testOnlyProjectDependencies() throws IOException, MavenReportExcepti { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() + new TestDependencyUpdatesReportMojo() .withDependencies( dependencyOf( "artifactA" ) ) .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), dependencyOf( "artifactC" ) ) @@ -220,7 +251,7 @@ public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() + new TestDependencyUpdatesReportMojo() .withDependencies( dependencyOf( "artifactA" ) ) .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), dependencyOf( "artifactC" ) ) @@ -233,42 +264,47 @@ public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, assertThat( output, containsString( "report.noUpdatesAvailable" ) ); } - + /** + * Dependencies should be rendered in alphabetical order + */ @Test - public void testSubincrementalUpdates() - throws IOException, MavenReportException + public void testDependenciesInAlphabeticalOrder() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestDependencyUpdatesReport() - .withDependencies( DependencyBuilder.newBuilder() - .withGroupId( "localhost" ) - .withArtifactId( "dummy-api" ) - .withVersion( "1.1" ) - .withScope( SCOPE_COMPILE ) - .withType( "jar" ) - .build() ) - .withArtifactMetadataSource( mockArtifactMetadataSource( new LinkedHashMap() + new TestDependencyUpdatesReportMojo() + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() {{ - put( "dummy-api", new String[] { "1.0.1", "1.0", "1.1.0-2", "1.1.1", "1.1.1-2", "1.1.2", - "1.1.2-SNAPSHOT", "1.1.3", "1.1", "1.1-SNAPSHOT", "1.2.1", "1.2.2", "1.2", "1.3", - "1.9.1-SNAPSHOT", "2.0", "2.1.1-SNAPSHOT", "2.1", "3.0", "3.1.1-SNAPSHOT", - "3.1.5-SNAPSHOT", "3.4.0-SNAPSHOT"} ); + put( "amstrad", new String[] {"1.0.0", "2.0.0"} ); + put( "atari", new String[] {"1.0.0", "2.0.0"} ); + put( "commodore", new String[] {"1.0.0", "2.0.0"} ); + put( "spectrum", new String[] {"1.0.0", "2.0.0"} ); }} ) ) + .withDependencies( dependencyOf( "spectrum" ), dependencyOf( "atari" ), + dependencyOf( "amstrad" ), dependencyOf( "commodore" ) ) .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - String output = os.toString() - .replaceAll( "<[^>]+>", " " ) - .replaceAll( "&[^;]+;", " " ) - .replaceAll( "\\s+", " " ); - assertThat( output, containsString( "localhost dummy-api 1.1 compile jar 1.1.0-2 1.1.3 1.3 3.0" ) ); - assertThat( output, containsString( "1.1.0-2 report.latestSubIncremental" ) ); - assertThat( output, containsString( "1.1.1 report.nextIncremental" ) ); - assertThat( output, containsString( "1.1.3 report.latestIncremental" ) ); - assertThat( output, containsString( "1.2 report.nextMinor" ) ); - assertThat( output, containsString( "1.3 report.latestMinor" ) ); - assertThat( output, containsString( "2.0 report.nextMajor" ) ); - assertThat( output, containsString( "3.0 report.latestMajor" ) ); + String output = os.toString().replaceAll( "\n", "" ); + assertThat( output, Matchers.stringContainsInOrder( "amstrad", "atari", "commodore", "spectrum" ) ); } + /** + * Dependency updates for dependency should override those for dependency management + */ + @Test + public void testDependenciesShouldOverrideDependencyManagement() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReportMojo() + .withProcessDependencyManagement( true ) + .withProcessDependencyManagementTransitive( true ) + .withDependencies( dependencyOf( "artifactA", "2.0.0" ), + dependencyOf( "artifactB" ) ) + .withDependencyManagement( dependencyOf( "artifactA" ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString().replaceAll( "\n", "" ); + assertThat( output, Matchers.stringContainsInOrder( "artifactB" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java index 6f890a8f7b..69889a7e91 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -30,6 +30,7 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer; import org.hamcrest.core.Is; import org.junit.Test; diff --git a/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java similarity index 89% rename from src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java rename to src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java index 95c81c19be..7854a027f1 100644 --- a/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java @@ -33,6 +33,8 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; +import org.codehaus.mojo.versions.reporting.ReportRendererFactoryImpl; +import org.codehaus.plexus.i18n.I18N; import org.junit.Test; import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; @@ -43,22 +45,23 @@ import static org.hamcrest.Matchers.allOf; /** - * Basic tests for {@linkplain ParentUpdatesReport}. + * Basic tests for {@linkplain ParentUpdatesReportMojo}. * * @author Andrzej Jarmoniuk */ -public class ParentUpdatesReportTest +public class ParentUpdatesReportMojoTest { + private static final I18N MOCK_I18N = mockI18N(); @Test public void testAllowSnapshots() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new ParentUpdatesReport( mockI18N(), mockRepositorySystem(), null, + new ParentUpdatesReportMojo( MOCK_I18N, mockRepositorySystem(), null, mockArtifactMetadataSource( new HashMap() {{ put( "default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"} ); - }} ), null ) + }} ), null, new ReportRendererFactoryImpl( MOCK_I18N ) ) {{ allowSnapshots = true; project = new MavenProject( new Model() diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java similarity index 86% rename from src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java rename to src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java index a8fad70d7f..25f2ea781a 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java @@ -37,7 +37,9 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.model.RuleSet; +import org.codehaus.mojo.versions.reporting.ReportRendererFactoryImpl; import org.codehaus.mojo.versions.utils.MockUtils; +import org.codehaus.plexus.i18n.I18N; import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; @@ -54,17 +56,19 @@ import static org.mockito.Mockito.when; /** - * Basic tests for {@linkplain PluginUpdatesReport}. + * Basic tests for {@linkplain PluginUpdatesReportMojo}. * * @author Andrzej Jarmoniuk */ -public class PluginUpdatesReportTest +public class PluginUpdatesReportMojoTest { - private static class TestPluginUpdatesReport extends PluginUpdatesReport + private static class TestPluginUpdatesReportMojo extends PluginUpdatesReportMojo { - TestPluginUpdatesReport() + static final I18N MOCK_I18N = mockI18N(); + TestPluginUpdatesReportMojo() { - super( mockI18N(), mockRepositorySystem(), null, mockArtifactMetadataSource(), null ); + super( MOCK_I18N, mockRepositorySystem(), null, mockArtifactMetadataSource(), + null, new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); @@ -74,38 +78,38 @@ private static class TestPluginUpdatesReport extends PluginUpdatesReport artifactMetadataSource = mockArtifactMetadataSource(); } - public TestPluginUpdatesReport withPlugins( Plugin... plugins ) + public TestPluginUpdatesReportMojo withPlugins( Plugin... plugins ) { project.getBuild().setPlugins( Arrays.asList( plugins ) ); return this; } - public TestPluginUpdatesReport withPluginManagement( Plugin... pluginManagement ) + public TestPluginUpdatesReportMojo withPluginManagement( Plugin... pluginManagement ) { project.getBuild().getPluginManagement().setPlugins( Arrays.asList( pluginManagement ) ); return this; } - public TestPluginUpdatesReport withOnlyUpgradable( boolean onlyUpgradable ) + public TestPluginUpdatesReportMojo withOnlyUpgradable( boolean onlyUpgradable ) { this.onlyUpgradable = onlyUpgradable; return this; } - public TestPluginUpdatesReport withOnlyProjectPlugins( boolean onlyProjectPlugins ) + public TestPluginUpdatesReportMojo withOnlyProjectPlugins( boolean onlyProjectPlugins ) { this.onlyProjectPlugins = onlyProjectPlugins; return this; } - public TestPluginUpdatesReport withRuleSet( + public TestPluginUpdatesReportMojo withRuleSet( RuleSet ruleSet ) { this.ruleSet = ruleSet; return this; } - public TestPluginUpdatesReport withIgnoredVersions( + public TestPluginUpdatesReportMojo withIgnoredVersions( Set ignoredVersions ) { this.ignoredVersions = ignoredVersions; @@ -143,7 +147,7 @@ public void testOnlyUpgradablePlugins() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestPluginUpdatesReport() + new TestPluginUpdatesReportMojo() .withPlugins( pluginOf( "artifactA" ), pluginOf( "artifactB" ), pluginOf( "artifactC" ) ) .withOnlyUpgradable( true ) @@ -159,7 +163,7 @@ public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenRe { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestPluginUpdatesReport() + new TestPluginUpdatesReportMojo() .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), pluginOf( "artifactC" ) ) .withOnlyUpgradable( true ) @@ -175,7 +179,7 @@ public void testOnlyProjectPlugins() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestPluginUpdatesReport() + new TestPluginUpdatesReportMojo() .withPlugins( pluginOf( "artifactA" ) ) .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), pluginOf( "artifactC" ) ) @@ -193,7 +197,7 @@ public void testOnlyProjectPluginsWithIgnoredVersions() throws IOException, Mave { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new TestPluginUpdatesReport() + new TestPluginUpdatesReportMojo() .withPlugins( pluginOf( "artifactA" ) ) .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), pluginOf( "artifactC" ) ) diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index ada1bf7294..89fcc92b49 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -287,4 +287,5 @@ public void testIgnoredVersionsShouldExtendTheRuleSet() throws MojoExecutionExce assertThat( ruleSet.getIgnoreVersions().stream().map( IgnoreVersion::getVersion ) .collect( Collectors.toList() ), containsInAnyOrder( ".*-M.", ".*-SNAPSHOT", "1.0.0" ) ); } + } From 3e1278d76ab922c7717b88899f04de0f4a71f979 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 6 Oct 2022 17:01:42 +0200 Subject: [PATCH 150/441] #725: Migrating Usage to markdown --- src/site/apt/usage.apt.vm | 272 ---------------------------------- src/site/markdown/usage.md.vm | 258 ++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+), 272 deletions(-) delete mode 100644 src/site/apt/usage.apt.vm create mode 100644 src/site/markdown/usage.md.vm diff --git a/src/site/apt/usage.apt.vm b/src/site/apt/usage.apt.vm deleted file mode 100644 index c159979237..0000000000 --- a/src/site/apt/usage.apt.vm +++ /dev/null @@ -1,272 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Usage - ----- - Stephen Connolly - ------ - 2008-09-02 - ------ - -Usage - - The plugin offers goals for updating the versions of artifacts referenced in - a Maven <<>> file. - -* Basic Usage - - Maven 2.0, 2.1, 2.2 and 3.0 do not currently support re-reading modifications of the <<>> within one - invocation of Maven. - - The following goals: - - * {{{./set-mojo.html}versions:set}} - - * {{{./lock-snapshots-mojo.html}versions:lock-snapshots}} - - * {{{./resolve-ranges-mojo.html}versions:resolve-ranges}} - - * {{{./unlock-snapshots-mojo.html}versions:unlock-snapshots}} - - * {{{./update-child-modules-mojo.html}versions:update-child-modules}} - - * {{{./update-parent-mojo.html}versions:update-parent}} - - * {{{./update-properties-mojo.html}versions:update-properties}} - - * {{{./set-property-mojo.html}versions:set-property}} - - * {{{./use-latest-releases-mojo.html}versions:use-latest-releases}} - - * {{{./use-latest-snapshots-mojo.html}versions:use-latest-snapshots}} - - * {{{./use-latest-versions-mojo.html}versions:use-latest-versions}} - - * {{{./use-next-releases-mojo.html}versions:use-next-releases}} - - * {{{./use-next-snapshots-mojo.html}versions:use-next-snapshots}} - - * {{{./use-next-versions-mojo.html}versions:use-next-versions}} - - * {{{./use-releases-mojo.html}versions:use-releases}} - - modify the <<>> file, you need to run these goals separately from any other goals or life-cycle phases. - - Note: The first time any of the goals that modify the <<>> file run, they will create a local backup copy - <<>>. Subsequent modifications will leave this backup unchanged. The - {{{./accept-mojo.html}versions:commit}} goal will remove the backup copy, while the - {{{./revert-mojo.html}versions:revert}} goal will restore the backup copy. It is best practice - to use a Source Code Management system and not rely on the <<>> files created by the - versions-maven-plugin. The {{{./accept-mojo.html}versions:commit}} and {{{./revert-mojo.html}versions:revert}} goals are - only a "Poor Man's SCM". - -* Goals that modify the <<>> - - Executing any of the following goals may modify your <<>> file. - -** Reverting modifications to the <<>> files (Note: modifies <<>> files) - - To restore your <<>> files to their initial state, before you started modifying it with the - versions-maven-plugin, invoke the <<>> goal. Note that it is best practice - to use a Source Code Management system and not rely on the <<>> files created by the - versions-maven-plugin. - ---- -mvn versions:revert ---- - -** Accepting modifications to the <<>> files - - To accept the modifications made to your <<>> files by the versions-maven-plugin invoke the <<>> - goal. This will have the effect of removing any <<>> files. Note that it is best practice - to use a Source Code Management system and not rely on the <<>> files created by the - versions-maven-plugin. - ---- -mvn versions:commit ---- - -** Updating the parent version (Note: modifies <<>> files) - - To update the parent version of your POM to the latest available, just invoke the <<>> goal. - ---- -mvn versions:update-parent ---- - - {{{./examples/update-parent.html} A more detailed example of the <<>> goal}}. - -** Fixing a multi-module build (Note: modifies <<>> files) - - If you have a multi-module build where the aggregator pom (i.e. the one with packaging of <<>> and the - <<>> section) is also the parent referenced by its child modules, and the aggregator version does not - match the version specified in the parent section of the child modules, Maven will not let you build the project. - To fix all the child modules, use the {{{./update-child-modules-mojo.html}versions:update-child-modules}} goal and - invoke Maven in non-recursive mode. - ---- -mvn -N versions:update-child-modules ---- - - {{{./examples/update-child-modules.html} A more detailed example of the <<>> goal}}. - -** Updating versions specified by properties (Note: modifies <<>> files) - - This goal helps when you use properties to define versions. Please see the - {{{./examples/update-properties.html}<<>> example}}. - -** Updating versions of dependencies (Note: modifies <<>> files) - - There are a set of goals to help with advancing dependency versions: <<>>, - <<>>, <<>>, <<>>, <<>>, and - <<>>. - - Please see the {{{./examples/advancing-dependency-versions.html}advancing dependency versions example}}. - -** Resolving version ranges (Note: modifies <<>> files) - - If a pom contains version ranges in one or more dependencies, it can be useful - to collapse those ranges to the specific versions used during the build, just invoke the <<>> goal. - ---- -mvn versions:resolve-ranges ---- - - More examples of the {{{./examples/resolve-ranges.html} <<>>}} goal. - -** Locking and unlocking -SNAPSHOT versions (Note: modifies <<>> files) - - If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it - can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. - In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their - release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a - useful hack. - - To replace -SNAPSHOT dependencies with their current locked snapshot equivalents, just invoke the <<>> - goal. - ---- -mvn versions:lock-snapshots ---- - - More examples of the {{{./examples/lock-snapshots.html} <<>>}} goal. - - To return to regular -SNAPSHOT dependencies, i.e. replace 1.9.6-20090103.152537-3 with 1.9.6-SNAPSHOT, just invoke - the <<>> goal. - ---- -mvn versions:unlock-snapshots ---- - - More examples of the {{{./examples/unlock-snapshots.html} <<>>}} goal. - -** Picking up releases of -SNAPSHOT dependencies (Note: modifies <<>> files) - - It is better to depend on a released version of a dependency, rather than the -SNAPSHOT of that version. For - example, it is better to depend on version 1.3.4 rather than 1.3.4-SNAPSHOT. Of course if you are waiting for - 1.3.4 to be released, you will have had to add 1.3.4-SNAPSHOT as a dependency. - - The <<>> goal will look at your project dependencies and see if any -SNAPSHOT versions have been - released, replacing the -SNAPSHOT version with the corresponding release version. - - To replace -SNAPSHOT dependencies with their corresponding release version, just invoke the <<>> - goal. - ---- -mvn versions:use-releases ---- - - More examples of the {{{./examples/use-releases.html} <<>>}} goal. - -** Setting the project version - - To set the project version to a specific version, just invoke the <<>> goal. - ---- -mvn versions:set -DnewVersion=1.0.1-SNAPSHOT ---- - - More examples of the {{{./examples/set.html} <<>>}} goal. - -* Goals that do not modify the <<>> - - Executing any of the following goals will not modify your <<>> file. - -** Checking for new versions of plugins - - To get information about newer versions of plugins that you are using in your build, just invoke the - <<>> goal. - ---- -mvn versions:display-plugin-updates ---- - - {{{./examples/display-plugin-updates.html} A more detailed example of the <<>> goal}}. - -** Checking for new versions of dependencies - - To get information about newer versions of dependencies that you are using in your build, just invoke the - <<>> goal. - ---- -mvn versions:display-dependency-updates ---- - - {{{./examples/display-dependency-updates.html} A more detailed example of the <<>> goal}}. - -** Checking for new versions of specified by properties - - To get information about newer versions of dependencies that you are using in your build, just invoke the - <<>> goal. - ---- -mvn versions:display-property-updates ---- - - {{{./examples/display-property-updates.html} A more detailed example of the <<>> goal}}. - -* Report Usage - - The plugin also offers some reporting views; these make no changes to your project, - but makes it easy for reviewers to survey available updates without even having - to launch Maven themselves. Updates are further categorized as major, minor, and - incremental, to make it easier to decide which updates to take. - - To add these reports to your project's site, add the following snippet to your POM: - -+---+ - - - - org.codehaus.mojo - versions-maven-plugin - ${pluginVersion} - - - - dependency-updates-report - plugin-updates-report - property-updates-report - - - - - - -+---+ - diff --git a/src/site/markdown/usage.md.vm b/src/site/markdown/usage.md.vm new file mode 100644 index 0000000000..dafa245201 --- /dev/null +++ b/src/site/markdown/usage.md.vm @@ -0,0 +1,258 @@ +title: Usage +autor: Stephen Connolly +date: 2008-09-02 + + + +## Velocity uses # as a prefix for macros and ## as a prefix for comments +#set($h1 = '#') +#set($h2 = '##') +#set($h3 = '###') + +$h1 Usage + +The plugin offers goals for updating the versions of artifacts referenced in +a Maven `pom.xml` file. + +$h2 Basic Usage + +Maven 2.0, 2.1, 2.2 and 3.0 do not currently support re-reading modifications of the `pom.xml` within one +invocation of Maven. + +The following goals: +- [versions:set](./set-mojo.html) +- [versions:lock-snapshots](./lock-snapshots-mojo.html) +- [versions:resolve-ranges](./resolve-ranges-mojo.html) +- [versions:unlock-snapshots](./unlock-snapshots-mojo.html) +- [versions:update-child-modules](./update-child-modules-mojo.html) +- [versions:update-parent](./update-parent-mojo.html) +- [versions:update-properties](./update-properties-mojo.html) +- [versions:set-property](./set-property-mojo.html) +- [versions:use-latest-releases](./use-latest-releases-mojo.html) +- [versions:use-latest-snapshots](./use-latest-snapshots-mojo.html) +- [versions:use-latest-versions](./use-latest-versions-mojo.html) +- [versions:use-next-releases](./use-next-releases-mojo.html) +- [versions:use-next-snapshots](./use-next-snapshots-mojo.html) +- [versions:use-next-versions](./use-next-versions-mojo.html) +- [versions:use-releases](./use-releases-mojo.html) + +modify the `pom.xml` file, you need to run these goals separately from any other goals or life-cycle phases. + +Note: The first time any of the goals that modify the `pom.xml` file run, they will create a local backup copy +`pom.xml.versionsBackup`. Subsequent modifications will leave this backup unchanged. The +[versions:commit](./commit-mojo.html) goal will remove the backup copy, while the +[versions:revert](./revert-mojo.html) goal will restore the backup copy. It is best practice +to use a Source Code Management system and not rely on the `pom.xml.versionsBackup` files created by the +versions-maven-plugin. The [versions:commit](./commit-mojo.html) and [versions:revert](./revert-mojo.html) goals are +only a "Poor Man's SCM". + +$h2 Goals that modify the `pom.xml` + +Executing any of the following goals may modify your `pom.xml` file. + +$h3 Reverting modifications to the `pom.xml` files (Note: modifies `pom.xml` files) + +To restore your `pom.xml` files to their initial state, before you started modifying it with the +versions-maven-plugin, invoke the `revert` goal. Note that it is best practice +to use a Source Code Management system and not rely on the `pom.xml.versionsBackup` files created by the +versions-maven-plugin. + +```sh +mvn versions:revert +``` + +$h3 Accepting modifications to the `pom.xml` files + +To accept the modifications made to your `pom.xml` files by the versions-maven-plugin invoke the `commit` +goal. This will have the effect of removing any `pom.xml.versionsBackup` files. Note that it is best practice +to use a Source Code Management system and not rely on the `pom.xml.versionsBackup` files created by the +versions-maven-plugin. + +```sh +mvn versions:commit +``` + +$h3 Updating the parent version (Note: modifies `pom.xml` files) + +To update the parent version of your POM to the latest available, just invoke the `update-parent` goal. + +```sh +mvn versions:update-parent +``` + +[A more detailed example of the `update-parent` goal](./examples/update-parent.html). + +$h3 Fixing a multi-module build (Note: modifies `pom.xml` files) + +If you have a multi-module build where the aggregator pom (i.e. the one with packaging of `pom` and the +`modules` section) is also the parent referenced by its child modules, and the aggregator version does not +match the version specified in the parent section of the child modules, Maven will not let you build the project. +To fix all the child modules, use the [versions:update-child-modules](./update-child-modules-mojo.html) goal and +invoke Maven in non-recursive mode. + +``` +mvn -N versions:update-child-modules +``` + +[A more detailed example of the `update-child-modules` goal](./examples/update-child-modules.html). + +$h3 Updating versions specified by properties (Note: modifies `pom.xml` files) + +This goal helps when you use properties to define versions. Please see the +[`update-properties` example](./examples/update-properties.html). + +$h3 Updating versions of dependencies (Note: modifies `pom.xml` files) + +There are a set of goals to help with advancing dependency versions: `use-latest-releases`, +`use-latest-snapshots`, `use-latest-versions`, `use-next-releases`, `use-next-snapshots`, and +`use-next-versions`. + +Please see the [advancing dependency versions example](./examples/advancing-dependency-versions.html). + +$h3 Resolving version ranges (Note: modifies `pom.xml` files) + +If a pom contains version ranges in one or more dependencies, it can be useful +to collapse those ranges to the specific versions used during the build, just invoke the `resolve-ranges` goal. + +```sh +mvn versions:resolve-ranges +``` + +More examples of the [`resolve-ranges`](./examples/resolve-ranges.html) goal. + +$h3 Locking and unlocking -SNAPSHOT versions (Note: modifies `pom.xml` files) + +If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it +can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. +In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their +release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a +useful hack. + +To replace -SNAPSHOT dependencies with their current locked snapshot equivalents, just invoke the `lock-snapshots` +goal. + +```sh +mvn versions:lock-snapshots +``` + +More examples of the [`lock-snapshots`](./examples/lock-snapshots.html) goal. + +To return to regular -SNAPSHOT dependencies, i.e. replace 1.9.6-20090103.152537-3 with 1.9.6-SNAPSHOT, just invoke +the `unlock-snapshots` goal. + +```sh +mvn versions:unlock-snapshots +``` + +More examples of the [`unlock-snapshots`](./examples/unlock-snapshots.html) goal. + +$h3 Picking up releases of -SNAPSHOT dependencies (Note: modifies `pom.xml` files) + +It is better to depend on a released version of a dependency, rather than the -SNAPSHOT of that version. For +example, it is better to depend on version 1.3.4 rather than 1.3.4-SNAPSHOT. Of course if you are waiting for +1.3.4 to be released, you will have had to add 1.3.4-SNAPSHOT as a dependency. + +The `use-releases` goal will look at your project dependencies and see if any -SNAPSHOT versions have been +released, replacing the -SNAPSHOT version with the corresponding release version. + +To replace -SNAPSHOT dependencies with their corresponding release version, just invoke the `use-releases` +goal. + +```sh +mvn versions:use-releases +``` + +More examples of the [`lock-snapshots`](./examples/use-releases.html) goal. + +$h3 Setting the project version + +To set the project version to a specific version, just invoke the `set` goal. + +```sh +mvn versions:set -DnewVersion=1.0.1-SNAPSHOT +``` + +More examples of the [`set`](./examples/set.html) goal. + +$h2 Goals that do not modify the `pom.xml` + +Executing any of the following goals will not modify your `pom.xml` file. + +$h3 Checking for new versions of plugins + +To get information about newer versions of plugins that you are using in your build, just invoke the +`display-plugin-updates` goal. + +```sh +mvn versions:display-plugin-updates +``` + +[A more detailed example of the `display-plugin-updates` goal](./examples/display-plugin-updates.html). + +$h3 Checking for new versions of dependencies + +To get information about newer versions of dependencies that you are using in your build, just invoke the +`display-dependency-updates` goal. + +```sh +mvn versions:display-dependency-updates +``` + +[A more detailed example of the `display-dependency-updates` goal](./examples/display-dependency-updates.html). + +$h3 Checking for new versions of specified by properties + +To get information about newer versions of dependencies that you are using in your build, just invoke the +`display-property-updates` goal. + +```sh +mvn versions:display-property-updates +``` + +[A more detailed example of the `display-property-updates` goal](./examples/display-property-updates.html). + +$h2 Report Usage + +The plugin also offers some reporting views; these make no changes to your project, +but makes it easy for reviewers to survey available updates without even having +to launch Maven themselves. Updates are further categorized as major, minor, and +incremental, to make it easier to decide which updates to take. + +To add these reports to your project's site, add the following snippet to your POM: + +```xml + + + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + + + dependency-updates-report + plugin-updates-report + property-updates-report + + + + + + +``` + From 021e437fc3d2dde8bafebad110226c586fd639c1 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 9 Oct 2022 06:49:35 +0200 Subject: [PATCH 151/441] #725 Migrating "Advancing dependency versions" to Markdown --- .../advancing-dependency-versions.apt.vm | 167 ------------------ .../advancing-dependency-versions.md.vm | 144 +++++++++++++++ 2 files changed, 144 insertions(+), 167 deletions(-) delete mode 100644 src/site/apt/examples/advancing-dependency-versions.apt.vm create mode 100644 src/site/markdown/examples/advancing-dependency-versions.md.vm diff --git a/src/site/apt/examples/advancing-dependency-versions.apt.vm b/src/site/apt/examples/advancing-dependency-versions.apt.vm deleted file mode 100644 index cf9eeb4f9f..0000000000 --- a/src/site/apt/examples/advancing-dependency-versions.apt.vm +++ /dev/null @@ -1,167 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Advancing dependency versions - ----- - Stephen Connolly - ------ - 2009-08-12 - ------ - -Advancing dependency versions - - There are a number of goals which can be used to advance dependency versions: - - * {{{../use-next-releases-mojo.html}versions:use-next-releases}} searches the pom for all non-SNAPSHOT versions which - have been a newer release and replaces them with the next release version. - - * {{{../use-latest-releases-mojo.html}versions:use-latest-releases}} searches the pom for all non-SNAPSHOT versions - which have been a newer release and replaces them with the latest release version. - - * {{{../use-next-snapshots-mojo.html}versions:use-next-snapshots}} searches the pom for all non-SNAPSHOT versions - which have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version. - - * {{{../use-latest-snapshots-mojo.html}versions:use-latest-snapshots}} searches the pom for all non-SNAPSHOT versions - which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version. - - * {{{../use-next-versions-mojo.html}versions:use-next-versions}} searches the pom for all versions which - have been a newer version and replaces them with the next version. - - * {{{../use-latest-versions-mojo.html}versions:use-latest-versions}} searches the pom for all versions which - have been a newer version and replaces them with the latest version. - - [] - - All of these goals share a common set of parameters. - -* Deciding which goal to use - - The following matrix should help decide which goal(s) to use: - -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| Goal | Modifies Release dependencies | Modifies -SNAPSHOT dependencies | Considers releases | Considers -SNAPSHOTs | Picks Next | Picks Latest | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-next-releases | | Yes | Yes | | Yes | | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-latest-releases | | Yes | Yes | | | Yes | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-next-snapshots | Yes | | | Yes | Yes | | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-latest-snapshots | Yes | | | Yes | | Yes | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-next-versions | Yes | Yes | Yes | If -DallowSnapshots=true | Yes | | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -| use-latest-versions | Yes | Yes | Yes | If -DallowSnapshots=true | | Yes | -*----------------------*-------------------------------*---------------------------------*--------------------*--------------------------*------------*--------------* -Goal Matrix - - The columns in the above goal matrix are as follows: - - * when scanning the <<>> for dependency to update, include those dependencies which - are for release versions (i.e. non-SNAPSHOT versions). - - * when scanning the <<>> for dependency to update, include those dependencies which - are for -SNAPSHOT versions. - - * when building the list of newer versions of a dependency, include release versions (i.e. non-SNAPSHOT - versions) in the list. - - * when building the list of newer versions of a dependency, include -SNAPSHOT versions in the list. - - * when the list of newer versions is sorted in increasing order, pick the first newer version in the list, i.e. - the oldest newer version available, also known as the "next" version. - - * when the list of newer versions is sorted in increasing order, pick the last newer version in the list, i.e. - the newest version available, also known as the "latest" version. - - [] - -* Controlling which dependencies are processed - - You can restrict which dependencies should be processed. For example, - the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId - "plexus-utils" - ---- -mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:plexus-utils ---- - - The <<>> and <<>> parameters follow the format <<>>. - Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. - - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". - ---- -mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:*,junit:junit ---- - - You can pre-configure defaults for <<>> and <<> in your <<>> if there is a specific - set of dependencies that you need to track on a regular basis, e.g. - ---- - - ... - - ... - - ... - - org.codehaus.mojo - versions-maven-plugin - ${pluginVersion} - - ... - - org.codehaus.plexus:* - junit:junit - - ... - - org.codehaus.plexus:plexus-utils - - ... - - - ... - - ... - - ... - ---- - - By default, both the <<>> and <<>> sections will be processed. - You can use the <<>> and <<>> parameters to control which sections - are processed. - - This example will only process the <<>> section of your pom: - ---- -mvn versions:use-next-releases -DprocessDependencies=false ---- - - While this example will only process the <<>> section of your pom: - ---- -mvn versions:use-next-releases -DprocessDependencyManagement=false ---- - - - diff --git a/src/site/markdown/examples/advancing-dependency-versions.md.vm b/src/site/markdown/examples/advancing-dependency-versions.md.vm new file mode 100644 index 0000000000..6e49008984 --- /dev/null +++ b/src/site/markdown/examples/advancing-dependency-versions.md.vm @@ -0,0 +1,144 @@ +title: Advancing dependency versions +autor: Stephen Connolly +date: 2009-08-12 + + + +Advancing dependency versions +============================= + +There are a number of goals which can be used to advance dependency versions: + +- [versions:use-next-releases](../use-next-releases-mojo.html) searches the pom for all non-SNAPSHOT versions which +have been a newer release and replaces them with the next release version. +- [versions:use-latest-releases](../use-latest-releases-mojo.html) searches the pom for all non-SNAPSHOT versions +which have been a newer release and replaces them with the latest release version. +- [versions:use-next-snapshots](../use-next-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions +which have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version. +- [versions:use-latest-snapshots](../use-latest-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions +which have been a newer -SNAPSHOT version and replaces them with the latest -SNAPSHOT version. +- [versions:use-next-versions](../use-next-versions-mojo.html) searches the pom for all versions which +have been a newer version and replaces them with the next version. + [versions:use-latest-versions](../use-latest-versions-mojo.html) searches the pom for all versions which +have been a newer version and replaces them with the latest version. + +All of these goals share a common set of parameters. + +Deciding which goal to use +-------------------------- + +The following matrix should help decide which goal(s) to use: + +| Goal | Modifies Release dependencies | Modifies -SNAPSHOT dependencies | Considers releases | Considers -SNAPSHOTs | Picks Next | Picks Latest | +|----------------------|:-----------------------------:|:-------------------------------:|:------------------:|:------------------------:|:----------:|:------------:| +| use-next-releases | | Yes | Yes | | Yes | | +| use-latest-releases | | Yes | Yes | | | Yes | +| use-next-snapshots | Yes | | | Yes | Yes | | +| use-latest-snapshots | Yes | | | Yes | | Yes | +| use-next-versions | Yes | Yes | Yes | If -DallowSnapshots=true | Yes | | +| use-latest-versions | Yes | Yes | Yes | If -DallowSnapshots=true | | Yes | + +The columns in the above goal matrix are as follows: + +- *Modified Release dependencies* when scanning the `pom.xml` for dependency to update, include those dependencies which +are for release versions (i.e. non-SNAPSHOT versions). +- *Modified -SNAPSHOT dependencies* when scanning the `pom.xml` for dependency to update, include those dependencies which +are for -SNAPSHOT versions. +- *Considers releases* when building the list of newer versions of a dependency, include release versions (i.e. non-SNAPSHOT +versions) in the list. +- *Considers releases* when building the list of newer versions of a dependency, include -SNAPSHOT versions in the list. +- *Picks Next* when the list of newer versions is sorted in increasing order, pick the first newer version in the list, i.e. +the oldest newer version available, also known as the "next" version. +- *Picks Latest* when the list of newer versions is sorted in increasing order, pick the last newer version in the list, i.e. +the newest version available, also known as the "latest" version. + +Controlling which dependencies are processed +-------------------------------------------- + +You can restrict which dependencies should be processed. For example, +the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId +"plexus-utils" + +```sh +mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:plexus-utils +``` + +The `includes` and `excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated separated list to specify multiple includes. Wildcards (\*) can also be used to match +multiple values. + +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". + +```sh +mvn versions:use-next-releases -Dincludes=org.codehaus.plexus:*,junit:junit +``` + +You can pre-configure defaults for `includes` and `excludes` in your `pom.xml` if there is a specific +set of dependencies that you need to track on a regular basis, e.g. + +```xml + + ... + + ... + + ... + + org.codehaus.mojo + versions-maven-plugin + ${pluginVersion} + + ... + + org.codehaus.plexus:* + junit:junit + + ... + + org.codehaus.plexus:plexus-utils + + ... + + + ... + + ... + + ... + +``` + +By default, both the `project/dependencyManagment` and `project/dependencies` sections will be processed. +You can use the `processDependencies` and `processDependencyManagement` parameters to control which sections +are processed. + +This example will only process the `project/dependencyManagment` section of your pom: + +```sh +mvn versions:use-next-releases -DprocessDependencies=false +``` + +While this example will only process the `project/dependencies` section of your pom: + +```sh +mvn versions:use-next-releases -DprocessDependencyManagement=false +``` + + + From 34d4eecd91bffd1aecf1c6c835eb8005548090d1 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk <1554729+ajarmoniuk@users.noreply.github.com> Date: Mon, 10 Oct 2022 14:38:11 +0200 Subject: [PATCH 152/441] Add a link to the actual Maven versioning specification --- src/site/markdown/version-rules.md.vm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/site/markdown/version-rules.md.vm b/src/site/markdown/version-rules.md.vm index 2c7c8fb13b..e6a058128d 100644 --- a/src/site/markdown/version-rules.md.vm +++ b/src/site/markdown/version-rules.md.vm @@ -20,21 +20,19 @@ under the License. --> ## Velocity uses # as a prefix for macros and ## as a prefix for comments -#set($h1 = '#') -#set($h2 = '##') #set($h3 = '###') -#set($h4 = '####') -$h1 Version number rules +Version number rules +==================== -$h2 Introduction +Introduction +------------ **Notice:** The limitations explained in this paragraph were true in Maven 2.x, but have been **fixed** in Maven 3.x (see [Maven Versioning Wiki page](https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning) for more details) -The current implementation of -[DefaultArtifactVersion](https://maven.apache.org/ref/current/maven-artifact/xref/org/apache/maven/artifact/versioning/DefaultArtifactVersion.html) -in the core of Maven expects that version numbers will have a very specific format: +The current implementation of the +[Maven Version Order Specification](https://maven.apache.org/pom.html#version-order-specification) will have a very specific format: ` . . - ` @@ -57,7 +55,8 @@ The `versions-maven-plugin` knows three rules for comparing version numbers: The `versions-maven-plugin` will assume that all version numbers follow the `maven` scheme unless you tell it otherwise. -$h2 Rules.xml +Rules.xml +--------- To specify the version schemes to use, you may define a [rule-set xml file](./rule.html), use the `ruleSet` element in the `versions-maven-plugin` plugin configuration, or specify ignored versions via From 2c16f8eaabd77b856233d2e3df61bc3f8d8dc504 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 10 Oct 2022 07:03:43 +0200 Subject: [PATCH 153/441] #725: Migrating Compare dependency versions --- .../apt/examples/compare-dependencies.apt | 63 ------------------- src/site/markdown/compare-dependencies.md | 57 +++++++++++++++++ 2 files changed, 57 insertions(+), 63 deletions(-) delete mode 100644 src/site/apt/examples/compare-dependencies.apt create mode 100644 src/site/markdown/compare-dependencies.md diff --git a/src/site/apt/examples/compare-dependencies.apt b/src/site/apt/examples/compare-dependencies.apt deleted file mode 100644 index bb47531b53..0000000000 --- a/src/site/apt/examples/compare-dependencies.apt +++ /dev/null @@ -1,63 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Comparing dependency versions - ----- - Paul Gier - ------ - 2009-01-09 - ------ - -Compare dependency versions - - The <<>> goal can be used to compare the dependencies in the current project to - the dependencyManagement of a remote project. This is useful, for example, for finding differences - between the current project dependencies and an organizational bill of materials (BOM) pom. - You specify the remote groupId, artifactId, and the version to which the current project - should be compared, for example - -+---+ -mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -+---+ - - By default the list of dependency differences will be output to the command line. This can be - written to a file using the "reportOutputFile" parameter. - -+---+ -mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DreportOutputFile=${project.build.directory}/depDiffs.txt -+---+ - - The plugin can also automatically update the dependencies of the current project to match - the remote project using the "updateDependencies" parameter. By default this is turned off. - -+---+ -mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DupdateDependencies=true -+---+ - - In addition to that, any property defined in the current project that represent the version - of one of several artifacts can be updated to match the remote project using the "updatePropertyVersions" - parameter. By default this is turned off. - -+---+ -mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -updatePropertyVersions=true -+---+ - - Such update will only occur if the dependencies linked to that version exist in the remote project - and all these dependencies have a single version. In any other case, the property is not updated. - - \ No newline at end of file diff --git a/src/site/markdown/compare-dependencies.md b/src/site/markdown/compare-dependencies.md new file mode 100644 index 0000000000..6d24c00155 --- /dev/null +++ b/src/site/markdown/compare-dependencies.md @@ -0,0 +1,57 @@ +title: Comparing dependency versions +author: Paul Gier +date: 2009-01-09 + + + +# Compare dependency versions + +The `compare-dependencies` goal can be used to compare the dependencies in the current project to +the dependencyManagement of a remote project. This is useful, for example, for finding differences +between the current project dependencies and an organizational bill of materials (BOM) pom. +You specify the remote groupId, artifactId, and the version to which the current project +should be compared, for example + +```sh +mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 +``` + +By default the list of dependency differences will be output to the command line. This can be +written to a file using the "reportOutputFile" parameter. + +```sh +mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DreportOutputFile=${project.build.directory}/depDiffs.txt +``` + +The plugin can also automatically update the dependencies of the current project to match +the remote project using the "updateDependencies" parameter. By default this is turned off. + +```sh +mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -DupdateDependencies=true +``` + +In addition to that, any property defined in the current project that represent the version +of one of several artifacts can be updated to match the remote project using the "updatePropertyVersions" +parameter. By default this is turned off. + +```sh +mvn versions:compare-dependencies -DremotePom=org.foo:bom-pom:1.0 -updatePropertyVersions=true +``` + +Such update will only occur if the dependencies linked to that version exist in the remote project +and all these dependencies have a single version. In any other case, the property is not updated. From fb28efc4185e3f6576509bc103f46a377dd458f7 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 10 Oct 2022 23:21:30 +0200 Subject: [PATCH 154/441] Bump project version to 2.13.0-SNAPSHOT ref #742 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ea6fff7958..27e525abfa 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.12.1-SNAPSHOT + 2.13.0-SNAPSHOT maven-plugin Versions Maven Plugin @@ -115,7 +115,7 @@ 1.11.1 ${project.version} 3.7 - 2022-09-06T06:39:51Z + 2022-10-10T21:19:23Z From f0bfd96c2ae26028b790d258c733060f04a0ad22 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 10 Oct 2022 08:45:38 +0200 Subject: [PATCH 155/441] Caching update information in reports to increase performance --- .../versions/api/ArtifactVersionsCache.java | 66 +++++++++++++++++++ .../AbstractVersionsReportRenderer.java | 18 +++-- .../DependencyUpdatesReportRenderer.java | 8 +-- .../PluginUpdatesReportRenderer.java | 29 ++++---- .../PropertyUpdatesReportRenderer.java | 8 +-- 5 files changed, 104 insertions(+), 25 deletions(-) create mode 100644 src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java new file mode 100644 index 0000000000..009070bcd3 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java @@ -0,0 +1,66 @@ +package org.codehaus.mojo.versions.api; + + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.function.BiFunction; + +import org.apache.commons.lang3.tuple.Pair; + +/** + * Utility providing a cached {@link ArtifactVersions#getOldestUpdate(Optional)} API + */ +public class ArtifactVersionsCache +{ + private BiFunction, ?> cachedFunction; + + private Map>, Object> updateCache = new HashMap<>(); + + /** + * Constructs a new instance given the concrete function for obtaining the details + * + * @param cachedFunction reference to the function computing the required information + */ + public ArtifactVersionsCache( BiFunction, ?> + cachedFunction ) + { + this.cachedFunction = cachedFunction; + } + + /** + * Returns the required information for the given {@link ArtifactVersions} object and the given update scope. + * If the information is already present in cache, the cached version is returned. Otherwise, + * the {@code artifactVersions} object is queried and the response is cached. + * + * @param artifactVersions {@linkplain ArtifactVersions} object referring to the given dependency + * @param updateScope update scope + * @return last retrieved update information + */ + @SuppressWarnings( "unchecked" ) + public R get( V artifactVersions, + Optional updateScope ) + { + return (R) updateCache.computeIfAbsent( Pair.of( artifactVersions, updateScope ), + pair -> cachedFunction.apply( pair.getLeft(), pair.getRight() ) ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 4f52245e53..c3f9102038 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -28,7 +28,9 @@ import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.api.ReportRenderer; import org.codehaus.plexus.i18n.I18N; @@ -56,6 +58,12 @@ public abstract class AbstractVersionsReportRenderer extends VersionsReportRe */ protected T model; + protected ArtifactVersionsCache oldestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + + protected ArtifactVersionsCache allUpdatesCache + = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); + /** * Constructor to be called by the dependency injection framework * @param i18n i18n object to be injected @@ -319,26 +327,26 @@ protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersion sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = details.getAllUpdates( empty() ); - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + ArtifactVersion[] versions = allUpdatesCache.get( details, empty() ); + if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index be5c140304..8c1f3d42ec 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -95,19 +95,19 @@ protected OverviewStats computeOverviewStats() OverviewStats stats = new OverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 869bcfd6e3..1df2288bed 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -30,7 +30,9 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.plexus.i18n.I18N; @@ -46,6 +48,9 @@ */ public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer { + protected ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); + public PluginUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, PluginUpdatesModel model ) { @@ -149,19 +154,19 @@ protected PluginOverviewStats computeOverviewStats() PluginOverviewStats stats = new PluginOverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } @@ -228,37 +233,37 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( of( MINOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( details.getNewestUpdate( of( MAJOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { safeBold(); - sink.text( details.getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index 32ebe9246a..fe5f2de286 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -394,19 +394,19 @@ protected OverviewStats computeOverviewStats() OverviewStats stats = new OverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } From 8a21578c7e65f6467b29aa04cc28ad9ab4791128 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 10 Oct 2022 07:06:58 +0200 Subject: [PATCH 156/441] #725: Migrating display-dependency-updates.apt --- .../display-dependency-updates.md} | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) rename src/site/{apt/examples/display-dependency-updates.apt => markdown/display-dependency-updates.md} (50%) diff --git a/src/site/apt/examples/display-dependency-updates.apt b/src/site/markdown/display-dependency-updates.md similarity index 50% rename from src/site/apt/examples/display-dependency-updates.apt rename to src/site/markdown/display-dependency-updates.md index 5666061a05..a8af766c23 100644 --- a/src/site/apt/examples/display-dependency-updates.apt +++ b/src/site/markdown/display-dependency-updates.md @@ -1,44 +1,40 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. +title: Checking for new dependency updates +author: Stephen Connolly +date: 2008-09-02 - ----- - Checking for new dependency updates - ----- - Stephen Connolly - ------ - 2008-09-02 - ------ + -Checking for new dependency updates +# Checking for new dependency updates - The <<>> goal will check all the dependencies used in your project and display a list - of those dependencies with newer versions available. +The `display-dependency-updates` goal will check all the dependencies used in your project and display a list +of those dependencies with newer versions available. - Here are some examples of what this looks like: +Here are some examples of what this looks like: ---- +```sh svn checkout http://svn.codehaus.org/mojo/trunk/mojo/build-helper-maven-plugin build-helper-maven-plugin cd build-helper-maven-plugin mvn versions:display-dependency-updates ---- +``` - Which produces the following output: +Which produces the following output: ---- +```sh [INFO] ------------------------------------------------------------------------ [INFO] Building Build Helper Maven Plugin [INFO] task-segment: [versions:display-dependency-updates] @@ -58,4 +54,4 @@ mvn versions:display-dependency-updates [INFO] Finished at: Fri Aug 15 10:46:03 IST 2008 [INFO] Final Memory: 10M/167M [INFO] ------------------------------------------------------------------------ ---- +``` From 1fdc3b9481bf5d0d3cb8edbbca87aedd81b413eb Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 8 Oct 2022 10:30:05 +0200 Subject: [PATCH 157/441] #283: allowMinorUpdates false should imply allowMajorUpdates false --- .../versions/AbstractVersionsUpdaterMojo.java | 42 ------ .../DisplayDependencyUpdatesMojo.java | 50 +++---- .../versions/DisplayPropertyUpdatesMojo.java | 13 +- .../mojo/versions/ResolveRangesMojo.java | 14 +- .../mojo/versions/UpdateParentMojo.java | 14 +- .../mojo/versions/UpdatePropertiesMojo.java | 17 ++- .../mojo/versions/UpdatePropertyMojo.java | 13 +- .../mojo/versions/UseLatestReleasesMojo.java | 14 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 8 +- .../mojo/versions/UseLatestVersionsMojo.java | 18 ++- .../mojo/versions/UseNextSnapshotsMojo.java | 8 +- .../ordering/MajorMinorIncrementalFilter.java | 122 ------------------ .../mojo/versions/utils/SegmentUtils.java | 95 ++++++++++++++ .../mojo/versions/UpdateParentMojoTest.java | 2 +- .../versions/UseLatestVersionsMojoTest.java | 22 ++-- .../MajorMinorIncrementalFilterTest.java | 102 --------------- 16 files changed, 209 insertions(+), 345 deletions(-) delete mode 100644 src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java create mode 100644 src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java delete mode 100644 src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index d374a9cc1d..ca59f3755f 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -31,7 +31,6 @@ import java.util.Optional; import java.util.Set; -import org.apache.commons.text.CaseUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -70,12 +69,6 @@ import org.codehaus.plexus.util.WriterFactory; import org.codehaus.stax2.XMLInputFactory2; -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; - /** * Abstract base class for Versions Mojos. * @@ -539,41 +532,6 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A return true; } - /** - *

    Based on the passed flags, determines which segment (0-based), which is not to be changed.

    - *

    The method will return, depending on the first parameter on the list to be true: - *

      - *
    • {@code allowMajorUpdates}: -1
    • - *
    • {@code allowMinorUpdates}: 0
    • - *
    • {@code allowIncrementalUpdates}: 1
    • - *
    • (none): 2
    • - *
    - * - * This can be used when determining an upper - * bound for the "latest" version. - * - * @param allowMajorUpdates Allow major updates - * @param allowMinorUpdates Allow minor updates - * @param allowIncrementalUpdates Allow incremental updates - * @return Returns the segment (0-based) that is unchangeable. If any segment can change, returns -1. - */ - protected Optional determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, - boolean allowIncrementalUpdates ) - { - Optional unchangedSegment = allowMajorUpdates ? empty() - : allowMinorUpdates ? of( MAJOR ) - : allowIncrementalUpdates ? of( MINOR ) - : of( INCREMENTAL ); - if ( getLog().isInfoEnabled() ) - { - getLog().info( - unchangedSegment.map( s -> - CaseUtils.toCamelCase( Segment.of( s.value() + 1 ).toString(), true ) ) - .orElse( "All" ) + " version changes allowed" ); - } - return unchangedSegment; - } - protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, PropertyVersions version, String currentVersion, boolean allowDowngrade, diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 5227465810..0c8c23d91a 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -54,14 +54,13 @@ import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyComparator; +import org.codehaus.mojo.versions.utils.SegmentUtils; import org.codehaus.plexus.util.StringUtils; import static java.util.Optional.empty; import static java.util.Optional.of; import static org.apache.commons.lang3.StringUtils.countMatches; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; /** * Displays all dependencies that have newer versions available. @@ -220,8 +219,9 @@ public class DisplayDependencyUpdatesMojo /** * Whether to allow the major version number to be changed. - * You need to set {@link #allowAnyUpdates} to false to - * get this configuration gets control. + * + *

    Note: {@code false} also implies {@linkplain #allowAnyUpdates} + * to be {@code false}

    * * @since 2.5 */ @@ -229,9 +229,10 @@ public class DisplayDependencyUpdatesMojo private boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. - * You need to set {@link #allowMajorUpdates} to false to - * get this configuration gets control. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowAnyUpdates} + * and {@linkplain #allowMajorUpdates} to be {@code false}

    * * @since 2.5 */ @@ -239,9 +240,11 @@ public class DisplayDependencyUpdatesMojo private boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. - * You need to set {@link #allowMinorUpdates} to false to - * get this configuration gets control. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowAnyUpdates}, + * {@linkplain #allowMajorUpdates}, and {@linkplain #allowMinorUpdates} + * to be {@code false}

    * * @since 2.5 */ @@ -691,28 +694,11 @@ private DependencyManagement getProjectDependencyManagement( MavenProject projec private Optional calculateUpdateScope() { - if ( !allowIncrementalUpdates && !allowMinorUpdates && !allowMajorUpdates && !allowAnyUpdates ) - { - throw new IllegalArgumentException( "One of: allowAnyUpdates, allowMajorUpdates, allowMinorUpdates, " - + "allowIncrementalUpdates must be true" ); - } - - if ( allowAnyUpdates && allowMajorUpdates && allowMinorUpdates ) - { - return empty(); - } - - if ( allowMajorUpdates && allowMinorUpdates ) - { - return of( MAJOR ); - } - - if ( allowMinorUpdates ) - { - return of( MINOR ); - } - - return of( INCREMENTAL ); + return allowAnyUpdates + ? empty() + : of( SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates, getLog() ).map( s -> Segment.of( s.value() - 1 ) ) + .orElse( MAJOR ) ); } private void logUpdates( Map updates, String section ) diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 97c15dc585..2120aac1cb 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -44,6 +44,7 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.SegmentUtils; /** * Displays properties that are linked to artifact versions and have updates available. @@ -107,7 +108,9 @@ public class DisplayPropertyUpdatesMojo private boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 2.5 */ @@ -115,7 +118,10 @@ public class DisplayPropertyUpdatesMojo private boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 2.5 */ @@ -158,7 +164,8 @@ public void execute() } Optional unchangedSegment = - determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates, getLog() ); try { ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 0ed8fe5b68..db997e1b09 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -48,6 +48,7 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.SegmentUtils; /** * Attempts to resolve dependency version ranges to the specific version being used in the build. For example a version @@ -94,7 +95,9 @@ public class ResolveRangesMojo private boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 2.5 */ @@ -102,7 +105,10 @@ public class ResolveRangesMojo private boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 2.5 */ @@ -312,8 +318,8 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom ) property.setVersion( currentVersion ); - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); // TODO: Check if we could add allowDowngrade ? try { diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index bece00a032..caa60b4ce8 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -48,6 +48,7 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.SegmentUtils; import static org.apache.maven.shared.utils.StringUtils.isBlank; @@ -112,7 +113,9 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo protected boolean allowMajorUpdates = true; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 2.13.0 */ @@ -120,7 +123,10 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo protected boolean allowMinorUpdates = true; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 2.13.0 */ @@ -227,8 +233,8 @@ protected ArtifactVersion resolveTargetVersion( String initialVersion ) } final ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); // currentVersion (set to parentVersion here) is not included in the version range for searching upgrades // unless we set allowDowngrade to true diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 9cb0e812e0..fda3617312 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -41,6 +41,7 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.SegmentUtils; /** * Sets properties to the latest versions of specific artifacts. @@ -107,16 +108,20 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo protected boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 2.4 */ - @Parameter( property = "allowMinorUpdates", - defaultValue = "true" ) + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) protected boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 2.4 */ @@ -181,8 +186,8 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( canUpdateProperty ) { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); try { ArtifactVersion targetVersion = diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index ea7e4c002c..dcc1d5d5c9 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -41,6 +41,7 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.SegmentUtils; /** * Sets a property to the latest version in a given range of associated artifacts. @@ -109,7 +110,9 @@ public class UpdatePropertyMojo protected boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 2.4 */ @@ -117,7 +120,10 @@ public class UpdatePropertyMojo protected boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 2.4 */ @@ -166,7 +172,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } Optional unchangedSegment = - determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates, getLog() ); try { ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 3613f131dd..d0464d1f40 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -52,6 +52,7 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; @@ -82,7 +83,9 @@ public class UseLatestReleasesMojo protected boolean allowMajorUpdates; /** - * Whether to allow the minor version number to be changed. + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * * @since 1.2 */ @@ -90,7 +93,10 @@ public class UseLatestReleasesMojo protected boolean allowMinorUpdates; /** - * Whether to allow the incremental version number to be changed. + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * * @since 1.2 */ @@ -148,8 +154,8 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); for ( Dependency dep : dependencies ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 50ee454d9f..b593d5263e 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -51,6 +51,7 @@ import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; import static org.codehaus.mojo.versions.api.Segment.MAJOR; @@ -77,6 +78,7 @@ public class UseLatestSnapshotsMojo /** * Whether to allow the minor version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.0-beta-1 */ @Parameter( property = "allowMinorUpdates", defaultValue = "false" ) @@ -85,6 +87,8 @@ public class UseLatestSnapshotsMojo /** * Whether to allow the incremental version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.0-beta-1 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) @@ -148,8 +152,8 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); for ( Dependency dep : dependencies ) { diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index da31fd138d..8b9b234301 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -45,9 +45,9 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; @@ -72,6 +72,7 @@ public class UseLatestVersionsMojo /** * Whether to allow the minor version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.2 */ @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) @@ -80,6 +81,8 @@ public class UseLatestVersionsMojo /** * Whether to allow the incremental version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.2 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) @@ -108,9 +111,6 @@ public UseLatestVersionsMojo( RepositorySystem repositorySystem, super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); } - /** - * {@inheritDoc} - */ @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -165,10 +165,8 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); - MajorMinorIncrementalFilter majorMinorIncfilter = - new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates ); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, + allowMinorUpdates, allowIncrementalUpdates, getLog() ); for ( Dependency dep : dependencies ) { @@ -199,11 +197,11 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection 0 ) { String newVersion = filteredVersions[filteredVersions.length - 1].toString(); diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 3050b2ce9a..a9e693a5bb 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -49,6 +49,7 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.codehaus.mojo.versions.utils.SegmentUtils; import static org.codehaus.mojo.versions.api.Segment.MAJOR; @@ -74,6 +75,7 @@ public class UseNextSnapshotsMojo /** * Whether to allow the minor version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.0-beta-1 */ @Parameter( property = "allowMinorUpdates", defaultValue = "false" ) @@ -82,6 +84,8 @@ public class UseNextSnapshotsMojo /** * Whether to allow the incremental version number to be changed. * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.0-beta-1 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) @@ -137,8 +141,8 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection - unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates ); + unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates, getLog() ); for ( Dependency dep : dependencies ) { diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java b/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java deleted file mode 100644 index 39b7cba69d..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilter.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.codehaus.mojo.versions.ordering; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; - -/** - * This class will handle the edge cases where a version update would have happened based on the usage of version ranges - * to limit the replacement of the versions. We have currently the following scenario: The user defined - * allowMajorUpdates=false and allowMinorUpdates=true. An given artifact - * groupId:artifactId:2.0.8 and a repository which contains the following versions of this artifact: - *
      - *
    • 2.0.11
    • - *
    • 2.1.0-M1
    • - *
    • 2.2.1
    • - *
    • 3.0-beta-3
    • - *
    • 3.0
    • - *
    • 3.1.0
    • - *
    • 3.3.0
    • - *
    - * The {@link AbstractVersionDetails#getNewerVersions(String, Optional, boolean, boolean)} will use an upper version of - * 2.1.0 to limit the versions to use. The result of this would be using 2.1.0-M1 which - * contradicts the wish of the user of not updating the minor version. The root cause of this is the comparison of Maven - * versions which will defined 2.1.0-M1 as less than 2.1.0. The method - * {@link #filter(ArtifactVersion, ArtifactVersion[])} will filter out those versions which violate the configuration - * {@link #allowMajorUpdates}, {@link #allowMinorUpdates} {@link #allowIncrementalUpdates}. - * - * @author Karl Heinz Marbaise - */ -public class MajorMinorIncrementalFilter -{ - - private final boolean allowMajorUpdates; - - private final boolean allowMinorUpdates; - - private final boolean allowIncrementalUpdates; - - public MajorMinorIncrementalFilter( boolean allowMajorUpdates, boolean allowMinorUpdates, - boolean allowIncrementalUpdates ) - { - this.allowMajorUpdates = allowMajorUpdates; - this.allowMinorUpdates = allowMinorUpdates; - this.allowIncrementalUpdates = allowIncrementalUpdates; - } - - /** - * @param selectedVersion The version which will be checked. - * @param newerVersions The list of identified versions which are greater or equal than the selectedVersion. - * @return The cleaned up list which obeys usage of {@link #allowMajorUpdates}, {@link #allowMinorUpdates}, - * {@link #allowIncrementalUpdates}. - */ - public ArtifactVersion[] filter( ArtifactVersion selectedVersion, ArtifactVersion[] newerVersions ) - { - List versionsToUse = new LinkedList<>(); - for ( ArtifactVersion artifactVersion : newerVersions ) - { - if ( artifactVersion.getMajorVersion() != selectedVersion.getMajorVersion() ) - { - if ( allowMajorUpdates ) - { - if ( !versionsToUse.contains( artifactVersion ) ) - { - versionsToUse.add( artifactVersion ); - } - } - } - else if ( artifactVersion.getMinorVersion() != selectedVersion.getMinorVersion() ) - { - if ( allowMinorUpdates ) - { - if ( !versionsToUse.contains( artifactVersion ) ) - { - versionsToUse.add( artifactVersion ); - } - } - } - else if ( artifactVersion.getIncrementalVersion() != selectedVersion.getIncrementalVersion() ) - { - if ( allowIncrementalUpdates ) - { - if ( !versionsToUse.contains( artifactVersion ) ) - { - versionsToUse.add( artifactVersion ); - } - } - } - else - { - // build number or qualifier. Will already be sorted and higher - if ( !versionsToUse.contains( artifactVersion ) ) - { - versionsToUse.add( artifactVersion ); - } - } - } - return versionsToUse.toArray( new ArtifactVersion[0] ); - - } -} diff --git a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java new file mode 100644 index 0000000000..6d4d21c46d --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java @@ -0,0 +1,95 @@ +package org.codehaus.mojo.versions.utils; + + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Optional; + +import org.apache.maven.plugin.logging.Log; +import org.codehaus.mojo.versions.api.Segment; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; + +/** + * Utility class for manipulating with {@link Segment} objects + */ +public class SegmentUtils +{ + /** + *

    Based on the passed flags, determines which segment which is not to be changed.

    + * + *

    Also, logs the enriched values of the {@code allowMajorUpdates}, {@code allowMinorUpdates}, + * and {@code allowIncrementalUpdates} options so that {@code allowMinorUpdates} equal to {@code false} + * implies that {@code allowMajorUpdates} is also {@code false}.

    + *

    Also, {@code allowIncrementalUpdates} equal to {@code false} + * implies that both {@code allowMajorUpdates} and {@code allowMinorUpdates} are also {@code false}.

    + * + * + * + * + * + * + * + * + * + * + * + * + *
    Effective values for update options
    allowMajorUpdatesallowMinorUpdatesallowIncrementalUpdates
    truetruetrue
    truetrue
    true
    + * + * @param allowMajorUpdates whether all updates should be allowed + * @param allowMinorUpdates if major updates are disallowed, minor, incremental updates should be allowed + * @param allowIncrementalUpdates if major and minor updates are disallowed, incremental updates are allowed + * @param log If not null, the {@linkplain Log} object to log the selected scope + * @return Returns the segment (0-based) that is unchangeable. If any segment can change, returns -1. + */ + public static Optional determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, + boolean allowIncrementalUpdates, Log log ) + { + if ( log != null && !allowIncrementalUpdates ) + { + log.info( "Assuming allowMinorUpdates false because allowIncrementalUpdates is false." ); + } + + if ( log != null && !allowMinorUpdates ) + { + log.info( "Assuming allowMajorUpdates false because allowMinorUpdates is false." ); + } + + Optional unchangedSegment = allowMajorUpdates && allowMinorUpdates + ? empty() + : allowMinorUpdates && allowIncrementalUpdates + ? of( MAJOR ) + : allowIncrementalUpdates + ? of( MINOR ) + : of( INCREMENTAL ); + if ( log != null && log.isInfoEnabled() ) + { + log.info( + unchangedSegment.map( s -> Segment.of( s.value() + 1 ).toString() ) + .orElse( "ALL" ) + " version changes allowed" ); + } + return unchangedSegment; + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 43ca78b36f..0350f8c684 100644 --- a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -337,7 +337,7 @@ public void testAllowMinorUpdates() }} ); mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = true; - mojo.allowIncrementalUpdates = false; + mojo.allowIncrementalUpdates = true; ArtifactVersion newVersion = mojo.resolveTargetVersion( "0.8.0" ); diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 47e0ed3393..e5b0ac4e1d 100644 --- a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -122,9 +122,13 @@ public void testDependenciesDowngradeMinor() setVariableValueToObject( mojo, "allowSnapshots", false ); setVariableValueToObject( mojo, "allowMajorUpdates", false ); setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); setVariableValueToObject( mojo, "allowDowngrade", true ); + mojo.getProject().getModel().setDependencies( Collections.singletonList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.0-SNAPSHOT", + "default", "pom", SCOPE_COMPILE ) ) ); + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) { pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) @@ -132,7 +136,8 @@ public void testDependenciesDowngradeMinor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.0.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", + "1.1.0-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -142,8 +147,8 @@ public void testDependenciesDowngradeMajor() setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); setVariableValueToObject( mojo, "allowMajorUpdates", true ); - setVariableValueToObject( mojo, "allowMinorUpdates", false ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowMinorUpdates", true ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); setVariableValueToObject( mojo, "allowDowngrade", true ); try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) @@ -153,7 +158,8 @@ public void testDependenciesDowngradeMajor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "0.9.0" ) ) ); + hasItem( new VersionChange( "default-group", "dependency-artifact", + "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -220,13 +226,13 @@ public void testPoisonDependencyVersion() "default", "pom", SCOPE_COMPILE ), DependencyBuilder.dependencyWith( "default-group", "poison-artifact", "1.1.1.1-SNAPSHOT", "default", "pom", SCOPE_COMPILE ) - ) ); + ) ); setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); setVariableValueToObject( mojo, "allowMajorUpdates", false ); setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); setVariableValueToObject( mojo, "allowDowngrade", true ); try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) @@ -239,7 +245,7 @@ public void testPoisonDependencyVersion() // being present in the dependency list assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.0.0" ) ) ); + "1.1.0" ) ) ); } @Test diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java deleted file mode 100644 index 4c5436c926..0000000000 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MajorMinorIncrementalFilterTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.codehaus.mojo.versions.ordering; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.junit.Test; - -import static org.hamcrest.Matchers.arrayContaining; -import static org.junit.Assert.assertThat; - -public class MajorMinorIncrementalFilterTest -{ - - private ArtifactVersion[] newerVersions = new ArtifactVersion[] {version( "1.1.1-sp1" ), - version( "1.1.1-1" ), - version( "1.1.2" ), - version( "1.1.3" ), - version( "1.2.0" ), - version( "2.0.0-SNAPSHOT" )}; - - @Test - public void checkFilter() - { - ArtifactVersion selectedVersion = version( "1.1.1" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( true, true, true ); - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); - assertThat( filteredVersions, arrayContaining( - version( "1.1.1-sp1" ), version( "1.1.1-1" ), - version( "1.1.2" ), version( "1.1.3" ), - version( "1.2.0" ), version( "2.0.0-SNAPSHOT" ) ) ); - } - - @Test - public void checkFilterWithNoMajorUpdates() - { - ArtifactVersion selectedVersion = version( "1.1.1" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, true, true ); - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); - assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ), - version( "1.1.2" ), version( "1.1.3" ), version( "1.2.0" ) ) ); - } - - @Test - public void checkFilterWithNoMajorOrMinorUpdates() - { - ArtifactVersion selectedVersion = version( "1.1.1" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, true ); - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); - assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ), - version( "1.1.2" ), version( "1.1.3" ) ) ); - } - - @Test - public void checkFilterWithNoMajorOrMinorOrIncrementalUpdates() - { - ArtifactVersion selectedVersion = version( "1.1.1" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, false ); - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); - assertThat( filteredVersions, arrayContaining( version( "1.1.1-sp1" ), version( "1.1.1-1" ) ) ); - } - - @Test - public void checkFilterWithSnapshotAtSameVersion() - { - ArtifactVersion selectedVersion = version( "1.1.1-SNAPSHOT" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( false, false, false ); - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, - new ArtifactVersion[] {version( "1.1.1" )} ); - assertThat( filteredVersions, arrayContaining( version( "1.1.1" ) ) ); - } - - - @Test - public void checkFilterWithNonStandardVersions() - { - ArtifactVersion selectedVersion = version( "1.1.1.1" ); - MajorMinorIncrementalFilter filter = new MajorMinorIncrementalFilter( true, true, true ); - - ArtifactVersion[] newerVersions = new ArtifactVersion[] {version( "1.1.1.1-sp1" ), - version( "1.1.1.2" ), - version( "1.1.2.21" ), - version( "1.1.3.0" ), - version( "1.2.0" ), - version( "1.2.0.1" ), - version( "2.0.0-SNAPSHOT" )}; - - - ArtifactVersion[] filteredVersions = filter.filter( selectedVersion, newerVersions ); - assertThat( filteredVersions, - arrayContaining( version( "1.1.1.1-sp1" ), - version( "1.1.1.2" ), - version( "1.1.2.21" ), - version( "1.1.3.0" ), - version( "1.2.0" ), - version( "1.2.0.1" ), - version( "2.0.0-SNAPSHOT" ) ) ); - } - - private ArtifactVersion version( String versionString ) - { - return new DefaultArtifactVersion( versionString ); - } -} From c53b1e6861a1a0cba5c96bfa7d061ebd119166b0 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 10 Oct 2022 16:22:17 +0200 Subject: [PATCH 158/441] Adding some of the remaining AbstractVersionDetails methods to the interface --- .../versions/api/AbstractVersionDetails.java | 75 +++++---- .../mojo/versions/api/VersionDetails.java | 158 ++++++++++++------ 2 files changed, 150 insertions(+), 83 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 747a448e47..e2830d4c6e 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -75,11 +75,13 @@ protected AbstractVersionDetails() { } + @Override public final boolean isCurrentVersionDefined() { return getCurrentVersion() != null; } + @Override public final ArtifactVersion getCurrentVersion() { synchronized ( currentVersionLock ) @@ -88,6 +90,7 @@ public final ArtifactVersion getCurrentVersion() } } + @Override public final void setCurrentVersion( ArtifactVersion currentVersion ) { synchronized ( currentVersionLock ) @@ -96,11 +99,13 @@ public final void setCurrentVersion( ArtifactVersion currentVersion ) } } + @Override public final void setCurrentVersion( String currentVersion ) { setCurrentVersion( currentVersion == null ? null : new DefaultArtifactVersion( currentVersion ) ); } + @Override public final boolean isIncludeSnapshots() { synchronized ( currentVersionLock ) @@ -109,6 +114,7 @@ public final boolean isIncludeSnapshots() } } + @Override public final void setIncludeSnapshots( boolean includeSnapshots ) { synchronized ( currentVersionLock ) @@ -117,23 +123,28 @@ public final void setIncludeSnapshots( boolean includeSnapshots ) } } + @Override public final ArtifactVersion[] getVersions() { return getVersions( isIncludeSnapshots() ); } + @Override public abstract ArtifactVersion[] getVersions( boolean includeSnapshots ); + @Override public final ArtifactVersion[] getVersions( VersionRange versionRange, boolean includeSnapshots ) { return getVersions( versionRange, null, includeSnapshots ); } + @Override public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound ) { return getVersions( lowerBound, upperBound, isIncludeSnapshots() ); } + @Override public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ) { @@ -141,17 +152,13 @@ public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, Artifact return getVersions( restriction, includeSnapshots ); } - private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) - { - Restriction restriction = new Restriction( version, false, null, false ); - return getVersions( restriction, includeSnapshots ); - } - + @Override public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) { return getNewestVersion( lowerBound, upperBound, isIncludeSnapshots() ); } + @Override public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ) { @@ -159,6 +166,7 @@ public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, Artif return getNewestVersion( restriction, includeSnapshots ); } + @Override public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ) { @@ -170,6 +178,7 @@ private static Iterable reverse( T[] array ) return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); } + @Override public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots, boolean allowDowngrade ) { @@ -194,16 +203,19 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restri return null; } + @Override public final ArtifactVersion getNewestVersion( Restriction restriction, boolean includeSnapshots ) { return getNewestVersion( null, restriction, includeSnapshots ); } + @Override public final ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ) { return getNewestVersion( versionRange, null, includeSnapshots ); } + @Override public final boolean containsVersion( String version ) { for ( ArtifactVersion candidate : getVersions( true ) ) @@ -216,25 +228,20 @@ public final boolean containsVersion( String version ) return false; } + private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) + { + Restriction restriction = new Restriction( version, false, null, false ); + return getVersions( restriction, includeSnapshots ); + } + + @Override public final ArtifactVersion[] getNewerVersions( String version, boolean includeSnapshots ) { return getNewerVersions( new DefaultArtifactVersion( version ), includeSnapshots ); } - /** - * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots - * should be included. - * - * @param version current version - * @param upperBoundSegment the upper bound segment; empty() means no upper bound - * @param includeSnapshots whether snapshot versions should be included - * @return array of newer versions fulfilling the criteria - * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than - * the segment count) - * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, Optional, boolean, boolean)}, - * boolean, boolean)} instead - */ @Deprecated + @Override public final ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, boolean includeSnapshots ) throws InvalidSegmentException @@ -242,19 +249,7 @@ public final ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade ) throws InvalidSegmentException @@ -279,17 +274,20 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional< return getVersions( restriction, includeSnapshots ); } + @Override public final ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ) { return getOldestVersion( versionRange, null, includeSnapshots ); } + @Override public final ArtifactVersion getOldestVersion( Restriction restriction, boolean includeSnapshots ) { return getOldestVersion( null, restriction, includeSnapshots ); } + @Override public final ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ) { @@ -321,11 +319,13 @@ else if ( versionComparator.compare( oldest, candidate ) > 0 ) return oldest; } + @Override public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ) { return getVersions( null, restriction, includeSnapshots ); } + @Override public final ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ) { @@ -350,6 +350,7 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, Restricti return result.toArray( new ArtifactVersion[0] ); } + @Override public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { @@ -364,6 +365,7 @@ public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Op } } + @Override public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { @@ -378,6 +380,7 @@ public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Op } } + @Override public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) { @@ -392,21 +395,25 @@ public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Op } } + @Override public final ArtifactVersion getOldestUpdate( Optional updateScope ) { return getOldestUpdate( updateScope, isIncludeSnapshots() ); } + @Override public final ArtifactVersion getNewestUpdate( Optional updateScope ) { return getNewestUpdate( updateScope, isIncludeSnapshots() ); } + @Override public final ArtifactVersion[] getAllUpdates( Optional updateScope ) { return getAllUpdates( updateScope, isIncludeSnapshots() ); } + @Override public final ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) @@ -416,6 +423,7 @@ public final ArtifactVersion getOldestUpdate( Optional updateScope, boo return null; } + @Override public final ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) @@ -425,6 +433,7 @@ public final ArtifactVersion getNewestUpdate( Optional updateScope, boo return null; } + @Override public final ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) { if ( isCurrentVersionDefined() ) @@ -434,11 +443,13 @@ public final ArtifactVersion[] getAllUpdates( Optional updateScope, boo return null; } + @Override public final ArtifactVersion[] getAllUpdates( VersionRange versionRange ) { return getAllUpdates( versionRange, isIncludeSnapshots() ); } + @Override public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ) { Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 60b48fe1a9..c42c9745f3 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -44,6 +44,42 @@ public interface VersionDetails */ boolean containsVersion( String version ); + /** + * Returns true if and only if getCurrentVersion() != null. + * + * @return true if and only if getCurrentVersion() != null. + * @since 1.0-beta-1 + */ + boolean isCurrentVersionDefined(); + + /** + * Sets the current version. + * + * @param currentVersion The new current version. + * @since 1.0-beta-1 + */ + void setCurrentVersion( ArtifactVersion currentVersion ); + + /** + * Sets the current version. + * + * @param currentVersion The new current version. + * @since 1.0-beta-1 + */ + void setCurrentVersion( String currentVersion ); + + boolean isIncludeSnapshots(); + + void setIncludeSnapshots( boolean includeSnapshots ); + + /** + * Retrieves the current version. + * + * @return The current version (may be null). + * @since 1.0-beta-1 + */ + ArtifactVersion getCurrentVersion(); + /** * Gets the rule for version comparison of this artifact. * @@ -122,6 +158,19 @@ public interface VersionDetails */ ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); + /** + * Returns the latest version given the version range, restricition, whether to include snapshots and/or + * allow downgrades, or {@code null} if no such version exists. + * + * @param versionRange range to look for the versions + * @param restriction restriction restricting the version lookup + * @param includeSnapshots true if snapshots are to be included. + * @param allowDowngrade whether downgrades are allowed + * @return the latest version satisfying the conditions or null if no version is available. + */ + ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, + boolean includeSnapshots, boolean allowDowngrade ); + /** * Returns the latest version newer than the specified lowerBound, but less than the specified upper bound or * null if no such version exists. @@ -180,6 +229,64 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up */ ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ); + /** + * Returns the newest version newer than the specified current version, but within the specified update scope or + * null if no such version exists. + * + * @param currentVersion the lower bound or null if the lower limit is unbounded. + * @param updateScope the update scope to include. + * @param includeSnapshots true if snapshots are to be included. + * @return the newest version after currentVersion within the specified update scope or null if no + * version is available. + * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments + * @since 1.0-beta-1 + */ + ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, + boolean includeSnapshots ) throws InvalidSegmentException; + + /** + * Returns an array of newer versions than the given version, given whether snapshots + * should be included. + * + * @param version current version in String format + * @param includeSnapshots whether snapshot versions should be included + * @return array of newer versions fulfilling the criteria + */ + ArtifactVersion[] getNewerVersions( String version, boolean includeSnapshots ); + + /** + * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots + * should be included. + * + * @param version current version + * @param upperBoundSegment the upper bound segment; empty() means no upper bound + * @param includeSnapshots whether snapshot versions should be included + * @return array of newer versions fulfilling the criteria + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) + * @deprecated please use {@link AbstractVersionDetails#getNewerVersions(String, Optional, boolean, boolean)}, + * boolean, boolean)} instead + */ + ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, + boolean includeSnapshots ) throws InvalidSegmentException; + + /** + * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots + * should be included. + * + * @param versionString current version + * @param upperBoundSegment the upper bound segment; empty() means no upper bound + * @param includeSnapshots whether snapshot versions should be included + * @param allowDowngrade whether to allow downgrading if the current version is a snapshots and snapshots + * are disallowed + * @return array of newer versions fulfilling the criteria + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) + */ + ArtifactVersion[] getNewerVersions( String versionString, Optional upperBoundSegment, + boolean includeSnapshots, boolean allowDowngrade ) + throws InvalidSegmentException; + /** * Returns the oldest version within the specified version range or null if no such version exists. * @@ -227,21 +334,6 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; - /** - * Returns the newest version newer than the specified current version, but within the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param updateScope the update scope to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the newest version after currentVersion within the specified update scope or null if no - * version is available. - * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments - * @since 1.0-beta-1 - */ - ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) throws InvalidSegmentException; - /** * Returns the all versions newer than the specified current version, but within the specified update scope. * @@ -255,42 +347,6 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; - /** - * Returns true if and only if getCurrentVersion() != null. - * - * @return true if and only if getCurrentVersion() != null. - * @since 1.0-beta-1 - */ - boolean isCurrentVersionDefined(); - - /** - * Sets the current version. - * - * @param currentVersion The new current version. - * @since 1.0-beta-1 - */ - void setCurrentVersion( ArtifactVersion currentVersion ); - - /** - * Sets the current version. - * - * @param currentVersion The new current version. - * @since 1.0-beta-1 - */ - void setCurrentVersion( String currentVersion ); - - boolean isIncludeSnapshots(); - - void setIncludeSnapshots( boolean includeSnapshots ); - - /** - * Retrieves the current version. - * - * @return The current version (may be null). - * @since 1.0-beta-1 - */ - ArtifactVersion getCurrentVersion(); - /** * Returns the oldest version newer than the current version, but within the specified update scope or * null if no such version exists. From c206f78320c0ff8b205d5e7b4e190e29635b9cc1 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 10 Oct 2022 16:48:06 +0200 Subject: [PATCH 159/441] #725: Migrating the plugin dependency updates example + correcting a typo in the "author" metadata --- .../advancing-dependency-versions.md.vm | 2 +- .../examples/display-plugin-updates.md} | 108 +++++++++--------- src/site/markdown/faq.md | 2 +- src/site/markdown/index.md | 2 +- src/site/markdown/usage.md.vm | 2 +- src/site/markdown/version-rules.md.vm | 2 +- 6 files changed, 57 insertions(+), 61 deletions(-) rename src/site/{apt/examples/display-plugin-updates.apt => markdown/examples/display-plugin-updates.md} (84%) diff --git a/src/site/markdown/examples/advancing-dependency-versions.md.vm b/src/site/markdown/examples/advancing-dependency-versions.md.vm index 6e49008984..188871f21b 100644 --- a/src/site/markdown/examples/advancing-dependency-versions.md.vm +++ b/src/site/markdown/examples/advancing-dependency-versions.md.vm @@ -1,5 +1,5 @@ title: Advancing dependency versions -autor: Stephen Connolly +author: Stephen Connolly date: 2009-08-12 -Checking for new plugin updates +# Checking for new plugin updates - The <<>> goal will check all the plugins and reports used in your project and display a list - of those plugins with newer versions available, first staying with the same Maven version prerequisite, then - additional options if you update the Maven version prerequisite. +The `display-plugin-updates` goal will check all the plugins and reports used in your project and display a list +of those plugins with newer versions available, first staying with the same Maven version prerequisite, then +additional options if you update the Maven version prerequisite. - Here are some examples of what this looks like: +Here are some examples of what this looks like: ---- +```sh svn checkout http://svn.codehaus.org/mojo/trunk/mojo/build-helper-maven-plugin build-helper-maven-plugin cd build-helper-maven-plugin mvn versions:display-plugin-updates ---- +``` - Which produces the following output: +Which produces the following output: ---- +```log [INFO] ------------------------------------------------------------------------ [INFO] Building Build Helper Maven Plugin [INFO] task-segment: [versions:display-plugin-updates] @@ -84,15 +80,15 @@ mvn versions:display-plugin-updates [INFO] Finished at: Wed Nov 30 21:59:36 GMT 2011 [INFO] Final Memory: 21M/81M [INFO] ------------------------------------------------------------------------ ---- +``` - The plugin will also warn if you have not specified the versions of any plugins that you are using and tell you what - version you are currently using. Best practice in Maven is to always specify the plugin versions in order to - ensure that builds are reproducible. +The plugin will also warn if you have not specified the versions of any plugins that you are using and tell you what +version you are currently using. Best practice in Maven is to always specify the plugin versions in order to +ensure that builds are reproducible. - For example the following <<>>: +For example the following `pom.xml`: ---- +```xml 4.0.0 @@ -135,11 +131,11 @@ mvn versions:display-plugin-updates ---- +``` - produces the following output (when run using Maven 2.0.6): +produces the following output (when run using Maven 2.0.6): ---- +```log [INFO] ---------------------------------------------------------------------------- [INFO] Building Unnamed - org.codehaus.mojo.versions-maven-plugin.it:parent:pom:2.0 [INFO] task-segment: [versions:display-plugin-updates] @@ -202,18 +198,18 @@ mvn versions:display-plugin-updates [INFO] Finished at: Wed Nov 30 22:02:14 GMT 2011 [INFO] Final Memory: 26M/81M [INFO] ------------------------------------------------------------------------ ---- +``` - Note: that because the POM does not specify versions for some plugins, Maven - defaults to using the latest compatible version (Maven 3 complains about the - version not being specified), and hence the reported minimum required Maven - version tends to be the same as the version of Maven that is running the mojo +Note: that because the POM does not specify versions for some plugins, Maven +defaults to using the latest compatible version (Maven 3 complains about the +version not being specified), and hence the reported minimum required Maven +version tends to be the same as the version of Maven that is running the mojo - When run with Maven 2.0.9 (which defines versions of core plugins in the - super-pom, and removes some plugin from the lifecycle for the pom lifecycle), - we get the following output: +When run with Maven 2.0.9 (which defines versions of core plugins in the +super-pom, and removes some plugin from the lifecycle for the pom lifecycle), +we get the following output: ---- +```log [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - org.codehaus.mojo.versions-maven-plugin.it:parent:pom:2.0 [INFO] task-segment: [versions:display-plugin-updates] @@ -264,11 +260,11 @@ mvn versions:display-plugin-updates [INFO] Finished at: Wed Nov 30 22:09:59 GMT 2011 [INFO] Final Memory: 20M/81M [INFO] ------------------------------------------------------------------------ ---- +``` - And the following POM: +And the following POM: ---- +```xml 4.0.0 @@ -312,11 +308,11 @@ mvn versions:display-plugin-updates ---- +``` produces the following output: ---- +```log [INFO] ------------------------------------------------------------------------ [INFO] Building Unnamed - org.codehaus.mojo.versions-maven-plugin.it:child:pom:2.0 [INFO] task-segment: [versions:display-plugin-updates] @@ -351,4 +347,4 @@ mvn versions:display-plugin-updates [INFO] Finished at: Fri Nov 25 18:28:34 GMT 2011 [INFO] Final Memory: 17M/81M [INFO] ------------------------------------------------------------------------ ---- \ No newline at end of file +``` diff --git a/src/site/markdown/faq.md b/src/site/markdown/faq.md index b7872d5d7c..7367e3813a 100644 --- a/src/site/markdown/faq.md +++ b/src/site/markdown/faq.md @@ -1,5 +1,5 @@ title: FAQ -autor: Stephen Connolly +author: Stephen Connolly @@ -323,6 +323,29 @@ java + + + src/main/mdo/rule.mdo + + 2.0.0 + + + + generate-reporting + generate-sources + + + xpp3-writer + + java + + + + src/main/mdo/dependency-updates-report.mdo + src/main/mdo/plugin-updates-report.mdo + + 2.0.0 + site-doc @@ -345,6 +368,8 @@ src/main/mdo/rule.mdo + src/main/mdo/dependency-updates-report.mdo + src/main/mdo/plugin-updates-report.mdo 2.0.0 @@ -392,6 +417,8 @@ org.codehaus.mojo.versions.model, org.codehaus.mojo.versions.model.io.xpp3 + org.codehaus.mojo.versions.reporting.model, + org.codehaus.mojo.versions.reporting.model.io.xpp3, diff --git a/src/it/it-dependency-updates-report-issue-755/invoker.properties b/src/it/it-dependency-updates-report-issue-755/invoker.properties new file mode 100644 index 0000000000..09f3f7db01 --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-755/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report +invoker.mavenOpts = -DdependencyUpdatesReportFormats=xml diff --git a/src/it/it-dependency-updates-report-issue-755/pom.xml b/src/it/it-dependency-updates-report-issue-755/pom.xml new file mode 100644 index 0000000000..c75353ed03 --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-755/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + localhost + dummy-artifact + 1.0.0-SNAPSHOT + + + + localhost + dummy-api + 1.0 + + + + diff --git a/src/it/it-dependency-updates-report-issue-755/verify.groovy b/src/it/it-dependency-updates-report-issue-755/verify.groovy new file mode 100644 index 0000000000..fc9b89d5c7 --- /dev/null +++ b/src/it/it-dependency-updates-report-issue-755/verify.groovy @@ -0,0 +1,5 @@ +report = new File( basedir, "target/dependency-updates-report.xml" ).text.replaceAll( '\\s*', '' ) + +assert report.contains( '1.0.1' ) +assert report.contains( '1.1' ) +assert report.contains( '2.0' ) diff --git a/src/it/it-plugin-updates-report-issue-755/invoker.properties b/src/it/it-plugin-updates-report-issue-755/invoker.properties new file mode 100644 index 0000000000..5faa3b4b61 --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-755/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:plugin-updates-report +invoker.mavenOpts = -DpluginUpdatesReportFormats=xml diff --git a/src/it/it-plugin-updates-report-issue-755/pom.xml b/src/it/it-plugin-updates-report-issue-755/pom.xml new file mode 100644 index 0000000000..6df231194c --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-755/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + localhost + dummy-artifact + 1.0.0-SNAPSHOT + + + + + localhost + dummy-maven-plugin + 1.0 + + + + + diff --git a/src/it/it-plugin-updates-report-issue-755/verify.groovy b/src/it/it-plugin-updates-report-issue-755/verify.groovy new file mode 100644 index 0000000000..f68411a704 --- /dev/null +++ b/src/it/it-plugin-updates-report-issue-755/verify.groovy @@ -0,0 +1,5 @@ +report = new File( basedir, "target/plugin-updates-report.xml" ).text.replaceAll( '\\s*', '' ) + +assert report.contains( '3.0.0' ) +assert report.contains( '2.3' ) +assert report.contains( '2.2.2' ) diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 8f40fa0f85..6cda7845a4 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -21,7 +21,10 @@ import javax.inject.Inject; -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -39,10 +42,10 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyComparator; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; import static java.util.Collections.emptyMap; @@ -205,27 +208,28 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! for ( String format : formats ) { + DependencyUpdatesModel model = + new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); if ( "html".equals( format ) ) { - rendererFactory.createReportRenderer( getOutputName(), sink, locale, - new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ) ) - .render(); + rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); } else if ( "xml".equals( format ) ) { - File outputDir = new File( getProject().getBuild().getDirectory() ); - if ( !outputDir.exists() ) + Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); + if ( !Files.exists( outputDir ) ) { - if ( !outputDir.mkdirs() ) + try { - throw new MavenReportException( "Could not create output directory" ); + Files.createDirectories( outputDir ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Could not create the output directory" ); } } - String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; - DependencyUpdatesXmlRenderer xmlGenerator = - new DependencyUpdatesXmlRenderer( dependencyUpdates, dependencyManagementUpdates, - outputFile ); - xmlGenerator.render(); + Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); + new DependencyUpdatesXmlReportRenderer( model, outputFile ).render(); } } } diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 32503ec04a..1b47c0f7c4 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -21,7 +21,10 @@ import javax.inject.Inject; -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Locale; import java.util.Map; import java.util.Set; @@ -38,10 +41,10 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.xml.PluginUpdatesXmlRenderer; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.mojo.versions.utils.PluginComparator; +import org.codehaus.mojo.versions.xml.PluginUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; import static org.codehaus.mojo.versions.utils.MiscUtils.filter; @@ -166,28 +169,29 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx plugin -> plugin.getVersions().length > 1 ); } + PluginUpdatesModel model = new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ); for ( String format : formats ) { if ( "html".equals( format ) ) { - rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, - new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ) ) - .render(); + rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model ).render(); } else if ( "xml".equals( format ) ) { - File outputDir = new File( getProject().getBuild().getDirectory() ); - if ( !outputDir.exists() ) + Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); + if ( !Files.exists( outputDir ) ) { - if ( !outputDir.mkdirs() ) + try { - throw new MavenReportException( "Could not create output directory" ); + Files.createDirectories( outputDir ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Could not create the output directory" ); } } - String outputFile = outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml"; - PluginUpdatesXmlRenderer xmlGenerator = - new PluginUpdatesXmlRenderer( pluginUpdates, pluginManagementUpdates, outputFile ); - xmlGenerator.render(); + Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); + new PluginUpdatesXmlReportRenderer( model, outputFile ).render(); } } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index 8c1f3d42ec..c26c7ca785 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -29,12 +29,6 @@ import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; import org.codehaus.plexus.i18n.I18N; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - /** * @param type of the model * @since 1.0-beta-1 @@ -92,31 +86,7 @@ protected void renderTable( String titleKey, Map c @Override protected OverviewStats computeOverviewStats() { - OverviewStats stats = new OverviewStats(); - model.getAllUpdates().values().forEach( details -> - { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - stats.incrementAny(); - } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - stats.incrementIncremental(); - } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) - { - stats.incrementMinor(); - } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - stats.incrementMajor(); - } - else - { - stats.incrementUpToDate(); - } - } ); - return stats; + return OverviewStats.fromUpdates( model.getAllUpdates().values(), oldestUpdateCache ); } protected void renderDependencyDetail( Dependency artifact, ArtifactVersions details ) diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java index 4cff6950a7..bde72a9218 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java @@ -20,12 +20,26 @@ * under the License. */ +import java.util.Collection; +import java.util.Optional; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.Segment; + +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + /** * Represents summary stats * * @author Andrzej Jarmoniuk */ -class OverviewStats +public class OverviewStats { private int major; @@ -37,6 +51,55 @@ class OverviewStats private int upToDate; + /** + * Creates a {@linkplain OverviewStats} instance based on the collection of version updates in + * the argument + * + * @param updates collection of all version updates, typically from + * {@linkplain org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel#getAllUpdates()} + * @param cache if not null, cache to retrieve the version information, initialised with + * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * @param subclass of {@linkplain OverviewStats} + * @param subclass of {@linkplain ArtifactVersions} + * @return instance of the {@linkplain OverviewStats} + */ + public static T fromUpdates( Collection updates, + ArtifactVersionsCache cache ) + { + OverviewStats stats = new OverviewStats(); + updates.forEach( details -> + { + if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + { + stats.incrementAny(); + } + else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + { + stats.incrementIncremental(); + } + else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + { + stats.incrementMinor(); + } + else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + { + stats.incrementMajor(); + } + else + { + stats.incrementUpToDate(); + } + } ); + return (T) stats; + } + + protected static ArtifactVersion getOldestUpdate( ArtifactVersionsCache cache, + V details, + Optional segment ) + { + return cache != null ? cache.get( details, segment ) : details.getOldestUpdate( segment ); + } + public int getMajor() { return major; diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java new file mode 100644 index 0000000000..5275c17e4f --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -0,0 +1,96 @@ +package org.codehaus.mojo.versions.reporting; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Collection; +import java.util.Optional; + +import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; + +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; + +public class PluginOverviewStats extends OverviewStats +{ + /** + * Extension of the {@linkplain OverviewStats} adding dependency stats + */ + private int dependencies; + + public int getDependencies() + { + return dependencies; + } + + public void incrementDependencies() + { + dependencies++; + } + + /** + * Creates a {@linkplain PluginOverviewStats} instance based on the collection of version updates in + * the argument + * + * @param updates collection of all version updates, typically from {@linkplain PluginUpdatesModel#getAllUpdates()} + * @param cache if not null, cache to retrieve the version information, initialised with + * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * @param always equal to {@linkplain PluginOverviewStats} + * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} + * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information + */ + public static T fromUpdates( Collection updates, + ArtifactVersionsCache cache ) + { + PluginOverviewStats stats = new PluginOverviewStats(); + updates.forEach( details -> + { + if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + { + stats.incrementAny(); + } + else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + { + stats.incrementIncremental(); + } + else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + { + stats.incrementMinor(); + } + else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + { + stats.incrementMajor(); + } + else + { + stats.incrementUpToDate(); + } + if ( ( ( PluginUpdatesDetails ) details ).isDependencyUpdateAvailable() ) + { + stats.incrementDependencies(); + } + } ); + return (T) stats; + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 1df2288bed..e1327dd56e 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -127,59 +127,13 @@ protected void renderSummaryTable( Map content sink.table_(); } - /** - * Extension of the {@linkplain OverviewStats} adding dependency stats - */ - static class PluginOverviewStats extends OverviewStats - { - private int dependencies; - - public int getDependencies() - { - return dependencies; - } - - public void incrementDependencies() - { - dependencies++; - } - } - /** * {@inheritDoc} */ @Override protected PluginOverviewStats computeOverviewStats() { - PluginOverviewStats stats = new PluginOverviewStats(); - model.getAllUpdates().values().forEach( details -> - { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - stats.incrementAny(); - } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - stats.incrementIncremental(); - } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) - { - stats.incrementMinor(); - } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - stats.incrementMajor(); - } - else - { - stats.incrementUpToDate(); - } - if ( details.isDependencyUpdateAvailable() ) - { - stats.incrementDependencies(); - } - } ); - return stats; + return PluginOverviewStats.fromUpdates( model.getAllUpdates().values(), oldestUpdateCache ); } @Override diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java deleted file mode 100644 index 6b890c7b52..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.codehaus.mojo.versions.xml; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.Map; -import java.util.Optional; -import java.util.TreeMap; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.model.Dependency; -import org.apache.maven.reporting.MavenReportException; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.utils.DependencyComparator; - -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - -/** - * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available - * dependency/dependency management updates. - * - * @author Illia Dubinin - * @since 2.4 - */ -public class DependencyUpdatesXmlRenderer -{ - - private static final String GROUP_ID = "groupId"; - - private static final String ARTIFACT_ID = "artifactId"; - - private static final String SCOPE = "scope"; - - private static final String CLASSIFIER = "classifier"; - - private static final String TYPE = "type"; - - private static final String CURRENT_VERSION = "currentVersion"; - - private static final String NEXT_VERSION = "nextVersion"; - - private static final String STATUS = "status"; - - private static final String OPEN_TAG = "<"; - - private static final String CLOSE_TAG = ">"; - - private static final String OPEN_CLOSING_TAG = " dependencyUpdates; - - private final Map dependencyManagementUpdates; - - private final String outputFileName; - - public DependencyUpdatesXmlRenderer( Map dependencyUpdates, - Map dependencyManagementUpdates, - String outputFileName ) - { - this.dependencyUpdates = dependencyUpdates; - this.dependencyManagementUpdates = dependencyManagementUpdates; - this.outputFileName = outputFileName; - } - - /** - * Makes report file with given name in target directory. - * - * @throws MavenReportException if something went wrong - */ - public void render() - throws MavenReportException - { - StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( NL ); - Map allUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); - allUpdates.putAll( dependencyManagementUpdates ); - allUpdates.putAll( dependencyUpdates ); - sb.append( getSummaryBlock( allUpdates.values() ) ); - sb.append( getDependencyInfoBlock( dependencyManagementUpdates, "dependencyManagements", - "dependencyManagement" ) ); - sb.append( getDependencyInfoBlock( dependencyUpdates, "dependencies", "dependency" ) ); - sb.append( "" ).append( NL ); - PrintWriter pw; - try - { - pw = new PrintWriter( outputFileName, "UTF8" ); - pw.print( sb ); - pw.close(); - } - catch ( IOException e ) - { - throw new MavenReportException( "Cannot create xml report.", e ); - } - } - - /** - * Method wraps value in xml tag. In ex: to wrap foo in tag bar you have to pass foo as value and bar as tag. As a - * result you will get: <bar>foo</bar> - * - * @param value - string to wrap - * @param tag - name of tag - * @return value wrapped in xml tag - */ - - public static String wrapElement( String value, String tag ) - { - return OPEN_TAG + tag + CLOSE_TAG + value + OPEN_CLOSING_TAG + tag + CLOSE_TAG; - } - - /** - * Returns summary of dependency analysis result in xml format: current version, next available, next incremental, - * next minor and next major versions. - * - * @param allUpdates all dependencies versions - * @return summary in xml format - */ - public static String getSummaryBlock( Collection allUpdates ) - { - int numInc = 0; - int numMin = 0; - int numMaj = 0; - int numAny = 0; - int numCur = 0; - for ( ArtifactVersions details : allUpdates ) - { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - numAny++; - } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) - { - numInc++; - } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) - { - numMin++; - } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) - { - numMaj++; - } - else - { - numCur++; - } - } - - String result = "\t%n" + "\t\t%d%n" - + "\t\t%d%n" - + "\t\t%d%n" - + "\t\t%d%n" + "\t\t%d%n" - + "\t%n"; - - return String.format( result, numCur, numAny, numInc, numMin, numMaj ); - } - - /** - * Returns xml report for current dependency state with following info: current version, next available version, - * next incremental/minor/major if available and status ('incremental available', 'minor available', 'major - * available' or 'no new available') - * - * @param versions version info for dependency - * @return xml reports about current possible updates. - */ - public static String getVersionsBlocks( ArtifactVersions versions ) - { - StringBuilder sBuilder = new StringBuilder(); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( versions.isCurrentVersionDefined() - ? versions.getCurrentVersion().toString() : versions.getArtifact().getVersionRange().toString(), - CURRENT_VERSION ) ).append( NL ); - ArtifactVersion nextVersion = versions.getOldestUpdate( empty() ); - if ( nextVersion != null ) - { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( nextVersion.toString(), - NEXT_VERSION ) ).append( NL ); - - String incrementalsBlock = getVersionsInScopeBlock( versions, of( INCREMENTAL ) ); - sBuilder.append( incrementalsBlock ); - String minorsBlock = getVersionsInScopeBlock( versions, of( MINOR ) ); - sBuilder.append( minorsBlock ); - String majorsBlock = getVersionsInScopeBlock( versions, of( MAJOR ) ); - sBuilder.append( majorsBlock ); - - String status = null; - if ( incrementalsBlock.length() > 0 ) - { - status = "incremental available"; - } - else if ( minorsBlock.length() > 0 ) - { - status = "minor available"; - } - else if ( majorsBlock.length() > 0 ) - { - status = "major available"; - } - - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( status, STATUS ) ).append( NL ); - } - else - { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( "no new available", - STATUS ) ).append( NL ); - } - - return sBuilder.toString(); - } - - private static String getDependencyInfoBlock( Map dependencyUpdates, String blockName, - String subblockName ) - { - StringBuilder sBuilder = new StringBuilder(); - sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - dependencyUpdates.forEach( ( dep, value ) -> - { - sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getGroupId(), - GROUP_ID ) ).append( NL ); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getArtifactId(), - ARTIFACT_ID ) ).append( NL ); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getScope(), - SCOPE ) ).append( NL ); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getClassifier(), - CLASSIFIER ) ).append( NL ); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( dep.getType(), - TYPE ) ).append( NL ); - - sBuilder.append( getVersionsBlocks( value ) ); - - sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - } ); - sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - return sBuilder.toString(); - } - - private static String getVersionsInScopeBlock( ArtifactVersions av, Optional scope ) - { - String versionsTag = scope.map( s -> s.name().toLowerCase() + "s" ).orElse( "any" ); - StringBuilder sBuilder = new StringBuilder(); - - ArtifactVersion nextVersion = av.getOldestUpdate( scope ); - if ( nextVersion != null ) - { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_TAG ).append( versionsTag ) - .append( CLOSE_TAG ).append( NL ); - ArtifactVersion[] versions = av.getAllUpdates( scope ); - for ( ArtifactVersion version : versions ) - { - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( TAB ) - .append( wrapElement( version.toString(), - scope.toString().toLowerCase() ) ).append( NL ); - } - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( versionsTag ) - .append( CLOSE_TAG ).append( NL ); - } - - return sBuilder.toString(); - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java new file mode 100644 index 0000000000..25dfb3dcbc --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java @@ -0,0 +1,146 @@ +package org.codehaus.mojo.versions.xml; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.ReportRenderer; +import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.reporting.OverviewStats; +import org.codehaus.mojo.versions.reporting.model.DependencyInfo; +import org.codehaus.mojo.versions.reporting.model.DependencyReportSummary; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesReport; +import org.codehaus.mojo.versions.reporting.model.io.xpp3.DependencyUpdatesReportXpp3Writer; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; + +/** + * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available + * dependency/dependency management updates. + * + * @author Illia Dubinin + * @since 2.4 + */ +public class DependencyUpdatesXmlReportRenderer implements ReportRenderer +{ + private final DependencyUpdatesModel model; + private final Path outputFile; + private final ArtifactVersionsCache oldestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + /** + * Creates a new instance + * @param model object containing the updates model + * @param outputFile output file for the report + */ + public DependencyUpdatesXmlReportRenderer( DependencyUpdatesModel model, Path outputFile ) + { + this.model = model; + this.outputFile = outputFile; + } + + /** + * Creates an XML report + */ + @Override + public void render() + { + try ( BufferedWriter writer = Files.newBufferedWriter( outputFile, + StandardCharsets.UTF_8 ) ) + { + new DependencyUpdatesReportXpp3Writer().write( writer, new DependencyUpdatesReport() + {{ + setSummary( new DependencyReportSummary() + {{ + OverviewStats overviewStats = OverviewStats.fromUpdates( model.getAllUpdates().values(), + oldestUpdateCache ); + setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); + setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); + setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); + setNextMinorAvailable( String.valueOf( overviewStats.getMinor() ) ); + setNextMajorAvailable( String.valueOf( overviewStats.getMajor() ) ); + }} ); + setDependencyManagements( createDependencyInfo( model.getArtifactManagementUpdates() ) ); + setDependencies( createDependencyInfo( model.getArtifactUpdates() ) ); + }} ); + } + catch ( IOException e ) + { + throw new RuntimeException( e ); + } + } + + private static void setSection( ArtifactVersions versions, Segment segment, Consumer> setterFunction ) + { + ofNullable( versions.getAllUpdates( of( segment ) ) ) + .map( v -> Arrays.stream( v ) + .map( ArtifactVersion::toString ) + .collect( Collectors.toList() ) ) + .ifPresent( setterFunction ); + } + + private static List createDependencyInfo( Map versions ) + { + return versions.entrySet().stream().map( e -> + new DependencyInfo() + {{ + setGroupId( e.getKey().getGroupId() ); + setArtifactId( e.getKey().getArtifactId() ); + setCurrentVersion( e.getKey().getVersion() ); + setScope( e.getKey().getScope() ); + setType( e.getKey().getType() ); + setClassifier( e.getKey().getClassifier() ); + + ofNullable( e.getValue().getOldestUpdate( empty() ) ) + .map( ArtifactVersion::toString ).ifPresent( this::setNextVersion ); + + setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); + setSection( e.getValue(), MINOR, this::setMinors ); + setSection( e.getValue(), MAJOR, this::setMajors ); + + setStatus( getNextVersion() == null + ? "no new available" + : getIncrementals() != null + ? "incremental available" + : getMinors() != null + ? "minor available" + : "major available" ); + }} ).collect( Collectors.toList() ); + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java deleted file mode 100644 index 7459323b31..0000000000 --- a/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlRenderer.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.codehaus.mojo.versions.xml; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Map; -import java.util.TreeMap; - -import org.apache.maven.model.Plugin; -import org.apache.maven.reporting.MavenReportException; -import org.codehaus.mojo.versions.PluginUpdatesDetails; -import org.codehaus.mojo.versions.utils.PluginComparator; - -import static org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer.getVersionsBlocks; -import static org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer.wrapElement; - -/** - * XML renderer for PluginUpdatesReport creates an xml file in target directory and writes report about available - * plugin/plugin management updates. - * - * @author Illia Dubinin - * @since 2.4 - */ -public class PluginUpdatesXmlRenderer -{ - - private static final String GROUP_ID = "groupId"; - - private static final String ARTIFACT_ID = "artifactId"; - - private static final String OPEN_TAG = "<"; - - private static final String CLOSE_TAG = ">"; - - private static final String OPEN_CLOSING_TAG = " pluginUpdates; - - private Map pluginManagementUpdates; - - private String outputFileName; - - public PluginUpdatesXmlRenderer( Map pluginUpdates, - Map pluginManagementUpdates, String outputFileName ) - { - this.pluginUpdates = pluginUpdates; - this.pluginManagementUpdates = pluginManagementUpdates; - this.outputFileName = outputFileName; - } - - /** - * Makes report file with given name in target directory. - * - * @throws MavenReportException if something went wrong - */ - public void render() - throws MavenReportException - { - StringBuilder sb = new StringBuilder(); - sb.append( "" ).append( NL ); - Map allUpdates = new TreeMap<>( PluginComparator.INSTANCE ); - allUpdates.putAll( pluginManagementUpdates ); - allUpdates.putAll( pluginUpdates ); - sb.append( getSummaryBlock( allUpdates ) ); - sb.append( getPluginsInfoBlock( pluginManagementUpdates, "pluginManagements", "pluginManagement" ) ); - sb.append( getPluginsInfoBlock( pluginUpdates, "plugins", "plugin" ) ); - sb.append( "" ).append( NL ); - PrintWriter pw; - try - { - pw = new PrintWriter( outputFileName, "UTF8" ); - pw.print( sb ); - pw.close(); - } - catch ( IOException e ) - { - throw new MavenReportException( "Cannot create xml report.", e ); - } - } - - private static String getSummaryBlock( Map allUpdates ) - { - return DependencyUpdatesXmlRenderer.getSummaryBlock( allUpdates.values() ); - } - - private static String getPluginsInfoBlock( Map pluginUpdates, String blockName, - String subblockName ) - { - StringBuilder sBuilder = new StringBuilder(); - sBuilder.append( TAB ).append( OPEN_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - pluginUpdates.forEach( ( plugin, value ) -> - { - sBuilder.append( TAB ).append( TAB ).append( OPEN_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( plugin.getGroupId(), - GROUP_ID ) ).append( NL ); - sBuilder.append( TAB ).append( TAB ).append( TAB ).append( wrapElement( plugin.getArtifactId(), - ARTIFACT_ID ) ).append( NL ); - - sBuilder.append( getVersionsBlocks( value ) ); - - sBuilder.append( TAB ).append( TAB ).append( OPEN_CLOSING_TAG ).append( subblockName ).append( CLOSE_TAG ) - .append( NL ); - } ); - sBuilder.append( TAB ).append( OPEN_CLOSING_TAG ).append( blockName ).append( CLOSE_TAG ).append( NL ); - return sBuilder.toString(); - } - -} diff --git a/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java new file mode 100644 index 0000000000..1f4d668028 --- /dev/null +++ b/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java @@ -0,0 +1,148 @@ +package org.codehaus.mojo.versions.xml; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.BufferedWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.ReportRenderer; +import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.reporting.PluginOverviewStats; +import org.codehaus.mojo.versions.reporting.model.PluginInfo; +import org.codehaus.mojo.versions.reporting.model.PluginReportSummary; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesReport; +import org.codehaus.mojo.versions.reporting.model.io.xpp3.PluginUpdatesReportXpp3Writer; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; + +/** + * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available + * dependency/dependency management updates. + * + * @author Illia Dubinin + * @since 2.4 + */ +public class PluginUpdatesXmlReportRenderer implements ReportRenderer +{ + private final PluginUpdatesModel model; + private final Path outputFile; + private final ArtifactVersionsCache oldestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + /** + * Creates a new instance + * @param model object containing the updates model + * @param outputFile output file for the report + */ + public PluginUpdatesXmlReportRenderer( PluginUpdatesModel model, Path outputFile ) + { + this.model = model; + this.outputFile = outputFile; + } + + /** + * Creates an XML report + */ + @Override + public void render() + { + try ( BufferedWriter writer = Files.newBufferedWriter( outputFile, + StandardCharsets.UTF_8 ) ) + { + new PluginUpdatesReportXpp3Writer().write( writer, new PluginUpdatesReport() + {{ + setSummary( new PluginReportSummary() + {{ + PluginOverviewStats overviewStats = PluginOverviewStats.fromUpdates( + model.getAllUpdates().values(), oldestUpdateCache ); + setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); + setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); + setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); + setNextMinorAvailable( String.valueOf( overviewStats.getMinor() ) ); + setNextMajorAvailable( String.valueOf( overviewStats.getMajor() ) ); + setDependencyUpdates( String.valueOf( overviewStats.getDependencies() ) ); + }} ); + setPluginManagements( createPluginInfo( model.getArtifactManagementUpdates() ) ); + setPlugins( createPluginInfo( model.getArtifactUpdates() ) ); + }} ); + } + catch ( IOException e ) + { + throw new RuntimeException( e ); + } + } + + private static void setSection( ArtifactVersions versions, Segment segment, Consumer> setterFunction ) + { + ofNullable( versions.getAllUpdates( of( segment ) ) ) + .map( v -> Arrays.stream( v ) + .map( ArtifactVersion::toString ) + .collect( Collectors.toList() ) ) + .ifPresent( setterFunction ); + } + + private static List createPluginInfo( Map versions ) + { + return versions.entrySet().stream().map( e -> + new PluginInfo() + {{ + setGroupId( e.getKey().getGroupId() ); + setArtifactId( e.getKey().getArtifactId() ); + setCurrentVersion( e.getKey().getVersion() ); + setScope( e.getKey().getScope() ); + setType( e.getKey().getType() ); + setClassifier( e.getKey().getClassifier() ); + + ofNullable( e.getValue().getOldestUpdate( empty() ) ) + .map( ArtifactVersion::toString ).ifPresent( this::setNextVersion ); + + setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); + setSection( e.getValue(), MINOR, this::setMinors ); + setSection( e.getValue(), MAJOR, this::setMajors ); + + setStatus( getNextVersion() == null + ? "no new available" + : getIncrementals() != null + ? "incremental available" + : getMinors() != null + ? "minor available" + : "major available" ); + }} ).collect( Collectors.toList() ); + } +} diff --git a/src/main/mdo/dependency-updates-report.mdo b/src/main/mdo/dependency-updates-report.mdo new file mode 100644 index 0000000000..28b723ee5a --- /dev/null +++ b/src/main/mdo/dependency-updates-report.mdo @@ -0,0 +1,177 @@ + + + + + + dependency-updates-report + DependencyUpdatesReport + + XML version of the Dependency Updates Report + + + + + package + org.codehaus.mojo.versions.reporting.model + + + + + namespace + + + + + + DependencyUpdatesReport + + + summary + true + + DependencyReportSummary + 1 + + + + dependencyManagements + + DependencyInfo + * + + + + dependencies + + DependencyInfo + * + + + + + + + DependencyReportSummary + + + usingLastVersion + true + String + + + nextVersionAvailable + true + String + + + nextIncrementalAvailable + 1.0.0+ + true + String + + + nextMinorAvailable + true + String + + + nextMajorAvailable + true + String + + + + + + DependencyInfo + + + groupId + true + String + + + artifactId + true + String + + + scope + true + String + + + classifier + String + + + type + true + String + + + currentVersion + String + + + nextVersion + String + + + any + + String + * + + + + incrementals + + String + * + + + + minors + + String + * + + + + majors + + String + * + + + + status + true + String + + + + + + diff --git a/src/main/mdo/plugin-updates-report.mdo b/src/main/mdo/plugin-updates-report.mdo new file mode 100644 index 0000000000..25c7fa428c --- /dev/null +++ b/src/main/mdo/plugin-updates-report.mdo @@ -0,0 +1,182 @@ + + + + + + plugin-updates-report + PluginUpdatesReport + + XML version of the Plugin Updates Report + + + + + package + org.codehaus.mojo.versions.reporting.model + + + + + namespace + + + + + + PluginUpdatesReport + + + summary + true + + PluginReportSummary + 1 + + + + pluginManagements + + PluginInfo + * + + + + plugins + + PluginInfo + * + + + + + + + PluginReportSummary + + + usingLastVersion + true + String + + + nextVersionAvailable + true + String + + + nextIncrementalAvailable + 1.0.0+ + true + String + + + nextMinorAvailable + true + String + + + nextMajorAvailable + true + String + + + dependencyUpdates + true + String + + + + + + PluginInfo + + + groupId + true + String + + + artifactId + true + String + + + scope + true + String + + + classifier + String + + + type + true + String + + + currentVersion + String + + + nextVersion + String + + + any + + String + * + + + + incrementals + + String + * + + + + minors + + String + * + + + + majors + + String + * + + + + status + true + String + + + + + + diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java index 69889a7e91..1d8994aa80 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -19,49 +19,86 @@ * under the License. */ +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlRenderer; -import org.hamcrest.core.Is; +import org.codehaus.mojo.versions.ordering.MavenVersionComparator; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.core.IsNull.nullValue; /** - * Basic tests for {@linkplain DependencyUpdatesXmlRenderer}. + * Basic tests for {@linkplain DependencyUpdatesXmlReportRenderer}. * * @author Andrzej Jarmoniuk */ public class DependencyUpdatesXmlRendererTest { - @Test - public void testGetVersionsBlocks() throws InvalidVersionSpecificationException + private Path tempFile; + + @Before + public void setUp() throws IOException + { + tempFile = Files.createTempFile( "xml-dependency-report", "" ); + } + + @After + public void tearDown() throws IOException { - List versions = - versionsOf( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1" ); - final Artifact artifact = - new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", - "bar", "jar", null ); - ArtifactVersions artifactVersions = new ArtifactVersions( artifact, versions, null ); - assertThat( artifactVersions.getCurrentVersion(), nullValue() ); - assertThat( artifactVersions.isCurrentVersionDefined(), Is.is( false ) ); - String versionsBlocks = DependencyUpdatesXmlRenderer.getVersionsBlocks( artifactVersions ); - assertThat( versionsBlocks, containsString( "[1.0,3.0]" ) ); + if ( tempFile != null && Files.exists( tempFile ) ) + { + Files.delete( tempFile ); + } } - private static List versionsOf( String... versions ) + @Test + public void testReportGeneration() throws IOException { - return Arrays.stream( versions ).map( DefaultArtifactVersion::new ).collect( Collectors.toList() ); + new DependencyUpdatesXmlReportRenderer( new DependencyUpdatesModel( + singletonMap( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "artifactA" ) + .withVersion( "1.0.0" ) + .build(), new ArtifactVersions( + new DefaultArtifact( "default-group", "artifactA", + "1.0.0", SCOPE_COMPILE, "jar", "default", + null ), + Arrays.asList( + new DefaultArtifactVersion( "1.0.0" ), + new DefaultArtifactVersion( "1.0.1" ), + new DefaultArtifactVersion( "1.1.0" ), + new DefaultArtifactVersion( "2.0.0" ) + ), + new MavenVersionComparator() ) ), + emptyMap() ), tempFile ).render(); + String output = String.join( "", Files.readAllLines( tempFile ) ) + .replaceAll( ">\\s*<", "><" ); + + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "1" ) ); + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "0" ) ); + + assertThat( output, containsString( "1.0.0" ) ); + assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "1.1.0" ) ); + assertThat( output, containsString( "2.0.0" ) ); + assertThat( output, containsString( "incremental available" ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java new file mode 100644 index 0000000000..5d653ae5e7 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java @@ -0,0 +1,128 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.model.Plugin; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.ordering.MavenVersionComparator; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; +import org.codehaus.mojo.versions.xml.PluginUpdatesXmlReportRenderer; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; + +/** + * Basic tests for {@linkplain DependencyUpdatesXmlReportRenderer}. + * + * @author Andrzej Jarmoniuk + */ +public class PluginUpdatesXmlRendererTest +{ + private Path tempFile; + + @Before + public void setUp() throws IOException + { + tempFile = Files.createTempFile( "xml-plugin-report", "" ); + } + + @After + public void tearDown() throws IOException + { + if ( tempFile != null && Files.exists( tempFile ) ) + { + Files.delete( tempFile ); + } + } + + @Test + public void testReportGeneration() throws IOException + { + PluginUpdatesModel pluginUpdates = new PluginUpdatesModel( + singletonMap( + pluginOf( "default-group", "artifactA", "1.0.0" ), + new PluginUpdatesDetails( + new ArtifactVersions( + artifactOf( "default-group", "artifactA", "1.0.0" ), + Stream.of( "1.0.0", "1.0.1", "1.1.0", "2.0.0" ) + .map( DefaultArtifactVersion::new ) + .collect( Collectors.toList() ), + new MavenVersionComparator() ), + singletonMap( DependencyBuilder.dependencyWith( "default-group", "artifactB", + "1.0.0" ), + new ArtifactVersions( + artifactOf( "default-group", "artifactB", "1.0.0" ), + Stream.of( "1.0.0", "1.0.1-SNAPSHOT", "1.1.0-rc1", "2.0.0" ) + .map( DefaultArtifactVersion::new ) + .collect( Collectors.toList() ), + new MavenVersionComparator() ) ), false ) ), + emptyMap() ); + new PluginUpdatesXmlReportRenderer( pluginUpdates, tempFile ).render(); + + String output = String.join( "", Files.readAllLines( tempFile ) ) + .replaceAll( ">\\s*<", "><" ); + + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "1" ) ); + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "0" ) ); + assertThat( output, containsString( "1" ) ); + + assertThat( output, containsString( "1.0.0" ) ); + assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "1.1.0" ) ); + assertThat( output, containsString( "2.0.0" ) ); + assertThat( output, containsString( "incremental available" ) ); + } + + private static DefaultArtifact artifactOf( String groupId, String artifactId, String version ) + { + return new DefaultArtifact( groupId, artifactId, version, SCOPE_COMPILE, "jar", "default", + null ); + } + + private static Plugin pluginOf( String groupId, String artifactId, String version ) + { + return new Plugin() + {{ + setGroupId( groupId ); + setArtifactId( artifactId ); + setVersion( version ); + }}; + } +} From 87d5f5b238313a5d5961116d6304050cb1e56b0a Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 15 Oct 2022 19:31:36 +0200 Subject: [PATCH 162/441] #760: Fixing the reported number of updates --- .../ordering/AbstractVersionComparator.java | 13 ++--------- .../DependencyUpdatesReportMojoTest.java | 22 +++++++++++++++++++ .../ordering/MavenVersionComparatorTest.java | 16 +++++++------- .../MercuryVersionComparatorTest.java | 16 +++++++------- .../NumericVersionComparatorTest.java | 16 +++++++------- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 1baeea0a35..ecc87f1a39 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -59,17 +59,8 @@ public final int getSegmentCount( ArtifactVersion v ) */ public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - if ( VersionComparators.isSnapshot( v ) ) - { - return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), - segment ) ); - } - int segmentCount = getSegmentCount( v ); - if ( segment.value() >= segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } - return innerIncrementSegment( v, segment ); + return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), + segment ) ); } protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index 7403e2610f..d14013bdc6 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -54,6 +54,7 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.matchesPattern; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -307,4 +308,25 @@ public void testDependenciesShouldOverrideDependencyManagement() throws IOExcept String output = os.toString().replaceAll( "\n", "" ); assertThat( output, Matchers.stringContainsInOrder( "artifactB" ) ); } + + @Test + public void testWrongReportBounds() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReportMojo() + .withOnlyUpgradable( true ) + .withDependencies( + dependencyOf( "test-artifact" ) ) + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + {{ + put( "test-artifact", new String[] { "1.0.0", "2.0.0-M1" } ); + }} ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString().replaceAll( "\n", "" ).replaceAll( "\r", "" ); + assertThat( output, allOf( + matchesPattern( ".*report.overview.numNewerMajorAvailable\\s*1.*" ), + matchesPattern( ".*report.overview.numUpToDate\\s*0.*" ) ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index 8edc29b3d1..2369712084 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -52,14 +52,14 @@ public void testSegmentCounting() @Test public void testSegmentIncrementing() throws InvalidSegmentException { - assertIncrement( "6", "5", MAJOR ); - assertIncrement( "6.0", "5.0", MAJOR ); - assertIncrement( "5.1", "5.0", MINOR ); - assertIncrement( "5.1.0", "5.0.1", MINOR ); - assertIncrement( "5.alpha.2", "5.alpha.1", MAJOR ); - assertIncrement( "5.alpha-1.2", "5.alpha-1.1", MAJOR ); - assertIncrement( "5.alpha-1.ba", "5.alpha-1.az", MAJOR ); - assertIncrement( "5.alpha-wins.2", "5.alpha-wins.1", MAJOR ); + assertIncrement( "6-SNAPSHOT", "5", MAJOR ); + assertIncrement( "6.0-SNAPSHOT", "5.0", MAJOR ); + assertIncrement( "5.1-SNAPSHOT", "5.0", MINOR ); + assertIncrement( "5.1.0-SNAPSHOT", "5.0.1", MINOR ); + assertIncrement( "5.alpha.2-SNAPSHOT", "5.alpha.1", MAJOR ); + assertIncrement( "5.alpha-1.2-SNAPSHOT", "5.alpha-1.1", MAJOR ); + assertIncrement( "5.alpha-1.ba-SNAPSHOT", "5.alpha-1.az", MAJOR ); + assertIncrement( "5.alpha-wins.2-SNAPSHOT", "5.alpha-wins.1", MAJOR ); assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index 27d75f4d17..52d2b6553d 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -45,21 +45,21 @@ public void testSegmentCounting() throws Exception @Test public void testSegmentIncrementing() throws Exception { - assertEquals( new DefaultArtifactVersion( "6" ).toString(), + assertEquals( new DefaultArtifactVersion( "6-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "6.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.1-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.1.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.beta-0.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.alpha-2.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.beta-0.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index 58fb889516..817468f86d 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -105,22 +105,22 @@ public void testSegmentCounting() @Test public void testSegmentIncrementing() throws Exception { - assertEquals( new DefaultArtifactVersion( "6" ).toString(), + assertEquals( new DefaultArtifactVersion( "6-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "6.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.1-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.1.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.alpha-2.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-1.2" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.alpha-1.2-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ) .toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0" ).toString(), + assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); } } From ca5e34789fcae488369033a85e358ca46ccabf5c Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Sat, 15 Oct 2022 16:04:02 +0200 Subject: [PATCH 163/441] Caching, Last Version on XML reports, Remove Oldest --- .../verify.bsh | 6 +- .../verify.bsh | 8 +- .../it-plugin-updates-report-001/verify.bsh | 6 +- .../it-plugin-updates-report-002/verify.bsh | 2 +- .../it-plugin-updates-report-003/verify.bsh | 2 +- .../versions/api/AbstractVersionDetails.java | 76 ---------------- .../versions/api/ArtifactVersionsCache.java | 2 +- .../mojo/versions/api/VersionDetails.java | 73 --------------- .../AbstractVersionsReportRenderer.java | 80 +++++++++++------ .../DependencyUpdatesReportRenderer.java | 2 +- .../versions/reporting/OverviewStats.java | 16 ++-- .../reporting/PluginOverviewStats.java | 10 +-- .../PluginUpdatesReportRenderer.java | 89 ++++++++++--------- .../PropertyUpdatesReportRenderer.java | 71 ++++++++------- .../reporting/VersionsReportRendererBase.java | 51 ----------- .../DependencyUpdatesXmlReportRenderer.java | 12 +-- .../xml/PluginUpdatesXmlReportRenderer.java | 12 +-- src/main/mdo/dependency-updates-report.mdo | 2 +- src/main/mdo/plugin-updates-report.mdo | 2 +- .../dependency-updates-report.properties | 5 -- .../parent-updates-report.properties | 4 - .../plugin-updates-report.properties | 5 -- .../property-updates-report.properties | 5 -- .../DependencyUpdatesXmlRendererTest.java | 2 +- .../PluginUpdatesXmlRendererTest.java | 2 +- .../versions/api/ArtifactVersionsTest.java | 2 +- 26 files changed, 185 insertions(+), 362 deletions(-) diff --git a/src/it/it-dependency-updates-report-001/verify.bsh b/src/it/it-dependency-updates-report-001/verify.bsh index 289ca69b24..0298f0d67d 100644 --- a/src/it/it-dependency-updates-report-001/verify.bsh +++ b/src/it/it-dependency-updates-report-001/verify.bsh @@ -23,7 +23,7 @@ try System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "1.1.1 Next Incremental" ) < 0) + if ( result.indexOf( "1.1.1" ) < 0) { System.out.println( "Did not identify next incremental" ); System.out.println( "Result = \"" + result +"\"" ); @@ -35,7 +35,7 @@ try System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "1.2 Next Minor" ) < 0) + if ( result.indexOf( "1.2" ) < 0) { System.out.println( "Did not identify next minor version" ); System.out.println( "Result = \"" + result +"\"" ); @@ -47,7 +47,7 @@ try System.out.println( "Result = \"" + result +"\"" ); return false; } - if ( result.indexOf( "2.0 Next Major" ) < 0) + if ( result.indexOf( "2.0" ) < 0) { System.out.println( "Did not identify next major version" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-dependency-updates-report-002/verify.bsh b/src/it/it-dependency-updates-report-002/verify.bsh index 8422b69484..019b615555 100644 --- a/src/it/it-dependency-updates-report-002/verify.bsh +++ b/src/it/it-dependency-updates-report-002/verify.bsh @@ -17,13 +17,13 @@ try // System.out.println( "Result = \"" + result +"\"" ); // return false; // } -// if ( result.indexOf( "1.1.0-2 Next Version" ) < 0) +// if ( result.indexOf( "1.1.0-2" ) < 0) // { // System.out.println( "Did not identify next version" ); // System.out.println( "Result = \"" + result +"\"" ); // return false; // } -// if ( result.indexOf( "1.1.1 Next Incremental" ) < 0) +// if ( result.indexOf( "1.1.1" ) < 0) // { // System.out.println( "Did not identify next incremental" ); // System.out.println( "Result = \"" + result +"\"" ); @@ -35,7 +35,7 @@ try // System.out.println( "Result = \"" + result +"\"" ); // return false; // } -// if ( result.indexOf( "1.2 Next Minor" ) < 0) +// if ( result.indexOf( "1.2" ) < 0) // { // System.out.println( "Did not identify next minor version" ); // System.out.println( "Result = \"" + result +"\"" ); @@ -47,7 +47,7 @@ try // System.out.println( "Result = \"" + result +"\"" ); // return false; // } -// if ( result.indexOf( "2.0 Next Major" ) < 0) +// if ( result.indexOf( "2.0" ) < 0) // { // System.out.println( "Did not identify next major version" ); // System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-001/verify.bsh b/src/it/it-plugin-updates-report-001/verify.bsh index 003f5155ce..d1caa0219f 100644 --- a/src/it/it-plugin-updates-report-001/verify.bsh +++ b/src/it/it-plugin-updates-report-001/verify.bsh @@ -32,15 +32,15 @@ try return false; } if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 " - + "Next Major 2.1 3.0 3.1 Latest Major" ) < 0) + + "2.1 3.0 3.1 Latest Major" ) < 0) { System.out.println( "Did not identify plugin next versions" ); System.out.println( "Result = \"" + result +"\"" ); return false; } if ( result.indexOf( "Group Id localhost Artifact Id dummy-api Current Version 1.1 Classifier Type jar Newer " - + "versions 1.1.0-2 Latest Subincremental 1.1.1 Next Incremental 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 Next " - + "Minor 1.2.1 1.2.2 1.3 Latest Minor 2.0 Next Major 2.1 3.0 Latest Major" ) < 0) + + "versions 1.1.0-2 Latest Subincremental 1.1.1 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 " + + "1.2.1 1.2.2 1.3 Latest Minor 2.0 2.1 3.0 Latest Major" ) < 0) { System.out.println( "Did not identify dependency next versions" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-002/verify.bsh b/src/it/it-plugin-updates-report-002/verify.bsh index ee113ae500..299dc4ca1e 100644 --- a/src/it/it-plugin-updates-report-002/verify.bsh +++ b/src/it/it-plugin-updates-report-002/verify.bsh @@ -26,7 +26,7 @@ try return false; } if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 " - + "Next Major 2.1 3.0 3.1 Latest Major" ) < 0) + + "2.1 3.0 3.1 Latest Major" ) < 0) { System.out.println( "Did not identify plugin next versions" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/it/it-plugin-updates-report-003/verify.bsh b/src/it/it-plugin-updates-report-003/verify.bsh index ee113ae500..299dc4ca1e 100644 --- a/src/it/it-plugin-updates-report-003/verify.bsh +++ b/src/it/it-plugin-updates-report-003/verify.bsh @@ -26,7 +26,7 @@ try return false; } if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 " - + "Next Major 2.1 3.0 3.1 Latest Major" ) < 0) + + "2.1 3.0 3.1 Latest Major" ) < 0) { System.out.println( "Did not identify plugin next versions" ); System.out.println( "Result = \"" + result +"\"" ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index e2830d4c6e..fea66d453e 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -274,51 +274,6 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional< return getVersions( restriction, includeSnapshots ); } - @Override - public final ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ) - { - return getOldestVersion( versionRange, null, includeSnapshots ); - } - - @Override - public final ArtifactVersion getOldestVersion( Restriction restriction, - boolean includeSnapshots ) - { - return getOldestVersion( null, restriction, includeSnapshots ); - } - - @Override - public final ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, - boolean includeSnapshots ) - { - ArtifactVersion oldest = null; - final VersionComparator versionComparator = getVersionComparator(); - for ( ArtifactVersion candidate : getVersions( includeSnapshots ) ) - { - if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) ) - { - continue; - } - if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) - { - continue; - } - if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) ) - { - continue; - } - if ( oldest == null ) - { - oldest = candidate; - } - else if ( versionComparator.compare( oldest, candidate ) > 0 ) - { - oldest = candidate; - } - } - return oldest; - } - @Override public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ) { @@ -350,21 +305,6 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, Restricti return result.toArray( new ArtifactVersion[0] ); } - @Override - public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) - { - try - { - return getOldestVersion( getVersionComparator().restrictionFor( currentVersion, updateScope ), - includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { - return null; - } - } - @Override public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) @@ -395,12 +335,6 @@ public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Op } } - @Override - public final ArtifactVersion getOldestUpdate( Optional updateScope ) - { - return getOldestUpdate( updateScope, isIncludeSnapshots() ); - } - @Override public final ArtifactVersion getNewestUpdate( Optional updateScope ) { @@ -413,16 +347,6 @@ public final ArtifactVersion[] getAllUpdates( Optional updateScope ) return getAllUpdates( updateScope, isIncludeSnapshots() ); } - @Override - public final ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) - { - if ( isCurrentVersionDefined() ) - { - return getOldestUpdate( getCurrentVersion(), updateScope, includeSnapshots ); - } - return null; - } - @Override public final ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java index 009070bcd3..e5aa2e384b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java @@ -28,7 +28,7 @@ import org.apache.commons.lang3.tuple.Pair; /** - * Utility providing a cached {@link ArtifactVersions#getOldestUpdate(Optional)} API + * Utility providing a cached {@link ArtifactVersions#getNewestUpdate(Optional)} API */ public class ArtifactVersionsCache { diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index c42c9745f3..bd414b40fc 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -287,53 +287,6 @@ ArtifactVersion[] getNewerVersions( String versionString, Optional uppe boolean includeSnapshots, boolean allowDowngrade ) throws InvalidSegmentException; - /** - * Returns the oldest version within the specified version range or null if no such version exists. - * - * @param versionRange The version range within which the version must exist. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version between currentVersion and upperBound or null if no version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots ); - - /** - * Returns the oldest version within the specified bounds or null if no such version exists. - * - * @param restriction version criteria. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version between lowerBound and upperBound or null if no version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestVersion( Restriction restriction, boolean includeSnapshots ); - - /** - * Returns the oldest version within the specified bounds or null if no such version exists. - * - * @param versionRange The version range within which the version must exist where null imples - * [,). - * @param restriction version criteria. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version between lowerBound and upperBound or null if no version is available. - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); - - /** - * Returns the oldest version newer than the specified current version, but within the specified update scope or - * null if no such version exists. - * - * @param currentVersion the lower bound or null if the lower limit is unbounded. - * @param updateScope the update scope to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) throws InvalidSegmentException; - /** * Returns the all versions newer than the specified current version, but within the specified update scope. * @@ -347,18 +300,6 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; - /** - * Returns the oldest version newer than the current version, but within the specified update scope or - * null if no such version exists. - * - * @param updateScope the update scope to include. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( Optional updateScope ) throws InvalidSegmentException; - /** * Returns the newest version newer than the specified current version, but within the specified update scope or * null if no such version exists. @@ -381,20 +322,6 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; - /** - * Returns the oldest version newer than the specified current version, but within the specified update scope or - * null if no such version exists. - * - * @param updateScope the update scope to include. - * @param includeSnapshots true if snapshots are to be included. - * @return the oldest version after currentVersion within the specified update scope or null if no - * version is available. - * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments - * @since 1.0-beta-1 - */ - ArtifactVersion getOldestUpdate( Optional updateScope, boolean includeSnapshots ) - throws InvalidSegmentException; - /** * Returns the newest version newer than the specified current version, but within the specified update scope or * null if no such version exists. diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index c3f9102038..7fe827e9fd 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -58,8 +58,8 @@ public abstract class AbstractVersionsReportRenderer extends VersionsReportRe */ protected T model; - protected ArtifactVersionsCache oldestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + protected ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); protected ArtifactVersionsCache allUpdatesCache = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); @@ -237,13 +237,15 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) "report.latestIncremental", "report.latestMinor", "report.latestMajor" ); } - protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions artifactVersions, - boolean includeScope ) + protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, + boolean includeScope ) { + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + sink.tableRow(); sink.tableCell(); - ArtifactVersion[] allUpdates = artifactVersions.getAllUpdates( empty() ); - if ( allUpdates == null || allUpdates.length == 0 ) + if ( upToDate ) { renderSuccessIcon(); } @@ -275,37 +277,37 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( MINOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( MAJOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -316,10 +318,13 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope ) { + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); sink.tableRow(); @@ -327,26 +332,25 @@ protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersion sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = allUpdatesCache.get( details, empty() ); - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -411,25 +415,25 @@ else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) sink.text( artifact.getType() ); sink.tableCell_(); sink.tableRow_(); - if ( versions != null && versions.length > 0 ) + if ( !upToDate ) { sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.updateVersions" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - for ( int i = 0; i < versions.length; i++ ) + for ( int i = 0; i < allUpdates.length; i++ ) { if ( i > 0 ) { sink.lineBreak(); } - String label = getLabel( versions[i], details ); + String label = getLabel( allUpdates[i], details ); if ( label != null ) { safeBold(); } - sink.text( versions[i].toString() ); + sink.text( allUpdates[i].toString() ); if ( label != null ) { safeBold_(); @@ -462,4 +466,30 @@ protected void renderTableHeaderCells( String... keys ) sink.tableHeaderCell_(); } ); } + + protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) + { + + if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) ) + { + return getText( "report.latestSubIncremental" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( INCREMENTAL ) ) ) ) + { + return getText( "report.latestIncremental" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( MINOR ) ) ) ) + { + return getText( "report.latestMinor" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( MAJOR ) ) ) ) + { + return getText( "report.latestMajor" ); + } + + return null; + } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index c26c7ca785..2d8948280a 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -86,7 +86,7 @@ protected void renderTable( String titleKey, Map c @Override protected OverviewStats computeOverviewStats() { - return OverviewStats.fromUpdates( model.getAllUpdates().values(), oldestUpdateCache ); + return OverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); } protected void renderDependencyDetail( Dependency artifact, ArtifactVersions details ) diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java index bde72a9218..998a2b0f52 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java @@ -58,7 +58,7 @@ public class OverviewStats * @param updates collection of all version updates, typically from * {@linkplain org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel#getAllUpdates()} * @param cache if not null, cache to retrieve the version information, initialised with - * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param subclass of {@linkplain OverviewStats} * @param subclass of {@linkplain ArtifactVersions} * @return instance of the {@linkplain OverviewStats} @@ -69,19 +69,19 @@ public static T fromUpdate OverviewStats stats = new OverviewStats(); updates.forEach( details -> { - if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } @@ -93,11 +93,11 @@ else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) return (T) stats; } - protected static ArtifactVersion getOldestUpdate( ArtifactVersionsCache cache, + protected static ArtifactVersion getNewestUpdate( ArtifactVersionsCache cache, V details, - Optional segment ) + Optional segment ) { - return cache != null ? cache.get( details, segment ) : details.getOldestUpdate( segment ); + return cache != null ? cache.get( details, segment ) : details.getNewestUpdate( segment ); } public int getMajor() diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 5275c17e4f..2d215b75cf 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -55,7 +55,7 @@ public void incrementDependencies() * * @param updates collection of all version updates, typically from {@linkplain PluginUpdatesModel#getAllUpdates()} * @param cache if not null, cache to retrieve the version information, initialised with - * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param always equal to {@linkplain PluginOverviewStats} * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information @@ -66,19 +66,19 @@ public static T fromUpdate PluginOverviewStats stats = new PluginOverviewStats(); updates.forEach( details -> { - if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index e1327dd56e..7f38c91d5b 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -30,9 +30,7 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.PluginUpdatesDetails; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.plexus.i18n.I18N; @@ -48,8 +46,6 @@ */ public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer { - protected ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); public PluginUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, PluginUpdatesModel model ) @@ -133,7 +129,7 @@ protected void renderSummaryTable( Map content @Override protected PluginOverviewStats computeOverviewStats() { - return PluginOverviewStats.fromUpdates( model.getAllUpdates().values(), oldestUpdateCache ); + return PluginOverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); } @Override @@ -157,9 +153,11 @@ protected void renderOverviewTableRow( T stats ) protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details ) { + boolean upToDate = !details.isUpdateAvailable(); + sink.tableRow(); sink.tableCell(); - if ( !details.isUpdateAvailable() ) + if ( upToDate ) { renderSuccessIcon(); } @@ -237,44 +235,69 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails } @SuppressWarnings( "checkstyle:MethodLength" ) - private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails plugin ) + private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails details ) { - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); sink.section2(); sink.sectionTitle2(); sink.text( MessageFormat.format( getText( "report.plugin" ), - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); + ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); sink.sectionTitle2_(); + + renderPluginDetailTable( details ); + + if ( !details.getDependencyVersions().isEmpty() ) + { + sink.section3(); + sink.sectionTitle3(); + sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), + ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); + sink.sectionTitle3_(); + + renderSummaryTable( details.getDependencyVersions(), false ); + + sink.section3_(); + + details.getDependencyVersions().forEach( this::renderDependencyDetail ); + } + sink.section2_(); + } + + private void renderPluginDetailTable( PluginUpdatesDetails details ) + { + // warning: using caches here may break plugin report + ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); + final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); - sink.tableRows( new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false ); + sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = plugin.getAllUpdates( empty() ); - if ( plugin.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( MINOR ) ) != null ) + else if ( details.getNewestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( details.getNewestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -293,7 +316,7 @@ else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.groupId" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getGroupId() ); + sink.text( details.getGroupId() ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); @@ -301,7 +324,7 @@ else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.artifactId" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getArtifactId() ); + sink.text( details.getArtifactId() ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); @@ -309,28 +332,28 @@ else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getVersion() ); + sink.text( details.getVersion() ); sink.tableCell_(); sink.tableRow_(); - if ( versions != null && versions.length > 0 ) + if ( !upToDate ) { sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.updateVersions" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - for ( int i = 0; i < versions.length; i++ ) + for ( int i = 0; i < allUpdates.length; i++ ) { if ( i > 0 ) { sink.lineBreak(); } - String label = getLabel( versions[i], plugin ); + String label = getLabel( allUpdates[i], details ); if ( label != null ) { safeBold(); } - sink.text( versions[i].toString() ); + sink.text( allUpdates[i].toString() ); if ( label != null ) { safeBold_(); @@ -345,22 +368,6 @@ else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) } sink.tableRows_(); sink.table_(); - - if ( !plugin.getDependencyVersions().isEmpty() ) - { - sink.section3(); - sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); - sink.sectionTitle3_(); - - renderSummaryTable( plugin.getDependencyVersions(), false ); - - sink.section3_(); - - plugin.getDependencyVersions().forEach( this::renderDependencyDetail ); - } - sink.section2_(); } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index fe5f2de286..ddb7287e82 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -114,11 +114,14 @@ protected void renderSummaryTable( Map contents ) sink.table_(); } - private void renderPropertySummaryTableRow( Property property, PropertyVersions versions ) + private void renderPropertySummaryTableRow( Property property, PropertyVersions details ) { + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + sink.tableRow(); sink.tableCell(); - if ( versions.getAllUpdates( empty() ).length == 0 ) + if ( upToDate ) { renderSuccessIcon(); } @@ -131,41 +134,41 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions sink.text( "${" + property.getName() + "}" ); sink.tableCell_(); sink.tableCell(); - sink.text( versions.getCurrentVersion().toString() ); + sink.text( details.getCurrentVersion().toString() ); sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( MINOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( MAJOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -174,12 +177,15 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions } @SuppressWarnings( "checkstyle:MethodLength" ) - protected void renderPropertyDetailTable( Property property, PropertyVersions versions ) + protected void renderPropertyDetailTable( Property property, PropertyVersions details ) { + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); sink.tableRow(); @@ -187,27 +193,25 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions ve sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] artifactVersions = versions.getAllUpdates( empty() ); - Set rangeVersions = getVersionsInRange( property, versions, artifactVersions ); - if ( versions.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -235,7 +239,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.associations" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactAssociation[] associations = versions.getAssociations(); + ArtifactAssociation[] associations = details.getAssociations(); for ( int i = 0; i < associations.length; i++ ) { if ( i > 0 ) @@ -252,25 +256,26 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( versions.getCurrentVersion().toString() ); + sink.text( details.getCurrentVersion().toString() ); sink.tableCell_(); sink.tableRow_(); - if ( artifactVersions.length > 0 ) + if ( !upToDate ) { + Set rangeVersions = getVersionsInRange( property, details, allUpdates ); sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.updateVersions" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); boolean someNotAllowed = false; - for ( int i = 0; i < artifactVersions.length; i++ ) + for ( int i = 0; i < allUpdates.length; i++ ) { if ( i > 0 ) { sink.lineBreak(); } - boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); - String label = getLabel( artifactVersions[i], versions ); + boolean allowed = ( rangeVersions.contains( allUpdates[i].toString() ) ); + String label = getLabel( allUpdates[i], details ); if ( !allowed ) { sink.text( "* " ); @@ -280,7 +285,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) { safeBold(); } - sink.text( artifactVersions[i].toString() ); + sink.text( allUpdates[i].toString() ); if ( label != null ) { if ( allowed ) @@ -394,19 +399,19 @@ protected OverviewStats computeOverviewStats() OverviewStats stats = new OverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } @@ -418,13 +423,13 @@ else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) return stats; } - private void renderPropertyDetail( Property property, PropertyVersions versions ) + private void renderPropertyDetail( Property property, PropertyVersions details ) { sink.section2(); sink.sectionTitle2(); sink.text( "${" + property.getName() + "}" ); sink.sectionTitle2_(); - renderPropertyDetailTable( property, versions ); + renderPropertyDetailTable( property, details ); sink.section2_(); } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java index 28640a78f8..589cfa8a80 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -25,15 +25,8 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.reporting.AbstractMavenReportRenderer; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.plexus.i18n.I18N; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - /** * Base class over AbstractVersionsReportRenderer providing base * utility methods @@ -149,48 +142,4 @@ protected void safeItalic_() } } - protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) - { - if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.latestSubIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.nextVersion" ); - } - - if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.nextIncremental" ); - } - - if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.latestIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.nextMinor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.latestMinor" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.nextMajor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.latestMajor" ); - } - - return ""; - } } diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java index 25dfb3dcbc..dee099f597 100644 --- a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java @@ -62,8 +62,8 @@ public class DependencyUpdatesXmlReportRenderer implements ReportRenderer { private final DependencyUpdatesModel model; private final Path outputFile; - private final ArtifactVersionsCache oldestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + private final ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); /** * Creates a new instance * @param model object containing the updates model @@ -89,7 +89,7 @@ public void render() setSummary( new DependencyReportSummary() {{ OverviewStats overviewStats = OverviewStats.fromUpdates( model.getAllUpdates().values(), - oldestUpdateCache ); + newestUpdateCache ); setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); @@ -127,14 +127,14 @@ private static List createDependencyInfo( Map createPluginInfo( MapString - nextVersion + lastVersion String diff --git a/src/main/mdo/plugin-updates-report.mdo b/src/main/mdo/plugin-updates-report.mdo index 25c7fa428c..12934b125f 100644 --- a/src/main/mdo/plugin-updates-report.mdo +++ b/src/main/mdo/plugin-updates-report.mdo @@ -139,7 +139,7 @@ under the License. String - nextVersion + lastVersion String diff --git a/src/main/resources/dependency-updates-report.properties b/src/main/resources/dependency-updates-report.properties index 1c5eb9722d..9b8626d4a1 100644 --- a/src/main/resources/dependency-updates-report.properties +++ b/src/main/resources/dependency-updates-report.properties @@ -40,14 +40,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available. diff --git a/src/main/resources/parent-updates-report.properties b/src/main/resources/parent-updates-report.properties index 2ddf8b1650..9b900def42 100644 --- a/src/main/resources/parent-updates-report.properties +++ b/src/main/resources/parent-updates-report.properties @@ -39,13 +39,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available. diff --git a/src/main/resources/plugin-updates-report.properties b/src/main/resources/plugin-updates-report.properties index c3a37ddc7c..deb1929afe 100644 --- a/src/main/resources/plugin-updates-report.properties +++ b/src/main/resources/plugin-updates-report.properties @@ -42,14 +42,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.dependencyStatus=Dependency status report.updateVersions=Newer versions diff --git a/src/main/resources/property-updates-report.properties b/src/main/resources/property-updates-report.properties index ed59150ed7..e0fe103cfb 100644 --- a/src/main/resources/property-updates-report.properties +++ b/src/main/resources/property-updates-report.properties @@ -37,14 +37,9 @@ report.detail.text= report.status=Status report.property=Property report.currentVersion=Current Version -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available. diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java index 1d8994aa80..bb8d851ae6 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -95,7 +95,7 @@ public void testReportGeneration() throws IOException assertThat( output, containsString( "0" ) ); assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "2.0.0" ) ); assertThat( output, containsString( "1.0.1" ) ); assertThat( output, containsString( "1.1.0" ) ); assertThat( output, containsString( "2.0.0" ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java index 5d653ae5e7..f39a880cc9 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java @@ -103,7 +103,7 @@ public void testReportGeneration() throws IOException assertThat( output, containsString( "1" ) ); assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "2.0.0" ) ); assertThat( output, containsString( "1.0.1" ) ); assertThat( output, containsString( "1.1.0" ) ); assertThat( output, containsString( "2.0.0" ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index 1cc1d974d2..05de76fc17 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -124,6 +124,6 @@ public void testReportLabels() Arrays.asList( versions ), new MavenVersionComparator() ); assertThat( instance.getNewestUpdate( of( SUBINCREMENTAL ) ).toString(), is( "1.1.0-2" ) ); - assertThat( instance.getOldestUpdate( of( INCREMENTAL ) ).toString(), is( "1.1.1" ) ); + assertThat( instance.getNewestUpdate( of( INCREMENTAL ) ).toString(), is( "1.1.3" ) ); } } From bce86461bdfd39ec066427c833649b5ff694426a Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 14 Oct 2022 19:50:19 +0200 Subject: [PATCH 164/441] #367: Include parent projects in property resolution --- .../codehaus/mojo/versions/api/PomHelper.java | 176 ++++++++++++------ .../DisplayPropertyUpdatesMojoTest.java | 88 +++++++++ .../mojo/versions/utils/TestUtils.java | 33 ++++ .../issue-367/child/pom.xml | 20 ++ .../issue-367/pom.xml | 11 ++ 5 files changed, 269 insertions(+), 59 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java create mode 100644 src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml create mode 100644 src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 8c66929c67..40bb3cac08 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -22,11 +22,13 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.events.XMLEvent; +import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -103,15 +105,12 @@ public static Model getRawModel( MavenProject project ) * @throws IOException if the file is not found or if the file does not parse. */ public static Model getRawModel( File moduleProjectFile ) - throws IOException + throws IOException { - try ( FileInputStream input = new FileInputStream( moduleProjectFile ) ) + try ( Reader reader = new BufferedReader( new InputStreamReader( Files.newInputStream( moduleProjectFile + .toPath() ) ) ) ) { - return new MavenXpp3Reader().read( input ); - } - catch ( XmlPullParserException e ) - { - throw new IOException( e.getMessage(), e ); + return getRawModel( reader ); } } @@ -123,11 +122,27 @@ public static Model getRawModel( File moduleProjectFile ) * @throws IOException if the file is not found or if the file does not parse. */ public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventReader ) - throws IOException + throws IOException { - try ( StringReader stringReader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() ) ) + try ( Reader reader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() ) ) { - return new MavenXpp3Reader().read( stringReader ); + return getRawModel( reader ); + } + } + + /** + * Gets the current raw model before any interpolation what-so-ever. + * + * @param reader The {@link Reader} to get the raw model for. + * @return The raw model. + * @throws IOException if the file is not found or if the file does not parse. + */ + public static Model getRawModel( Reader reader ) + throws IOException + { + try + { + return new MavenXpp3Reader().read( reader ); } catch ( XmlPullParserException e ) { @@ -967,6 +982,37 @@ else if ( matchScopeRegex.matcher( path ).matches() ) return madeReplacement; } + /** + * Traverses the project tree upwards, adding the raw models of every project it encounters to the map + * + * @param project maven project of the child for which the models need to be gathered + * @return gathered map of raw models per project + */ + private static Map getRawModelWithParents( MavenProject project ) throws IOException + { + // constructs a tree sorted from children to parents + Map models = new TreeMap<>( ( p1, p2 ) -> + { + for ( MavenProject p = p1; p != null; p = p.getParent() ) + { + if ( p == p2 ) // meaning p2 is an ancestor to p1 or p1 == p2 + { + return p == p1 + ? 0 + : -1; // p1 is the child + } + } + return 1; + } ); + for ( MavenProject p = project; p != null; p = p.getParent() ) + { + models.put( p, p.getFile() != null + ? getRawModel( p ) + : p.getOriginalModel() ); + } + return models; + } + /** * Examines the project to find any properties which are associated with versions of artifacts in the project. * @@ -978,11 +1024,12 @@ else if ( matchScopeRegex.matcher( path ).matches() ) * @since 1.0-alpha-3 */ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHelper helper, MavenProject project ) - throws ExpressionEvaluationException, IOException + throws ExpressionEvaluationException, IOException { ExpressionEvaluator expressionEvaluator = helper.getExpressionEvaluator( project ); - Model projectModel = getRawModel( project ); - Map result = new TreeMap<>(); + Map reactorModels = getRawModelWithParents( project ); + + Map propertiesMap = new TreeMap<>(); Set activeProfiles = new TreeSet<>(); for ( Profile profile : project.getActiveProfiles() ) @@ -991,58 +1038,72 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel } // add any properties from profiles first (as they override properties from the project - for ( Profile profile : projectModel.getProfiles() ) + for ( Iterator it = reactorModels.values().stream() + .flatMap( model -> model.getProfiles().stream() ) + .filter( profile -> activeProfiles.contains( profile.getId() ) ) + .iterator(); it.hasNext(); ) { - if ( !activeProfiles.contains( profile.getId() ) ) - { - continue; - } - addProperties( helper, result, profile.getId(), profile.getProperties() ); - if ( profile.getDependencyManagement() != null ) - { - addDependencyAssocations( helper, expressionEvaluator, result, - profile.getDependencyManagement().getDependencies(), false ); - } - addDependencyAssocations( helper, expressionEvaluator, result, profile.getDependencies(), false ); - if ( profile.getBuild() != null ) + Profile profile = it.next(); + try { - if ( profile.getBuild().getPluginManagement() != null ) + addProperties( helper, propertiesMap, profile.getId(), profile.getProperties() ); + if ( profile.getDependencyManagement() != null ) + { + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, + profile.getDependencyManagement().getDependencies(), false ); + } + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, + profile.getDependencies(), + false ); + if ( profile.getBuild() != null ) { - addPluginAssociations( helper, expressionEvaluator, result, - profile.getBuild().getPluginManagement().getPlugins() ); + if ( profile.getBuild().getPluginManagement() != null ) + { + addPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getBuild().getPluginManagement().getPlugins() ); + } + addPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getBuild().getPlugins() ); + } + if ( profile.getReporting() != null ) + { + addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getReporting().getPlugins() ); } - addPluginAssociations( helper, expressionEvaluator, result, profile.getBuild().getPlugins() ); } - if ( profile.getReporting() != null ) + catch ( ExpressionEvaluationException e ) { - addReportPluginAssociations( helper, expressionEvaluator, result, profile.getReporting().getPlugins() ); + throw new RuntimeException( e ); } } // second, we add all the properties in the pom - addProperties( helper, result, null, projectModel.getProperties() ); - Model model = projectModel; - MavenProject currentPrj = project; - while ( currentPrj != null ) + reactorModels.values().forEach( model -> addProperties( helper, propertiesMap, null, model.getProperties() ) ); + + + for ( MavenProject currentPrj = project; currentPrj != null; currentPrj = currentPrj.getParent() ) { + Model model = reactorModels.get( currentPrj ); + if ( model.getDependencyManagement() != null ) { - addDependencyAssocations( helper, expressionEvaluator, result, - model.getDependencyManagement().getDependencies(), false ); + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, + model.getDependencyManagement().getDependencies(), false ); } - addDependencyAssocations( helper, expressionEvaluator, result, model.getDependencies(), false ); + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, model.getDependencies(), false ); if ( model.getBuild() != null ) { if ( model.getBuild().getPluginManagement() != null ) { - addPluginAssociations( helper, expressionEvaluator, result, - model.getBuild().getPluginManagement().getPlugins() ); + addPluginAssociations( helper, expressionEvaluator, propertiesMap, + model.getBuild().getPluginManagement().getPlugins() ); } - addPluginAssociations( helper, expressionEvaluator, result, model.getBuild().getPlugins() ); + addPluginAssociations( helper, expressionEvaluator, propertiesMap, model.getBuild().getPlugins() ); } if ( model.getReporting() != null ) { - addReportPluginAssociations( helper, expressionEvaluator, result, model.getReporting().getPlugins() ); + addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, + model.getReporting().getPlugins() ); } // third, we add any associations from the active profiles @@ -1054,36 +1115,33 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel } if ( profile.getDependencyManagement() != null ) { - addDependencyAssocations( helper, expressionEvaluator, result, - profile.getDependencyManagement().getDependencies(), false ); + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, + profile.getDependencyManagement().getDependencies(), false ); } - addDependencyAssocations( helper, expressionEvaluator, result, profile.getDependencies(), false ); + addDependencyAssocations( helper, expressionEvaluator, propertiesMap, profile.getDependencies(), + false ); if ( profile.getBuild() != null ) { if ( profile.getBuild().getPluginManagement() != null ) { - addPluginAssociations( helper, expressionEvaluator, result, - profile.getBuild().getPluginManagement().getPlugins() ); + addPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getBuild().getPluginManagement().getPlugins() ); } - addPluginAssociations( helper, expressionEvaluator, result, profile.getBuild().getPlugins() ); + addPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getBuild().getPlugins() ); } if ( profile.getReporting() != null ) { - addReportPluginAssociations( helper, expressionEvaluator, result, - profile.getReporting().getPlugins() ); + addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, + profile.getReporting().getPlugins() ); } } - currentPrj = currentPrj.getParent(); - if ( currentPrj != null ) - { - model = currentPrj.getOriginalModel(); - } } // finally, remove any properties without associations - purgeProperties( result ); + purgeProperties( propertiesMap ); - return result.values().toArray( new PropertyVersionsBuilder[0] ); + return propertiesMap.values().toArray( new PropertyVersionsBuilder[0] ); } /** diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java new file mode 100644 index 0000000000..be01de3bdf --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java @@ -0,0 +1,88 @@ +package org.codehaus.mojo.versions; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; + +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.codehaus.mojo.versions.utils.MockUtils; +import org.codehaus.mojo.versions.utils.TestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.apache.commons.codec.CharEncoding.UTF_8; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * Unit tests for {@link DisplayPropertyUpdatesMojo} + */ +public class DisplayPropertyUpdatesMojoTest extends AbstractMojoTestCase +{ + @Rule + public MojoRule mojoRule = new MojoRule( this ); + + private Path tempDir; + + @Before + public void setUp() throws Exception + { + super.setUp(); + tempDir = TestUtils.createTempDir( "display-property-updates" ); + } + + @After + public void tearDown() throws Exception + { + try + { + TestUtils.tearDownTempDir( tempDir ); + } + finally + { + super.tearDown(); + } + } + + @Test + public void testPropertiesFromParent() throws Exception + { + Path tempFile = Files.createTempFile( tempDir, "output", "" ); + + TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367" ), + tempDir ); + DisplayPropertyUpdatesMojo mojo = + (DisplayPropertyUpdatesMojo) mojoRule.lookupConfiguredMojo( tempDir.resolve( "child" ).toFile(), + "display-property-updates" ); + mojo.outputEncoding = UTF_8; + mojo.outputFile = tempFile.toFile(); + mojo.setPluginContext( new HashMap<>() ); + mojo.artifactMetadataSource = MockUtils.mockArtifactMetadataSource(); + mojo.execute(); + + assertThat( String.join( "", Files.readAllLines( tempFile ) ), + matchesPattern( ".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*" ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java b/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java index 6e45c91b97..950a9d184d 100644 --- a/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java +++ b/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java @@ -26,6 +26,7 @@ import java.nio.file.attribute.BasicFileAttributes; import static java.nio.file.FileVisitResult.CONTINUE; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static org.apache.commons.text.CaseUtils.toCamelCase; /** @@ -35,6 +36,7 @@ public class TestUtils { /** * Creates a temporary directory with the given name + * * @param name name of the directory to create * @return {@linkplain Path} object pointing to the directory * @throws IOException should the I/O operation fail @@ -46,6 +48,7 @@ public static Path createTempDir( String name ) throws IOException /** * Deletes the given directory together with all its contents + * * @param dir directory to delete * @throws IOException should an I/O operation fail */ @@ -71,4 +74,34 @@ public FileVisitResult postVisitDirectory( Path dir, IOException exc ) throws IO } ); } } + + /** + * Copies the {@code src} directory to {@code dst} recursively, + * creating the missing directories if necessary + * + * @param src source directory path + * @param dst destination directory path + * @throws IOException should an I/O error occur + */ + public static void copyDir( Path src, Path dst ) throws IOException + { + Files.walkFileTree( src, new SimpleFileVisitor() + { + @Override + public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) + throws IOException + { + Files.createDirectories( dst.resolve( src.relativize( dir ) ) ); + return CONTINUE; + } + + @Override + public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) + throws IOException + { + Files.copy( file, dst.resolve( src.relativize( file ) ), REPLACE_EXISTING ); + return CONTINUE; + } + } ); + } } diff --git a/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml b/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml new file mode 100644 index 0000000000..270daa5a5d --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + + default-group + parent + 1.0.0 + + child + + + + + default-group + artifactA + ${ver} + + + + + diff --git a/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml b/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml new file mode 100644 index 0000000000..3a342f4087 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + default-group + parent + 1.0.0 + pom + + + 1.0.0 + + From 80f424ada61d1ce4cf6ec86eb2c08664c7c212ba Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 16 Oct 2022 09:26:25 +0200 Subject: [PATCH 165/441] Remove redundant logs in info level --- .../java/org/codehaus/mojo/versions/utils/SegmentUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java index 6d4d21c46d..8b262ecf98 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java @@ -84,9 +84,9 @@ public static Optional determineUnchangedSegment( boolean allowMajorUpd : allowIncrementalUpdates ? of( MINOR ) : of( INCREMENTAL ); - if ( log != null && log.isInfoEnabled() ) + if ( log != null && log.isDebugEnabled() ) { - log.info( + log.debug( unchangedSegment.map( s -> Segment.of( s.value() + 1 ).toString() ) .orElse( "ALL" ) + " version changes allowed" ); } From 0e8e0eafa3ad5db8b124e9a39d4e7e345b72693c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 17 Oct 2022 23:04:04 +0200 Subject: [PATCH 166/441] Move examples in correct place --- src/site/markdown/{ => examples}/compare-dependencies.md | 0 src/site/markdown/{ => examples}/display-dependency-updates.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/site/markdown/{ => examples}/compare-dependencies.md (100%) rename src/site/markdown/{ => examples}/display-dependency-updates.md (100%) diff --git a/src/site/markdown/compare-dependencies.md b/src/site/markdown/examples/compare-dependencies.md similarity index 100% rename from src/site/markdown/compare-dependencies.md rename to src/site/markdown/examples/compare-dependencies.md diff --git a/src/site/markdown/display-dependency-updates.md b/src/site/markdown/examples/display-dependency-updates.md similarity index 100% rename from src/site/markdown/display-dependency-updates.md rename to src/site/markdown/examples/display-dependency-updates.md From 47ff2e7976998d012a7a20de183beab48b5ec190 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Sun, 16 Oct 2022 01:37:48 +0200 Subject: [PATCH 167/441] Fix Reports Success/Warning icons, counts --- .../AbstractVersionsReportRenderer.java | 64 ++++++------------- .../PluginUpdatesReportRenderer.java | 8 +-- 2 files changed, 21 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 7fe827e9fd..2193ddef18 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -136,59 +136,33 @@ protected void renderOverview() */ protected void renderOverviewTableRow( Q stats ) { - sink.tableCell(); - renderSuccessIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numUpToDate" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( stats.getUpToDate() ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerVersionAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( stats.getAny() ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( stats.getIncremental() ) ); - sink.tableCell_(); - sink.tableRow_(); + renderStatRow( "report.overview.numUpToDate", stats.getUpToDate(), true ); + renderStatRow( "report.overview.numNewerVersionAvailable", stats.getAny(), false ); + renderStatRow( "report.overview.numNewerIncrementalAvailable", stats.getIncremental(), false ); + renderStatRow( "report.overview.numNewerMinorAvailable", stats.getMinor(), false ); + renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor(), false ); + } + + protected void renderStatRow( String textKey, int statCount, boolean forceSuccessIcon ) + { sink.tableRow(); sink.tableCell(); - renderWarningIcon(); + if ( statCount == 0 || forceSuccessIcon ) + { + renderSuccessIcon(); + } + else + { + renderWarningIcon(); + } sink.tableCell_(); sink.tableCell(); - sink.text( getText( "report.overview.numNewerMinorAvailable" ) ); + sink.text( getText( textKey ) ); sink.tableCell_(); sink.tableCell(); - sink.text( Integer.toString( stats.getMinor() ) ); + sink.text( Integer.toString( statCount ) ); sink.tableCell_(); sink.tableRow_(); - sink.tableRow(); - sink.tableCell(); - renderWarningIcon(); - sink.tableCell_(); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerMajorAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( stats.getMajor() ) ); - sink.tableCell_(); } /** diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 7f38c91d5b..6d0713cd41 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -143,12 +143,8 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) protected void renderOverviewTableRow( T stats ) { super.renderOverviewTableRow( stats ); - sink.tableCell(); - sink.text( getText( "report.overview.numNewerDependenciesAvailable" ) ); - sink.tableCell_(); - sink.tableCell(); - sink.text( Integer.toString( ( (PluginOverviewStats) stats ).getDependencies() ) ); - sink.tableCell_(); + super.renderStatRow( "report.overview.numNewerDependenciesAvailable", + ( (PluginOverviewStats) stats ).getDependencies(), false ); } protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details ) From 12ea57cf0df7d75940f0e454cd528687f13fd49b Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 16 Oct 2022 10:50:38 +0200 Subject: [PATCH 168/441] Add caching to getNewestUpdates in report renderers. Use streams API in AbstractVersionDetails --- .../versions/api/AbstractVersionDetails.java | 64 ++++++------------- 1 file changed, 18 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index fea66d453e..ebcd62b7cc 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -20,11 +20,7 @@ */ import java.util.Arrays; -import java.util.Collections; import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -35,6 +31,7 @@ import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; +import static java.util.Collections.reverseOrder; import static java.util.Optional.empty; import static java.util.Optional.of; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; @@ -173,34 +170,20 @@ public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restri return getNewestVersion( versionRange, restriction, includeSnapshots, false ); } - private static Iterable reverse( T[] array ) - { - return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); - } - @Override public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots, boolean allowDowngrade ) { - // reverse( getVersions( ... ) ) will contain versions sorted from latest to oldest, + // reverseOrder( getVersions( ... ) ) will contain versions sorted from latest to oldest, // so we only need to find the first candidate fulfilling the criteria - for ( ArtifactVersion candidate : reverse( getVersions( includeSnapshots ) ) ) - { - if ( allowDowngrade || versionRange == null - || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) - { - if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) - { - continue; - } - if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) ) - { - continue; - } - return candidate; - } - } - return null; + return Arrays.stream( getVersions( includeSnapshots ) ) + .sorted( reverseOrder() ) + .filter( candidate -> allowDowngrade || versionRange == null + || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) + .filter( candidate -> restriction == null || isVersionInRestriction( restriction, candidate ) ) + .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) + .findAny() + .orElse( null ); } @Override @@ -284,25 +267,14 @@ public final ArtifactVersion[] getVersions( Restriction restriction, boolean inc public final ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ) { - final VersionComparator versionComparator = getVersionComparator(); - Set result = new TreeSet<>( versionComparator ); - for ( ArtifactVersion candidate : getVersions( includeSnapshots ) ) - { - if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) ) - { - continue; - } - if ( restriction != null && !isVersionInRestriction( restriction, candidate ) ) - { - continue; - } - if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) ) - { - continue; - } - result.add( candidate ); - } - return result.toArray( new ArtifactVersion[0] ); + return Arrays.stream( getVersions( includeSnapshots ) ) + .filter( candidate -> + versionRange == null || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) + .filter( candidate -> restriction == null || isVersionInRestriction( restriction, candidate ) ) + .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) + .sorted( getVersionComparator() ) + .distinct() + .toArray( ArtifactVersion[]::new ); } @Override From 4cd4065394606ff574bffd5913032e5e7a5d9bc6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 17 Oct 2022 23:18:36 +0200 Subject: [PATCH 169/441] Build Modello improvement, change namespace for xsd - all Modello source will have the same version of model - generate Modello documentation in model directory - we have the same report name as documentation for model - change name space to https://www.mojohaus.org/VERSIONS/... - preserver old version of rule.xsd --- pom.xml | 31 +----- src/main/mdo/dependency-updates-report.mdo | 4 +- src/main/mdo/plugin-updates-report.mdo | 4 +- src/main/mdo/rule.mdo | 4 +- src/site/markdown/version-rules.md.vm | 8 +- src/site/markdown/xsd/index.md | 20 ++++ src/site/resources/xsd/rule-2.0.0.xsd | 116 +++++++++++++++++++++ src/site/site.xml | 4 +- 8 files changed, 153 insertions(+), 38 deletions(-) create mode 100644 src/site/markdown/xsd/index.md create mode 100644 src/site/resources/xsd/rule-2.0.0.xsd diff --git a/pom.xml b/pom.xml index f40b44df50..b2cb535f69 100644 --- a/pom.xml +++ b/pom.xml @@ -313,8 +313,7 @@ modello-maven-plugin - generate-rule - generate-sources + generate-source xpp3-reader @@ -323,29 +322,6 @@ java - - - src/main/mdo/rule.mdo - - 2.0.0 - - - - generate-reporting - generate-sources - - - xpp3-writer - - java - - - - src/main/mdo/dependency-updates-report.mdo - src/main/mdo/plugin-updates-report.mdo - - 2.0.0 - site-doc @@ -353,6 +329,9 @@ xdoc + + ${project.build.directory}/generated-site/xdoc/model + site-xsd @@ -371,7 +350,7 @@ src/main/mdo/dependency-updates-report.mdo src/main/mdo/plugin-updates-report.mdo - 2.0.0 + 2.1.0 diff --git a/src/main/mdo/dependency-updates-report.mdo b/src/main/mdo/dependency-updates-report.mdo index 03d9a7cdc2..c8f41b2d8d 100644 --- a/src/main/mdo/dependency-updates-report.mdo +++ b/src/main/mdo/dependency-updates-report.mdo @@ -21,8 +21,8 @@ under the License. + xml.namespace="https://www.mojohaus.org/VERSIONS/DEPENDENCY-UPDATES-REPORT/${version}" + xml.schemaLocation="https://www.mojohaus.org/versions-maven-plugin/xsd/dependency-updates-report-${version}.xsd"> dependency-updates-report DependencyUpdatesReport diff --git a/src/main/mdo/plugin-updates-report.mdo b/src/main/mdo/plugin-updates-report.mdo index 12934b125f..685d75e3d0 100644 --- a/src/main/mdo/plugin-updates-report.mdo +++ b/src/main/mdo/plugin-updates-report.mdo @@ -21,8 +21,8 @@ under the License. + xml.namespace="https://www.mojohaus.org/VERSIONS/PLUGIN-UPDATES-REPORT/${version}" + xml.schemaLocation="https://www.mojohaus.org/versions-maven-plugin/xsd/plugin-updates-report-${version}.xsd"> plugin-updates-report PluginUpdatesReport diff --git a/src/main/mdo/rule.mdo b/src/main/mdo/rule.mdo index 0c9a9c68a7..d86917ae49 100644 --- a/src/main/mdo/rule.mdo +++ b/src/main/mdo/rule.mdo @@ -21,8 +21,8 @@ under the License. + xml.namespace="https://www.mojohaus.org/VERSIONS/RULE/${version}" + xml.schemaLocation="https://www.mojohaus.org/versions-maven-plugin/xsd/rule-${version}.xsd"> rule Rule diff --git a/src/site/markdown/version-rules.md.vm b/src/site/markdown/version-rules.md.vm index 3f1754cbec..89c617702e 100644 --- a/src/site/markdown/version-rules.md.vm +++ b/src/site/markdown/version-rules.md.vm @@ -58,7 +58,7 @@ it otherwise. Rules.xml --------- -To specify the version schemes to use, you may define a [rule-set xml file](./rule.html), use the `ruleSet` +To specify the version schemes to use, you may define a [rule-set xml file](./model/rule.html), use the `ruleSet` element in the `versions-maven-plugin` plugin configuration, or specify ignored versions via the `maven.version.ignore` property. @@ -68,8 +68,8 @@ The `rules.xml` file should conform to the xsd specified in the example below. ```xml + xmlns="https://www.mojohaus.org/VERSIONS/RULE/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="https://www.mojohaus.org/VERSIONS/RULE/2.1.0 https://www.mojohaus.org/versions-maven-plugin/xsd/rule-2.1.0.xsd"> @@ -79,7 +79,7 @@ The `rules.xml` file should conform to the xsd specified in the example below. ``` -The rule-set files must match the [XSD schema](./xsd/rule-2.0.0.xsd). +The rule-set files must match the [XSD schema](./xsd/index.html). You can then use the `rulesUri` parameter to specify the rule-set to be used by the `versions-maven-plugin`. diff --git a/src/site/markdown/xsd/index.md b/src/site/markdown/xsd/index.md new file mode 100644 index 0000000000..ec05854c6a --- /dev/null +++ b/src/site/markdown/xsd/index.md @@ -0,0 +1,20 @@ +title: XML schemas +author: Slawomir Jaranowski +date: 2022-10-17 + + + +# Versions - XML schemas + +## dependency-updates-report.xsd + + - [dependency-updates-report-2.1.0.xsd](dependency-updates-report-2.1.0.xsd) + +## plugin-updates-report.xsd + + - [plugin-updates-report-2.1.0.xsd](plugin-updates-report-2.1.0.xsd) + +## rule.xsd + + - [rule-2.0.0.xsd](rule-2.0.0.xsd) + - [rule-2.1.0.xsd](rule-2.1.0.xsd) diff --git a/src/site/resources/xsd/rule-2.0.0.xsd b/src/site/resources/xsd/rule-2.0.0.xsd new file mode 100644 index 0000000000..45dedf444b --- /dev/null +++ b/src/site/resources/xsd/rule-2.0.0.xsd @@ -0,0 +1,116 @@ + + + + + + + + + 1.0.0+ + + Describes a set of rules for how versions of artifacts should be handled. + + + + + + 1.0.0+ + + Describes a set of rules for how versions of artifacts should be handled. + + + + + + 2.0.0+ + Version patterns to ignore for all artifacts. + + + + + + + + + + 1.0.0+ + + + + + + + + + + + 1.0.0+ + The comparison method to use when no rule matches. + + + + + + + + 2.0.0+ + A version to ignore. + + + + 2.0.0+ + The type of ignore mechanism to use. Allowed values are 'exact' and 'regex'. + + + + + + + + 1.0.0+ + + Describes a rule for how versions of artifacts should be handled. + + + + + + 2.0.0+ + Version patterns to ignore for this rule. + + + + + + + + + + + 1.0.0+ + + The for groupId to which this rule applies. Wildcards with ? and * are valid. + A rule applies to all child groupIds unless overridden by a subsequent rule. + A rule without wildcards will override a rule with wildcards. + A rule with ? wildcards will override a rule with * wildcards. + + + + + + 1.0.0+ + + The artifactId to which this rule applies. Wildcards with ? and * are valid. + A rule without wildcards will override a rule with wildcards. + A rule with ? wildcards will override a rule with * wildcards. + + + + + + 1.0.0+ + The comparison method that this rule specifies. + + + + diff --git a/src/site/site.xml b/src/site/site.xml index 9da0008a59..3a21555dd9 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -30,8 +30,8 @@ - - + +
    From 0fc892f4fb1ed4148bbc28fab9ae1a9ea7102ad2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Oct 2022 13:16:17 +0000 Subject: [PATCH 170/441] Bump mockito-inline from 4.8.0 to 4.8.1 Bumps [mockito-inline](https://github.com/mockito/mockito) from 4.8.0 to 4.8.1. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.8.0...v4.8.1) --- updated-dependencies: - dependency-name: org.mockito:mockito-inline dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b2cb535f69..59589e3d14 100644 --- a/pom.xml +++ b/pom.xml @@ -265,7 +265,7 @@ org.mockito mockito-inline - 4.8.0 + 4.8.1 test From 98c703eb496e4662426c316f9c54c18cec3a2c06 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Tue, 18 Oct 2022 21:27:16 +0200 Subject: [PATCH 171/441] Fixing #769 --- .../mojo/versions/utils/SegmentUtils.java | 2 +- .../mojo/versions/utils/SegmentUtilsTest.java | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java index 8b262ecf98..1331890d8e 100644 --- a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java +++ b/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java @@ -77,7 +77,7 @@ public static Optional determineUnchangedSegment( boolean allowMajorUpd log.info( "Assuming allowMajorUpdates false because allowMinorUpdates is false." ); } - Optional unchangedSegment = allowMajorUpdates && allowMinorUpdates + Optional unchangedSegment = allowMajorUpdates && allowMinorUpdates && allowIncrementalUpdates ? empty() : allowMinorUpdates && allowIncrementalUpdates ? of( MAJOR ) diff --git a/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java b/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java new file mode 100644 index 0000000000..4170e2dc7e --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java @@ -0,0 +1,70 @@ +package org.codehaus.mojo.versions.utils; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.junit.Test; + +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +/** + * Unit tests for {@link SegmentUtils} + */ +public class SegmentUtilsTest +{ + @Test + public void testIncremental() + { + assertThat( determineUnchangedSegment( false, false, false, null ), + is( of( INCREMENTAL ) ) ); + assertThat( determineUnchangedSegment( true, false, false, null ), + is( of( INCREMENTAL ) ) ); + assertThat( determineUnchangedSegment( true, true, false, null ), + is( of( INCREMENTAL ) ) ); + } + + @Test + public void testMinor() + { + assertThat( determineUnchangedSegment( false, false, true, null ), + is( of( MINOR ) ) ); + assertThat( determineUnchangedSegment( true, false, true, null ), + is( of( MINOR ) ) ); + } + + @Test + public void testMajor() + { + assertThat( determineUnchangedSegment( false, true, true, null ), + is( of( MAJOR ) ) ); + } + + @Test + public void testEmpty() + { + assertThat( determineUnchangedSegment( true, true, true, null ), + is( empty() ) ); + } +} From 7ec406bd77120390194f006812e4507a274efd1d Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Fri, 21 Oct 2022 18:03:05 +0200 Subject: [PATCH 172/441] Bump parent version from 70 to 71 https://github.com/mojohaus/mojo-parent/releases/tag/71 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 59589e3d14..5467043ad7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codehaus.mojo mojo-parent - 70 + 71 versions-maven-plugin From 61f741169d0ab45c5e125638ba8b7ab51f2761bc Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 22 Oct 2022 10:42:29 +0200 Subject: [PATCH 173/441] #725: Migrating Resolve Ranges to Markdown --- src/site/apt/examples/resolve-ranges.apt | 121 ------------------- src/site/markdown/examples/resolve-ranges.md | 116 ++++++++++++++++++ 2 files changed, 116 insertions(+), 121 deletions(-) delete mode 100644 src/site/apt/examples/resolve-ranges.apt create mode 100644 src/site/markdown/examples/resolve-ranges.md diff --git a/src/site/apt/examples/resolve-ranges.apt b/src/site/apt/examples/resolve-ranges.apt deleted file mode 100644 index a1a13127d6..0000000000 --- a/src/site/apt/examples/resolve-ranges.apt +++ /dev/null @@ -1,121 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Resolve Ranges - ----- - Paul Gier, Stephen Connolly - ------ - 2009-04-20 - ------ - -Resolve ranges - - A pom may specify version ranges for certain dependencies. - -+---+ - - - - org.apache.maven - maven-project - [2.0.7, 2.0.9) - - - - org.codehaus.plexus - plexus-utils - [1.5.0, 1.5.1 ] - - - - junit - junit - [3.0, 3.8.2) - - - -+---+ - - Using the resolve-ranges goal, the version ranges can be set to the specific version - used in the build. - ---- -mvn versions:resolve-ranges ---- - - The pom dependencies are modified to look like the following. - -+---+ - - - - org.apache.maven - maven-project - 2.0.8 - - - - org.codehaus.plexus - plexus-utils - 1.5.1 - - - - junit - junit - 3.8.1 - - - -+---+ - - You can restrict which dependencies should have their ranges collapsed. For example, - the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId - "plexus-utils" - ---- -mvn versions:resolve-ranges -Dincludes=org.codehaus.plexus:plexus-utils ---- - - The <<>> and <<>> parameters follow the format <<>>. - Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. - - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". - ---- -mvn versions:resolve-ranges -Dincludes=org.codehaus.plexus:*,junit:junit ---- - - By default, both the <<>> and <<>> sections will be processed. - You can use the <<>> and <<>> parameters to control which sections - are processed. - - This example will only process the <<>> section of your pom: - ---- -mvn versions:resolve-ranges -DprocessDependencies=false ---- - - While this example will only process the <<>> section of your pom: - ---- -mvn versions:resolve-ranges -DprocessDependencyManagement=false ---- - diff --git a/src/site/markdown/examples/resolve-ranges.md b/src/site/markdown/examples/resolve-ranges.md new file mode 100644 index 0000000000..78c54ecb8c --- /dev/null +++ b/src/site/markdown/examples/resolve-ranges.md @@ -0,0 +1,116 @@ +title: Resolve Ranges +author: Paul Gier, Stephen Connolly +date: 2009-04-20 + + + +# Resolve ranges + +A pom may specify version ranges for certain dependencies. + +```xml + + + + org.apache.maven + maven-project + [2.0.7, 2.0.9) + + + + org.codehaus.plexus + plexus-utils + [1.5.0, 1.5.1 ] + + + + junit + junit + [3.0, 3.8.2) + + + +``` + +Using the resolve-ranges goal, the version ranges can be set to the specific version +used in the build. + +```sh +mvn versions:resolve-ranges +``` + + The pom dependencies are modified to look like the following. + +```xml + + + + org.apache.maven + maven-project + 2.0.8 + + + + org.codehaus.plexus + plexus-utils + 1.5.1 + + + + junit + junit + 3.8.1 + + + +``` + +You can restrict which dependencies should have their ranges collapsed. For example, +the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId +"plexus-utils" + +```sh +mvn versions:resolve-ranges -Dincludes=org.codehaus.plexus:plexus-utils +``` + +The `includes` and `excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match +multiple values. + +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". + +```sh +mvn versions:resolve-ranges -Dincludes=org.codehaus.plexus:*,junit:junit +``` + +By default, both the `project/dependencyManagment` and `project/dependencies` sections will be processed. +You can use the `processDependencies` and `processDependencyManagement` parameters to control which sections +are processed. + +This example will only process the `project/dependencyManagment` section of your pom: + +```sh +mvn versions:resolve-ranges -DprocessDependencies=false +``` + +While this example will only process the `project/dependencies` section of your pom: + +```sh +mvn versions:resolve-ranges -DprocessDependencyManagement=false +``` From 8ee15b705f8180b28ecc668923f894669e269ea4 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 21 Oct 2022 21:02:35 +0200 Subject: [PATCH 174/441] #725: Migrate display-property-updates.apt to Markdown --- .../examples/display-property-updates.md} | 74 +++++++++---------- 1 file changed, 35 insertions(+), 39 deletions(-) rename src/site/{apt/examples/display-property-updates.apt => markdown/examples/display-property-updates.md} (57%) diff --git a/src/site/apt/examples/display-property-updates.apt b/src/site/markdown/examples/display-property-updates.md similarity index 57% rename from src/site/apt/examples/display-property-updates.apt rename to src/site/markdown/examples/display-property-updates.md index 420332f0bb..f74637d0be 100644 --- a/src/site/apt/examples/display-property-updates.apt +++ b/src/site/markdown/examples/display-property-updates.md @@ -1,45 +1,41 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. +title: Checking for new property-linked updates +author: Stephen Connolly +date: 2009-08-12 - ----- - Checking for new property-linked updates - ----- - Stephen Connolly - ------ - 2009-08-12 - ------ + -Checking for new property-linked updates +# Checking for new property-linked updates - The <<>> goal will check all the properties in your project and display a list - of those properties which are used to control versions of dependencies, plugins and plugin dependencies and - it will detail which properties have newer versions available. +The `display-property-updates` goal will check all the properties in your project and display a list +of those properties which are used to control versions of dependencies, plugins and plugin dependencies and +it will detail which properties have newer versions available. - Here are some examples of what this looks like: +Here are some examples of what this looks like: ---- +```sh svn checkout http://svn.codehaus.org/mojo/trunk/mojo/build-helper-maven-plugin build-helper-maven-plugin cd build-helper-maven-plugin mvn versions:display-property-updates ---- +``` - Which produces the following output: +Which produces the following output: ---- +```log [INFO] ------------------------------------------------------------------------ [INFO] Building Build Helper Maven Plugin [INFO] task-segment: [versions:display-property-updates] @@ -55,19 +51,19 @@ mvn versions:display-property-updates [INFO] Finished at: Wed Aug 12 13:28:04 BST 2009 [INFO] Final Memory: 11M/22M [INFO] ------------------------------------------------------------------------ ---- +``` - Another example, using a project which uses properties to control the version of multiple artifacts: +Another example, using a project which uses properties to control the version of multiple artifacts: ---- +```sh svn checkout http://svn.codehaus.org/mojo/trunk/mojo/versions-maven-plugin versions-maven-plugin cd versions-maven-plugin mvn versions:display-property-updates ---- +``` - Which produces the following output: +Which produces the following output: ---- +```log [INFO] ------------------------------------------------------------------------ [INFO] Building Versions Maven Plugin [INFO] task-segment: [versions:display-property-updates] @@ -85,4 +81,4 @@ mvn versions:display-property-updates [INFO] Finished at: Wed Aug 12 13:28:49 BST 2009 [INFO] Final Memory: 11M/24M [INFO] ------------------------------------------------------------------------ ---- +``` From d421b45b9644a5a75f053662cc2bb2bc0f5a5221 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 21 Oct 2022 20:15:45 +0200 Subject: [PATCH 175/441] Resolves #776: onlyUpgradable change the filter to versions where the current version is not the latest one --- .../versions/DependencyUpdatesReportMojo.java | 20 +- .../versions/PluginUpdatesReportMojo.java | 6 +- .../versions/api/AbstractVersionDetails.java | 6 + .../versions/api/DefaultVersionsHelper.java | 204 +++++------------- .../mojo/versions/api/VersionDetails.java | 8 + .../DependencyUpdatesReportMojoTest.java | 20 +- .../versions/PluginUpdatesReportMojoTest.java | 49 ++++- 7 files changed, 143 insertions(+), 170 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 6cda7845a4..c831013008 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -25,15 +25,18 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Arrays; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.stream.Collectors; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; @@ -202,8 +205,21 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! if ( onlyUpgradable ) { - dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 1 ); - dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 1 ); + dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 0 ); + dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 0 ); + } + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Dependency versions:" ); + dependencyUpdates.forEach( ( key, value ) -> getLog().debug( key.toString() + ": " + + Arrays.stream( value.getVersions() ).map( ArtifactVersion::toString ) + .collect( Collectors.joining( ", " ) ) ) ); + + getLog().debug( "Dependency management versions:" ); + dependencyManagementUpdates.forEach( ( key, value ) -> getLog().debug( key.toString() + ": " + + Arrays.stream( value.getVersions() ).map( ArtifactVersion::toString ) + .collect( Collectors.joining( ", " ) ) ) ); } for ( String format : formats ) diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 1b47c0f7c4..05b9bdbfe2 100644 --- a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -163,10 +163,8 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx if ( onlyUpgradable ) { - pluginUpdates = - filter( pluginUpdates, plugin -> plugin.getVersions().length > 1 ); - pluginManagementUpdates = filter( pluginManagementUpdates, - plugin -> plugin.getVersions().length > 1 ); + pluginUpdates = filter( pluginUpdates, p -> p.getVersions().length > 0 ); + pluginManagementUpdates = filter( pluginManagementUpdates, p -> p.getVersions().length > 0 ); } PluginUpdatesModel model = new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index ebcd62b7cc..ed8134ba89 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -339,6 +339,12 @@ public final ArtifactVersion[] getAllUpdates( Optional updateScope, boo return null; } + @Override + public final ArtifactVersion[] getAllUpdates() + { + return getAllUpdates( (VersionRange) null, isIncludeSnapshots() ); + } + @Override public final ArtifactVersion[] getAllUpdates( VersionRange versionRange ) { diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 947333b60b..ed959429d8 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -38,7 +38,6 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -46,6 +45,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; @@ -668,109 +669,95 @@ public ArtifactVersion createArtifactVersion( String version ) return new DefaultArtifactVersion( version ); } + /** + * Returns a map of all possible updates per dependency. The lookup is done in parallel using + * {@code LOOKUP_PARALLEL_THREADS} threads. + * + * @param dependencies The set of {@link Dependency} instances to look up. + * @param usePluginRepositories Search the plugin repositories. + * @return map containing the ArtifactVersions object per dependency + * @throws ArtifactMetadataRetrievalException if the lookup does not succeed + */ @Override public Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException { - // Create the request for details collection for parallel lookup... - final List> requestsForDetails = - new ArrayList<>( dependencies.size() ); - for ( final Dependency dependency : dependencies ) - { - requestsForDetails.add( new DependencyLookup( dependency, usePluginRepositories ) ); - } - - final Map dependencyUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); - - // Lookup details in parallel... - final ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); + ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try { - final List> responseForDetails = - executor.invokeAll( requestsForDetails ); - - // Construct the final results... - for ( final Future details : responseForDetails ) + Map dependencyUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); + List>> futures = dependencies.stream() + .map( dependency -> executor.submit( () -> new ImmutablePair<> + ( dependency, lookupDependencyUpdates( dependency, usePluginRepositories ) ) ) ) + .collect( Collectors.toList() ); + for ( Future> details : futures ) { - final DependencyArtifactVersions dav = details.get(); - dependencyUpdates.put( dav.getDependency(), dav.getArtifactVersions() ); + Pair pair = details.get(); + dependencyUpdates.put( pair.getKey(), pair.getValue() ); } + + return dependencyUpdates; } catch ( ExecutionException | InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for dependencies " + dependencies - + ": " + ie.getMessage(), ie, null ); + + ": " + ie.getMessage(), ie, null ); } finally { - executor.shutdownNow(); + executor.shutdown(); } - return dependencyUpdates; } @Override public ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) throws ArtifactMetadataRetrievalException { - getLog().debug( "Checking " - + ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) - + " for updates newer than " + dependency.getVersion() ); - - return lookupArtifactVersions( createDependencyArtifact( dependency ), usePluginRepositories ); + ArtifactVersions allVersions = lookupArtifactVersions( createDependencyArtifact( dependency ), + usePluginRepositories ); + return new ArtifactVersions( allVersions.getArtifact(), Arrays.stream( allVersions.getAllUpdates() ) + .collect( Collectors.toList() ), allVersions.getVersionComparator() ); } @Override public Map lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) throws ArtifactMetadataRetrievalException { - // Create the request for details collection for parallel lookup... - List> requestsForDetails = new ArrayList<>( plugins.size() ); - for ( final Plugin plugin : plugins ) - { - requestsForDetails.add( new PluginLookup( plugin, allowSnapshots ) ); - } - - Map pluginUpdates = new TreeMap<>( PluginComparator.INSTANCE ); - - // Lookup details in parallel... ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try { - final List> responseForDetails = - executor.invokeAll( requestsForDetails ); - - // Construct the final results... - for ( final Future details : responseForDetails ) + Map pluginUpdates = new TreeMap<>( PluginComparator.INSTANCE ); + List>> futures = plugins.stream() + .map( p -> executor.submit( () -> new ImmutablePair<> + ( p, lookupPluginUpdates( p, allowSnapshots ) ) ) ) + .collect( Collectors.toList() ); + for ( Future> details : futures ) { - final PluginPluginUpdatesDetails pud = details.get(); - pluginUpdates.put( pud.getPlugin(), pud.getPluginUpdatesDetails() ); + Pair pair = details.get(); + pluginUpdates.put( pair.getKey(), pair.getValue() ); } + + return pluginUpdates; } catch ( ExecutionException | InterruptedException ie ) { throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " - + ie.getMessage(), ie, null ); + + ie.getMessage(), ie, null ); } finally { - executor.shutdownNow(); + executor.shutdown(); } - return pluginUpdates; } @Override public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) throws ArtifactMetadataRetrievalException { - String version = plugin.getVersion(); - version = version == null ? "LATEST" : version; - getLog().debug( "Checking " + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) - + " for updates newer than " + version ); - - final ArtifactVersions pluginArtifactVersions = - lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), version ), - true ); + String version = plugin.getVersion() != null + ? plugin.getVersion() + : "LATEST"; Set pluginDependencies = new TreeSet<>( DependencyComparator.INSTANCE ); if ( plugin.getDependencies() != null ) @@ -780,7 +767,13 @@ public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSna Map pluginDependencyDetails = lookupDependenciesUpdates( pluginDependencies, false ); - return new PluginUpdatesDetails( pluginArtifactVersions, pluginDependencyDetails, allowSnapshots ); + ArtifactVersions allVersions = + lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), version ), + true ); + ArtifactVersions updatedVersions = new ArtifactVersions( allVersions.getArtifact(), + Arrays.stream( allVersions.getAllUpdates() ).collect( Collectors.toList() ), + allVersions.getVersionComparator() ); + return new PluginUpdatesDetails( updatedVersions, pluginDependencyDetails, allowSnapshots ); } @Override @@ -832,8 +825,8 @@ public Map getVersionPropertiesMap( MavenProject pro } } - List includePropertiesList = getSplittedProperties( includeProperties ); - List excludePropertiesList = getSplittedProperties( excludeProperties ); + List includePropertiesList = getSplitProperties( includeProperties ); + List excludePropertiesList = getSplitProperties( excludeProperties ); getLog().debug( "Searching for properties associated with builders" ); Iterator i = properties.values().iterator(); @@ -902,7 +895,7 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr return propertyVersions; } - private List getSplittedProperties( String commaSeparatedProperties ) + private List getSplitProperties( String commaSeparatedProperties ) { List propertiesList = Collections.emptyList(); if ( StringUtils.isNotEmpty( commaSeparatedProperties ) ) @@ -913,97 +906,6 @@ private List getSplittedProperties( String commaSeparatedProperties ) return propertiesList; } - // This is a data container to hold the result of a Dependency lookup to its ArtifactVersions. - private static class DependencyArtifactVersions - { - private final Dependency dependency; - - private final ArtifactVersions artifactVersions; - - DependencyArtifactVersions( final Dependency dependency, final ArtifactVersions artifactVersions ) - { - this.dependency = dependency; - this.artifactVersions = artifactVersions; - } - - public Dependency getDependency() - { - return dependency; - } - - public ArtifactVersions getArtifactVersions() - { - return artifactVersions; - } - } - - // This is a data container to hold the result of a Dependency lookup to its ArtifactVersions. - private static class PluginPluginUpdatesDetails - { - private final Plugin plugin; - - private final PluginUpdatesDetails pluginUpdatesDetails; - - PluginPluginUpdatesDetails( final Plugin plugin, final PluginUpdatesDetails pluginUpdatesDetails ) - { - this.plugin = plugin; - this.pluginUpdatesDetails = pluginUpdatesDetails; - } - - public Plugin getPlugin() - { - return plugin; - } - - public PluginUpdatesDetails getPluginUpdatesDetails() - { - return pluginUpdatesDetails; - } - } - - // This Callable wraps lookupDependencyUpdates so that it can be run in parallel. - private class DependencyLookup - implements Callable - { - private final Dependency dependency; - - private final boolean usePluginRepositories; - - DependencyLookup( final Dependency dependency, final boolean usePluginRepositories ) - { - this.dependency = dependency; - this.usePluginRepositories = usePluginRepositories; - } - - public DependencyArtifactVersions call() - throws Exception - { - return new DependencyArtifactVersions( dependency, - lookupDependencyUpdates( dependency, usePluginRepositories ) ); - } - } - - // This Callable wraps lookupPluginUpdates so that it can be run in parallel. - private class PluginLookup - implements Callable - { - private final Plugin plugin; - - private final boolean allowSnapshots; - - PluginLookup( final Plugin plugin, final Boolean allowSnapshots ) - { - this.plugin = plugin; - this.allowSnapshots = allowSnapshots; - } - - public PluginPluginUpdatesDetails call() - throws Exception - { - return new PluginPluginUpdatesDetails( plugin, lookupPluginUpdates( plugin, allowSnapshots ) ); - } - } - /** * Builder class for {@linkplain DefaultVersionsHelper} */ diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index bd414b40fc..265b4fcfaa 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -348,6 +348,14 @@ ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeS ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) throws InvalidSegmentException; + /** + * Returns the all versions newer than the specified current version + * + * @return the all versions after currentVersion + * @since 2.13.0 + */ + ArtifactVersion[] getAllUpdates(); + /** * Returns the all versions newer than the specified current version, but within the specified update scope. * diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index d14013bdc6..3b31c751f4 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -149,6 +149,12 @@ public TestDependencyUpdatesReportMojo withIgnoredVersions( return this; } + public TestDependencyUpdatesReportMojo withAllowSnapshots( boolean allowSnapshots ) + { + this.allowSnapshots = allowSnapshots; + return this; + } + private static RepositorySystem mockRepositorySystem() { RepositorySystem repositorySystem = mock( RepositorySystem.class ); @@ -183,13 +189,21 @@ public void testOnlyUpgradableDependencies() throws IOException, MavenReportExce SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() .withOnlyUpgradable( true ) + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); + }} ) ) .withDependencies( - dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) + dependencyOf( "artifactA", "1.0.0" ), + dependencyOf( "artifactB", "1.0.0" ), + dependencyOf( "artifactC", "2.0.0" ) ) .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); - assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, containsString( "artifactA" ) ); + assertThat( output, not( containsString( "artifactB" ) ) ); assertThat( output, not( containsString( "artifactC" ) ) ); } diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java index 25f2ea781a..46053944ce 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java @@ -24,10 +24,12 @@ import java.io.OutputStream; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Locale; import java.util.Set; import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Build; @@ -45,7 +47,6 @@ import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; -import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; @@ -84,6 +85,13 @@ public TestPluginUpdatesReportMojo withPlugins( Plugin... plugins ) return this; } + public TestPluginUpdatesReportMojo withArtifactMetadataSource( + ArtifactMetadataSource artifactMetadataSource ) + { + this.artifactMetadataSource = artifactMetadataSource; + return this; + } + public TestPluginUpdatesReportMojo withPluginManagement( Plugin... pluginManagement ) { project.getBuild().getPluginManagement().setPlugins( Arrays.asList( pluginManagement ) ); @@ -131,13 +139,18 @@ private static RepositorySystem mockRepositorySystem() } private static Plugin pluginOf( String artifactId ) + { + return pluginOf( artifactId, "1.0.0" ); + } + + private static Plugin pluginOf( String artifactId, String version ) { return new Plugin() { { setGroupId( "defaultGroup" ); setArtifactId( artifactId ); - setVersion( "1.0.0" ); + setVersion( version ); } }; } @@ -148,13 +161,21 @@ public void testOnlyUpgradablePlugins() throws IOException, MavenReportException OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withPlugins( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); + }} ) ) + .withPlugins( pluginOf( "artifactA", "1.0.0" ), + pluginOf( "artifactB", "1.0.0" ), + pluginOf( "artifactC", "2.0.0" ) ) + .withOnlyUpgradable( true ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); - assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, containsString( "artifactA" ) ); + assertThat( output, not( containsString( "artifactB" ) ) ); assertThat( output, not( containsString( "artifactC" ) ) ); } @@ -164,13 +185,21 @@ public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenRe OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); + }} ) ) + .withPluginManagement( pluginOf( "artifactA", "1.0.0" ), + pluginOf( "artifactB", "1.0.0" ), + pluginOf( "artifactC", "2.0.0" ) ) .withOnlyUpgradable( true ) .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); - assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); + assertThat( output, containsString( "artifactA" ) ); + assertThat( output, not( containsString( "artifactB" ) ) ); assertThat( output, not( containsString( "artifactC" ) ) ); } From 32345e29caa7551a0e86d6537c6040f4636612bb Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 22 Oct 2022 10:37:35 +0200 Subject: [PATCH 176/441] #725: Migrating Lock Snapshots to Markdown --- src/site/apt/examples/lock-snapshots.apt | 103 ------------------- src/site/markdown/examples/lock-snapshots.md | 98 ++++++++++++++++++ 2 files changed, 98 insertions(+), 103 deletions(-) delete mode 100644 src/site/apt/examples/lock-snapshots.apt create mode 100644 src/site/markdown/examples/lock-snapshots.md diff --git a/src/site/apt/examples/lock-snapshots.apt b/src/site/apt/examples/lock-snapshots.apt deleted file mode 100644 index 8f603edfe9..0000000000 --- a/src/site/apt/examples/lock-snapshots.apt +++ /dev/null @@ -1,103 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Locking snapshot dependencies - ----- - Stephen Connolly, Paul Gier - ------ - 2009-04-20 - ------ - -Locking snapshot dependencies - - If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it - can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. - In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their - release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a - useful hack. - - A pom will most likely specify -SNAPSHOT versions for certain dependencies. - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-SNAPSHOT - - - -+---+ - - Using the <<>> goal, the version can be locked down to the specific timestamped snapshot version used - in the build. - ---- -mvn versions:lock-snapshots ---- - - The pom dependencies are modified to look like the following. - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-20081117.213112-16 - - - -+---+ - - You can restrict which dependencies should have their -SNAPSHOT versions locked down. For example, - the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId - "plexus-utils" - ---- -mvn versions:lock-snapshots -Dincludes=org.codehaus.plexus:plexus-utils ---- - - The <<>> and <<>> parameters follow the format <<>>. - Use a comma separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. - - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". - ---- -mvn versions:lock-snapshots -Dincludes=org.codehaus.plexus:*,junit:junit ---- - - By default, both the <<>> and <<>> sections will be processed. - You can use the <<>> and <<>> parameters to control which sections - are processed. - - This example will only process the <<>> section of your pom: - ---- -mvn versions:lock-snapshots -DprocessDependencies=false ---- - - While this example will only process the <<>> section of your pom: - ---- -mvn versions:lock-snapshots -DprocessDependencyManagement=false ---- - diff --git a/src/site/markdown/examples/lock-snapshots.md b/src/site/markdown/examples/lock-snapshots.md new file mode 100644 index 0000000000..dd457bbf9c --- /dev/null +++ b/src/site/markdown/examples/lock-snapshots.md @@ -0,0 +1,98 @@ +title: Locking snapshot dependencies +author: Stephen Connolly, Paul Gier +date: 2009-04-20 + + + +# Locking snapshot dependencies + +If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it +can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. +In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their +release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a +useful hack. + +A pom will most likely specify -SNAPSHOT versions for certain dependencies. + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-SNAPSHOT + + + +``` + +Using the `lock-snapshots` goal, the version can be locked down to the specific timestamped snapshot version used +in the build. + +```sh +mvn versions:lock-snapshots +``` + + The pom dependencies are modified to look like the following. + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-20081117.213112-16 + + + +``` + +You can restrict which dependencies should have their -SNAPSHOT versions locked down. For example, +the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId +"plexus-utils" + +```sh +mvn versions:lock-snapshots -Dincludes=org.codehaus.plexus:plexus-utils +``` + +The `includes` and `excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated list to specify multiple includes. Wildcards (*) can also be used to match +multiple values. + +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". + +```sh +mvn versions:lock-snapshots -Dincludes=org.codehaus.plexus:*,junit:junit +``` + +By default, both the `project/dependencyManagment` and `project/dependencies` sections will be processed. +You can use the `processDependencies` and `processDependencyManagement` parameters to control which sections +are processed. + +This example will only process the `project/dependencyManagment` section of your pom: + +```sh +mvn versions:lock-snapshots -DprocessDependencies=false +``` + +While this example will only process the `project/dependencies` section of your pom: + +```sh +mvn versions:lock-snapshots -DprocessDependencyManagement=false +``` From 27a9b5fb161b312815225b54c1e44de6922e938d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 22 Oct 2022 10:51:06 +0200 Subject: [PATCH 177/441] #725: Migrating Set to Markdown --- .../set.apt => markdown/examples/set.md} | 211 +++++++++--------- 1 file changed, 109 insertions(+), 102 deletions(-) rename src/site/{apt/examples/set.apt => markdown/examples/set.md} (52%) diff --git a/src/site/apt/examples/set.apt b/src/site/markdown/examples/set.md similarity index 52% rename from src/site/apt/examples/set.apt rename to src/site/markdown/examples/set.md index cb387cc307..20c18a4e29 100644 --- a/src/site/apt/examples/set.apt +++ b/src/site/markdown/examples/set.md @@ -1,48 +1,53 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Changing the project version - ----- - Stephen Connolly - ------ - 2009-05-25 - ------ - -Changing the project version - - The <<>> goal can be used to update the version of the current module. It will automatically climb up local - directories to find the aggregation root. It will automatically update explicitly referenced dependencies. - You specify the version to update to via the newVersion property, for example - -+---+ +title: Changing the project version +author: Stephen Connolly +date: 2009-05-25 + + + +# Changing the project version + +The `set` goal can be used to update the version of the current module. It will automatically climb up local +directories to find the aggregation root. It will automatically update explicitly referenced dependencies. +You specify the version to update to via the newVersion property, for example + +```sh mvn versions:set -DnewVersion=1.0.3-SNAPSHOT -+---+ +``` - Here is a real-life example: +Here is a real-life example: -+---+ +```sh svn co http://svn.apache.org/repos/asf/maven/enforcer/trunk/@778424 enforcer +``` + +```log A enforcer/maven-enforcer-plugin [...] A enforcer/enforcer-rules/pom.xml U enforcer Checked out revision 778424. +``` + +```sh mvn versions:set -DnewVersion=2.0.0-SNAPSHOT -f enforcer/pom.xml +``` + +```log [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] Enforcer @@ -85,64 +90,66 @@ mvn versions:set -DnewVersion=2.0.0-SNAPSHOT -f enforcer/pom.xml [INFO] Finished at: Mon May 25 15:30:00 IST 2009 [INFO] Final Memory: 22M/355M [INFO] ------------------------------------------------------------------------ -+---+ - - To illustrate how dependencies version updating and aggregator root detection works reactor, we need to edit the - dependencyManagement section of the root <<>> to reference the version explicitly, as opposed to - via a property. - - Change: - -+---+ - - - - org.apache.maven.enforcer - enforcer-api - ${project.version} - - - org.apache.maven.enforcer - enforcer-rules - ${project.version} - - - org.apache.maven.enforcer - enforcer-rules - ${project.version} - test-jar - test - -+---+ - - To - -+---+ - - - - org.apache.maven.enforcer - enforcer-api - 2.0.0-SNAPSHOT - - - org.apache.maven.enforcer - enforcer-rules - 2.0.0-SNAPSHOT - - - org.apache.maven.enforcer - enforcer-rules - 2.0.0-SNAPSHOT - test-jar - test - -+---+ - - Now if we run - -+---+ +``` + +To illustrate how dependencies version updating and aggregator root detection works reactor, we need to edit the +dependencyManagement section of the root `pom.xml` to reference the version explicitly, as opposed to +via a property. + +Change: + +```xml + + + + org.apache.maven.enforcer + enforcer-api + ${project.version} + + + org.apache.maven.enforcer + enforcer-rules + ${project.version} + + + org.apache.maven.enforcer + enforcer-rules + ${project.version} + test-jar + test + +``` + +To + +```xml + + + + org.apache.maven.enforcer + enforcer-api + 2.0.0-SNAPSHOT + + + org.apache.maven.enforcer + enforcer-rules + 2.0.0-SNAPSHOT + + + org.apache.maven.enforcer + enforcer-rules + 2.0.0-SNAPSHOT + test-jar + test + +``` + +Now if we run + +```sh mvn versions:set -DnewVersion=2.1.0-SNAPSHOT -f enforcer/enforcer-api/pom.xml +``` +```log [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Enforcer API @@ -166,19 +173,19 @@ mvn versions:set -DnewVersion=2.1.0-SNAPSHOT -f enforcer/enforcer-api/pom.xml [INFO] Finished at: Mon May 25 15:41:54 IST 2009 [INFO] Final Memory: 22M/350M [INFO] ------------------------------------------------------------------------ -+---+ +``` - In this case it has updated the version of enforcer-api, it has found that enforcer-api is part of an aggregator - build in the local filesystem, and it has updated all references to enforcer-api in the aggregator build to - reference the new version. +In this case it has updated the version of enforcer-api, it has found that enforcer-api is part of an aggregator +build in the local filesystem, and it has updated all references to enforcer-api in the aggregator build to +reference the new version. -Widening the scope of the change +## Widening the scope of the change - You can increase or change the scope of the change by specifying the <<>> or <<>> or - <<>> on the command line directly. These can also support wildcards to help match multiple modules - which will become origins of change. +You can increase or change the scope of the change by specifying the `groupId` or `artifactId` or +`oldVersion` on the command line directly. These can also support wildcards to help match multiple modules +which will become origins of change. -+---+ +```sh mvn versions:set -DgroupId=org.apache.maven.* -DartifactId=* -DoldVersion=2.* -DnewVersion=2.1.0-SNAPSHOT -+---+ +``` \ No newline at end of file From de4ec6622e8a5f1fa91b8a93ffa9a858da24167e Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 16 Oct 2022 10:50:38 +0200 Subject: [PATCH 178/441] Correcting BoundArtifactComparison and eliminating incrementSegment --- src/it/it-use-latest-versions-011/pom.xml | 2 - .../versions/AbstractVersionsDisplayMojo.java | 1 + .../mojo/versions/UseLatestSnapshotsMojo.java | 86 +++++++------- .../mojo/versions/UseNextSnapshotsMojo.java | 50 ++++----- .../versions/api/AbstractVersionDetails.java | 8 +- .../mojo/versions/api/ArtifactVersions.java | 34 ++++++ .../mojo/versions/api/PropertyVersions.java | 43 ------- .../ordering/AbstractVersionComparator.java | 13 --- .../ordering/BoundArtifactVersion.java | 75 +++++++++++-- .../versions/ordering/VersionComparator.java | 20 +--- .../DependencyUpdatesReportMojoTest.java | 24 ++++ .../versions/api/ArtifactVersionsTest.java | 23 +++- .../ordering/BoundArtifactVersionTest.java | 106 ++++++++++++++++++ .../ordering/MavenVersionComparatorTest.java | 69 ++++-------- .../MercuryVersionComparatorTest.java | 33 ++---- .../NumericVersionComparatorTest.java | 43 +++---- .../ordering/VersionComparatorTestBase.java | 100 +++++++++++++++++ .../ordering/VersionComparatorsTest.java | 78 ------------- 18 files changed, 461 insertions(+), 347 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java create mode 100644 src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java delete mode 100644 src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java diff --git a/src/it/it-use-latest-versions-011/pom.xml b/src/it/it-use-latest-versions-011/pom.xml index 6aba0eb5e3..eadb2621c7 100644 --- a/src/it/it-use-latest-versions-011/pom.xml +++ b/src/it/it-use-latest-versions-011/pom.xml @@ -31,8 +31,6 @@ @project.version@ true - false - true false diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 396e6ea7ac..47057ffd46 100644 --- a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -93,6 +93,7 @@ protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); } + @SuppressWarnings( "unchecked" ) protected void logInit() { if ( outputFile != null && !outputFileError ) diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index b593d5263e..8e64ab4915 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -47,14 +47,13 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; /** * Replaces any release versions with the latest snapshot version (if it has been deployed). @@ -191,65 +190,58 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection= MAJOR.value() - ? versionComparator.incrementSegment( lowerBound, unchangedSegment.get() ) - : null; - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - ArtifactVersion[] newer = versions.getVersions( restriction, true ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); + ArtifactVersion upperBound = unchangedSegment + .map( s -> + (ArtifactVersion) new BoundArtifactVersion( lowerBound, Segment.of( s.value() + 1 ) ) ) + .orElse( null ); + + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + ArtifactVersion[] newer = versions.getVersions( restriction, true ); + getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - // TODO consider creating a search + filter in the Details services to get latest snapshot. - String latestVersion; - ArrayList snapshotsOnly = new ArrayList<>(); + // TODO consider creating a search + filter in the Details services to get latest snapshot. + String latestVersion; + ArrayList snapshotsOnly = new ArrayList<>(); - for ( ArtifactVersion artifactVersion : newer ) + for ( ArtifactVersion artifactVersion : newer ) + { + String newVersion = artifactVersion.toString(); + if ( matchSnapshotRegex.matcher( newVersion ).matches() ) { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) - { - snapshotsOnly.add( artifactVersion ); - } + snapshotsOnly.add( artifactVersion ); } - ArtifactVersion[] filteredVersions = snapshotsOnly.toArray( - new ArtifactVersion[snapshotsOnly.size()] ); - if ( filteredVersions.length > 0 ) + } + ArtifactVersion[] filteredVersions = snapshotsOnly.toArray( + new ArtifactVersion[snapshotsOnly.size()] ); + if ( filteredVersions.length > 0 ) + { + latestVersion = filteredVersions[filteredVersions.length - 1].toString(); + if ( getProject().getParent() != null ) { - latestVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + final Artifact parentArtifact = getProject().getParentArtifact(); + if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) + if ( PomHelper.setProjectParentVersion( pom, latestVersion ) ) { - if ( PomHelper.setProjectParentVersion( pom, latestVersion ) ) - { - getLog().debug( "Made parent update from " + version + " to " + latestVersion ); + getLog().debug( "Made parent update from " + version + " to " + latestVersion ); - this.getChangeRecorder() - .recordUpdate( "useLatestSnapshots", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), version, latestVersion ); - } + this.getChangeRecorder() + .recordUpdate( "useLatestSnapshots", parentArtifact.getGroupId(), + parentArtifact.getArtifactId(), version, latestVersion ); } } + } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - latestVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + latestVersion ); + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + latestVersion, getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + latestVersion ); - this.getChangeRecorder().recordUpdate( "useLatestSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, latestVersion ); - } + this.getChangeRecorder().recordUpdate( "useLatestSnapshots", dep.getGroupId(), + dep.getArtifactId(), version, latestVersion ); } } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), - dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); - } } } } diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index a9e693a5bb..b7482490ca 100644 --- a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -46,13 +46,11 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; - /** * Replaces any release versions with the next snapshot version (if it has been deployed). * @@ -178,38 +176,32 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection + (ArtifactVersion) new BoundArtifactVersion( lowerBound, Segment.of( s.value() + 1 ) ) ) + .orElse( null ); + + getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); + Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); + ArtifactVersion[] newer = versions.getVersions( restriction, true ); + getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); + for ( ArtifactVersion artifactVersion : newer ) { - ArtifactVersion upperBound = unchangedSegment.isPresent() - && unchangedSegment.get().value() >= MAJOR.value() - ? versionComparator.incrementSegment( lowerBound, unchangedSegment.get() ) - : null; - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - ArtifactVersion[] newer = versions.getVersions( restriction, true ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - for ( ArtifactVersion artifactVersion : newer ) + String newVersion = artifactVersion.toString(); + if ( matchSnapshotRegex.matcher( newVersion ).matches() ) { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, + newVersion, getProject().getModel() ) ) { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useNextSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); - } - break; + getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + + this.getChangeRecorder().recordUpdate( "useNextSnapshots", dep.getGroupId(), + dep.getArtifactId(), version, newVersion ); } + break; } } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), - dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); - } } } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index ed8134ba89..1d3f9665fd 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -233,20 +233,18 @@ public final ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, + public final ArtifactVersion[] getNewerVersions( String versionString, Optional unchangedSegment, boolean includeSnapshots, boolean allowDowngrade ) throws InvalidSegmentException { ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); ArtifactVersion lowerBound = allowDowngrade - ? getLowerBound( currentVersion, upperBoundSegment ) + ? getLowerBound( currentVersion, unchangedSegment ) .map( DefaultArtifactVersion::new ) .orElse( null ) : currentVersion; ArtifactVersion upperBound = - !upperBoundSegment.isPresent() - ? null - : upperBoundSegment + unchangedSegment .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s.isMajorTo( SUBINCREMENTAL ) ? Segment.of( s.value() + 1 ) diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index db28d1e990..ec624f677b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -23,6 +23,8 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -112,6 +114,38 @@ public int compareTo( ArtifactVersions that ) : compare( getVersion(), that.getVersion() ); } + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + + if ( !( o instanceof ArtifactVersions ) ) + { + return false; + } + + ArtifactVersions that = (ArtifactVersions) o; + + return new EqualsBuilder() + .append( getArtifact(), that.getArtifact() ) + .append( getVersions(), that.getVersions() ) + .append( getVersionComparator(), that.getVersionComparator() ) + .isEquals(); + } + + @Override + public int hashCode() + { + return new HashCodeBuilder( 17, 37 ) + .append( getArtifact() ) + .append( getVersions() ) + .append( getVersionComparator() ) + .toHashCode(); + } + /** * Checks if the version is in the range (and ensures that the range respects the -! syntax to rule out * any qualifiers from range boundaries). diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 9b25e60462..fb4867604d 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -432,21 +432,6 @@ else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) return result; } - private ArtifactVersion getNewestVersion( String currentVersion, VersionsHelper helper, - Optional unchangedSegment, - boolean includeSnapshots, VersionRange range ) - throws InvalidSegmentException - { - ArtifactVersion lowerBound = helper.createArtifactVersion( currentVersion ); - ArtifactVersion upperBound = null; - if ( unchangedSegment.isPresent() ) - { - upperBound = getVersionComparator().incrementSegment( lowerBound, unchangedSegment.get() ); - } - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - return getNewestVersion( range, restriction, includeSnapshots ); - } - private final class PropertyVersionComparator implements VersionComparator { public int compare( ArtifactVersion v1, ArtifactVersion v2 ) @@ -507,33 +492,5 @@ public int getSegmentCount( ArtifactVersion v ) } return result; } - - public ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException - { - if ( !isAssociated() ) - { - throw new IllegalStateException( "Cannot compare versions for a property with no associations" ); - } - VersionComparator[] comparators = lookupComparators(); - assert comparators.length >= 1 : "we have at least one association => at least one comparator"; - ArtifactVersion result = comparators[0].incrementSegment( v, segment ); - for ( int i = 1; i < comparators.length; i++ ) - { - ArtifactVersion alt = comparators[i].incrementSegment( v, segment ); - if ( !result.toString().equals( alt.toString() ) ) - { - throw new IllegalStateException( - "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the two of versions being compared.\n" - + "First rule says incrementSegment(\"" - + v + "\", " + segment + ") = " + result - + "\nSecond rule says incrementSegment(\"" + v + "\", " - + segment + ") = " + alt ); - } - } - return result; - } - } } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index ecc87f1a39..30a4835026 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -20,7 +20,6 @@ */ import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; /** * Base class for version comparators. @@ -54,18 +53,6 @@ public final int getSegmentCount( ArtifactVersion v ) protected abstract int innerGetSegmentCount( ArtifactVersion v ); - /** - * {@inheritDoc} - */ - public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException - { - return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), - segment ) ); - } - - protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) - throws InvalidSegmentException; - /** * Returns a hash code value for the comparator class. * diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java b/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java index 2f923668e6..49b043e82e 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java @@ -3,6 +3,8 @@ import java.util.Iterator; import java.util.List; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.codehaus.mojo.versions.api.Segment; @@ -26,7 +28,6 @@ public class BoundArtifactVersion extends DefaultArtifactVersion * All segments that are more major than this one are held in place. */ private final Segment segment; - private final BoundComparableVersion comparator; /** @@ -62,9 +63,42 @@ public int compareTo( ArtifactVersion other ) return comparator.compareTo( new ComparableVersion( other.toString() ) ); } + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + + if ( !( o instanceof BoundArtifactVersion ) ) + { + return false; + } + + BoundArtifactVersion that = (BoundArtifactVersion) o; + + return new EqualsBuilder() + .appendSuper( super.equals( o ) ) + .append( getSegment(), that.getSegment() ) + .append( comparator, that.comparator ) + .isEquals(); + } + + @Override + public int hashCode() + { + return new HashCodeBuilder( 17, 37 ) + .appendSuper( super.hashCode() ) + .append( getSegment() ) + .append( comparator ) + .toHashCode(); + } + protected static class BoundComparableVersion extends ComparableVersion { private BoundArtifactVersion artifactVersion; + protected BoundComparableVersion( BoundArtifactVersion artifactVersion ) { super( artifactVersion.toString() ); @@ -74,20 +108,43 @@ protected BoundComparableVersion( BoundArtifactVersion artifactVersion ) @Override public int compareTo( ComparableVersion o ) { + // all segments more or equally major than artifactVersion.segment can change return compareTo( ( (List) items ).iterator(), ( (Iterable) o.items ).iterator(), artifactVersion.segment.value() ); } - @SuppressWarnings( "checkstyle:InnerAssignment" ) - private int compareTo( Iterator left, Iterator right, int comparisonLimit ) + private int compareTo( Iterator left, Iterator right, int comparisonsLeft ) + { + if ( comparisonsLeft <= 0 ) + { + // always greater than the other version if all more major segments are equal + return 1; + } + + int result = left.hasNext() && right.hasNext() + ? integerItemOrZero( left.next() ).compareTo( right.next() ) + : left.hasNext() || right.hasNext() + ? compareToZero( left, right ) + : 1; + + return result != 0 + ? result + : compareTo( left, right, comparisonsLeft - 1 ); + } + + private static int compareToZero( Iterator left, Iterator right ) + { + return left.hasNext() + ? integerItemOrZero( left.next() ).compareTo( ZERO ) + : -right.next().compareTo( ZERO ); + } + + private static Item integerItemOrZero( Item item ) { - int r; - return !( comparisonLimit > 0 && right.hasNext() ) - ? 1 - : ( r = -( right.next().compareTo( left.hasNext() ? left.next() : ZERO ) ) ) != 0 - ? r - : compareTo( left, right, comparisonLimit - 1 ); + return item instanceof IntegerItem + ? item + : ZERO; } } } diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 50edfe7e89..91a40848c8 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -44,17 +44,6 @@ public interface VersionComparator */ int getSegmentCount( ArtifactVersion artifactVersion ); - /** - * Increment the specified segment of the supplied version. - * - * @param artifactVersion The artifact version to increment. - * @param segment The segment number to increment. - * @return An artifact version with the specified segment incremented. - * @since 1.0-beta-1 - * @throws InvalidSegmentException if {@code segment} ∉ [0, segmentCount) - */ - ArtifactVersion incrementSegment( ArtifactVersion artifactVersion, Segment segment ) throws InvalidSegmentException; - /** *

    Returns a {@linkplain Restriction} object for computing version upgrades * with the given segment allowing updates, with all more major segments locked in place.

    @@ -73,10 +62,11 @@ public interface VersionComparator default Restriction restrictionFor( ArtifactVersion currentVersion, Optional scope ) throws InvalidSegmentException { - ArtifactVersion nextVersion = scope.isPresent() && scope.get().isMajorTo( SUBINCREMENTAL ) - ? incrementSegment( currentVersion, scope.get() ) - : currentVersion; - return new Restriction( nextVersion, nextVersion != currentVersion, scope.filter( MAJOR::isMajorTo ) + ArtifactVersion nextVersion = scope.filter( s -> s.isMajorTo( SUBINCREMENTAL ) ) + .map( s -> (ArtifactVersion) + new BoundArtifactVersion( currentVersion, Segment.of( s.value() + 1 ) ) ) + .orElse( currentVersion ); + return new Restriction( nextVersion, false, scope.filter( MAJOR::isMajorTo ) .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ).orElse( null ), false ); } diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index 3b31c751f4..37850e7dc9 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -343,4 +343,28 @@ public void testWrongReportBounds() throws IOException, MavenReportException matchesPattern( ".*report.overview.numNewerMajorAvailable\\s*1.*" ), matchesPattern( ".*report.overview.numUpToDate\\s*0.*" ) ) ); } + + @Test + public void testIt001Overview() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReportMojo() + .withOnlyUpgradable( true ) + .withDependencies( + dependencyOf( "test-artifact", "1.1" ) ) + .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + {{ + put( "test-artifact", new String[] { "1.1.0-2", "1.1", "1.1.1", "1.1.1-2", + "1.1.2", "1.1.3", "1.2", "1.2.1", "1.2.2", "1.3", "2.0", "2.1", "3.0"} ); + }} ) ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString() + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ); + assertThat( "Did not generate summary correctly", output, + containsString( "groupA test-artifact 1.1 compile pom default 1.1.0-2 1.1.3 1.3 3.0" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index 05de76fc17..1f4b3633e1 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -26,15 +26,16 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; import org.codehaus.mojo.versions.ordering.MercuryVersionComparator; -import org.hamcrest.Matchers; import org.junit.Test; import static java.util.Optional.of; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -56,14 +57,14 @@ public void test4DigitVersions() throws Exception assertEquals( "artifact", instance.getArtifactId() ); assertEquals( "group", instance.getGroupId() ); assertThat( instance.getVersions(), - Matchers.arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", + arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); assertThat( instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ), - Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); + arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); assertThat( instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ), //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); - Matchers.arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); + arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); assertEquals( new DefaultArtifactVersion( "2.121.2.1" ), instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), @@ -126,4 +127,18 @@ public void testReportLabels() assertThat( instance.getNewestUpdate( of( SUBINCREMENTAL ) ).toString(), is( "1.1.0-2" ) ); assertThat( instance.getNewestUpdate( of( INCREMENTAL ) ).toString(), is( "1.1.3" ) ); } + + @Test + public void testGetNewerVersionsWithSnapshot() throws InvalidSegmentException + { + ArtifactVersion[] versions = versions( "1.0.0-SNAPSHOT", "1.0.0" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.0.0-SNAPSHOT", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + + assertThat( instance.getNewerVersions( "1.0.0-SNAPSHOT", of( SUBINCREMENTAL ), false, false ), + arrayContaining( new DefaultArtifactVersion( "1.0.0" ) ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java new file mode 100644 index 0000000000..d62e972303 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java @@ -0,0 +1,106 @@ +package org.codehaus.mojo.versions.ordering; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.codehaus.mojo.versions.api.Segment; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.lessThan; + +/** + * Unit tests for {@link BoundArtifactVersion} + */ +public class BoundArtifactVersionTest +{ + @Test + public void testMajorUpperBoundGreaterThanNextMajor() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3" ), + Segment.MAJOR ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "2.0.0" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testSubIncrementalUpperBoundGreaterThanNextSubIncremental() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3-2" ), + Segment.SUBINCREMENTAL ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.2.3-3" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testVersionShorterThanSegment() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + Segment.INCREMENTAL ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testVersionBoundArtifactVersionShorterThanConcreteVersionAndSegment() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + Segment.SUBINCREMENTAL ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); + assertThat( bound.compareTo( artifactVersion ), lessThan( 0 ) ); + } + + @Test + public void testVersionSubIncrementalBoundGreaterThanSubIncremental() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + Segment.SUBINCREMENTAL ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.0-2" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testVersionSubIncrementalBoundGreaterThanIncremental() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + Segment.INCREMENTAL ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testVersionSubIncrementalBoundGreaterThanMinor() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + Segment.MINOR ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.3" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } + + @Test + public void testSnapshotWithSubIncremental() + { + BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), + Segment.MINOR ); + ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.0.0" ); + assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index 2369712084..452ef34786 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -20,88 +20,63 @@ */ import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.core.Is.is; -public class MavenVersionComparatorTest +public class MavenVersionComparatorTest extends VersionComparatorTestBase { - private MavenVersionComparator instance = new MavenVersionComparator(); - - @Test - public void testSegmentCounting() - throws Exception + public MavenVersionComparatorTest() { - assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ) ); - assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ) ); - assertThat( 4, is( instance.getSegmentCount( new DefaultArtifactVersion( "5-0" ) ) ) ); - assertThat( 1, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.3.a" ) ) ) ); - assertThat( 1, is( instance.getSegmentCount( new DefaultArtifactVersion( "5.0.a.1.4.5" ) ) ) ); - assertThat( 3, is( instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ) ); + super( new MavenVersionComparator() ); } @Test - public void testSegmentIncrementing() throws InvalidSegmentException - { - assertIncrement( "6-SNAPSHOT", "5", MAJOR ); - assertIncrement( "6.0-SNAPSHOT", "5.0", MAJOR ); - assertIncrement( "5.1-SNAPSHOT", "5.0", MINOR ); - assertIncrement( "5.1.0-SNAPSHOT", "5.0.1", MINOR ); - assertIncrement( "5.alpha.2-SNAPSHOT", "5.alpha.1", MAJOR ); - assertIncrement( "5.alpha-1.2-SNAPSHOT", "5.alpha-1.1", MAJOR ); - assertIncrement( "5.alpha-1.ba-SNAPSHOT", "5.alpha-1.az", MAJOR ); - assertIncrement( "5.alpha-wins.2-SNAPSHOT", "5.alpha-wins.1", MAJOR ); - assertIncrement( "1.0-alpha-3-SNAPSHOT", "1.0-alpha-2-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-alpha-90-SNAPSHOT", "1.0-alpha-9-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-za-SNAPSHOT", "1.0-z-SNAPSHOT", SUBINCREMENTAL ); - assertIncrement( "1.0-z90-SNAPSHOT", "1.0-z9-SNAPSHOT", SUBINCREMENTAL ); - } - - private void assertIncrement( String expected, String initial, Segment segment ) throws InvalidSegmentException + public void testSegmentCounting() { - assertThat( instance.incrementSegment( new DefaultArtifactVersion( initial ), segment ).toString(), - is( expected ) ); + assertThat( 3, is( instance.getSegmentCount( version( "5" ) ) ) ); + assertThat( 3, is( instance.getSegmentCount( version( "5.0" ) ) ) ); + assertThat( 4, is( instance.getSegmentCount( version( "5-0" ) ) ) ); + assertThat( 1, is( instance.getSegmentCount( version( "5.3.a" ) ) ) ); + assertThat( 1, is( instance.getSegmentCount( version( "5.0.a.1.4.5" ) ) ) ); + assertThat( 3, is( instance.getSegmentCount( version( "" ) ) ) ); } @Test public void testUpperBoundaryCustom() { - assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3" ), - INCREMENTAL ), new DefaultArtifactVersion( "1.2.3-ANDRZEJ" ) ), greaterThan( 0 ) ); + assertThat( instance.compare( new BoundArtifactVersion( version( "1.2.3" ), + INCREMENTAL ), version( "1.2.3-ANDRZEJ" ) ), greaterThan( 0 ) ); } @Test public void testUpperBoundaryRelease() { - assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.1.0" ), - INCREMENTAL ), new DefaultArtifactVersion( "1.1.0" ) ), greaterThan( 0 ) ); + assertThat( instance.compare( new BoundArtifactVersion( version( "1.1.0" ), + INCREMENTAL ), version( "1.1.0" ) ), greaterThan( 0 ) ); } @Test public void testUpperBoundarySnapshot() { - assertThat( instance.compare( new BoundArtifactVersion( new DefaultArtifactVersion( "1.1.0" ), - INCREMENTAL ), new DefaultArtifactVersion( "1.1.0-SNAPSHOT" ) ), greaterThan( 0 ) ); + assertThat( instance.compare( new BoundArtifactVersion( version( "1.1.0" ), + INCREMENTAL ), version( "1.1.0-SNAPSHOT" ) ), greaterThan( 0 ) ); } @Test public void testScopeLessThanNumSegmentsUpper() { - ArtifactVersion artifactVersion = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), + ArtifactVersion artifactVersion = new BoundArtifactVersion( version( "1.1" ), SUBINCREMENTAL ); - assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.0.1" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1-SNAPSHOT" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1.0-2" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( new DefaultArtifactVersion( "1.1.1-2" ) ), lessThan( 0 ) ); + assertThat( artifactVersion.compareTo( version( "1.0.1" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( version( "1.1-SNAPSHOT" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( version( "1.1" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( version( "1.1.0-2" ) ), greaterThan( 0 ) ); + assertThat( artifactVersion.compareTo( version( "1.1.1-2" ) ), lessThan( 0 ) ); } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index 52d2b6553d..9af7bbc4c6 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -22,17 +22,17 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.junit.Assert.assertEquals; -public class MercuryVersionComparatorTest +public class MercuryVersionComparatorTest extends VersionComparatorTestBase { - private MercuryVersionComparator instance = new MercuryVersionComparator(); + public MercuryVersionComparatorTest() + { + super( new MercuryVersionComparator() ); + } @Test - public void testSegmentCounting() throws Exception + public void testSegmentCounting() { assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); @@ -42,24 +42,5 @@ public void testSegmentCounting() throws Exception assertEquals( 0, instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ); } - @Test - public void testSegmentIncrementing() throws Exception - { - assertEquals( new DefaultArtifactVersion( "6-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta-0.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); - } + } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index 817468f86d..3b858ee5d4 100644 --- a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -22,15 +22,15 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.junit.Test; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class NumericVersionComparatorTest +public class NumericVersionComparatorTest extends VersionComparatorTestBase { - private NumericVersionComparator instance = new NumericVersionComparator(); + public NumericVersionComparatorTest() + { + super( new NumericVersionComparator() ); + } private int instanceCompare( String v1, String v2 ) { @@ -39,7 +39,6 @@ private int instanceCompare( String v1, String v2 ) @Test public void testSmokes() - throws Exception { assertTrue( instanceCompare( "1.0.0.0.0", "1.0.0.0.1" ) < 0 ); assertTrue( instanceCompare( "1.0.0.0.0", "2.0.0.0.1" ) < 0 ); @@ -50,7 +49,6 @@ public void testSmokes() @Test public void testBigValues() - throws Exception { assertTrue( instanceCompare( "1.92.0", "1.100000000000000000000000.0" ) < 0 ); assertTrue( instanceCompare( "1.100000000000000000000000.0", "1.92.0" ) > 0 ); @@ -59,7 +57,6 @@ public void testBigValues() @Test public void testStringValues() - throws Exception { assertTrue( instanceCompare( "1.a20.0", "1.a3.0" ) < 0 ); assertTrue( instanceCompare( "1.a20.0", "1.b10.0" ) < 0 ); @@ -81,7 +78,6 @@ public void testStringValues() @Test public void testQualifiers() - throws Exception { assertTrue( instanceCompare( "1.0-alpha.10", "1.0-alpha.20" ) < 0 ); assertTrue( instanceCompare( "1.0-alpha.10", "1.0-beta.1" ) < 0 ); @@ -92,7 +88,6 @@ public void testQualifiers() @Test public void testSegmentCounting() - throws Exception { assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); @@ -102,25 +97,15 @@ public void testSegmentCounting() assertEquals( 0, instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ); } - @Test - public void testSegmentIncrementing() throws Exception + @Override + public void testVersionComparatorRow5() + { + // non-numeric -- does not apply + } + + @Override + public void testVersionComparatorRow6() { - assertEquals( new DefaultArtifactVersion( "6-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "6.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MAJOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.1.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.0.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-2.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), MINOR ).toString() ); - assertEquals( new DefaultArtifactVersion( "5.alpha-1.2-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-1.1" ), INCREMENTAL ) - .toString() ); - assertEquals( new DefaultArtifactVersion( "5.beta.0-SNAPSHOT" ).toString(), - instance.incrementSegment( new DefaultArtifactVersion( "5.alpha-wins.1" ), MINOR ).toString() ); + // non-numeric -- does not apply } } diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java new file mode 100644 index 0000000000..28e326a2ec --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java @@ -0,0 +1,100 @@ +package org.codehaus.mojo.versions.ordering; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.lessThan; + +/** + * Abstract base class for {@link MavenVersionComparatorTest}, {@link MercuryVersionComparatorTest}, + * and {@link NumericVersionComparatorTest} + */ +public abstract class VersionComparatorTestBase +{ + protected final VersionComparator instance; + + public VersionComparatorTestBase( VersionComparator instance ) + { + this.instance = instance; + } + + protected static ArtifactVersion version( String version ) + { + return new DefaultArtifactVersion( version ); + } + + @Test + public void testVersionComparatorRow1() + { + assertThat( instance.compare( version( "1" ), version( "2" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0" ), version( "2.0" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow2() + { + assertThat( instance.compare( version( "1.0" ), version( "2.0" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow3() + { + assertThat( instance.compare( version( "1.0.0" ), version( "2.0.0" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0" ), version( "1.1.0" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0" ), version( "1.0.1" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow4() + { + assertThat( instance.compare( version( "1.0.0-1" ), version( "2.0.0-1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-1" ), version( "1.1.0-1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-1" ), version( "1.0.1-1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-1" ), version( "1.0.0-2" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow5() + { + assertThat( instance.compare( version( "1.0.0-sp1" ), version( "2.0.0-sp1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.1.0-sp1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.0.1-sp1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.0.0-1-sp1" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow6() + { + assertThat( instance.compare( version( "foobar" ), version( "foobar-1" ) ), lessThan( 0 ) ); + } + + @Test + public void testVersionComparatorRow7() + { + assertThat( instance.compare( version( "1-alpha-1" ), version( "2-alpha-1" ) ), lessThan( 0 ) ); + assertThat( instance.compare( version( "1-alpha-1" ), version( "1-alpha-2" ) ), lessThan( 0 ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java b/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java deleted file mode 100644 index c33852d23e..0000000000 --- a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorsTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.codehaus.mojo.versions.ordering; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class VersionComparatorsTest -{ - private final String[] versionDataset = { - "1", - "1.0", - "1.0.0", - "1.0.0-1", - "1.0.0-sp1", - "foobar", - "1-alpha-1", - }; - - @Test - public void testMavenVersionComparator() throws InvalidSegmentException - { - assertVersions( new MavenVersionComparator() ); - } - - @Test - public void testMercuryVersionComparator() throws InvalidSegmentException - { - assertVersions( new MercuryVersionComparator() ); - } - - @Test - public void testNumericVersionComparator() throws InvalidSegmentException - { - assertVersions( new NumericVersionComparator() ); - } - - public void assertVersions( VersionComparator instance ) throws InvalidSegmentException - { - for ( String s : versionDataset ) - { - assertLater( s, instance ); - assertLater( s + "-SNAPSHOT", instance ); - } - } - - public void assertLater( String version, VersionComparator instance ) throws InvalidSegmentException - { - ArtifactVersion v1 = new DefaultArtifactVersion( version ); - int count = instance.getSegmentCount( v1 ); - for ( int i = 0; i < count; i++ ) - { - ArtifactVersion v2 = instance.incrementSegment( v1, Segment.of( i ) ); - assertTrue( v1 + " < " + v2, instance.compare( v1, v2 ) < 0 ); - } - } -} From 4aa3d9c8ced41f4d3ea7cdbe98733edc7d8eebc6 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 23 Oct 2022 17:41:43 +0200 Subject: [PATCH 179/441] [maven-release-plugin] prepare release 2.13.0 --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5467043ad7..22e4213272 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.13.0-SNAPSHOT + 2.13.0 maven-plugin Versions Maven Plugin @@ -102,7 +102,7 @@ scm:git:https://github.com/mojohaus/versions-maven-plugin.git scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git https://github.com/mojohaus/versions-maven-plugin/tree/master - HEAD + 2.13.0 @@ -115,7 +115,7 @@ 1.11.1 ${project.version} 3.7 - 2022-10-10T21:19:23Z + 2022-10-23T15:39:53Z From 1826b64b7b8fd2c2746a78383711c83f6d23462b Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 23 Oct 2022 17:41:47 +0200 Subject: [PATCH 180/441] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 22e4213272..1e04469689 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ versions-maven-plugin - 2.13.0 + 2.14.0-SNAPSHOT maven-plugin Versions Maven Plugin @@ -115,7 +115,7 @@ 1.11.1 ${project.version} 3.7 - 2022-10-23T15:39:53Z + 2022-10-23T15:41:47Z From 89d8e7949bfe714e51e88e459d0a77db1bceea03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 13:23:04 +0000 Subject: [PATCH 181/441] Bump plexus-utils from 3.4.2 to 3.5.0 Bumps [plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.4.2 to 3.5.0. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.4.2...plexus-utils-3.5.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1e04469689..8cba2fa141 100644 --- a/pom.xml +++ b/pom.xml @@ -222,7 +222,7 @@ org.codehaus.plexus plexus-utils - 3.4.2 + 3.5.0 org.codehaus.plexus From a3f0515cd0d8c55ef0627ba52affac50ac7bb782 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 18:53:30 +0200 Subject: [PATCH 182/441] #725: Migrate Update Properties to Markdown --- .../examples/update-properties.md.vm} | 176 ++++++++---------- 1 file changed, 82 insertions(+), 94 deletions(-) rename src/site/{apt/examples/update-properties.apt.vm => markdown/examples/update-properties.md.vm} (61%) diff --git a/src/site/apt/examples/update-properties.apt.vm b/src/site/markdown/examples/update-properties.md.vm similarity index 61% rename from src/site/apt/examples/update-properties.apt.vm rename to src/site/markdown/examples/update-properties.md.vm index e2aec7f8fa..8d00778d7f 100644 --- a/src/site/apt/examples/update-properties.apt.vm +++ b/src/site/markdown/examples/update-properties.md.vm @@ -1,35 +1,31 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Update Properties - ----- - Stephen Connolly - ------ - 2009-03-27 - ------ - -Update Properties - - This goal is useful when you define dependency versions using properties. For example if you have a suite of projects - and you want to ensure that you use the same version of each dependency in the suite, you might have a dependency - section that looks like this: - ---- +title: Update Properties +author: Stephen Connolly +date: 2009-03-27 + + + +# Update Properties + +This goal is useful when you define dependency versions using properties. For example if you have a suite of projects +and you want to ensure that you use the same version of each dependency in the suite, you might have a dependency +section that looks like this: + +```xml ... @@ -55,15 +51,15 @@ Update Properties ... ---- +``` - The aim being to allow updating the version of all the suite components in one go. The versions-maven-plugin can help - you to automate these updates. +The aim being to allow updating the version of all the suite components in one go. The versions-maven-plugin can help +you to automate these updates. - By default, the versions-maven-plugin will look at the dependencies in your POM. If any dependencies declare a version - which depends on evaluating a single property that is defined in the POM, for example: +By default, the versions-maven-plugin will look at the dependencies in your POM. If any dependencies declare a version +which depends on evaluating a single property that is defined in the POM, for example: ---- +```xml com.foo.bar @@ -91,16 +87,16 @@ Update Properties manchu-core [1.0.0,${manchu.version}] ---- +``` - If multiple dependencies use the property to define the version, then the all dependencies will be used to determine - what versions are available (and consequently what version to update the property to). The version chosen in such - cases must be available for all associated dependencies. +If multiple dependencies use the property to define the version, then the all dependencies will be used to determine +what versions are available (and consequently what version to update the property to). The version chosen in such +cases must be available for all associated dependencies. - The automatic detection can be assisted by adding a version-maven-plugin configuration section to the POM, - for example if we add the following to the POM: +The automatic detection can be assisted by adding a version-maven-plugin configuration section to the POM, +for example if we add the following to the POM: ---- +```xml ... @@ -137,16 +133,16 @@ Update Properties ... ---- +``` - Then executing the <<>> goal will update the <<>> property to the latest common - version of both manchu-core and manchu-wibble available to you (i.e. based on your local repository and all - currently active remote repositories). +Then executing the `update-properties` goal will update the `manchu.version` property to the latest common +version of both manchu-core and manchu-wibble available to you (i.e. based on your local repository and all +currently active remote repositories). - If you want to restrict updates to within a specific range, for example, suppose we only want the 1.5 stream of - manchu: +If you want to restrict updates to within a specific range, for example, suppose we only want the 1.5 stream of +manchu: ---- +```xml ... @@ -178,11 +174,11 @@ Update Properties ... ---- +``` - Additionally, if you want to disable the automatic detection of properties set the autoLinkItemDependencies to false +Additionally, if you want to disable the automatic detection of properties set the autoLinkItemDependencies to false ---- +```xml ... @@ -214,13 +210,13 @@ Update Properties ... ---- +``` - By default, the reactor will also be searched to see if it can satisfy the property's associated dependencies. - If you want to disable the preference given to the reactor (i.e. stop the reactor version always winning) +By default, the reactor will also be searched to see if it can satisfy the property's associated dependencies. +If you want to disable the preference given to the reactor (i.e. stop the reactor version always winning) ---- +```xml ... @@ -252,11 +248,11 @@ Update Properties ... ---- +``` - If you want to disable the searching the reactor at all: +If you want to disable the searching the reactor at all: ---- +```xml ... @@ -288,12 +284,12 @@ Update Properties ... ---- +``` - The allowSnapshots property and configuration option allow the inclusion of snapshots, if you want to ensure that - snapshots are never resolved, +The allowSnapshots property and configuration option allow the inclusion of snapshots, if you want to ensure that +snapshots are *never* resolved, ---- +```xml ... @@ -327,22 +323,22 @@ Update Properties ... ---- +``` -* Restricting the properties to be updated using includes / excludes +## Restricting the properties to be updated using includes / excludes - The <> and <>> parameters follow the format <<>>. - Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. +The **includes** and **excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match +multiple values. - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". - Only properties that map to artifacts that are allowed by the inclusion and exclusion patterns will be updated. +Only properties that map to artifacts that are allowed by the inclusion and exclusion patterns will be updated. - With a project that looks like this: +With a project that looks like this: ---- +```xml ... @@ -375,29 +371,21 @@ Update Properties ... ---- +``` - To update the property for only the "com.foo.bar" dependencies, you can run: +To update the property for only the "com.foo.bar" dependencies, you can run: -+---+ +```shell mvn versions:update-properties -Dincludes=com.foo.bar:* -+---+ +``` - Would result in the property for the manchu.version being updated, but not the blarg.version property. +Would result in the property for the manchu.version being updated, but not the blarg.version property. - In the above example, you could achieve the same result using: +In the above example, you could achieve the same result using: -+---+ +```shell mvn versions:update-properties -Dexcludes=org.blarg:* -+---+ - - If a property is used by artifacts that are not allowed by the set of specified <> and <> then the property - will not be updated. - - - - - - - +``` +If a property is used by artifacts that are not allowed by the set of specified **includes** and **excludes** then the property +will not be updated. From abc2e9726701056043804364f7d73f32e0520e2d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 19:42:14 +0200 Subject: [PATCH 183/441] #725: Migrate Use Releases to Markdown --- src/site/apt/examples/use-releases.apt | 99 ---------------------- src/site/markdown/examples/use-releases.md | 94 ++++++++++++++++++++ 2 files changed, 94 insertions(+), 99 deletions(-) delete mode 100644 src/site/apt/examples/use-releases.apt create mode 100644 src/site/markdown/examples/use-releases.md diff --git a/src/site/apt/examples/use-releases.apt b/src/site/apt/examples/use-releases.apt deleted file mode 100644 index 456a65ae2c..0000000000 --- a/src/site/apt/examples/use-releases.apt +++ /dev/null @@ -1,99 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Replacing -SNAPSHOT versions with their corresponding releases - ----- - Stephen Connolly, Paul Gier - ------ - 2009-04-20 - ------ - -Replacing -SNAPSHOT versions with their corresponding releases - - If you need a new feature that is being developed in a dependency of your project, and that feature has not been - released yet, you may decide to add a dependency on the -SNAPSHOT version of the next release: - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-alpha-7-SNAPSHOT - - - -+---+ - - At some stage, this -SNAPSHOT version will be released. The <<>> goal, will look at all your project - dependencies and see what -SNAPSHOT versions have been released. If any of your projects -SNAPSHOT versions have - a corresponding release version, then it will replace the -SNAPSHOT with its corresponding release version. - ---- -mvn versions:use-releases ---- - - When org.codehaus.cargo:cargo-core-api releases the 1.0-alpha-7 version this would update the pom to look like: - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-alpha-7 - - - -+---+ - - You can restrict which dependencies should be processed. For example, - the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId - "plexus-utils" - ---- -mvn versions:use-releases -Dincludes=org.codehaus.plexus:plexus-utils ---- - - The <<>> and <<>> parameters follow the format <<>>. - Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. - - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". - ---- -mvn versions:use-releases -Dincludes=org.codehaus.plexus:*,junit:junit ---- - - By default, both the <<>> and <<>> sections will be processed. - You can use the <<>> and <<>> parameters to control which sections - are processed. - - This example will only process the <<>> section of your pom: - ---- -mvn versions:use-releases -DprocessDependencies=false ---- - - While this example will only process the <<>> section of your pom: - ---- -mvn versions:use-releases -DprocessDependencyManagement=false ---- - diff --git a/src/site/markdown/examples/use-releases.md b/src/site/markdown/examples/use-releases.md new file mode 100644 index 0000000000..c313fe5613 --- /dev/null +++ b/src/site/markdown/examples/use-releases.md @@ -0,0 +1,94 @@ +title: Replacing -SNAPSHOT versions with their corresponding releases +author: Stephen Connolly, Paul Gier +date: 2009-04-20 + + + +# Replacing -SNAPSHOT versions with their corresponding releases + +If you need a new feature that is being developed in a dependency of your project, and that feature has not been +released yet, you may decide to add a dependency on the -SNAPSHOT version of the next release: + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-alpha-7-SNAPSHOT + + + +``` + +At some stage, this -SNAPSHOT version will be released. The `use-releases` goal, will look at all your project +dependencies and see what -SNAPSHOT versions have been released. If any of your projects -SNAPSHOT versions have +a corresponding release version, then it will replace the -SNAPSHOT with its corresponding release version. + +```shell +mvn versions:use-releases +``` + +When org.codehaus.cargo:cargo-core-api releases the 1.0-alpha-7 version this would update the pom to look like: + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-alpha-7 + + + +``` + +You can restrict which dependencies should be processed. For example, +the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId +"plexus-utils" + +```shell +mvn versions:use-releases -Dincludes=org.codehaus.plexus:plexus-utils +``` + +The `includes` and `excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match +multiple values. + +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". + +```shell +mvn versions:use-releases -Dincludes=org.codehaus.plexus:*,junit:junit +``` + +By default, both the `project/dependencyManagment` and `project/dependencies` sections will be processed. +You can use the `processDependencies` and `processDependencyManagement` parameters to control which sections +are processed. + +This example will only process the `project/dependencyManagment` section of your pom: + +```shell +mvn versions:use-releases -DprocessDependencies=false +``` + +While this example will only process the `project/dependencies` section of your pom: + +```shell +mvn versions:use-releases -DprocessDependencyManagement=false +``` From f793fe1741033393a0ead9b91363bd9ab5951597 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 18:42:28 +0200 Subject: [PATCH 184/441] #725: Migrate Update Child Modules to Markdown --- .../apt/examples/update-child-modules.apt | 129 ------------------ .../markdown/examples/update-child-modules.md | 123 +++++++++++++++++ 2 files changed, 123 insertions(+), 129 deletions(-) delete mode 100644 src/site/apt/examples/update-child-modules.apt create mode 100644 src/site/markdown/examples/update-child-modules.md diff --git a/src/site/apt/examples/update-child-modules.apt b/src/site/apt/examples/update-child-modules.apt deleted file mode 100644 index 12ab4385a3..0000000000 --- a/src/site/apt/examples/update-child-modules.apt +++ /dev/null @@ -1,129 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Fixing a multi-module build - ----- - Stephen Connolly - ------ - 2008-09-25 - ------ - -Fixing a multi-module build - - If you have a multi-module build where the aggregator pom (i.e. the one with packaging of <<>> and the - <<>> section) is also the parent referenced by its child modules, and the aggregator version does not - match the version specified in the parent section of the child modules, Maven will not let you build the project. - - The <<>> is designed to try and help you fix these kind of build failures. - - You know you have this kind of problem when you see output from Maven like this: - ---- -[INFO] Scanning for projects... -[INFO] ------------------------------------------------------------------------ -[ERROR] FATAL ERROR -[INFO] ------------------------------------------------------------------------ -[INFO] Error building POM (may not be this project's POM). - - -Project ID: com.foo.bar:bar-child:jar:null - -Reason: Cannot find parent: com.foo.bar:bar for project: com.foo.bar:bar-child:jar:null ---- - - The above example was for a project structured like this: - ---- -/pom.xml -/bar-child/pom.xml ---- - - With <<
    >> looking like - ---- - - 4.0.0 - - com.foo.bar - bar - 2.0 - pom - - - bar-child - - - ... - - ---- - - And with <<>> referencing a previous version of the parent: - ---- - - 4.0.0 - - - com.foo.bar - bar - 1.0 - - - bar-child - - ... - - ---- - - In order to fix the project, you need to either update the version of the child-module, or roll-back the version of - the parent module. When there is only one child module, this is easiest to do by hand. When there are many modules, - some referencing the new version and some referencing old versions of the parent, this is easiest to do using the - {{{../update-child-modules-mojo.html}versions:update-child-modules}} goal. - - Note: it is essential in this situation to run Maven with the <<<-N>>> option, as otherwise Maven will be unable - to run the goal. - ---- -mvn -N versions:update-child-modules ---- - - Which produces the following output: - ---- -[INFO] Scanning for projects... -[INFO] ------------------------------------------------------------------------ -[INFO] Building update-child-modules -[INFO] task-segment: [versions:update-child-modules] (aggregator-style) -[INFO] ------------------------------------------------------------------------ -[INFO] [versions:update-child-modules] -[INFO] Module: bar-child -[INFO] Parent was com.foo.bar:bar:1.0, now com.foo.bar:bar:2.0 -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESSFUL -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 3 seconds -[INFO] Finished at: Thu Nov 20 15:37:40 GMT 2008 -[INFO] Final Memory: 12M/288M -[INFO] ------------------------------------------------------------------------ ---- - - If you have several layers of projects, and the versions are really out of whack, you may have to change directory - into the child aggregator projects and re-run the {{{../update-child-modules-mojo.html}versions:update-child-modules}} - goal in order to finish fixing the project. diff --git a/src/site/markdown/examples/update-child-modules.md b/src/site/markdown/examples/update-child-modules.md new file mode 100644 index 0000000000..f9a8443b40 --- /dev/null +++ b/src/site/markdown/examples/update-child-modules.md @@ -0,0 +1,123 @@ +title: Fixing a multi-module build +author: Stephen Connolly +date: 2008-09-25 + + + +# Fixing a multi-module build + +If you have a multi-module build where the aggregator pom (i.e. the one with packaging of `pom` and the +`modules` section) is also the parent referenced by its child modules, and the aggregator version does not +match the version specified in the parent section of the child modules, Maven will not let you build the project. + +The `update-child-modules` is designed to try and help you fix these kind of build failures. + +You know you have this kind of problem when you see output from Maven like this: + +```log +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[ERROR] FATAL ERROR +[INFO] ------------------------------------------------------------------------ +[INFO] Error building POM (may not be this project's POM). + + +Project ID: com.foo.bar:bar-child:jar:null + +Reason: Cannot find parent: com.foo.bar:bar for project: com.foo.bar:bar-child:jar:null +``` + +The above example was for a project structured like this: + +- /pom.xml + - /bar-child/pom.xml + +With `/pom.xml` looking like + +```xml + + 4.0.0 + + com.foo.bar + bar + 2.0 + pom + + + bar-child + + + ... + + +``` + +And with `/bar-child/pom.xml` referencing a previous version of the parent: + +```xml + + 4.0.0 + + + com.foo.bar + bar + 1.0 + + + bar-child + + ... + + +``` + +In order to fix the project, you need to either update the version of the child-module, or roll-back the version of +the parent module. When there is only one child module, this is easiest to do by hand. When there are many modules, +some referencing the new version and some referencing old versions of the parent, this is easiest to do using the +[versions:update-child-modules](../update-child-modules-mojo.html) goal. + +Note: it is essential in this situation to run Maven with the `-N` option, as otherwise Maven will be unable +to run the goal. + +```shell +mvn -N versions:update-child-modules +``` + + Which produces the following output: + +```log +[INFO] Scanning for projects... +[INFO] ------------------------------------------------------------------------ +[INFO] Building update-child-modules +[INFO] task-segment: [versions:update-child-modules] (aggregator-style) +[INFO] ------------------------------------------------------------------------ +[INFO] [versions:update-child-modules] +[INFO] Module: bar-child +[INFO] Parent was com.foo.bar:bar:1.0, now com.foo.bar:bar:2.0 +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 3 seconds +[INFO] Finished at: Thu Nov 20 15:37:40 GMT 2008 +[INFO] Final Memory: 12M/288M +[INFO] ------------------------------------------------------------------------ +``` + +If you have several layers of projects, and the versions are really out of whack, you may have to change directory +into the child aggregator projects and re-run the [versions:update-child-modules](../update-child-modules-mojo.html) +goal in order to finish fixing the project. From b3ae89217c20ac08b71109329c469262c158bcfa Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 15:35:25 +0200 Subject: [PATCH 185/441] #725: Migrate Unlock Snapshots to Markdown --- src/site/apt/examples/unlock-snapshots.apt | 104 ------------------ .../markdown/examples/unlock-snapshots.md | 99 +++++++++++++++++ 2 files changed, 99 insertions(+), 104 deletions(-) delete mode 100644 src/site/apt/examples/unlock-snapshots.apt create mode 100644 src/site/markdown/examples/unlock-snapshots.md diff --git a/src/site/apt/examples/unlock-snapshots.apt b/src/site/apt/examples/unlock-snapshots.apt deleted file mode 100644 index d3e83b1848..0000000000 --- a/src/site/apt/examples/unlock-snapshots.apt +++ /dev/null @@ -1,104 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Unlocking snapshot dependencies - ----- - Stephen Connolly, Paul Gier - ------ - 2009-04-20 - ------ - -Unlocking snapshot dependencies - - If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it - can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. - In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their - release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a - useful hack. - - If your pom has specified locked snapshot versions (these will end with the form -YYYYMMDD.HHMMSS-NNN) for certain - ependencies: - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-20081117.213112-16 - - - -+---+ - - Using the <<>> goal, the locked snapshot versions can be unlocked again to regular -SNAPSHOT - versions. - ---- -mvn versions:unlock-snapshots ---- - - The pom dependencies are modified to look like the following. - -+---+ - - - - org.codehaus.cargo - cargo-core-api - 1.0-SNAPSHOT - - - -+---+ - - You can restrict which dependencies should have their -SNAPSHOT versions unlocked. For example, - the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId - "plexus-utils" - ---- -mvn versions:unlock-snapshots -Dincludes=org.codehaus.plexus:plexus-utils ---- - - The <<>> and <<>> parameters follow the format <<>>. - Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match - multiple values. - - This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and - artifactId matching "junit". - ---- -mvn versions:unlock-snapshots -Dincludes=org.codehaus.plexus:*,junit:junit ---- - - By default, both the <<>> and <<>> sections will be processed. - You can use the <<>> and <<>> parameters to control which sections - are processed. - - This example will only process the <<>> section of your pom: - ---- -mvn versions:unlock-snapshots -DprocessDependencies=false ---- - - While this example will only process the <<>> section of your pom: - ---- -mvn versions:unlock-snapshots -DprocessDependencyManagement=false ---- - diff --git a/src/site/markdown/examples/unlock-snapshots.md b/src/site/markdown/examples/unlock-snapshots.md new file mode 100644 index 0000000000..1f65e0e5b4 --- /dev/null +++ b/src/site/markdown/examples/unlock-snapshots.md @@ -0,0 +1,99 @@ +title: Unlocking snapshot dependencies +author: Stephen Connolly, Paul Gier +date: 2009-04-20 + + + +# Unlocking snapshot dependencies + +If your pom contains a lot of -SNAPSHOT dependencies and those -SNAPSHOT dependencies are a moving target, it +can sometimes be helpful to temporarily replace the -SNAPSHOT with a locked -YYYYMMDD.HHMMSS-NNN snapshot. +In the long term, you will need to return to the -SNAPSHOT dependencies and then replace them with their +release version, but if you need a short term semi-reproducible build, locked -SNAPSHOTs can sometimes be a +useful hack. + +If your pom has specified locked snapshot versions (these will end with the form -YYYYMMDD.HHMMSS-NNN) for certain +ependencies: + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-20081117.213112-16 + + + +``` + +Using the `unlock-snapshots` goal, the locked snapshot versions can be unlocked again to regular -SNAPSHOT +versions. + +```shell +mvn versions:unlock-snapshots +``` + +The pom dependencies are modified to look like the following. + +```xml + + + + org.codehaus.cargo + cargo-core-api + 1.0-SNAPSHOT + + + +``` + +You can restrict which dependencies should have their -SNAPSHOT versions unlocked. For example, +the following will only match dependencies that match the groupId "org.codehaus.plexus" and artifactId +"plexus-utils" + +```shell +mvn versions:unlock-snapshots -Dincludes=org.codehaus.plexus:plexus-utils +``` + +The `includes` and `excludes` parameters follow the format `groupId:artifactId:type:classifier`. +Use a comma separated separated list to specify multiple includes. Wildcards (*) can also be used to match +multiple values. + +This example will match anything with the groupId "org.codehaus.plexus" and anything with the groupId and +artifactId matching "junit". + +```shell +mvn versions:unlock-snapshots -Dincludes=org.codehaus.plexus:*,junit:junit +``` + +By default, both the `project/dependencyManagment` and `project/dependencies` sections will be processed. +You can use the `processDependencies` and `processDependencyManagement` parameters to control which sections +are processed. + +This example will only process the `project/dependencyManagment` section of your pom: + +```shell +mvn versions:unlock-snapshots -DprocessDependencies=false +``` + +While this example will only process the `project/dependencies` section of your pom: + +```shell +mvn versions:unlock-snapshots -DprocessDependencyManagement=false +``` From 07fcf534256369d29dc9bff1fa00827ded074c12 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 18:48:56 +0200 Subject: [PATCH 186/441] #725: Migrate Update Parent to Markdown --- src/site/apt/examples/update-parent.apt | 70 --------------------- src/site/markdown/examples/update-parent.md | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 70 deletions(-) delete mode 100644 src/site/apt/examples/update-parent.apt create mode 100644 src/site/markdown/examples/update-parent.md diff --git a/src/site/apt/examples/update-parent.apt b/src/site/apt/examples/update-parent.apt deleted file mode 100644 index 476a201ee6..0000000000 --- a/src/site/apt/examples/update-parent.apt +++ /dev/null @@ -1,70 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Update Parent - ----- - Stephen Connolly - ------ - 2008-09-02 - ------ - -Update Parent - - Here's an example: - ---- -svn checkout http://svn.codehaus.org/mojo/tags/xmlbeans-maven-plugin-2.3.1 xmlbeans-maven-plugin -cd xmlbeans-maven-plugin -mvn versions:update-parent ---- - - Which produces the following output: - ---- -[INFO] Scanning for projects... -... -[INFO] ------------------------------------------------------------------------ -[INFO] Building Maven XML Beans Plugin -[INFO] task-segment: [versions:update-parent] -[INFO] ------------------------------------------------------------------------ -[INFO] [versions:update-parent] -... -[INFO] artifact org.codehaus.mojo:mojo: checking for updates from codehaus.org -[INFO] artifact org.codehaus.mojo:mojo: checking for updates from central -[INFO] Updating parent from 14 to 17 -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESSFUL -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 24 seconds -[INFO] Finished at: Thu Aug 14 15:17:04 IST 2008 -[INFO] Final Memory: 9M/166M -[INFO] ------------------------------------------------------------------------ ---- - - You can restrict the versions to be considered: - ---- -mvn versions:update-parent "-DparentVersion=[14,16)" ---- - - Note that, by default, -SNAPSHOT versions are ignored. You can force snapshots to be - included with the allowSnapshots parameter: - ---- -mvn versions:update-parent -DallowSnapshots=true ---- diff --git a/src/site/markdown/examples/update-parent.md b/src/site/markdown/examples/update-parent.md new file mode 100644 index 0000000000..a1e86c501f --- /dev/null +++ b/src/site/markdown/examples/update-parent.md @@ -0,0 +1,66 @@ +title: Update Parent +author: Stephen Connolly +date: 2008-09-02 + + + +# Update Parent + +Here's an example: + +```shell +svn checkout http://svn.codehaus.org/mojo/tags/xmlbeans-maven-plugin-2.3.1 xmlbeans-maven-plugin +cd xmlbeans-maven-plugin +mvn versions:update-parent +``` + +Which produces the following output: + +```log +[INFO] Scanning for projects... +... +[INFO] ------------------------------------------------------------------------ +[INFO] Building Maven XML Beans Plugin +[INFO] task-segment: [versions:update-parent] +[INFO] ------------------------------------------------------------------------ +[INFO] [versions:update-parent] +... +[INFO] artifact org.codehaus.mojo:mojo: checking for updates from codehaus.org +[INFO] artifact org.codehaus.mojo:mojo: checking for updates from central +[INFO] Updating parent from 14 to 17 +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 24 seconds +[INFO] Finished at: Thu Aug 14 15:17:04 IST 2008 +[INFO] Final Memory: 9M/166M +[INFO] ------------------------------------------------------------------------ +``` + +You can restrict the versions to be considered: + +```shell +mvn versions:update-parent "-DparentVersion=[14,16)" +``` + +Note that, by default, -SNAPSHOT versions are ignored. You can force snapshots to be +included with the allowSnapshots parameter: + +```shell +mvn versions:update-parent -DallowSnapshots=true +``` From 98a002f26f311f02956d3b8511f9ade00237b1c0 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 15:22:33 +0200 Subject: [PATCH 187/441] #725: Migrate Recording Changes to Markdown --- src/site/apt/examples/recording-changes.apt | 49 ------------------- .../markdown/examples/recording-changes.md | 44 +++++++++++++++++ 2 files changed, 44 insertions(+), 49 deletions(-) delete mode 100644 src/site/apt/examples/recording-changes.apt create mode 100644 src/site/markdown/examples/recording-changes.md diff --git a/src/site/apt/examples/recording-changes.apt b/src/site/apt/examples/recording-changes.apt deleted file mode 100644 index a7b559476b..0000000000 --- a/src/site/apt/examples/recording-changes.apt +++ /dev/null @@ -1,49 +0,0 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Recording Changes - ----- - Mark Raynsford - ------ - 2020-06-27 - ------ - -Recording Changes - - Here's an example: - ---- -mvn versions:use-latest-releases -DchangeRecorderFormat=xml ---- - - Which writes a file to <<>> that looks something - like: - ---- - - - - ---- - - The contents of this file records the fact that <<>> - was upgraded to <<<3.0>>>. diff --git a/src/site/markdown/examples/recording-changes.md b/src/site/markdown/examples/recording-changes.md new file mode 100644 index 0000000000..9497d8248b --- /dev/null +++ b/src/site/markdown/examples/recording-changes.md @@ -0,0 +1,44 @@ +title: Recording Changes +author: Mark Raynsford +date: 2020-06-27 + + + +# Recording Changes + +Here's an example: + +```sh +mvn versions:use-latest-releases -DchangeRecorderFormat=xml +``` + +Which writes a file to `target/versions-changes.xml` that looks something like: + +```xml + + + + +``` + +The contents of this file records the fact that `localhost:dummy-api:1.1.1-2` +was upgraded to `3.0`. From cdd2446e01ffd8db9f238e29cab2d4942d76d2ff Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 23 Oct 2022 15:29:51 +0200 Subject: [PATCH 188/441] #725: Migrate Set Aggregator to Markdown --- .../examples/setaggregator.md} | 139 +++++++++--------- 1 file changed, 69 insertions(+), 70 deletions(-) rename src/site/{apt/examples/setaggregator.apt => markdown/examples/setaggregator.md} (65%) diff --git a/src/site/apt/examples/setaggregator.apt b/src/site/markdown/examples/setaggregator.md similarity index 65% rename from src/site/apt/examples/setaggregator.apt rename to src/site/markdown/examples/setaggregator.md index 0cbd728797..a11b0099b5 100644 --- a/src/site/apt/examples/setaggregator.apt +++ b/src/site/markdown/examples/setaggregator.md @@ -1,35 +1,32 @@ - ~~ Licensed to the Apache Software Foundation (ASF) under one - ~~ or more contributor license agreements. See the NOTICE file - ~~ distributed with this work for additional information - ~~ regarding copyright ownership. The ASF licenses this file - ~~ to you under the Apache License, Version 2.0 (the - ~~ "License"); you may not use this file except in compliance - ~~ with the License. You may obtain a copy of the License at - ~~ - ~~ http://www.apache.org/licenses/LICENSE-2.0 - ~~ - ~~ Unless required by applicable law or agreed to in writing, - ~~ software distributed under the License is distributed on an - ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~~ KIND, either express or implied. See the License for the - ~~ specific language governing permissions and limitations - ~~ under the License. - - ----- - Changing the version of an Aggregator - ----- - Karl Heinz Marbaise - ------ - 2017-06-17 - ------ - -Changing the version of an Aggregator - - Let us assume we have a multi module project which consists of the following - modules: - -+----+ - +title: Changing the version of an Aggregator +author: Karl Heinz Marbaise +date: 2017-06-17 + + +# Changing the version of an Aggregator + +Let us assume we have a multi-module project which consists of the following +modules: + +```xml + 4.0.0 localdomain.localhost @@ -49,13 +46,15 @@ Changing the version of an Aggregator
    .. -+---+ +``` - A module <<>>: +A module `separate-module`: -+----+ +```xml - + 4.0.0 com.soebes.smpp @@ -70,13 +69,15 @@ Changing the version of an Aggregator 2.0.7-SNAPSHOT -+----+ +``` - And two other modules first <> which looks like this: +And two other modules first `module-a2` which looks like this: -+----+ +```xml - + 4.0.0 localdomain.localhost @@ -90,13 +91,15 @@ Changing the version of an Aggregator 1.2.0 -+----+ +``` - An finally the module <> which looks like this: +An finally the module `module-a3` which looks like this: -+----+ +```xml - + 4.0.0 localdomain.localhost @@ -109,18 +112,17 @@ Changing the version of an Aggregator pom -+----+ +``` - So now you decide to change the version of the module to a different version like - <<3.6.0>>. +So now you decide to change the version of the module to a different version like `3.6.0`. -+---+ +```shell mvn versions:set -DnewVersion=3.6.0 -+---+ +``` - So the following output will be generated: +So the following output will be generated: -+----+ +```log [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: @@ -166,30 +168,30 @@ mvn versions:set -DnewVersion=3.6.0 [INFO] Finished at: 2017-06-17T14:17:50+02:00 [INFO] Final Memory: 23M/369M [INFO] ------------------------------------------------------ -+----+ +``` - If you have carefully read the output you have seen that the module <> - is not listed here with something like <>>. +If you have carefully read the output you have seen that the module `separate-module` +is not listed here with something like `Processing ...`. - This means that this module has not been changed to get a new version as you wished by the - call. +This means that this module has not been changed to get a new version as you wished by the +call. - To get that working you need to add supplemental command line parameters: +To get that working you need to add supplemental command line parameters: -+---+ +```shell mvn versions:set -DnewVersion=3.6.0 -DoldVersion=* -DgroupId=* -DartifactId=* -+---+ +``` - This is needed otherwise the filter for the versions (via <<-DoldVersion=*>>) would have - filtered out that module cause it has a different version than the rest of modules. - Furthermore you need to add the <<-DgroupId=*>> and <<-DartifactId=*>> otherwise - the <> will also filtered out based on the differences in groupId - and artifactId. +This is needed otherwise the filter for the versions (via `-DoldVersion=*`) would have +filtered out that module cause it has a different version than the rest of modules. +Furthermore you need to add the `-DgroupId=*` and `-DartifactId=*` otherwise +the `separate-module` will also filtered out based on the differences in groupId +and artifactId. - So in end the result of the above call looks like this: +So in end the result of the above call looks like this: -+----+ +```log [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Reactor Build Order: @@ -239,7 +241,4 @@ mvn versions:set -DnewVersion=3.6.0 -DoldVersion=* -DgroupId=* -DartifactId=* [INFO] Finished at: 2017-06-17T16:17:51+02:00 [INFO] Final Memory: 23M/310M [INFO] ------------------------------------------------------------------------ -+----+ - - [] - +``` From 6ad99f83a6df9aeb93716ee0fdb4ab6e46c7a5a0 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 24 Oct 2022 08:32:27 +0200 Subject: [PATCH 189/441] Resolves #790: Correct update scope determination --- .../DisplayDependencyUpdatesMojo.java | 11 +- .../DisplayDependencyUpdatesMojoTest.java | 173 +++++++++++++++++- 2 files changed, 177 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 0c8c23d91a..fa246271b1 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -226,7 +226,7 @@ public class DisplayDependencyUpdatesMojo * @since 2.5 */ @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) - private boolean allowMajorUpdates; + private boolean allowMajorUpdates = true; /** *

    Whether to allow the minor version number to be changed.

    @@ -237,7 +237,7 @@ public class DisplayDependencyUpdatesMojo * @since 2.5 */ @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) - private boolean allowMinorUpdates; + private boolean allowMinorUpdates = true; /** *

    Whether to allow the incremental version number to be changed.

    @@ -249,7 +249,7 @@ public class DisplayDependencyUpdatesMojo * @since 2.5 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) - private boolean allowIncrementalUpdates; + private boolean allowIncrementalUpdates = true; /** * Whether to allow any version change to be allowed. This keeps @@ -263,7 +263,7 @@ public class DisplayDependencyUpdatesMojo */ @Deprecated @Parameter( property = "allowAnyUpdates", defaultValue = "true" ) - private boolean allowAnyUpdates; + private boolean allowAnyUpdates = true; /** * Whether to show additional information such as dependencies that do not need updating. Defaults to false. @@ -697,7 +697,8 @@ private Optional calculateUpdateScope() return allowAnyUpdates ? empty() : of( SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ).map( s -> Segment.of( s.value() - 1 ) ) + allowIncrementalUpdates, getLog() ) + .map( s -> Segment.of( s.value() + 1 ) ) .orElse( MAJOR ) ); } diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 6fe8c5b82d..905f12e62f 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -165,7 +165,8 @@ null, mockArtifactMetadataSource( new HashMap() new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) {{ setProject( createProject() ); - setVariableValueToObject( this, "allowMinorUpdates", true ); + setVariableValueToObject( this, "allowAnyUpdates", false ); + setVariableValueToObject( this, "allowMajorUpdates", false ); setVariableValueToObject( this, "processDependencies", true ); setVariableValueToObject( this, "dependencyIncludes", singletonList( WildcardMatcher.WILDCARD ) ); @@ -189,6 +190,132 @@ null, mockArtifactMetadataSource( new HashMap() } } + @Test + public void testAllowMajorUpdatesFalse() + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException + { + Path tempPath = null; + try + { + tempPath = Files.createTempFile( "display-dependency-updates", "" ); + final File tempFile = tempPath.toFile(); + new DisplayDependencyUpdatesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); + }} ), null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + {{ + setProject( createProject() ); + setVariableValueToObject( this, "allowAnyUpdates", false ); + setVariableValueToObject( this, "allowMajorUpdates", false ); + setVariableValueToObject( this, "processDependencies", true ); + setVariableValueToObject( this, "dependencyIncludes", + singletonList( WildcardMatcher.WILDCARD ) ); + setVariableValueToObject( this, "dependencyExcludes", emptyList() ); + this.outputFile = tempFile; + setPluginContext( new HashMap<>() ); + }}.execute(); + + String output = String.join( "", Files.readAllLines( tempPath ) ); + + assertThat( output, containsString( "1.1.0" ) ); + assertThat( output, not( containsString( "2.0.0" ) ) ); + } + finally + { + if ( tempPath != null && Files.exists( tempPath ) ) + { + Files.delete( tempPath ); + } + } + } + + @Test + public void testAllowMinorUpdatesFalse() + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException + { + Path tempPath = null; + try + { + tempPath = Files.createTempFile( "display-dependency-updates", "" ); + final File tempFile = tempPath.toFile(); + new DisplayDependencyUpdatesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + {{ + setProject( createProject() ); + setVariableValueToObject( this, "allowAnyUpdates", false ); + setVariableValueToObject( this, "allowMinorUpdates", false ); + setVariableValueToObject( this, "processDependencies", true ); + setVariableValueToObject( this, "dependencyIncludes", + singletonList( WildcardMatcher.WILDCARD ) ); + setVariableValueToObject( this, "dependencyExcludes", emptyList() ); + this.outputFile = tempFile; + setPluginContext( new HashMap<>() ); + }}.execute(); + + String output = String.join( "", Files.readAllLines( tempPath ) ); + + assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, not( containsString( "1.1.0" ) ) ); + assertThat( output, not( containsString( "2.0.0" ) ) ); + } + finally + { + if ( tempPath != null && Files.exists( tempPath ) ) + { + Files.delete( tempPath ); + } + } + } + + @Test + public void testAllowIncrementalUpdatesFalse() + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException + { + Path tempPath = null; + try + { + tempPath = Files.createTempFile( "display-dependency-updates", "" ); + final File tempFile = tempPath.toFile(); + new DisplayDependencyUpdatesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + {{ + setProject( createProject() ); + setVariableValueToObject( this, "allowAnyUpdates", false ); + setVariableValueToObject( this, "allowIncrementalUpdates", false ); + setVariableValueToObject( this, "processDependencies", true ); + setVariableValueToObject( this, "dependencyIncludes", + singletonList( WildcardMatcher.WILDCARD ) ); + setVariableValueToObject( this, "dependencyExcludes", emptyList() ); + this.outputFile = tempFile; + setPluginContext( new HashMap<>() ); + }}.execute(); + + String output = String.join( "", Files.readAllLines( tempPath ) ); + + assertThat( output, containsString( "1.0.0-1" ) ); + assertThat( output, not( containsString( "1.0.1" ) ) ); + assertThat( output, not( containsString( "1.1.0" ) ) ); + assertThat( output, not( containsString( "2.0.0" ) ) ); + } + finally + { + if ( tempPath != null && Files.exists( tempPath ) ) + { + Files.delete( tempPath ); + } + } + } + @Test public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException @@ -207,7 +334,8 @@ null, mockArtifactMetadataSource( new HashMap() new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) {{ setProject( createProject() ); - setVariableValueToObject( this, "allowIncrementalUpdates", true ); + setVariableValueToObject( this, "allowAnyUpdates", false ); + setVariableValueToObject( this, "allowMinorUpdates", false ); setVariableValueToObject( this, "processDependencies", true ); setVariableValueToObject( this, "dependencyIncludes", singletonList( WildcardMatcher.WILDCARD ) ); @@ -230,4 +358,45 @@ null, mockArtifactMetadataSource( new HashMap() } } } + + @Test + public void testDetermineUpdatedSegment() throws Exception + { + File outputFile = null; + try + { + outputFile = File.createTempFile( "display-dependency-updates", "" ); + assert outputFile.exists(); + + DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( + new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset" ), + "display-dependency-updates" ); + + assertThat( mojo.ruleSet, notNullValue() ); + assertThat( mojo.ruleSet.getIgnoreVersions(), notNullValue() ); + assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + assertThat( mojo.ruleSet.getIgnoreVersions(), hasItem( matches( + new TestIgnoreVersions().withVersion( "1.0.1" ) ) ) ); + assertThat( mojo.ruleSet.getIgnoreVersions(), containsInAnyOrder( + matches( new TestIgnoreVersions().withVersion( "1.0.1" ) ), + matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-SNAPSHOT" ) ), + matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-M\\d+" ) ) ) ); + + // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging + mojo.outputFile = outputFile; + mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + {{ + put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); + }} ); + + assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + mojo.execute(); + List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); + assertThat( output, not( hasItem( containsString( "1.1.0-M1" ) ) ) ); + } + finally + { + assert outputFile == null || !outputFile.exists() || outputFile.delete(); + } + } } From b75a5656113f8974e7bb26f2cd0cdeacff59800e Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 26 Oct 2022 18:48:44 +0200 Subject: [PATCH 190/441] Upgrade com.fasterxml.woodstox:woodstox-core to 6.4.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8cba2fa141..4fc1fcde21 100644 --- a/pom.xml +++ b/pom.xml @@ -232,7 +232,7 @@ com.fasterxml.woodstox woodstox-core - 6.3.1 + 6.4.0 org.apache.commons From e4ecca6a4cd81a0301353cccbce680e9da68e9ee Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Tue, 25 Oct 2022 08:01:02 +0200 Subject: [PATCH 191/441] Resolves #793: Added includeParent to DisplayPropertyUpdates and PropertyUpdatesReport --- .../versions/CompareDependenciesMojo.java | 4 +- .../versions/DisplayPropertyUpdatesMojo.java | 19 +- .../versions/PropertyUpdatesReportMojo.java | 19 +- .../mojo/versions/ResolveRangesMojo.java | 7 +- .../mojo/versions/SetPropertyMojo.java | 9 +- .../mojo/versions/UpdatePropertiesMojo.java | 14 +- .../mojo/versions/UpdatePropertyMojo.java | 10 +- .../versions/api/DefaultVersionsHelper.java | 39 ++-- .../codehaus/mojo/versions/api/PomHelper.java | 13 +- .../mojo/versions/api/VersionsHelper.java | 189 +++++++++++++++++- .../DisplayPropertyUpdatesMojoTest.java | 22 ++ .../PropertyUpdatesReportMojoTest.java | 98 +++++++++ .../api/DefaultVersionsHelperTest.java | 9 +- 13 files changed, 400 insertions(+), 52 deletions(-) create mode 100644 src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 1c015fd82c..eb7d80d8b7 100644 --- a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -47,6 +47,7 @@ import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -206,7 +207,8 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( updatePropertyVersions ) { Map versionProperties = - this.getHelper().getVersionPropertiesMap( getProject(), null, null, null, true ); + this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ).build() ); List diff = updatePropertyVersions( pom, versionProperties, remoteDepsMap ); propertyDiffs.addAll( diff ); } diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 2120aac1cb..f0f11a7a5a 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -42,6 +42,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -128,6 +129,14 @@ public class DisplayPropertyUpdatesMojo @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) private boolean allowIncrementalUpdates; + /** + *

    Whether to include property updates from parent.

    + * + * @since 2.14.0 + */ + @Parameter( property = "includeParent", defaultValue = "true" ) + protected boolean includeParent = true; + // -------------------------- STATIC METHODS -------------------------- // -------------------------- OTHER METHODS -------------------------- @@ -150,8 +159,14 @@ public void execute() List updates = new ArrayList<>(); Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, excludeProperties, - autoLinkItems ); + this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( properties ) + .withIncludeProperties( includeProperties ) + .withExcludeProperties( excludeProperties ) + .withIncludeParent( includeParent ) + .withAutoLinkItems( autoLinkItems ) + .build() ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 3299d0e0ed..60f758678c 100644 --- a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -36,6 +36,7 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; import org.codehaus.mojo.versions.utils.PropertyComparator; @@ -84,6 +85,14 @@ public class PropertyUpdatesReportMojo extends AbstractVersionsReportWhether to include property updates from parent.

    + * + * @since 2.14.0 + */ + @Parameter( property = "includeParent", defaultValue = "true" ) + private boolean includeParent = true; + @Inject protected PropertyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, @@ -120,8 +129,14 @@ protected void doGenerateReport( Locale locale, Sink sink ) final Map updateSet = new TreeMap<>( PropertyComparator.INSTANCE ); try { - updateSet.putAll( getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties, - excludeProperties, autoLinkItems ) ); + updateSet.putAll( getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( properties ) + .withIncludeProperties( includeProperties ) + .withExcludeProperties( excludeProperties ) + .withIncludeParent( includeParent ) + .withAutoLinkItems( autoLinkItems ) + .build() ) ); } catch ( MojoExecutionException e ) { diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index db997e1b09..5c05c8b083 100644 --- a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -46,6 +46,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -304,7 +305,11 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom ) { Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), null, includeProperties, excludeProperties, true ); + this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withIncludeProperties( includeProperties ) + .withExcludeProperties( excludeProperties ) + .build() ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 6ab5915347..da046d430d 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; @@ -154,8 +155,12 @@ private void update( ModifiedPomXMLEventReader pom, Property[] propertiesConfig, throws MojoExecutionException, XMLStreamException { Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), propertiesConfig, properties, "", - autoLinkItems ); + this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( propertiesConfig ) + .withIncludeProperties( properties ) + .withAutoLinkItems( autoLinkItems ) + .build() ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property currentProperty = entry.getKey(); diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 9e20ce0766..bd692db5a3 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -39,6 +39,7 @@ import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -156,11 +157,14 @@ public UpdatePropertiesMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - Map propertyVersions = this.getHelper().getVersionPropertiesMap( getProject(), - properties, - includeProperties, - excludeProperties, - autoLinkItems ); + Map propertyVersions = getHelper().getVersionPropertiesMap( + VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( properties ) + .withIncludeProperties( includeProperties ) + .withExcludeProperties( excludeProperties ) + .withAutoLinkItems( autoLinkItems ) + .build() ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 4e8cecc7e4..ed9d279617 100644 --- a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -39,6 +39,7 @@ import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -158,8 +159,13 @@ protected void update( ModifiedPomXMLEventReader pom ) Property propertyConfig = new Property( property ); propertyConfig.setVersion( newVersion ); Map propertyVersions = - this.getHelper().getVersionPropertiesMap( getProject(), new Property[] {propertyConfig}, property, "", - autoLinkItems ); + this.getHelper().getVersionPropertiesMap( + VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( new Property[] {propertyConfig} ) + .withIncludeProperties( property ) + .withAutoLinkItems( autoLinkItems ) + .build() ); for ( Map.Entry entry : propertyVersions.entrySet() ) { Property property = entry.getKey(); diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index ed959429d8..ce0f210c97 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -783,27 +783,22 @@ public ExpressionEvaluator getExpressionEvaluator( MavenProject project ) } @Override - public Map getVersionPropertiesMap( MavenProject project, - Property[] propertyDefinitions, - String includeProperties, String excludeProperties, - boolean autoLinkItems ) + public Map getVersionPropertiesMap( VersionPropertiesMapRequest request ) throws MojoExecutionException { Map properties = new HashMap<>(); - if ( propertyDefinitions != null ) + if ( request.getPropertyDefinitions() != null ) { - for ( Property propertyDefinition : propertyDefinitions ) - { - properties.put( propertyDefinition.getName(), propertyDefinition ); - } + Arrays.stream( request.getPropertyDefinitions() ).forEach( p -> properties.put( p.getName(), p ) ); } Map builders = new HashMap<>(); - if ( autoLinkItems ) + if ( request.isAutoLinkItems() ) { final PropertyVersionsBuilder[] propertyVersionsBuilders; try { - propertyVersionsBuilders = PomHelper.getPropertyVersionsBuilders( this, project ); + propertyVersionsBuilders = PomHelper.getPropertyVersionsBuilders( this, request.getMavenProject(), + request.isIncludeParent() ); } catch ( ExpressionEvaluationException | IOException e ) { @@ -825,8 +820,12 @@ public Map getVersionPropertiesMap( MavenProject pro } } - List includePropertiesList = getSplitProperties( includeProperties ); - List excludePropertiesList = getSplitProperties( excludeProperties ); + List includePropertiesList = request.getIncludeProperties() != null + ? Arrays.asList( request.getIncludeProperties().split( "\\s*,\\s*" ) ) + : Collections.emptyList(); + List excludePropertiesList = request.getExcludeProperties() != null + ? Arrays.asList( request.getExcludeProperties().split( "\\s*,\\s*" ) ) + : Collections.emptyList(); getLog().debug( "Searching for properties associated with builders" ); Iterator i = properties.values().iterator(); @@ -884,7 +883,8 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr + builder.getVersionRange() ); property.setVersion( builder.getVersionRange() ); } - versions.setCurrentVersion( project.getProperties().getProperty( property.getName() ) ); + versions.setCurrentVersion( request.getMavenProject().getProperties() + .getProperty( property.getName() ) ); propertyVersions.put( property, versions ); } catch ( ArtifactMetadataRetrievalException e ) @@ -895,17 +895,6 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr return propertyVersions; } - private List getSplitProperties( String commaSeparatedProperties ) - { - List propertiesList = Collections.emptyList(); - if ( StringUtils.isNotEmpty( commaSeparatedProperties ) ) - { - String[] splittedProps = StringUtils.split( commaSeparatedProperties, "," ); - propertiesList = Arrays.asList( StringUtils.stripAll( splittedProps ) ); - } - return propertiesList; - } - /** * Builder class for {@linkplain DefaultVersionsHelper} */ diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 40bb3cac08..557f0eac0c 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -72,6 +72,7 @@ import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import static java.util.Collections.singletonMap; import static java.util.stream.IntStream.range; /** @@ -1018,16 +1019,20 @@ private static Map getRawModelWithParents( MavenProject pro * * @param helper Our versions helper. * @param project The project to examine. + * @param includeParent whether parent POMs should be included * @return An array of properties that are associated within the project. * @throws ExpressionEvaluationException if an expression cannot be evaluated. * @throws IOException if the project's pom file cannot be parsed. * @since 1.0-alpha-3 */ - public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHelper helper, MavenProject project ) + public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHelper helper, MavenProject project, + boolean includeParent ) throws ExpressionEvaluationException, IOException { ExpressionEvaluator expressionEvaluator = helper.getExpressionEvaluator( project ); - Map reactorModels = getRawModelWithParents( project ); + Map reactorModels = includeParent + ? getRawModelWithParents( project ) + : singletonMap( project, getRawModel( project ) ); Map propertiesMap = new TreeMap<>(); @@ -1081,7 +1086,9 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel reactorModels.values().forEach( model -> addProperties( helper, propertiesMap, null, model.getProperties() ) ); - for ( MavenProject currentPrj = project; currentPrj != null; currentPrj = currentPrj.getParent() ) + for ( MavenProject currentPrj = project; currentPrj != null; currentPrj = includeParent + ? currentPrj.getParent() + : null ) { Model model = reactorModels.get( currentPrj ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 3d57779676..57f03e4538 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -221,20 +221,193 @@ PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots * {@link org.codehaus.mojo.versions.Property} instances consisting of the properties defined in the project which * are associated with version information. * - * @param project The project. - * @param propertyDefinitions Any extra hints about properties. - * @param includeProperties A comma separated list of properties to include. - * @param excludeProperties A comma separated list of properties to exclude. - * @param autoLinkItems whether to automatically infer associations + * @param request {@link VersionPropertiesMapRequest} instance containing the arguments * @return a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by * {@link org.codehaus.mojo.versions.Property} instances. * @throws MojoExecutionException if something goes wrong. */ - Map getVersionPropertiesMap( MavenProject project, Property[] propertyDefinitions, - String includeProperties, String excludeProperties, - boolean autoLinkItems ) + Map getVersionPropertiesMap( VersionPropertiesMapRequest request ) throws MojoExecutionException; + /** + * Argument builder class for + * {@link VersionsHelper#getVersionPropertiesMap(VersionPropertiesMapRequest)}. + */ + class VersionPropertiesMapRequest + { + private MavenProject mavenProject; + private Property[] propertyDefinitions; + private String includeProperties; + private String excludeProperties; + private boolean includeParent; + private boolean autoLinkItems; + + /** + * Returns the {@link MavenProject} object + * @return {@link MavenProject} object + */ + protected MavenProject getMavenProject() + { + return mavenProject; + } + + /** + * Returns the {@link Property} array + * @return {@link Property} array + */ + protected Property[] getPropertyDefinitions() + { + return propertyDefinitions; + } + + /** + * Returns the value of {@link #includeProperties} + * @return value of {@link #includeProperties} + */ + protected String getIncludeProperties() + { + return includeProperties; + } + + /** + * Returns the value of {@link #excludeProperties} + * @return value of {@link #excludeProperties} + */ + protected String getExcludeProperties() + { + return excludeProperties; + } + + /** + * Returns the value of {@link #includeParent}. + * If not set, it is assumed to be {@code true} + * + * @return value of {@link #includeParent} + */ + protected boolean isIncludeParent() + { + return includeParent; + } + + /** + * Returns the value of {@link #autoLinkItems} + * If not set, it is assumed to be {@code true} + * @return value of {@link #autoLinkItems} + */ + protected boolean isAutoLinkItems() + { + return autoLinkItems; + } + + /** + * Returns a new {@link Builder} instance + * @return new {@link Builder} instance + */ + public static Builder builder() + { + return new Builder(); + } + + /** + * Builder class for {@link VersionPropertiesMapRequest} + */ + public static class Builder + { + private MavenProject mavenProject; + private Property[] propertyDefinitions; + private String includeProperties; + private String excludeProperties; + private Boolean includeParent; + private Boolean autoLinkItems; + + private Builder() + { + } + + /** + * Supplies the {@link MavenProject} instance + * @param mavenProject {@link MavenProject} instance + * @return {@link Builder} instance + */ + public Builder withMavenProject( MavenProject mavenProject ) + { + this.mavenProject = mavenProject; + return this; + } + + /** + * Supplies the {@link MavenProject} instance + * @param propertyDefinitions array of property definitions + * @return {@link Builder} instance + */ + public Builder withPropertyDefinitions( Property[] propertyDefinitions ) + { + this.propertyDefinitions = propertyDefinitions; + return this; + } + + /** + * Supplies the properties to include + * @param includeProperties comma-delimited properties to include + * @return {@link Builder} instance + */ + public Builder withIncludeProperties( String includeProperties ) + { + this.includeProperties = includeProperties; + return this; + } + + /** + * Supplies the properties to exclude + * @param excludeProperties comma-delimited properties to exclude + * @return {@link Builder} instance + */ + public Builder withExcludeProperties( String excludeProperties ) + { + this.excludeProperties = excludeProperties; + return this; + } + + /** + * Supplies the includeParent parameter (whether parent POMs should be included) + * @param includeParent whether parent POMs should be included + * @return {@link Builder} instance + */ + public Builder withIncludeParent( boolean includeParent ) + { + this.includeParent = includeParent; + return this; + } + + /** + * Supplies the information whether to automatically infer associations + * @param autoLinkItems whether to automatically infer associations + * @return {@link Builder} instance + */ + public Builder withAutoLinkItems( boolean autoLinkItems ) + { + this.autoLinkItems = autoLinkItems; + return this; + } + + /** + * Returns the {@link VersionPropertiesMapRequest} instance + * @return {@link VersionPropertiesMapRequest} instance + */ + public VersionPropertiesMapRequest build() + { + VersionPropertiesMapRequest instance = new VersionPropertiesMapRequest(); + instance.mavenProject = this.mavenProject; + instance.propertyDefinitions = propertyDefinitions; + instance.includeProperties = includeProperties; + instance.excludeProperties = excludeProperties; + instance.includeParent = includeParent == null || includeParent; + instance.autoLinkItems = autoLinkItems == null || autoLinkItems; + return instance; + } + } + } + /** * Attempts to resolve the artifact. * diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java index be01de3bdf..f306faed95 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java @@ -35,6 +35,7 @@ import static org.apache.commons.codec.CharEncoding.UTF_8; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.not; /** * Unit tests for {@link DisplayPropertyUpdatesMojo} @@ -85,4 +86,25 @@ public void testPropertiesFromParent() throws Exception assertThat( String.join( "", Files.readAllLines( tempFile ) ), matchesPattern( ".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*" ) ); } + + @Test + public void testDisablePropertiesFromParent() throws Exception + { + Path tempFile = Files.createTempFile( tempDir, "output", "" ); + + TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367" ), + tempDir ); + DisplayPropertyUpdatesMojo mojo = + (DisplayPropertyUpdatesMojo) mojoRule.lookupConfiguredMojo( tempDir.resolve( "child" ).toFile(), + "display-property-updates" ); + mojo.outputEncoding = UTF_8; + mojo.outputFile = tempFile.toFile(); + mojo.setPluginContext( new HashMap<>() ); + mojo.artifactMetadataSource = MockUtils.mockArtifactMetadataSource(); + mojo.includeParent = false; + mojo.execute(); + + assertThat( String.join( "", Files.readAllLines( tempFile ) ), + not( matchesPattern( ".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*" ) ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java new file mode 100644 index 0000000000..4d498592d4 --- /dev/null +++ b/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java @@ -0,0 +1,98 @@ +package org.codehaus.mojo.versions; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.OutputStream; +import java.util.Locale; + +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; +import org.apache.maven.doxia.sink.SinkFactory; +import org.apache.maven.doxia.tools.SiteTool; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.junit.Rule; +import org.junit.Test; + +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockSiteTool; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.not; + +/** + * Unit tests for {@link PropertyUpdatesReportMojo} + */ +public class PropertyUpdatesReportMojoTest extends AbstractMojoTestCase +{ + @Rule + public MojoRule mojoRule = new MojoRule( this ); + private static final ArtifactMetadataSource ARTIFACT_METADATA_SOURCE = mockArtifactMetadataSource(); + private static final SiteTool SITE_TOOL = mockSiteTool(); + private static final StubArtifactRepository LOCAL_REPOSITORY = new StubArtifactRepository( "" ); + + @Test + public void testIncludeParentTrueShouldContainProperty() throws Exception + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + + PropertyUpdatesReportMojo mojo = + (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( + new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), + "property-updates-report" ); + setVariableValueToObject( mojo, "localRepository", LOCAL_REPOSITORY ); + setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); + setVariableValueToObject( mojo, "artifactMetadataSource", ARTIFACT_METADATA_SOURCE ); + setVariableValueToObject( mojo, "includeParent", true ); + mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString() + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ); + assertThat( output, containsString( "${ver}" ) ); + } + + @Test + public void testIncludeParentFalseShouldNotCountainProperty() throws Exception + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + + PropertyUpdatesReportMojo mojo = + (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( + new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), + "property-updates-report" ); + setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( "" ) ); + setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); + setVariableValueToObject( mojo, "artifactMetadataSource", ARTIFACT_METADATA_SOURCE ); + setVariableValueToObject( mojo, "includeParent", false ); + mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString() + .replaceAll( "<[^>]+>", " " ) + .replaceAll( "&[^;]+;", " " ) + .replaceAll( "\\s+", " " ); + assertThat( output, not( containsString( "${ver}" ) ) ); + } +} diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 89fcc92b49..0ccf473e9f 100644 --- a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -182,7 +182,14 @@ public void testMVERSIONS159ExcludedAndNotIncluded() }; // should not throw an IllegalStateException Map result = - helper.getVersionPropertiesMap( project, propertyDefinitions, "foo.version", "bar.version", false ); + helper.getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( project ) + .withPropertyDefinitions( propertyDefinitions ) + .withIncludeProperties( "foo.version" ) + .withExcludeProperties( "bar.version" ) + .withIncludeParent( false ) + .withAutoLinkItems( false ) + .build() ); assertTrue( result.isEmpty() ); } From 6647b8d8f41b1d09c65f4d627a1f22dc5ba1e6c8 Mon Sep 17 00:00:00 2001 From: Torsten Kruse Date: Wed, 26 Oct 2022 12:14:42 +0200 Subject: [PATCH 192/441] interpolate version from model properties if necessary --- .../versions/DependencyUpdatesReportMojo.java | 4 +- .../DisplayDependencyUpdatesMojo.java | 1 + .../versions/api/DefaultVersionsHelper.java | 18 ++++++++ .../mojo/versions/api/VersionsHelper.java | 10 ++++ .../DependencyUpdatesReportMojoTest.java | 29 ++++++++++++ .../DisplayDependencyUpdatesMojoTest.java | 30 ++++++++++++ .../version-interpolation/pom.xml | 46 +++++++++++++++++++ 7 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index c831013008..f7c1a30c99 100644 --- a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -174,8 +174,10 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! // TODO: I'm not 100% sure if this will work correctly in all cases. for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) { + dep = getHelper().interpolateVersion( dep, getProject() ); + getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" - + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); } dependencyManagement.addAll( getProject().getOriginalModel().getDependencyManagement().getDependencies() ); diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index fa246271b1..da5b9a0b8a 100644 --- a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -535,6 +535,7 @@ public void execute() } else { + dependency = getHelper().interpolateVersion( dependency, getProject() ); dependencyManagement.add( dependency ); } } diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index ce0f210c97..a4d6d3f7fe 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -895,6 +895,24 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr return propertyVersions; } + @Override + public Dependency interpolateVersion( final Dependency dependency, final MavenProject project ) + { + + // resolve version from model properties if necessary (e.g. "${mycomponent.myversion}" + if ( dependency.getVersion().startsWith( "${" ) ) + { + final String resolvedVersion = project.getOriginalModel() + .getProperties().getProperty( + dependency.getVersion().substring( 2, dependency.getVersion().length() - 1 ) ); + if ( resolvedVersion != null && !resolvedVersion.isEmpty() ) + { + dependency.setVersion( resolvedVersion ); + } + } + return dependency; + } + /** * Builder class for {@linkplain DefaultVersionsHelper} */ diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 57f03e4538..beabeabd5e 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -419,4 +419,14 @@ public VersionPropertiesMapRequest build() */ void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException; + + /** + * Attempts to interpolate the version from model properties. + * + * @param dependency the dependency + * @param project the maven project + * @return the dependency with interpolated property (as far as possible) + * @since 2.14.0 + */ + Dependency interpolateVersion( Dependency dependency, MavenProject project ); } diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index 37850e7dc9..b7e853e788 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -155,6 +155,12 @@ public TestDependencyUpdatesReportMojo withAllowSnapshots( boolean allowSnapshot return this; } + public TestDependencyUpdatesReportMojo withOriginalProperty( String name, String value ) + { + project.getOriginalModel().getProperties().put( name, value ); + return this; + } + private static RepositorySystem mockRepositorySystem() { RepositorySystem repositorySystem = mock( RepositorySystem.class ); @@ -367,4 +373,27 @@ public void testIt001Overview() throws IOException, MavenReportException assertThat( "Did not generate summary correctly", output, containsString( "groupA test-artifact 1.1 compile pom default 1.1.0-2 1.1.3 1.3 3.0" ) ); } + + @Test + public void testResolvedVersionsWithoutTransitiveDependencyManagement() throws IOException, MavenReportException + { + OutputStream os = new ByteArrayOutputStream(); + SinkFactory sinkFactory = new Xhtml5SinkFactory(); + new TestDependencyUpdatesReportMojo() + .withOriginalDependencyManagement( + dependencyOf( "artifactA", "1.0.0" ), + dependencyOf( "artifactB", "${mycomponent.version}" ) ) + .withDependencyManagement( + dependencyOf( "artifactA", "1.0.0" ), + dependencyOf( "artifactB", "${mycomponent.version}" ) ) + .withProcessDependencyManagement( true ) + .withProcessDependencyManagementTransitive( false ) + .withOnlyUpgradable( false ) + .withOriginalProperty( "mycomponent.version", "1.2.3" ) + .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + + String output = os.toString(); + assertThat( output, Matchers + .stringContainsInOrder( "artifactA", "1.0.0", "artifactB", "1.2.3" ) ); + } } diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 905f12e62f..25250b203d 100644 --- a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -399,4 +399,34 @@ public void testDetermineUpdatedSegment() throws Exception assert outputFile == null || !outputFile.exists() || outputFile.delete(); } } + + @Test + public void testVersionInterpolation() throws Exception + { + File outputFile = null; + try + { + outputFile = File.createTempFile( "display-dependency-updates", "" ); + assert outputFile.exists(); + + DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( + new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/version-interpolation" ), + "display-dependency-updates" ); + + // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging + mojo.outputFile = outputFile; + mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + {{ + put( "dummy-api", new String[] { "2.0.1" } ); + }} ); + setVariableValueToObject( mojo, "processDependencyManagementTransitive", false ); + mojo.execute(); + List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); + assertThat( output, not( hasItem( containsString( "mycomponent.version" ) ) ) ); + } + finally + { + assert outputFile == null || !outputFile.exists() || outputFile.delete(); + } + } } diff --git a/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml b/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml new file mode 100644 index 0000000000..19213f0c01 --- /dev/null +++ b/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml @@ -0,0 +1,46 @@ + + 4.0.0 + default-group + default-artifact + 1.0 + pom + + + 1.2.3 + + + + + + localhost + dummy-api + ${mycomponent.version} + + + + + + + localhost + dummy-api + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${project.version} + + display-dependency-updates + + + + + + + + + From 5ae680a5d6e3c78891892e7d91f9166707367020 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Wed, 26 Oct 2022 19:35:29 +0200 Subject: [PATCH 193/441] Switch Maven Wrapper to 4.0.0-alpha-2 --- .mvn/wrapper/maven-wrapper.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 25a1876bb8..c45a650fa4 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# https://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-alpha-2/apache-maven-4.0.0-alpha-2-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From 80fba4665852f3401b7dfedc5001aa3a7c801ed7 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sun, 30 Oct 2022 18:20:31 +0100 Subject: [PATCH 194/441] Revert "Switch Maven Wrapper to 4.0.0-alpha-2" due to issues with Enforcer plugin This reverts commit 5ae680a5d6e3c78891892e7d91f9166707367020. --- .mvn/wrapper/maven-wrapper.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index c45a650fa4..25a1876bb8 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/4.0.0-alpha-2/apache-maven-4.0.0-alpha-2-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar From 80bf105dd30a7131da56f13ebd41c44824abb479 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 29 Oct 2022 09:24:23 +0200 Subject: [PATCH 195/441] #758: First stage of the module split --- model-report/pom.xml | 106 +++++ .../main/mdo/dependency-updates-report.mdo | 0 .../src}/main/mdo/plugin-updates-report.mdo | 0 model/pom.xml | 105 +++++ {src => model/src}/main/mdo/rule.mdo | 0 pom.xml | 404 +++--------------- src/site/markdown/xsd/index.md | 20 - src/site/resources/xsd/rule-2.0.0.xsd | 116 ----- src/site/site.xml | 70 +-- versions-maven-plugin/pom.xml | 297 +++++++++++++ .../src}/changes/changes.xml | 0 .../src}/it-repo/dummy-api-1.0.1.pom | 0 .../src}/it-repo/dummy-api-1.0.pom | 0 .../src}/it-repo/dummy-api-1.1-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-1.1.0-2.pom | 0 .../src}/it-repo/dummy-api-1.1.1-2.pom | 0 .../src}/it-repo/dummy-api-1.1.1.pom | 0 .../src}/it-repo/dummy-api-1.1.2-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-1.1.2.pom | 0 .../src}/it-repo/dummy-api-1.1.3.pom | 0 .../src}/it-repo/dummy-api-1.1.pom | 0 .../src}/it-repo/dummy-api-1.2.1.pom | 0 .../src}/it-repo/dummy-api-1.2.2.pom | 0 .../src}/it-repo/dummy-api-1.2.pom | 0 .../src}/it-repo/dummy-api-1.3.pom | 0 .../src}/it-repo/dummy-api-1.9.1-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-2.0.pom | 0 .../src}/it-repo/dummy-api-2.1.1-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-2.1.pom | 0 .../src}/it-repo/dummy-api-3.0.pom | 0 .../src}/it-repo/dummy-api-3.1.1-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-3.1.5-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-api-3.4.0-SNAPSHOT.pom | 0 .../it-repo/dummy-api-impl-bom-pom-1.0.pom | 0 .../it-repo/dummy-api-impl-bom-pom-2.0.pom | 0 .../it-repo/dummy-bom-maven-mismatch-1.0.pom | 0 .../src}/it-repo/dummy-bom-pom-1.0.pom | 0 .../src}/it-repo/dummy-impl-1.0.pom | 0 .../src}/it-repo/dummy-impl-1.1.pom | 0 .../src}/it-repo/dummy-impl-1.2.pom | 0 .../src}/it-repo/dummy-impl-1.3.pom | 0 .../src}/it-repo/dummy-impl-1.4.pom | 0 .../src}/it-repo/dummy-impl-2.0.pom | 0 .../src}/it-repo/dummy-impl-2.1.pom | 0 .../src}/it-repo/dummy-impl-2.2.pom | 0 .../src}/it-repo/dummy-maven-plugin-1.0.pom | 0 .../src}/it-repo/dummy-maven-plugin-2.0.pom | 0 .../src}/it-repo/dummy-maven-plugin-2.1.pom | 0 .../src}/it-repo/dummy-maven-plugin-3.0.pom | 0 .../src}/it-repo/dummy-maven-plugin-3.1.pom | 0 .../src}/it-repo/dummy-parent-1.0.pom | 0 .../src}/it-repo/dummy-parent-2.0.pom | 0 .../src}/it-repo/dummy-parent-3.0.pom | 0 .../it-repo/dummy-parent-issue-582-1.0.pom | 0 .../src}/it-repo/dummy-parent2-1.0.pom | 0 .../src}/it-repo/dummy-parent2-2.0.pom | 0 .../it-repo/dummy-parent2-3.0-SNAPSHOT.pom | 0 .../it-repo/dummy-parent2-3.0-alpha-1.pom | 0 .../src}/it-repo/dummy-parent2-3.0-beta-1.pom | 0 .../src}/it-repo/dummy-parent2-3.0-rc-1.pom | 0 .../src}/it-repo/dummy-parent2-3.0.pom | 0 .../src}/it-repo/dummy-parent2-3.1.pom | 0 .../it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-parent3-1.0.0.pom | 0 .../src}/it-repo/dummy-parent4-70.pom | 0 .../it-repo/dummy-parent4-71-SNAPSHOT.pom | 0 .../src}/it-repo/dummy-parent5-1.0.0.pom | 0 .../src}/it-repo/dummy-parent5-2.0.0-rc1.pom | 0 .../src}/it-repo/issue-114-artifact-1.0.jar | 0 .../src}/it-repo/issue-114-artifact-1.0.pom | 0 .../src}/it-repo/issue-114-artifact-1.1.jar | 0 .../src}/it-repo/issue-114-artifact-1.1.pom | 0 .../src}/it-repo/issue-114-depmgmt-1.0.pom | 0 .../it-repo/latest-versions-api-2.0.11.pom | 0 .../it-repo/latest-versions-api-2.0.8.pom | 0 .../it-repo/latest-versions-api-2.1.0-M1.pom | 0 .../it-repo/latest-versions-api-2.2.1.pom | 0 .../latest-versions-api-3.0-beta-3.pom | 0 .../src}/it-repo/latest-versions-api-3.0.pom | 0 .../it-repo/latest-versions-api-3.1.0.pom | 0 .../it-repo/latest-versions-api-3.3.0.pom | 0 .../src}/it-repo/module-a1-1.0.pom | 0 .../test/bigversion/dummy-lib-1.1.1.1.jar | 0 .../test/bigversion/dummy-lib-1.1.1.1.pom | 0 .../test/bigversion/dummy-lib-2.0.0.0.jar | 0 .../test/bigversion/dummy-lib-2.0.0.0.pom | 0 .../test/bigversion/dummy-lib-2.0.10.0.jar | 0 .../test/bigversion/dummy-lib-2.0.10.0.pom | 0 .../test/bigversion/dummy-lib-2.12.0.0.jar | 0 .../test/bigversion/dummy-lib-2.12.0.0.pom | 0 .../bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar | 0 .../bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom | 0 .../it-repo/test/package/module-0.0.2.19.jar | 0 .../it-repo/test/package/module-0.0.2.19.pom | 0 .../test/package/module-1.2.3-SNAPSHOT.jar | 0 .../test/package/module-1.2.3-SNAPSHOT.pom | 0 .../test/package/moduleTest-0.0.2.18.jar | 0 .../test/package/moduleTest-0.0.2.18.pom | 0 .../test/package/moduleTest-0.0.2.19.jar | 0 .../test/package/moduleTest-0.0.2.19.pom | 0 .../test/package/moduleTest-0.0.2.20.jar | 0 .../test/package/moduleTest-0.0.2.20.pom | 0 .../package/moduleTest-1.2.3-SNAPSHOT.jar | 0 .../package/moduleTest-1.2.3-SNAPSHOT.pom | 0 .../src}/it-repo/the-grandparent-1.0.pom | 0 .../src}/it-repo/the-parent-1.0.pom | 0 .../src}/it-repo/update-api-1.9.5.pom | 0 .../src}/it-repo/update-api-2.0.0-beta.pom | 0 .../src}/it-repo/versions-rules-3.0.1-1.1.pom | 0 .../src}/it-repo/versions-rules-3.0.1-1.pom | 0 .../src}/it-repo/versions-rules-3.0.1.pom | 0 .../invoker.properties | 0 .../it-abstract-versions-report-001/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it-changerecord-update-parent-001/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it/it-compare-dependencies-001/pom.xml | 0 .../test.properties | 0 .../it/it-compare-dependencies-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-compare-dependencies-002/pom.xml | 0 .../test.properties | 0 .../it/it-compare-dependencies-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-compare-dependencies-003/pom.xml | 0 .../test.properties | 0 .../it/it-compare-dependencies-003/verify.bsh | 0 .../invoker.properties | 0 .../it/it-compare-dependencies-004/pom.xml | 0 .../test.properties | 0 .../it/it-compare-dependencies-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-compare-dependencies-005/pom.xml | 0 .../test.properties | 0 .../it/it-compare-dependencies-005/verify.bsh | 0 .../invoker.properties | 0 .../it-dependency-updates-report-001/pom.xml | 0 .../src/site/site.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-dependency-updates-report-002/pom.xml | 0 .../src/site/site.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-dependency-updates-report-003/pom.xml | 0 .../src/site/site.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-dependency-updates-report-004/pom.xml | 0 .../src/site/site.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it-display-dependency-updates-001/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it-display-dependency-updates-002/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-display-dependency-updates-003/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-display-dependency-updates-004/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-display-dependency-updates-005/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-display-dependency-updates-006/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../test.properties | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-001/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-002/pom.xml | 0 .../it-display-plugin-updates-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-003/pom.xml | 0 .../it-display-plugin-updates-003/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-004/pom.xml | 0 .../it-display-plugin-updates-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-005/pom.xml | 0 .../it-display-plugin-updates-005/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-006/pom.xml | 0 .../it-display-plugin-updates-006/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-007/pom.xml | 0 .../it-display-plugin-updates-007/verify.bsh | 0 .../invoker.properties | 0 .../it/it-display-plugin-updates-008/pom.xml | 0 .../it-display-plugin-updates-008/verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../parent/pom.xml | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it-display-property-updates-001/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../it/it-encoding-001/invoker.properties | 0 .../src}/it/it-encoding-001/pom.xml | 0 .../src}/it/it-encoding-001/verify.bsh | 0 .../invoker.properties | 0 .../module/pom.xml | 0 .../it/it-parent-updates-report-001/pom.xml | 0 .../src/site/site.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-plugin-updates-report-001/pom.xml | 0 .../src/site/site.xml | 0 .../it-plugin-updates-report-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-plugin-updates-report-002/pom.xml | 0 .../src/site/site.xml | 0 .../it-plugin-updates-report-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-plugin-updates-report-003/pom.xml | 0 .../src/site/site.xml | 0 .../it-plugin-updates-report-003/verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-property-updates-report-001/pom.xml | 0 .../src/site/site.xml | 0 .../it-property-updates-report-001/verify.bsh | 0 .../invoker.properties | 0 .../maven-version-rules.xml | 0 .../pom.xml | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../it-resolve-ranges-001/invoker.properties | 0 .../src}/it/it-resolve-ranges-001/pom.xml | 0 .../src}/it/it-resolve-ranges-001/verify.bsh | 0 .../it-resolve-ranges-002/invoker.properties | 0 .../src}/it/it-resolve-ranges-002/pom.xml | 0 .../src}/it/it-resolve-ranges-002/verify.bsh | 0 .../it/it-resolve-ranges-003/child/pom.xml | 0 .../it/it-resolve-ranges-003/child2/pom.xml | 0 .../it-resolve-ranges-003/invoker.properties | 0 .../src}/it/it-resolve-ranges-003/pom.xml | 0 .../src}/it/it-resolve-ranges-003/verify.bsh | 0 .../it/it-resolve-ranges-004/child/pom.xml | 0 .../it-resolve-ranges-004/invoker.properties | 0 .../src}/it/it-resolve-ranges-004/pom.xml | 0 .../src}/it/it-resolve-ranges-004/verify.bsh | 0 .../it-resolve-ranges-005/invoker.properties | 0 .../src}/it/it-resolve-ranges-005/pom.xml | 0 .../src}/it/it-resolve-ranges-005/verify.bsh | 0 .../it-resolve-ranges-006/invoker.properties | 0 .../src}/it/it-resolve-ranges-006/pom.xml | 0 .../src}/it/it-resolve-ranges-006/verify.bsh | 0 .../invoker.properties | 0 .../it/it-resolve-ranges-issue-442/pom.xml | 0 .../it-resolve-ranges-issue-442/verify.groovy | 0 .../invoker.properties | 0 .../it/it-resolve-ranges-issue-454/pom.xml | 0 .../it-resolve-ranges-issue-454/verify.groovy | 0 .../it/it-revert-isssue-265/aggregate/pom.xml | 0 .../it-revert-isssue-265/invoker.properties | 0 .../it/it-revert-isssue-265/module-a/pom.xml | 0 .../it/it-revert-isssue-265/module-b/pom.xml | 0 .../it/it-revert-isssue-265/verify.groovy | 0 .../invoker.properties | 0 .../it/it-rules-via-classpath-001/pom.xml | 0 .../it/it-rules-via-classpath-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-rules-via-classpath-002/pom.xml | 0 .../it/it-rules-via-classpath-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-rules-via-classpath-003/pom.xml | 0 .../it/it-rules-via-classpath-003/verify.bsh | 0 .../it/it-set-001-issue-76/invoker.properties | 0 .../src}/it/it-set-001-issue-76/pom.xml | 0 .../src}/it/it-set-001-issue-76/verify.groovy | 0 .../src}/it/it-set-001/invoker.properties | 0 .../src}/it/it-set-001/pom.xml | 0 .../src}/it/it-set-001/verify.bsh | 0 .../src}/it/it-set-002/child/pom.xml | 0 .../src}/it/it-set-002/invoker.properties | 0 .../src}/it/it-set-002/pom.xml | 0 .../src}/it/it-set-002/verify.bsh | 0 .../src}/it/it-set-003/child/pom.xml | 0 .../src}/it/it-set-003/child2/pom.xml | 0 .../src}/it/it-set-003/invoker.properties | 0 .../src}/it/it-set-003/pom.xml | 0 .../src}/it/it-set-003/verify.bsh | 0 .../src}/it/it-set-004/invoker.properties | 0 .../src}/it/it-set-004/pom.xml | 0 .../src}/it/it-set-004/verify.bsh | 0 .../src}/it/it-set-005/invoker.properties | 0 .../src}/it/it-set-005/module-a1/pom.xml | 0 .../src}/it/it-set-005/module-a2/pom.xml | 0 .../src}/it/it-set-005/pom.xml | 0 .../src}/it/it-set-005/verify.bsh | 0 .../src}/it/it-set-006/invoker.properties | 0 .../src}/it/it-set-006/module-a1/pom.xml | 0 .../src}/it/it-set-006/module-a2/pom.xml | 0 .../src}/it/it-set-006/module-a3/pom.xml | 0 .../src}/it/it-set-006/pom.xml | 0 .../src}/it/it-set-006/verify.bsh | 0 .../src}/it/it-set-007/invoker.properties | 0 .../src}/it/it-set-007/module-a1/pom.xml | 0 .../src}/it/it-set-007/module-a2/pom.xml | 0 .../src}/it/it-set-007/pom.xml | 0 .../src}/it/it-set-007/verify.bsh | 0 .../src}/it/it-set-008/invoker.properties | 0 .../it/it-set-008/module-a1/module-b1/pom.xml | 0 .../it/it-set-008/module-a1/module-b2/pom.xml | 0 .../it/it-set-008/module-a1/module-b3/pom.xml | 0 .../src}/it/it-set-008/module-a1/pom.xml | 0 .../src}/it/it-set-008/module-a2/pom.xml | 0 .../src}/it/it-set-008/pom.xml | 0 .../src}/it/it-set-008/verify.groovy | 0 .../src}/it/it-set-009/alternative-pom.xml | 0 .../src}/it/it-set-009/child/pom.xml | 0 .../src}/it/it-set-009/invoker.properties | 0 .../src}/it/it-set-009/verify.groovy | 0 .../it/it-set-010-issue-198/fake-api/pom.xml | 0 .../src/main/java/org/eclipse/jetty/App.java | 0 .../test/java/org/eclipse/jetty/AppTest.java | 0 .../it-set-010-issue-198/invoker.properties | 0 .../src}/it/it-set-010-issue-198/pom.xml | 0 .../it/it-set-010-issue-198/the-bom/pom.xml | 0 .../it/it-set-010-issue-198/verify.groovy | 0 .../src}/it/it-set-010/invoker.properties | 0 .../src}/it/it-set-010/pom.xml | 0 .../src}/it/it-set-010/verify.bsh | 0 .../src}/it/it-set-011/child/pom.xml | 0 .../src}/it/it-set-011/invoker.properties | 0 .../src}/it/it-set-011/pom.xml | 0 .../src}/it/it-set-011/verify.bsh | 0 .../src}/it/it-set-012/invoker.properties | 0 .../src}/it/it-set-012/pom.xml | 0 .../src}/it/it-set-012/verify.bsh | 0 .../src}/it/it-set-013/invoker.properties | 0 .../src}/it/it-set-013/pom.xml | 0 .../src}/it/it-set-013/verify.bsh | 0 .../src}/it/it-set-014/invoker.properties | 0 .../src}/it/it-set-014/pom.xml | 0 .../src}/it/it-set-014/verify.bsh | 0 .../src}/it/it-set-015/invoker.properties | 0 .../src}/it/it-set-015/pom.xml | 0 .../src}/it/it-set-015/verify.bsh | 0 .../src}/it/it-set-016/child/pom.xml | 0 .../src}/it/it-set-016/invoker.properties | 0 .../src}/it/it-set-016/pom.xml | 0 .../src}/it/it-set-016/verify.bsh | 0 .../it-set-017-issue-321/invoker.properties | 0 .../it/it-set-017-issue-321/module-a1/pom.xml | 0 .../it/it-set-017-issue-321/module-a2/pom.xml | 0 .../src}/it/it-set-017-issue-321/pom.xml | 0 .../src}/it/it-set-017-issue-321/verify.bsh | 0 .../it/it-set-018-issue-82/invoker.properties | 0 .../module-a1/module-b1/pom.xml | 0 .../module-a1/module-b2/pom.xml | 0 .../module-a1/module-b3/pom.xml | 0 .../it/it-set-018-issue-82/module-a1/pom.xml | 0 .../it/it-set-018-issue-82/module-a2/pom.xml | 0 .../src}/it/it-set-018-issue-82/pom.xml | 0 .../src}/it/it-set-018-issue-82/verify.groovy | 0 .../it-set-019-issue-426/invoker.properties | 0 .../module-a1/module-b1/pom.xml | 0 .../module-a1/module-b2/pom.xml | 0 .../module-a1/module-b3/pom.xml | 0 .../it/it-set-019-issue-426/module-a1/pom.xml | 0 .../it/it-set-019-issue-426/module-a2/pom.xml | 0 .../src}/it/it-set-019-issue-426/pom.xml | 0 .../it/it-set-019-issue-426/verify.groovy | 0 .../invoker.properties | 0 .../it/it-set-019-outputTimestamp/pom.xml | 0 .../it-set-019-outputTimestamp/verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.groovy | 0 .../child/pom.xml | 0 .../invoker.properties | 0 .../it-set-024-versionless-dependency/pom.xml | 0 .../it/it-set-property-001/invoker.properties | 0 .../src}/it/it-set-property-001/pom.xml | 0 .../src}/it/it-set-property-001/verify.bsh | 0 .../it/it-set-property-002/invoker.properties | 0 .../src}/it/it-set-property-002/pom.xml | 0 .../src}/it/it-set-property-002/verify.bsh | 0 .../invoker.properties | 0 .../pom.xml | 0 .../verify.bsh | 0 .../it/it-set-scm-tag-001/invoker.properties | 0 .../src}/it/it-set-scm-tag-001/pom.xml | 0 .../src}/it/it-set-scm-tag-001/verify.groovy | 0 .../it/it-set-scm-tag-002/invoker.properties | 0 .../src}/it/it-set-scm-tag-002/pom.xml | 0 .../it/it-set-scm-tag-003/invoker.properties | 0 .../src}/it/it-set-scm-tag-003/pom.xml | 0 .../it/it-set-scm-tag-004/invoker.properties | 0 .../it/it-set-scm-tag-004/module-a1/pom.xml | 0 .../it/it-set-scm-tag-004/module-a2/pom.xml | 0 .../src}/it/it-set-scm-tag-004/pom.xml | 0 .../src}/it/it-set-scm-tag-004/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-unlock-snapshots-001/pom.xml | 0 .../it/it-unlock-snapshots-001/verify.bsh | 0 .../it-update-child-modules-001/child/pom.xml | 0 .../invoker.properties | 0 .../it/it-update-child-modules-001/pom.xml | 0 .../it/it-update-child-modules-001/verify.bsh | 0 .../it-update-child-modules-002/child/pom.xml | 0 .../child/subchild/pom.xml | 0 .../child/subchild2/pom.xml | 0 .../child2/pom.xml | 0 .../invoker.properties | 0 .../it/it-update-child-modules-002/pom.xml | 0 .../it/it-update-child-modules-002/verify.bsh | 0 .../it-update-parent-001/invoker.properties | 0 .../src}/it/it-update-parent-001/pom.xml | 0 .../src}/it/it-update-parent-001/verify.bsh | 0 .../it-update-parent-004/invoker.properties | 0 .../src}/it/it-update-parent-004/pom.xml | 0 .../src}/it/it-update-parent-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-parent-005-issue-610/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-update-parent-005-issue-670/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it/it-update-parent-issue-454/pom.xml | 0 .../it-update-parent-issue-454/verify.groovy | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-001/pom.xml | 0 .../it/it-update-properties-001/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-002/pom.xml | 0 .../it/it-update-properties-002/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-003/pom.xml | 0 .../it/it-update-properties-003/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-004/pom.xml | 0 .../it/it-update-properties-004/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-005/pom.xml | 0 .../it/it-update-properties-005/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-006/pom.xml | 0 .../it/it-update-properties-006/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-007/pom.xml | 0 .../it/it-update-properties-007/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-008/pom.xml | 0 .../it/it-update-properties-008/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-009/pom.xml | 0 .../it/it-update-properties-009/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-010/pom.xml | 0 .../it/it-update-properties-010/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-011/pom.xml | 0 .../it/it-update-properties-011/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-012/pom.xml | 0 .../it/it-update-properties-012/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-013/pom.xml | 0 .../it/it-update-properties-013/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-014/pom.xml | 0 .../it/it-update-properties-014/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-015/pom.xml | 0 .../it/it-update-properties-015/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-016/pom.xml | 0 .../it/it-update-properties-016/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-017/pom.xml | 0 .../it/it-update-properties-017/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-018/pom.xml | 0 .../it/it-update-properties-018/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-019/pom.xml | 0 .../it/it-update-properties-019/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-020/pom.xml | 0 .../it/it-update-properties-020/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-021/pom.xml | 0 .../it/it-update-properties-021/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-022/pom.xml | 0 .../it/it-update-properties-022/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-update-properties-023/pom.xml | 0 .../it/it-update-properties-023/verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-279-1/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-279-2/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-279-3/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-279-4/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-279-5/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-properties-issue-582/pom.xml | 0 .../verify.groovy | 0 .../invoker.properties | 0 .../it-update-properties-issue-98-1/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../it-update-properties-issue-98-2/pom.xml | 0 .../verify.bsh | 0 .../it-update-property-001/invoker.properties | 0 .../src}/it/it-update-property-001/pom.xml | 0 .../src}/it/it-update-property-001/verify.bsh | 0 .../it-update-property-002/invoker.properties | 0 .../src}/it/it-update-property-002/pom.xml | 0 .../src}/it/it-update-property-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-property-issue-140-1/pom.xml | 0 .../it-update-property-issue-140-1/verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-property-issue-140-2/pom.xml | 0 .../it-update-property-issue-140-2/verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-property-issue-140-3/pom.xml | 0 .../it-update-property-issue-140-3/verify.bsh | 0 .../invoker.properties | 0 .../it/it-update-property-issue-140/pom.xml | 0 .../it-update-property-issue-140/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-001/pom.xml | 0 .../it/it-use-latest-releases-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-002/pom.xml | 0 .../it/it-use-latest-releases-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-003/pom.xml | 0 .../it-use-latest-releases-003/rule-set.xml | 0 .../it/it-use-latest-releases-003/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-004/pom.xml | 0 .../it/it-use-latest-releases-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-005/pom.xml | 0 .../it/it-use-latest-releases-005/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-006/pom.xml | 0 .../it/it-use-latest-releases-006/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-releases-007/pom.xml | 0 .../it/it-use-latest-releases-007/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-snapshots-001/pom.xml | 0 .../it/it-use-latest-snapshots-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-snapshots-002/pom.xml | 0 .../it/it-use-latest-snapshots-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-snapshots-003/pom.xml | 0 .../it/it-use-latest-snapshots-003/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-snapshots-004/pom.xml | 0 .../it/it-use-latest-snapshots-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-snapshots-005/pom.xml | 0 .../it/it-use-latest-snapshots-005/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-001/pom.xml | 0 .../it/it-use-latest-versions-001/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-002/pom.xml | 0 .../it/it-use-latest-versions-002/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-003/pom.xml | 0 .../it/it-use-latest-versions-003/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-004/pom.xml | 0 .../it/it-use-latest-versions-004/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-005/pom.xml | 0 .../it/it-use-latest-versions-005/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-006/pom.xml | 0 .../it/it-use-latest-versions-006/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-007/pom.xml | 0 .../it/it-use-latest-versions-007/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-008/pom.xml | 0 .../it/it-use-latest-versions-008/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-009/pom.xml | 0 .../it/it-use-latest-versions-009/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-010/pom.xml | 0 .../it/it-use-latest-versions-010/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-011/pom.xml | 0 .../it/it-use-latest-versions-011/verify.bsh | 0 .../invoker.properties | 0 .../it/it-use-latest-versions-012/pom.xml | 0 .../it/it-use-latest-versions-012/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-releases-001/pom.xml | 0 .../it/it-use-next-releases-001/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-releases-002/pom.xml | 0 .../it/it-use-next-releases-002/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-releases-003/pom.xml | 0 .../it/it-use-next-releases-003/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-releases-004/pom.xml | 0 .../it/it-use-next-releases-004/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-snapshots-001/pom.xml | 0 .../it/it-use-next-snapshots-001/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-snapshots-002/pom.xml | 0 .../it/it-use-next-snapshots-002/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-versions-001/pom.xml | 0 .../it/it-use-next-versions-001/verify.bsh | 0 .../invoker.properties | 0 .../it-use-next-versions-002-snapshot/pom.xml | 0 .../verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-versions-002/pom.xml | 0 .../it/it-use-next-versions-002/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-next-versions-003/pom.xml | 0 .../it/it-use-next-versions-003/verify.bsh | 0 .../it/it-use-reactor-001/invoker.properties | 0 .../it/it-use-reactor-001/module-a1/pom.xml | 0 .../it/it-use-reactor-001/module-a2/pom.xml | 0 .../src}/it/it-use-reactor-001/pom.xml | 0 .../the-grandparent/pom.xml | 0 .../it/it-use-reactor-001/the-parent/pom.xml | 0 .../src}/it/it-use-reactor-001/verify.bsh | 0 .../it/it-use-reactor-002/invoker.properties | 0 .../it/it-use-reactor-002/module-a1/pom.xml | 0 .../it/it-use-reactor-002/module-a2/pom.xml | 0 .../src}/it/it-use-reactor-002/pom.xml | 0 .../the-grandparent/pom.xml | 0 .../it/it-use-reactor-002/the-parent/pom.xml | 0 .../src}/it/it-use-reactor-002/verify.bsh | 0 .../it/it-use-releases-001/invoker.properties | 0 .../src}/it/it-use-releases-001/pom.xml | 0 .../src}/it/it-use-releases-001/verify.bsh | 0 .../it/it-use-releases-002/invoker.properties | 0 .../src}/it/it-use-releases-002/pom.xml | 0 .../src}/it/it-use-releases-002/verify.bsh | 0 .../it/it-use-releases-003/invoker.properties | 0 .../src}/it/it-use-releases-003/pom.xml | 0 .../src}/it/it-use-releases-003/verify.bsh | 0 .../invoker.properties | 0 .../src}/it/it-use-releases-issue-583/pom.xml | 0 .../it/it-use-releases-issue-583/verify.bsh | 0 .../src}/it/prep-settings.xml | 0 .../src}/it/settings.xml | 0 .../invoker.properties | 0 .../it/setup-provide-rules-in-jar/pom.xml | 0 .../main/resources/package/foo/bar/rules.xml | 0 ...AbstractVersionsDependencyUpdaterMojo.java | 0 .../versions/AbstractVersionsDisplayMojo.java | 0 .../mojo/versions/AbstractVersionsReport.java | 0 .../versions/AbstractVersionsUpdaterMojo.java | 0 .../codehaus/mojo/versions/CommitMojo.java | 0 .../versions/CompareDependenciesMojo.java | 0 .../versions/DependencyUpdatesReportMojo.java | 0 .../DisplayDependencyUpdatesMojo.java | 0 .../versions/DisplayParentUpdatesMojo.java | 0 .../versions/DisplayPluginUpdatesMojo.java | 0 .../versions/DisplayPropertyUpdatesMojo.java | 0 .../mojo/versions/ForceReleasesMojo.java | 0 .../org/codehaus/mojo/versions/LinkItem.java | 0 .../mojo/versions/LockSnapshotsMojo.java | 0 .../MinimalMavenBuildVersionFinder.java | 0 .../versions/ParentUpdatesReportMojo.java | 0 .../mojo/versions/PluginUpdatesDetails.java | 0 .../versions/PluginUpdatesReportMojo.java | 0 .../org/codehaus/mojo/versions/Property.java | 0 .../versions/PropertyUpdatesReportMojo.java | 0 .../mojo/versions/ResolveRangesMojo.java | 0 .../codehaus/mojo/versions/RevertMojo.java | 0 .../org/codehaus/mojo/versions/SetMojo.java | 0 .../mojo/versions/SetPropertyMojo.java | 0 .../codehaus/mojo/versions/SetScmTagMojo.java | 320 +++++++------- .../mojo/versions/UnlockSnapshotsMojo.java | 0 .../mojo/versions/UpdateChildModulesMojo.java | 0 .../mojo/versions/UpdateParentMojo.java | 0 .../mojo/versions/UpdatePropertiesMojo.java | 0 .../mojo/versions/UpdatePropertyMojo.java | 0 .../mojo/versions/UseDepVersionMojo.java | 0 .../mojo/versions/UseLatestReleasesMojo.java | 0 .../mojo/versions/UseLatestSnapshotsMojo.java | 0 .../mojo/versions/UseLatestVersionsMojo.java | 0 .../mojo/versions/UseNextReleasesMojo.java | 0 .../mojo/versions/UseNextSnapshotsMojo.java | 0 .../mojo/versions/UseNextVersionsMojo.java | 0 .../mojo/versions/UseReactorMojo.java | 0 .../mojo/versions/UseReleasesMojo.java | 0 .../versions/api/AbstractVersionDetails.java | 0 .../versions/api/ArtifactAssociation.java | 0 .../mojo/versions/api/ArtifactVersions.java | 0 .../versions/api/ArtifactVersionsCache.java | 0 .../api/DefaultArtifactAssociation.java | 0 .../versions/api/DefaultVersionsHelper.java | 0 .../codehaus/mojo/versions/api/PomHelper.java | 0 .../mojo/versions/api/PropertyVersions.java | 0 .../versions/api/PropertyVersionsBuilder.java | 0 .../mojo/versions/api/ReportRenderer.java | 0 .../codehaus/mojo/versions/api/Segment.java | 0 .../mojo/versions/api/VersionDetails.java | 0 .../mojo/versions/api/VersionsHelper.java | 0 .../change/AbstractVersionChanger.java | 0 .../change/CompositeVersionChanger.java | 0 .../change/DependencyVersionChanger.java | 0 .../versions/change/ParentVersionChanger.java | 0 .../versions/change/PluginVersionChanger.java | 0 .../change/ProjectVersionChanger.java | 0 .../mojo/versions/change/VersionChange.java | 0 .../mojo/versions/change/VersionChanger.java | 0 .../change/VersionChangerFactory.java | 0 .../versions/filtering/DependencyFilter.java | 0 .../filtering/NullAwareWildcardMatcher.java | 0 .../versions/filtering/TokenizedMatcher.java | 0 .../versions/filtering/WildcardMatcher.java | 0 .../ordering/AbstractVersionComparator.java | 0 .../ordering/BoundArtifactVersion.java | 0 .../versions/ordering/ComparableVersion.java | 0 .../ordering/InvalidSegmentException.java | 0 .../ordering/MavenVersionComparator.java | 0 .../ordering/MercuryVersionComparator.java | 0 .../ordering/NumericVersionComparator.java | 0 .../ordering/ReactorDepthComparator.java | 0 .../versions/ordering/VersionComparator.java | 0 .../versions/ordering/VersionComparators.java | 0 .../versions/recording/ChangeRecorder.java | 0 .../recording/ChangeRecorderNull.java | 0 .../versions/recording/ChangeRecorderXML.java | 0 .../AbstractVersionsReportRenderer.java | 0 .../DependencyUpdatesReportRenderer.java | 0 .../versions/reporting/OverviewStats.java | 0 .../ParentUpdatesReportRenderer.java | 0 .../reporting/PluginOverviewStats.java | 0 .../PluginUpdatesReportRenderer.java | 0 .../PropertyUpdatesReportRenderer.java | 0 .../reporting/ReportRendererFactory.java | 0 .../reporting/ReportRendererFactoryImpl.java | 0 .../reporting/VersionsReportRendererBase.java | 0 .../reporting/model/AbstractUpdatesModel.java | 0 .../model/DependencyUpdatesModel.java | 0 .../reporting/model/ParentUpdatesModel.java | 0 .../reporting/model/PluginUpdatesModel.java | 0 .../reporting/model/PropertyUpdatesModel.java | 0 .../rewriting/ModifiedPomXMLEventReader.java | 0 .../mojo/versions/utils/ContextualLog.java | 0 .../utils/DelegatingContextualLog.java | 0 .../versions/utils/DependencyBuilder.java | 0 .../versions/utils/DependencyComparator.java | 0 .../mojo/versions/utils/MiscUtils.java | 0 .../mojo/versions/utils/PluginComparator.java | 0 .../utils/PropertiesVersionsFileReader.java | 0 .../versions/utils/PropertyComparator.java | 0 .../mojo/versions/utils/RegexUtils.java | 0 .../mojo/versions/utils/SegmentUtils.java | 0 .../utils/VersionsExpressionEvaluator.java | 0 .../mojo/versions/utils/WagonUtils.java | 0 .../DependencyUpdatesXmlReportRenderer.java | 0 .../xml/PluginUpdatesXmlReportRenderer.java | 0 .../m2e/lifecycle-mapping-metadata.xml | 0 .../dependency-updates-report.properties | 0 .../mojo/versions/recording/schema-1.0.xsd | 0 .../parent-updates-report.properties | 0 .../plugin-updates-report.properties | 0 .../property-updates-report.properties | 0 .../advancing-dependency-versions.md.vm | 0 .../markdown/examples/compare-dependencies.md | 0 .../examples/display-dependency-updates.md | 0 .../examples/display-plugin-updates.md | 0 .../examples/display-property-updates.md | 0 .../site/markdown/examples/lock-snapshots.md | 0 .../markdown/examples/recording-changes.md | 0 .../site/markdown/examples/resolve-ranges.md | 0 .../src}/site/markdown/examples/set.md | 0 .../site/markdown/examples/setaggregator.md | 0 .../markdown/examples/unlock-snapshots.md | 0 .../markdown/examples/update-child-modules.md | 0 .../site/markdown/examples/update-parent.md | 0 .../markdown/examples/update-properties.md.vm | 0 .../site/markdown/examples/use-releases.md | 0 .../src}/site/markdown/faq.md | 0 .../src}/site/markdown/index.md | 0 .../src}/site/markdown/usage.md.vm | 0 .../src}/site/markdown/version-rules.md.vm | 0 .../src/site/markdown/xsd/index.md.vm | 20 + versions-maven-plugin/src/site/site.xml | 40 ++ .../AbstractVersionsUpdaterMojoTest.java | 0 .../DependencyUpdatesReportMojoTest.java | 0 .../DependencyUpdatesXmlRendererTest.java | 0 .../DisplayDependencyUpdatesMojoTest.java | 0 .../DisplayPropertyUpdatesMojoTest.java | 0 .../codehaus/mojo/versions/HasGAVMatcher.java | 0 .../MinimalMavenBuildVersionFinderTest.java | 0 .../versions/ParentUpdatesReportMojoTest.java | 0 .../versions/PluginUpdatesReportMojoTest.java | 0 .../PluginUpdatesXmlRendererTest.java | 0 .../PropertyUpdatesReportMojoTest.java | 0 .../mojo/versions/RevertMojoTest.java | 0 .../mojo/versions/RewriteWithStAXTest.java | 0 ...ratePatternsForIncludesAnExcludesTest.java | 0 .../codehaus/mojo/versions/SetMojoTest.java | 0 .../mojo/versions/SetPropertyMojoTest.java | 0 .../mojo/versions/SetScmTagMojoTest.java | 0 .../mojo/versions/UpdateParentMojoTest.java | 0 .../versions/UpdatePropertiesMojoTest.java | 0 .../UpdatePropertiesMojoTestBase.java | 0 .../mojo/versions/UpdatePropertyMojoTest.java | 0 .../mojo/versions/UseDepVersionMojoTest.java | 0 .../versions/UseLatestReleasesMojoTest.java | 0 .../versions/UseLatestVersionsMojoTest.java | 0 .../versions/api/ArtifactVersionsTest.java | 0 .../api/DefaultVersionsHelperTest.java | 0 .../mojo/versions/api/PomHelperTest.java | 0 .../filtering/DependencyFilterTest.java | 0 .../filtering/TokenizedMatcherTest.java | 0 .../filtering/WildcardMatcherTest.java | 0 .../versions/model/TestIgnoreVersions.java | 0 .../ordering/BoundArtifactVersionTest.java | 0 .../ordering/MavenVersionComparatorTest.java | 0 .../MercuryVersionComparatorTest.java | 0 .../NumericVersionComparatorTest.java | 0 .../ordering/VersionComparatorTestBase.java | 0 .../recording/ChangeRecorderXMLTest.java | 0 .../ModifiedPomXMLEventReaderTest.java | 0 .../mojo/versions/utils/MockUtils.java | 0 .../utils/ModifiedPomXMLEventReaderUtils.java | 0 .../PropertiesVersionsFileReaderTest.java | 0 .../mojo/versions/utils/SegmentUtilsTest.java | 0 .../versions/utils/TestChangeRecorder.java | 0 .../mojo/versions/utils/TestUtils.java | 0 .../ruleset/pom.xml | 0 .../version-interpolation/pom.xml | 19 + .../display-plugin-updates/ruleset/pom.xml | 0 .../issue-367/child/pom.xml | 0 .../issue-367/pom.xml | 0 .../mojo/revert/issue-265/aggregate/pom.xml | 0 .../aggregate/pom.xml.versionsBackup | 0 .../mojo/revert/issue-265/module-a/pom.xml | 0 .../issue-265/module-a/pom.xml.versionsBackup | 0 .../mojo/revert/issue-265/module-b/pom.xml | 0 .../issue-265/module-b/pom.xml.versionsBackup | 0 .../set-property/null-new-version/pom.xml | 0 .../mojo/set-property/null-property/pom.xml | 0 .../org/codehaus/mojo/set-scm-tag/pom.xml | 0 .../codehaus/mojo/set/remove-snapshot/pom.xml | 0 .../codehaus/mojo/set/versionless-01/pom.xml | 0 .../mojo/update-properties/issue-454-pom.xml | 0 .../mojo/use-dep-version/issue-637/pom.xml | 0 ...elperTest.dependencyManagementBOMs.pom.xml | 0 .../PomHelperTest.noGroupIdOnChild.pom.xml | 0 .../PomHelperTest.testLongProperties.pom.xml | 0 .../org/codehaus/mojo/versions/api/rules.xml | 0 .../mojo/versions/recording/expectedFile.xml | 0 .../testPropertiesVersionsFile.properties | 0 988 files changed, 845 insertions(+), 672 deletions(-) create mode 100644 model-report/pom.xml rename {src => model-report/src}/main/mdo/dependency-updates-report.mdo (100%) rename {src => model-report/src}/main/mdo/plugin-updates-report.mdo (100%) create mode 100644 model/pom.xml rename {src => model/src}/main/mdo/rule.mdo (100%) delete mode 100644 src/site/markdown/xsd/index.md delete mode 100644 src/site/resources/xsd/rule-2.0.0.xsd create mode 100644 versions-maven-plugin/pom.xml rename {src => versions-maven-plugin/src}/changes/changes.xml (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.0.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.0-2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.1-2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.2-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.3.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.2.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.2.2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.3.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-1.9.1-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-2.1.1-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-2.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-3.1.1-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-3.1.5-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-3.4.0-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-impl-bom-pom-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-api-impl-bom-pom-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-bom-maven-mismatch-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-bom-pom-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-1.2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-1.3.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-1.4.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-2.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-impl-2.2.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-maven-plugin-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-maven-plugin-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-maven-plugin-2.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-maven-plugin-3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-maven-plugin-3.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent-3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent-issue-582-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-2.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.0-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.0-alpha-1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.0-beta-1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.0-rc-1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent2-3.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent3-1.0.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent4-70.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent4-71-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent5-1.0.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/dummy-parent5-2.0.0-rc1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/issue-114-artifact-1.0.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/issue-114-artifact-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/issue-114-artifact-1.1.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/issue-114-artifact-1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/issue-114-depmgmt-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-2.0.11.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-2.0.8.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-2.1.0-M1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-2.2.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-3.0-beta-3.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-3.1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/latest-versions-api-3.3.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/module-a1-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-1.1.1.1.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-1.1.1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.0.0.0.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.0.0.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.0.10.0.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.0.10.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.12.0.0.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-2.12.0.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/module-0.0.2.19.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/module-0.0.2.19.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/module-1.2.3-SNAPSHOT.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/module-1.2.3-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.18.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.18.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.19.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.19.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.20.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-0.0.2.20.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.jar (100%) rename {src => versions-maven-plugin/src}/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/the-grandparent-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/the-parent-1.0.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/update-api-1.9.5.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/update-api-2.0.0-beta.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/versions-rules-3.0.1-1.1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/versions-rules-3.0.1-1.pom (100%) rename {src => versions-maven-plugin/src}/it-repo/versions-rules-3.0.1.pom (100%) rename {src => versions-maven-plugin/src}/it/it-abstract-versions-report-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-abstract-versions-report-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-abstract-versions-report-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-parent-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-parent-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-parent-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-properties-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-properties-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-update-properties-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-releases-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-releases-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-releases-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-snapshots-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-snapshots-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-snapshots-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-versions-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-versions-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-latest-versions-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-next-versions-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-next-versions-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-changerecord-use-next-versions-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-001/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-002/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-003/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-004/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-005/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-compare-dependencies-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-001/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-002/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-003/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-004/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-684-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-684-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-684-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-755/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-755/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-dependency-updates-report-issue-755/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-007-outputFile/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-007-outputFile/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-007-outputFile/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-008-outputLineWidth/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-1/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-1/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-2/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-2/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-3/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-3/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-4/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-4/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-4/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-5/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-5/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-34-5/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-007/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-007/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-007/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-008/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-008/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-008/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-009-issue-422/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-009-issue-422/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-009-issue-422/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-010-issue-526/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-010-issue-526/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-010-issue-526/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-012-outputLineWidth/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-002-outputLineWidth/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-002-outputLineWidth/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-002-outputLineWidth/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-encoding-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-encoding-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-encoding-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-parent-updates-report-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-parent-updates-report-001/module/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-parent-updates-report-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-parent-updates-report-001/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-parent-updates-report-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-001/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-002/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-003/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-684-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-684-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-684-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-755/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-755/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-plugin-updates-report-issue-755/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-001/src/site/site.xml (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-002-slow/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-002-slow/maven-version-rules.xml (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-002-slow/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-issue-684-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-issue-684-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-property-updates-report-issue-684-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-003/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-003/child2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-004/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-442/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-442/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-442/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-454/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-454/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-resolve-ranges-issue-454/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-revert-isssue-265/aggregate/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-revert-isssue-265/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-revert-isssue-265/module-a/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-revert-isssue-265/module-b/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-revert-isssue-265/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-rules-via-classpath-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-001-issue-76/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-001-issue-76/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-001-issue-76/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-002/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-003/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-003/child2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-005/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-005/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/module-a3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-007/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-007/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-007/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-007/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-007/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/module-a1/module-b1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/module-a1/module-b2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/module-a1/module-b3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-008/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-009/alternative-pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-009/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-009/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-009/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/fake-api/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/fake-api/src/main/java/org/eclipse/jetty/App.java (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/fake-api/src/test/java/org/eclipse/jetty/AppTest.java (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/the-bom/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-010-issue-198/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-010/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-010/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-010/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-011/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-011/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-011/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-011/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-012/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-012/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-012/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-013/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-013/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-013/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-014/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-014/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-014/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-015/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-015/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-015/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-016/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-016/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-016/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-016/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-017-issue-321/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-017-issue-321/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-017-issue-321/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-017-issue-321/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-017-issue-321/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/module-a1/module-b1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/module-a1/module-b2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/module-a1/module-b3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-018-issue-82/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/module-a1/module-b1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/module-a1/module-b2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/module-a1/module-b3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-issue-426/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-outputTimestamp/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-outputTimestamp/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-019-outputTimestamp/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-020-outputTimestamp-disabled/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-020-outputTimestamp-disabled/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-020-outputTimestamp-disabled/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-021-outputTimestampPolicy-always/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-021-outputTimestampPolicy-always/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-021-outputTimestampPolicy-always/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-022-outputTimestampPolicy-onchange/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-023-outputTimestampPolicy-never/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-023-outputTimestampPolicy-never/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-023-outputTimestampPolicy-never/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-024-versionless-dependency/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-024-versionless-dependency/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-024-versionless-dependency/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-003-multiple-properties/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-003-multiple-properties/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-property-003-multiple-properties/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-001/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-004/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-004/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-set-scm-tag-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-unlock-snapshots-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-unlock-snapshots-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-unlock-snapshots-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-001/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/child/subchild/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/child/subchild2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/child2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-child-modules-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-610/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-610/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-610/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-670/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-670/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-005-issue-670/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-issue-454/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-issue-454/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-parent-issue-454/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-007/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-007/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-007/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-008/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-008/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-008/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-009/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-009/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-009/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-010/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-010/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-010/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-011/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-011/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-011/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-012/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-012/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-012/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-013/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-013/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-013/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-014/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-014/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-014/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-015/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-015/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-015/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-016/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-016/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-016/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-017/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-017/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-017/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-018/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-018/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-018/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-019/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-019/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-019/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-020/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-020/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-020/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-021/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-021/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-021/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-022/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-022/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-022/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-023/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-023/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-023/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-1/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-1/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-2/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-2/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-3/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-3/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-4/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-4/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-4/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-5/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-5/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-279-5/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-582/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-582/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-582/verify.groovy (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-1/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-1/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-2/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-properties-issue-98-2/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-1/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-1/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-2/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-2/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-3/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-3/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140-3/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-update-property-issue-140/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-003/rule-set.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-007/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-007/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-releases-007/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-snapshots-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-005/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-005/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-005/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-006/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-006/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-006/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-007/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-007/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-007/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-008/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-008/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-008/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-009/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-009/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-009/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-010/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-010/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-010/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-011/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-011/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-011/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-012/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-012/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-latest-versions-012/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-004/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-004/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-releases-004/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-snapshots-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002-snapshot/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002-snapshot/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002-snapshot/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-next-versions-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/the-grandparent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/the-parent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/module-a1/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/module-a2/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/the-grandparent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/the-parent/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-reactor-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-001/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-001/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-001/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-002/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-002/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-002/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-003/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-003/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-003/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-issue-583/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-issue-583/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/it-use-releases-issue-583/verify.bsh (100%) rename {src => versions-maven-plugin/src}/it/prep-settings.xml (100%) rename {src => versions-maven-plugin/src}/it/settings.xml (100%) rename {src => versions-maven-plugin/src}/it/setup-provide-rules-in-jar/invoker.properties (100%) rename {src => versions-maven-plugin/src}/it/setup-provide-rules-in-jar/pom.xml (100%) rename {src => versions-maven-plugin/src}/it/setup-provide-rules-in-jar/src/main/resources/package/foo/bar/rules.xml (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/CommitMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/LinkItem.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/Property.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/RevertMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/SetMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java (97%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseReactorMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/PomHelper.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/Segment.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/VersionDetails.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/VersionChange.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/VersionChanger.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java (100%) rename {src => versions-maven-plugin/src}/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml (100%) rename {src => versions-maven-plugin/src}/main/resources/dependency-updates-report.properties (100%) rename {src => versions-maven-plugin/src}/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd (100%) rename {src => versions-maven-plugin/src}/main/resources/parent-updates-report.properties (100%) rename {src => versions-maven-plugin/src}/main/resources/plugin-updates-report.properties (100%) rename {src => versions-maven-plugin/src}/main/resources/property-updates-report.properties (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/advancing-dependency-versions.md.vm (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/compare-dependencies.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/display-dependency-updates.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/display-plugin-updates.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/display-property-updates.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/lock-snapshots.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/recording-changes.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/resolve-ranges.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/set.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/setaggregator.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/unlock-snapshots.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/update-child-modules.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/update-parent.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/update-properties.md.vm (100%) rename {src => versions-maven-plugin/src}/site/markdown/examples/use-releases.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/faq.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/index.md (100%) rename {src => versions-maven-plugin/src}/site/markdown/usage.md.vm (100%) rename {src => versions-maven-plugin/src}/site/markdown/version-rules.md.vm (100%) create mode 100644 versions-maven-plugin/src/site/markdown/xsd/index.md.vm create mode 100644 versions-maven-plugin/src/site/site.xml rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/RevertMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/SetMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/MockUtils.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java (100%) rename {src => versions-maven-plugin/src}/test/java/org/codehaus/mojo/versions/utils/TestUtils.java (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml (62%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/api/rules.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml (100%) rename {src => versions-maven-plugin/src}/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties (100%) diff --git a/model-report/pom.xml b/model-report/pom.xml new file mode 100644 index 0000000000..a8220b7376 --- /dev/null +++ b/model-report/pom.xml @@ -0,0 +1,106 @@ + + + + versions + org.codehaus.mojo.versions + 2.14.0-SNAPSHOT + + 4.0.0 + + model-report + + + + org.codehaus.plexus + plexus-utils + 3.4.2 + + + + + + + org.codehaus.modello + modello-maven-plugin + + + generate-rule + generate-sources + + + xpp3-reader + + xpp3-writer + + java + + + + site-doc + pre-site + + xdoc + + + + site-xsd + pre-site + + xsd + + + ${project.build.directory}/generated-site/resources/xsd + + + + + + src/main/mdo/dependency-updates-report.mdo + src/main/mdo/plugin-updates-report.mdo + + ${modelloNamespaceVersion} + + + + + maven-javadoc-plugin + + true + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + + + check-java18 + test + + check + + + + org.codehaus.mojo.signature + java18 + 1.0 + + + + + + + + + + \ No newline at end of file diff --git a/src/main/mdo/dependency-updates-report.mdo b/model-report/src/main/mdo/dependency-updates-report.mdo similarity index 100% rename from src/main/mdo/dependency-updates-report.mdo rename to model-report/src/main/mdo/dependency-updates-report.mdo diff --git a/src/main/mdo/plugin-updates-report.mdo b/model-report/src/main/mdo/plugin-updates-report.mdo similarity index 100% rename from src/main/mdo/plugin-updates-report.mdo rename to model-report/src/main/mdo/plugin-updates-report.mdo diff --git a/model/pom.xml b/model/pom.xml new file mode 100644 index 0000000000..98406b4e19 --- /dev/null +++ b/model/pom.xml @@ -0,0 +1,105 @@ + + + + versions + org.codehaus.mojo.versions + 2.14.0-SNAPSHOT + + 4.0.0 + + model + + + + org.codehaus.plexus + plexus-utils + 3.4.2 + + + + + + + org.codehaus.modello + modello-maven-plugin + + + generate-rule + generate-sources + + + xpp3-reader + + xpp3-writer + + java + + + + site-doc + pre-site + + xdoc + + + + site-xsd + pre-site + + xsd + + + ${project.build.directory}/generated-site/resources/xsd + + + + + + src/main/mdo/rule.mdo + + ${modelloNamespaceVersion} + + + + + maven-javadoc-plugin + + true + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + + + check-java18 + test + + check + + + + org.codehaus.mojo.signature + java18 + 1.0 + + + + + + + + + + \ No newline at end of file diff --git a/src/main/mdo/rule.mdo b/model/src/main/mdo/rule.mdo similarity index 100% rename from src/main/mdo/rule.mdo rename to model/src/main/mdo/rule.mdo diff --git a/pom.xml b/pom.xml index 4fc1fcde21..2fe60a985f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 @@ -7,9 +9,10 @@ 71 - versions-maven-plugin + org.codehaus.mojo.versions + versions 2.14.0-SNAPSHOT - maven-plugin + pom Versions Maven Plugin https://www.mojohaus.org/versions-maven-plugin/ @@ -105,6 +108,12 @@ 2.13.0 + + versions-maven-plugin + model + model-report + + 1.8 ${mojo.java.target} @@ -115,6 +124,7 @@ 1.11.1 ${project.version} 3.7 + 2.0.0 2022-10-23T15:41:47Z @@ -127,161 +137,59 @@ pom import
    + + org.apache.maven.reporting + maven-reporting-api + 3.1.1 + + + org.apache.maven.reporting + maven-reporting-impl + 3.2.0 + + + org.apache.maven.shared + maven-common-artifact-filters + 3.3.2 + + + org.codehaus.plexus + plexus-interactivity-api + 1.1 + + + com.fasterxml.woodstox + woodstox-core + 6.3.1 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 3.3.0 + + + org.mockito + mockito-inline + 4.8.1 + + + org.hamcrest + hamcrest + 2.2 + + + org.slf4j + slf4j-simple + 1.7.36 + - - - org.apache.maven.plugin-tools - maven-plugin-annotations - provided - - - - org.apache.maven - maven-artifact - ${mavenVersion} - provided - - - org.apache.maven - maven-core - ${mavenVersion} - provided - - - org.apache.maven - maven-compat - ${mavenVersion} - provided - - - org.apache.maven - maven-model - ${mavenVersion} - provided - - - org.apache.maven - maven-plugin-api - ${mavenVersion} - provided - - - org.apache.maven - maven-settings - ${mavenVersion} - provided - - - org.apache.maven.reporting - maven-reporting-api - 3.1.1 - - - org.apache.maven.reporting - maven-reporting-impl - 3.2.0 - - - org.apache.maven.shared - maven-common-artifact-filters - 3.3.2 - - - org.apache.maven.wagon - wagon-provider-api - ${wagonVersion} - provided - - - org.apache.maven.wagon - wagon-file - ${wagonVersion} - - - - - org.apache.maven.doxia - doxia-core - ${doxiaVersion} - - - org.apache.maven.doxia - doxia-sink-api - ${doxiaVersion} - - - - - org.apache.maven.doxia - doxia-site-renderer - ${doxia-sitetoolsVersion} - - - - org.codehaus.plexus - plexus-utils - 3.5.0 - - - org.codehaus.plexus - plexus-interactivity-api - 1.1 - - - com.fasterxml.woodstox - woodstox-core - 6.4.0 - - - org.apache.commons - commons-lang3 - 3.12.0 - - - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - 3.3.0 - test - - - org.junit.jupiter - junit-jupiter - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - - - org.mockito - mockito-inline - 4.8.1 - test - - - org.hamcrest - hamcrest - 2.2 - test - - - org.slf4j - slf4j-simple - 1.7.36 - test - - - @@ -308,193 +216,7 @@ - - org.codehaus.modello - modello-maven-plugin - - - generate-source - - - xpp3-reader - - xpp3-writer - - java - - - - site-doc - pre-site - - xdoc - - - ${project.build.directory}/generated-site/xdoc/model - - - - site-xsd - pre-site - - xsd - - - ${project.build.directory}/generated-site/resources/xsd - - - - - - src/main/mdo/rule.mdo - src/main/mdo/dependency-updates-report.mdo - src/main/mdo/plugin-updates-report.mdo - - 2.1.0 - - - - org.apache.maven.plugins - maven-invoker-plugin - - src/it - ${project.build.directory}/it - ${project.build.directory}/local-repo - src/it/settings.xml - true - true - - 1 - - */pom.xml - - - - it-property-updates-report-002-slow/* - - verify - - ${repository.proxy.url} - - -Xmx256m - - - - maven-javadoc-plugin - - - - org.codehaus.mojo.versions.model, - org.codehaus.mojo.versions.model.io.xpp3 - org.codehaus.mojo.versions.reporting.model, - org.codehaus.mojo.versions.reporting.model.io.xpp3, - - - - - - - maven-javadoc-plugin - - ${mojo.java.target} - - - - maven-invoker-plugin - - - - report - - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - - - - dependency-updates-report - plugin-updates-report - property-updates-report - parent-updates-report - - - - - - - - - - - run-its - - verify - - - - org.codehaus.mojo - mrm-maven-plugin - - - - start - stop - - - - - repository.proxy.url - - - src/it-repo - - - ${project.build.directory}/local-repo - - - - - - - org.apache.maven.plugins - maven-invoker-plugin - - - integration-test - - install - integration-test - verify - - - false - true - - - - - - - -
    diff --git a/src/site/markdown/xsd/index.md b/src/site/markdown/xsd/index.md deleted file mode 100644 index ec05854c6a..0000000000 --- a/src/site/markdown/xsd/index.md +++ /dev/null @@ -1,20 +0,0 @@ -title: XML schemas -author: Slawomir Jaranowski -date: 2022-10-17 - - - -# Versions - XML schemas - -## dependency-updates-report.xsd - - - [dependency-updates-report-2.1.0.xsd](dependency-updates-report-2.1.0.xsd) - -## plugin-updates-report.xsd - - - [plugin-updates-report-2.1.0.xsd](plugin-updates-report-2.1.0.xsd) - -## rule.xsd - - - [rule-2.0.0.xsd](rule-2.0.0.xsd) - - [rule-2.1.0.xsd](rule-2.1.0.xsd) diff --git a/src/site/resources/xsd/rule-2.0.0.xsd b/src/site/resources/xsd/rule-2.0.0.xsd deleted file mode 100644 index 45dedf444b..0000000000 --- a/src/site/resources/xsd/rule-2.0.0.xsd +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - 1.0.0+ - - Describes a set of rules for how versions of artifacts should be handled. - - - - - - 1.0.0+ - - Describes a set of rules for how versions of artifacts should be handled. - - - - - - 2.0.0+ - Version patterns to ignore for all artifacts. - - - - - - - - - - 1.0.0+ - - - - - - - - - - - 1.0.0+ - The comparison method to use when no rule matches. - - - - - - - - 2.0.0+ - A version to ignore. - - - - 2.0.0+ - The type of ignore mechanism to use. Allowed values are 'exact' and 'regex'. - - - - - - - - 1.0.0+ - - Describes a rule for how versions of artifacts should be handled. - - - - - - 2.0.0+ - Version patterns to ignore for this rule. - - - - - - - - - - - 1.0.0+ - - The for groupId to which this rule applies. Wildcards with ? and * are valid. - A rule applies to all child groupIds unless overridden by a subsequent rule. - A rule without wildcards will override a rule with wildcards. - A rule with ? wildcards will override a rule with * wildcards. - - - - - - 1.0.0+ - - The artifactId to which this rule applies. Wildcards with ? and * are valid. - A rule without wildcards will override a rule with wildcards. - A rule with ? wildcards will override a rule with * wildcards. - - - - - - 1.0.0+ - The comparison method that this rule specifies. - - - - diff --git a/src/site/site.xml b/src/site/site.xml index 3a21555dd9..d9443a64dc 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -1,37 +1,37 @@ - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + org.apache.maven.skins + maven-fluido-skin + 1.8 + + + + + + mojohaus/versions-maven-plugin + right + gray + + + + + + + + + + + +
    + Apache ${project.name}, ${project.name}, Apache, the Apache feather logo, and the Apache ${project.name} project logos are trademarks of The Apache Software Foundation.

    + ]]> +
    + +
    diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml new file mode 100644 index 0000000000..28483c340d --- /dev/null +++ b/versions-maven-plugin/pom.xml @@ -0,0 +1,297 @@ + + 4.0.0 + + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + + + org.codehaus.mojo + versions-maven-plugin + maven-plugin + + + + org.codehaus.mojo.versions + model + ${project.version} + + + + org.codehaus.mojo.versions + model-report + ${project.version} + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + + org.apache.maven + maven-artifact + ${mavenVersion} + provided + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.apache.maven + maven-compat + ${mavenVersion} + provided + + + org.apache.maven + maven-model + ${mavenVersion} + provided + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + provided + + + org.apache.maven + maven-settings + ${mavenVersion} + provided + + + org.apache.maven.reporting + maven-reporting-api + + + org.apache.maven.reporting + maven-reporting-impl + + + org.apache.maven.shared + maven-common-artifact-filters + + + org.apache.maven.wagon + wagon-provider-api + ${wagonVersion} + provided + + + org.apache.maven.wagon + wagon-file + ${wagonVersion} + + + + + org.apache.maven.doxia + doxia-core + ${doxiaVersion} + + + org.apache.maven.doxia + doxia-sink-api + ${doxiaVersion} + + + + + org.apache.maven.doxia + doxia-site-renderer + ${doxia-sitetoolsVersion} + + + + org.codehaus.plexus + plexus-interactivity-api + + + com.fasterxml.woodstox + woodstox-core + + + org.apache.commons + commons-lang3 + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + org.mockito + mockito-inline + test + + + org.hamcrest + hamcrest + test + + + org.slf4j + slf4j-simple + test + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + src/it + ${project.build.directory}/it + ${project.build.directory}/local-repo + src/it/settings.xml + true + true + + 1 + + */pom.xml + + + + it-property-updates-report-002-slow/* + + verify + + ${repository.proxy.url} + + -Xmx256m + + + + + + + + + maven-javadoc-plugin + + ${mojo.java.target} + + + + maven-invoker-plugin + + + + report + + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + + + + dependency-updates-report + plugin-updates-report + property-updates-report + parent-updates-report + + + + + + + + + + + run-its + + verify + + + + org.codehaus.mojo + mrm-maven-plugin + + + + start + stop + + + + + repository.proxy.url + + + src/it-repo + + + ${project.build.directory}/local-repo + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + integration-test + + install + integration-test + verify + + + false + true + + + + + + + + + diff --git a/src/changes/changes.xml b/versions-maven-plugin/src/changes/changes.xml similarity index 100% rename from src/changes/changes.xml rename to versions-maven-plugin/src/changes/changes.xml diff --git a/src/it-repo/dummy-api-1.0.1.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.0.1.pom similarity index 100% rename from src/it-repo/dummy-api-1.0.1.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.0.1.pom diff --git a/src/it-repo/dummy-api-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.0.pom similarity index 100% rename from src/it-repo/dummy-api-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.0.pom diff --git a/src/it-repo/dummy-api-1.1-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-1.1-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-1.1.0-2.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.0-2.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.0-2.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.0-2.pom diff --git a/src/it-repo/dummy-api-1.1.1-2.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.1-2.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.1-2.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.1-2.pom diff --git a/src/it-repo/dummy-api-1.1.1.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.1.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.1.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.1.pom diff --git a/src/it-repo/dummy-api-1.1.2-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.2-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.2-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.2-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-1.1.2.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.2.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.2.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.2.pom diff --git a/src/it-repo/dummy-api-1.1.3.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.3.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.3.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.3.pom diff --git a/src/it-repo/dummy-api-1.1.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.1.pom similarity index 100% rename from src/it-repo/dummy-api-1.1.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.1.pom diff --git a/src/it-repo/dummy-api-1.2.1.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.2.1.pom similarity index 100% rename from src/it-repo/dummy-api-1.2.1.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.2.1.pom diff --git a/src/it-repo/dummy-api-1.2.2.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.2.2.pom similarity index 100% rename from src/it-repo/dummy-api-1.2.2.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.2.2.pom diff --git a/src/it-repo/dummy-api-1.2.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.2.pom similarity index 100% rename from src/it-repo/dummy-api-1.2.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.2.pom diff --git a/src/it-repo/dummy-api-1.3.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.3.pom similarity index 100% rename from src/it-repo/dummy-api-1.3.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.3.pom diff --git a/src/it-repo/dummy-api-1.9.1-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-1.9.1-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-1.9.1-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-1.9.1-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-api-2.0.pom similarity index 100% rename from src/it-repo/dummy-api-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-api-2.0.pom diff --git a/src/it-repo/dummy-api-2.1.1-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-2.1.1-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-2.1.1-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-2.1.1-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-2.1.pom b/versions-maven-plugin/src/it-repo/dummy-api-2.1.pom similarity index 100% rename from src/it-repo/dummy-api-2.1.pom rename to versions-maven-plugin/src/it-repo/dummy-api-2.1.pom diff --git a/src/it-repo/dummy-api-3.0.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.0.pom similarity index 100% rename from src/it-repo/dummy-api-3.0.pom rename to versions-maven-plugin/src/it-repo/dummy-api-3.0.pom diff --git a/src/it-repo/dummy-api-3.1.1-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.1.1-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-3.1.1-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-3.1.1-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-3.1.5-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.1.5-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-3.1.5-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-3.1.5-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom diff --git a/src/it-repo/dummy-api-impl-bom-pom-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-api-impl-bom-pom-1.0.pom similarity index 100% rename from src/it-repo/dummy-api-impl-bom-pom-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-api-impl-bom-pom-1.0.pom diff --git a/src/it-repo/dummy-api-impl-bom-pom-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-api-impl-bom-pom-2.0.pom similarity index 100% rename from src/it-repo/dummy-api-impl-bom-pom-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-api-impl-bom-pom-2.0.pom diff --git a/src/it-repo/dummy-bom-maven-mismatch-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom-maven-mismatch-1.0.pom similarity index 100% rename from src/it-repo/dummy-bom-maven-mismatch-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-bom-maven-mismatch-1.0.pom diff --git a/src/it-repo/dummy-bom-pom-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom-pom-1.0.pom similarity index 100% rename from src/it-repo/dummy-bom-pom-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-bom-pom-1.0.pom diff --git a/src/it-repo/dummy-impl-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-impl-1.0.pom similarity index 100% rename from src/it-repo/dummy-impl-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-1.0.pom diff --git a/src/it-repo/dummy-impl-1.1.pom b/versions-maven-plugin/src/it-repo/dummy-impl-1.1.pom similarity index 100% rename from src/it-repo/dummy-impl-1.1.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-1.1.pom diff --git a/src/it-repo/dummy-impl-1.2.pom b/versions-maven-plugin/src/it-repo/dummy-impl-1.2.pom similarity index 100% rename from src/it-repo/dummy-impl-1.2.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-1.2.pom diff --git a/src/it-repo/dummy-impl-1.3.pom b/versions-maven-plugin/src/it-repo/dummy-impl-1.3.pom similarity index 100% rename from src/it-repo/dummy-impl-1.3.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-1.3.pom diff --git a/src/it-repo/dummy-impl-1.4.pom b/versions-maven-plugin/src/it-repo/dummy-impl-1.4.pom similarity index 100% rename from src/it-repo/dummy-impl-1.4.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-1.4.pom diff --git a/src/it-repo/dummy-impl-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-impl-2.0.pom similarity index 100% rename from src/it-repo/dummy-impl-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-2.0.pom diff --git a/src/it-repo/dummy-impl-2.1.pom b/versions-maven-plugin/src/it-repo/dummy-impl-2.1.pom similarity index 100% rename from src/it-repo/dummy-impl-2.1.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-2.1.pom diff --git a/src/it-repo/dummy-impl-2.2.pom b/versions-maven-plugin/src/it-repo/dummy-impl-2.2.pom similarity index 100% rename from src/it-repo/dummy-impl-2.2.pom rename to versions-maven-plugin/src/it-repo/dummy-impl-2.2.pom diff --git a/src/it-repo/dummy-maven-plugin-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-1.0.pom similarity index 100% rename from src/it-repo/dummy-maven-plugin-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-maven-plugin-1.0.pom diff --git a/src/it-repo/dummy-maven-plugin-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-2.0.pom similarity index 100% rename from src/it-repo/dummy-maven-plugin-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-maven-plugin-2.0.pom diff --git a/src/it-repo/dummy-maven-plugin-2.1.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-2.1.pom similarity index 100% rename from src/it-repo/dummy-maven-plugin-2.1.pom rename to versions-maven-plugin/src/it-repo/dummy-maven-plugin-2.1.pom diff --git a/src/it-repo/dummy-maven-plugin-3.0.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.0.pom similarity index 100% rename from src/it-repo/dummy-maven-plugin-3.0.pom rename to versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.0.pom diff --git a/src/it-repo/dummy-maven-plugin-3.1.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom similarity index 100% rename from src/it-repo/dummy-maven-plugin-3.1.pom rename to versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom diff --git a/src/it-repo/dummy-parent-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent-1.0.pom similarity index 100% rename from src/it-repo/dummy-parent-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent-1.0.pom diff --git a/src/it-repo/dummy-parent-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent-2.0.pom similarity index 100% rename from src/it-repo/dummy-parent-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent-2.0.pom diff --git a/src/it-repo/dummy-parent-3.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent-3.0.pom similarity index 100% rename from src/it-repo/dummy-parent-3.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent-3.0.pom diff --git a/src/it-repo/dummy-parent-issue-582-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent-issue-582-1.0.pom similarity index 100% rename from src/it-repo/dummy-parent-issue-582-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent-issue-582-1.0.pom diff --git a/src/it-repo/dummy-parent2-1.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-1.0.pom similarity index 100% rename from src/it-repo/dummy-parent2-1.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-1.0.pom diff --git a/src/it-repo/dummy-parent2-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-2.0.pom similarity index 100% rename from src/it-repo/dummy-parent2-2.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-2.0.pom diff --git a/src/it-repo/dummy-parent2-3.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.0-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.0-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.0-SNAPSHOT.pom diff --git a/src/it-repo/dummy-parent2-3.0-alpha-1.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.0-alpha-1.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.0-alpha-1.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.0-alpha-1.pom diff --git a/src/it-repo/dummy-parent2-3.0-beta-1.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.0-beta-1.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.0-beta-1.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.0-beta-1.pom diff --git a/src/it-repo/dummy-parent2-3.0-rc-1.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.0-rc-1.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.0-rc-1.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.0-rc-1.pom diff --git a/src/it-repo/dummy-parent2-3.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.0.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.0.pom diff --git a/src/it-repo/dummy-parent2-3.1.pom b/versions-maven-plugin/src/it-repo/dummy-parent2-3.1.pom similarity index 100% rename from src/it-repo/dummy-parent2-3.1.pom rename to versions-maven-plugin/src/it-repo/dummy-parent2-3.1.pom diff --git a/src/it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-parent3-1.0.0-SNAPSHOT.pom diff --git a/src/it-repo/dummy-parent3-1.0.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent3-1.0.0.pom similarity index 100% rename from src/it-repo/dummy-parent3-1.0.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent3-1.0.0.pom diff --git a/src/it-repo/dummy-parent4-70.pom b/versions-maven-plugin/src/it-repo/dummy-parent4-70.pom similarity index 100% rename from src/it-repo/dummy-parent4-70.pom rename to versions-maven-plugin/src/it-repo/dummy-parent4-70.pom diff --git a/src/it-repo/dummy-parent4-71-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-parent4-71-SNAPSHOT.pom similarity index 100% rename from src/it-repo/dummy-parent4-71-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/dummy-parent4-71-SNAPSHOT.pom diff --git a/src/it-repo/dummy-parent5-1.0.0.pom b/versions-maven-plugin/src/it-repo/dummy-parent5-1.0.0.pom similarity index 100% rename from src/it-repo/dummy-parent5-1.0.0.pom rename to versions-maven-plugin/src/it-repo/dummy-parent5-1.0.0.pom diff --git a/src/it-repo/dummy-parent5-2.0.0-rc1.pom b/versions-maven-plugin/src/it-repo/dummy-parent5-2.0.0-rc1.pom similarity index 100% rename from src/it-repo/dummy-parent5-2.0.0-rc1.pom rename to versions-maven-plugin/src/it-repo/dummy-parent5-2.0.0-rc1.pom diff --git a/src/it-repo/issue-114-artifact-1.0.jar b/versions-maven-plugin/src/it-repo/issue-114-artifact-1.0.jar similarity index 100% rename from src/it-repo/issue-114-artifact-1.0.jar rename to versions-maven-plugin/src/it-repo/issue-114-artifact-1.0.jar diff --git a/src/it-repo/issue-114-artifact-1.0.pom b/versions-maven-plugin/src/it-repo/issue-114-artifact-1.0.pom similarity index 100% rename from src/it-repo/issue-114-artifact-1.0.pom rename to versions-maven-plugin/src/it-repo/issue-114-artifact-1.0.pom diff --git a/src/it-repo/issue-114-artifact-1.1.jar b/versions-maven-plugin/src/it-repo/issue-114-artifact-1.1.jar similarity index 100% rename from src/it-repo/issue-114-artifact-1.1.jar rename to versions-maven-plugin/src/it-repo/issue-114-artifact-1.1.jar diff --git a/src/it-repo/issue-114-artifact-1.1.pom b/versions-maven-plugin/src/it-repo/issue-114-artifact-1.1.pom similarity index 100% rename from src/it-repo/issue-114-artifact-1.1.pom rename to versions-maven-plugin/src/it-repo/issue-114-artifact-1.1.pom diff --git a/src/it-repo/issue-114-depmgmt-1.0.pom b/versions-maven-plugin/src/it-repo/issue-114-depmgmt-1.0.pom similarity index 100% rename from src/it-repo/issue-114-depmgmt-1.0.pom rename to versions-maven-plugin/src/it-repo/issue-114-depmgmt-1.0.pom diff --git a/src/it-repo/latest-versions-api-2.0.11.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-2.0.11.pom similarity index 100% rename from src/it-repo/latest-versions-api-2.0.11.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-2.0.11.pom diff --git a/src/it-repo/latest-versions-api-2.0.8.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-2.0.8.pom similarity index 100% rename from src/it-repo/latest-versions-api-2.0.8.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-2.0.8.pom diff --git a/src/it-repo/latest-versions-api-2.1.0-M1.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-2.1.0-M1.pom similarity index 100% rename from src/it-repo/latest-versions-api-2.1.0-M1.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-2.1.0-M1.pom diff --git a/src/it-repo/latest-versions-api-2.2.1.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-2.2.1.pom similarity index 100% rename from src/it-repo/latest-versions-api-2.2.1.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-2.2.1.pom diff --git a/src/it-repo/latest-versions-api-3.0-beta-3.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-3.0-beta-3.pom similarity index 100% rename from src/it-repo/latest-versions-api-3.0-beta-3.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-3.0-beta-3.pom diff --git a/src/it-repo/latest-versions-api-3.0.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-3.0.pom similarity index 100% rename from src/it-repo/latest-versions-api-3.0.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-3.0.pom diff --git a/src/it-repo/latest-versions-api-3.1.0.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-3.1.0.pom similarity index 100% rename from src/it-repo/latest-versions-api-3.1.0.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-3.1.0.pom diff --git a/src/it-repo/latest-versions-api-3.3.0.pom b/versions-maven-plugin/src/it-repo/latest-versions-api-3.3.0.pom similarity index 100% rename from src/it-repo/latest-versions-api-3.3.0.pom rename to versions-maven-plugin/src/it-repo/latest-versions-api-3.3.0.pom diff --git a/src/it-repo/module-a1-1.0.pom b/versions-maven-plugin/src/it-repo/module-a1-1.0.pom similarity index 100% rename from src/it-repo/module-a1-1.0.pom rename to versions-maven-plugin/src/it-repo/module-a1-1.0.pom diff --git a/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.jar b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.jar similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-1.1.1.1.jar rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.jar diff --git a/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.pom b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.pom similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-1.1.1.1.pom rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-1.1.1.1.pom diff --git a/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.jar b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.jar similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.0.0.0.jar rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.jar diff --git a/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.pom b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.pom similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.0.0.0.pom rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.0.0.pom diff --git a/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.jar b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.jar similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.0.10.0.jar rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.jar diff --git a/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.pom b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.pom similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.0.10.0.pom rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.0.10.0.pom diff --git a/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.jar b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.jar similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.12.0.0.jar rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.jar diff --git a/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.pom b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.pom similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-2.12.0.0.pom rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-2.12.0.0.pom diff --git a/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.jar diff --git a/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom similarity index 100% rename from src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/test/bigversion/dummy-lib-3.0.0.0-SNAPSHOT.pom diff --git a/src/it-repo/test/package/module-0.0.2.19.jar b/versions-maven-plugin/src/it-repo/test/package/module-0.0.2.19.jar similarity index 100% rename from src/it-repo/test/package/module-0.0.2.19.jar rename to versions-maven-plugin/src/it-repo/test/package/module-0.0.2.19.jar diff --git a/src/it-repo/test/package/module-0.0.2.19.pom b/versions-maven-plugin/src/it-repo/test/package/module-0.0.2.19.pom similarity index 100% rename from src/it-repo/test/package/module-0.0.2.19.pom rename to versions-maven-plugin/src/it-repo/test/package/module-0.0.2.19.pom diff --git a/src/it-repo/test/package/module-1.2.3-SNAPSHOT.jar b/versions-maven-plugin/src/it-repo/test/package/module-1.2.3-SNAPSHOT.jar similarity index 100% rename from src/it-repo/test/package/module-1.2.3-SNAPSHOT.jar rename to versions-maven-plugin/src/it-repo/test/package/module-1.2.3-SNAPSHOT.jar diff --git a/src/it-repo/test/package/module-1.2.3-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/test/package/module-1.2.3-SNAPSHOT.pom similarity index 100% rename from src/it-repo/test/package/module-1.2.3-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/test/package/module-1.2.3-SNAPSHOT.pom diff --git a/src/it-repo/test/package/moduleTest-0.0.2.18.jar b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.18.jar similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.18.jar rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.18.jar diff --git a/src/it-repo/test/package/moduleTest-0.0.2.18.pom b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.18.pom similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.18.pom rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.18.pom diff --git a/src/it-repo/test/package/moduleTest-0.0.2.19.jar b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.19.jar similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.19.jar rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.19.jar diff --git a/src/it-repo/test/package/moduleTest-0.0.2.19.pom b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.19.pom similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.19.pom rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.19.pom diff --git a/src/it-repo/test/package/moduleTest-0.0.2.20.jar b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.20.jar similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.20.jar rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.20.jar diff --git a/src/it-repo/test/package/moduleTest-0.0.2.20.pom b/versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.20.pom similarity index 100% rename from src/it-repo/test/package/moduleTest-0.0.2.20.pom rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-0.0.2.20.pom diff --git a/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.jar b/versions-maven-plugin/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.jar similarity index 100% rename from src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.jar rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.jar diff --git a/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.pom similarity index 100% rename from src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.pom rename to versions-maven-plugin/src/it-repo/test/package/moduleTest-1.2.3-SNAPSHOT.pom diff --git a/src/it-repo/the-grandparent-1.0.pom b/versions-maven-plugin/src/it-repo/the-grandparent-1.0.pom similarity index 100% rename from src/it-repo/the-grandparent-1.0.pom rename to versions-maven-plugin/src/it-repo/the-grandparent-1.0.pom diff --git a/src/it-repo/the-parent-1.0.pom b/versions-maven-plugin/src/it-repo/the-parent-1.0.pom similarity index 100% rename from src/it-repo/the-parent-1.0.pom rename to versions-maven-plugin/src/it-repo/the-parent-1.0.pom diff --git a/src/it-repo/update-api-1.9.5.pom b/versions-maven-plugin/src/it-repo/update-api-1.9.5.pom similarity index 100% rename from src/it-repo/update-api-1.9.5.pom rename to versions-maven-plugin/src/it-repo/update-api-1.9.5.pom diff --git a/src/it-repo/update-api-2.0.0-beta.pom b/versions-maven-plugin/src/it-repo/update-api-2.0.0-beta.pom similarity index 100% rename from src/it-repo/update-api-2.0.0-beta.pom rename to versions-maven-plugin/src/it-repo/update-api-2.0.0-beta.pom diff --git a/src/it-repo/versions-rules-3.0.1-1.1.pom b/versions-maven-plugin/src/it-repo/versions-rules-3.0.1-1.1.pom similarity index 100% rename from src/it-repo/versions-rules-3.0.1-1.1.pom rename to versions-maven-plugin/src/it-repo/versions-rules-3.0.1-1.1.pom diff --git a/src/it-repo/versions-rules-3.0.1-1.pom b/versions-maven-plugin/src/it-repo/versions-rules-3.0.1-1.pom similarity index 100% rename from src/it-repo/versions-rules-3.0.1-1.pom rename to versions-maven-plugin/src/it-repo/versions-rules-3.0.1-1.pom diff --git a/src/it-repo/versions-rules-3.0.1.pom b/versions-maven-plugin/src/it-repo/versions-rules-3.0.1.pom similarity index 100% rename from src/it-repo/versions-rules-3.0.1.pom rename to versions-maven-plugin/src/it-repo/versions-rules-3.0.1.pom diff --git a/src/it/it-abstract-versions-report-001/invoker.properties b/versions-maven-plugin/src/it/it-abstract-versions-report-001/invoker.properties similarity index 100% rename from src/it/it-abstract-versions-report-001/invoker.properties rename to versions-maven-plugin/src/it/it-abstract-versions-report-001/invoker.properties diff --git a/src/it/it-abstract-versions-report-001/pom.xml b/versions-maven-plugin/src/it/it-abstract-versions-report-001/pom.xml similarity index 100% rename from src/it/it-abstract-versions-report-001/pom.xml rename to versions-maven-plugin/src/it/it-abstract-versions-report-001/pom.xml diff --git a/src/it/it-abstract-versions-report-001/verify.groovy b/versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy similarity index 100% rename from src/it/it-abstract-versions-report-001/verify.groovy rename to versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy diff --git a/src/it/it-changerecord-update-parent-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-update-parent-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-update-parent-001/invoker.properties diff --git a/src/it/it-changerecord-update-parent-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/pom.xml similarity index 100% rename from src/it/it-changerecord-update-parent-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-update-parent-001/pom.xml diff --git a/src/it/it-changerecord-update-parent-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-update-parent-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh diff --git a/src/it/it-changerecord-update-properties-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-update-properties-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-update-properties-001/invoker.properties diff --git a/src/it/it-changerecord-update-properties-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/pom.xml similarity index 100% rename from src/it/it-changerecord-update-properties-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-update-properties-001/pom.xml diff --git a/src/it/it-changerecord-update-properties-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-update-properties-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh diff --git a/src/it/it-changerecord-use-latest-releases-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-use-latest-releases-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/invoker.properties diff --git a/src/it/it-changerecord-use-latest-releases-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/pom.xml similarity index 100% rename from src/it/it-changerecord-use-latest-releases-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/pom.xml diff --git a/src/it/it-changerecord-use-latest-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-use-latest-releases-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh diff --git a/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-use-latest-snapshots-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/invoker.properties diff --git a/src/it/it-changerecord-use-latest-snapshots-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/pom.xml similarity index 100% rename from src/it/it-changerecord-use-latest-snapshots-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/pom.xml diff --git a/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-use-latest-snapshots-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh diff --git a/src/it/it-changerecord-use-latest-versions-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-use-latest-versions-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/invoker.properties diff --git a/src/it/it-changerecord-use-latest-versions-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/pom.xml similarity index 100% rename from src/it/it-changerecord-use-latest-versions-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/pom.xml diff --git a/src/it/it-changerecord-use-latest-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-use-latest-versions-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh diff --git a/src/it/it-changerecord-use-next-versions-001/invoker.properties b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/invoker.properties similarity index 100% rename from src/it/it-changerecord-use-next-versions-001/invoker.properties rename to versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/invoker.properties diff --git a/src/it/it-changerecord-use-next-versions-001/pom.xml b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/pom.xml similarity index 100% rename from src/it/it-changerecord-use-next-versions-001/pom.xml rename to versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/pom.xml diff --git a/src/it/it-changerecord-use-next-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh similarity index 100% rename from src/it/it-changerecord-use-next-versions-001/verify.bsh rename to versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh diff --git a/src/it/it-compare-dependencies-001/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-001/invoker.properties similarity index 100% rename from src/it/it-compare-dependencies-001/invoker.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-001/invoker.properties diff --git a/src/it/it-compare-dependencies-001/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-001/pom.xml similarity index 100% rename from src/it/it-compare-dependencies-001/pom.xml rename to versions-maven-plugin/src/it/it-compare-dependencies-001/pom.xml diff --git a/src/it/it-compare-dependencies-001/test.properties b/versions-maven-plugin/src/it/it-compare-dependencies-001/test.properties similarity index 100% rename from src/it/it-compare-dependencies-001/test.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-001/test.properties diff --git a/src/it/it-compare-dependencies-001/verify.bsh b/versions-maven-plugin/src/it/it-compare-dependencies-001/verify.bsh similarity index 100% rename from src/it/it-compare-dependencies-001/verify.bsh rename to versions-maven-plugin/src/it/it-compare-dependencies-001/verify.bsh diff --git a/src/it/it-compare-dependencies-002/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-002/invoker.properties similarity index 100% rename from src/it/it-compare-dependencies-002/invoker.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-002/invoker.properties diff --git a/src/it/it-compare-dependencies-002/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-002/pom.xml similarity index 100% rename from src/it/it-compare-dependencies-002/pom.xml rename to versions-maven-plugin/src/it/it-compare-dependencies-002/pom.xml diff --git a/src/it/it-compare-dependencies-002/test.properties b/versions-maven-plugin/src/it/it-compare-dependencies-002/test.properties similarity index 100% rename from src/it/it-compare-dependencies-002/test.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-002/test.properties diff --git a/src/it/it-compare-dependencies-002/verify.bsh b/versions-maven-plugin/src/it/it-compare-dependencies-002/verify.bsh similarity index 100% rename from src/it/it-compare-dependencies-002/verify.bsh rename to versions-maven-plugin/src/it/it-compare-dependencies-002/verify.bsh diff --git a/src/it/it-compare-dependencies-003/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-003/invoker.properties similarity index 100% rename from src/it/it-compare-dependencies-003/invoker.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-003/invoker.properties diff --git a/src/it/it-compare-dependencies-003/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-003/pom.xml similarity index 100% rename from src/it/it-compare-dependencies-003/pom.xml rename to versions-maven-plugin/src/it/it-compare-dependencies-003/pom.xml diff --git a/src/it/it-compare-dependencies-003/test.properties b/versions-maven-plugin/src/it/it-compare-dependencies-003/test.properties similarity index 100% rename from src/it/it-compare-dependencies-003/test.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-003/test.properties diff --git a/src/it/it-compare-dependencies-003/verify.bsh b/versions-maven-plugin/src/it/it-compare-dependencies-003/verify.bsh similarity index 100% rename from src/it/it-compare-dependencies-003/verify.bsh rename to versions-maven-plugin/src/it/it-compare-dependencies-003/verify.bsh diff --git a/src/it/it-compare-dependencies-004/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-004/invoker.properties similarity index 100% rename from src/it/it-compare-dependencies-004/invoker.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-004/invoker.properties diff --git a/src/it/it-compare-dependencies-004/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-004/pom.xml similarity index 100% rename from src/it/it-compare-dependencies-004/pom.xml rename to versions-maven-plugin/src/it/it-compare-dependencies-004/pom.xml diff --git a/src/it/it-compare-dependencies-004/test.properties b/versions-maven-plugin/src/it/it-compare-dependencies-004/test.properties similarity index 100% rename from src/it/it-compare-dependencies-004/test.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-004/test.properties diff --git a/src/it/it-compare-dependencies-004/verify.bsh b/versions-maven-plugin/src/it/it-compare-dependencies-004/verify.bsh similarity index 100% rename from src/it/it-compare-dependencies-004/verify.bsh rename to versions-maven-plugin/src/it/it-compare-dependencies-004/verify.bsh diff --git a/src/it/it-compare-dependencies-005/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-005/invoker.properties similarity index 100% rename from src/it/it-compare-dependencies-005/invoker.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-005/invoker.properties diff --git a/src/it/it-compare-dependencies-005/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-005/pom.xml similarity index 100% rename from src/it/it-compare-dependencies-005/pom.xml rename to versions-maven-plugin/src/it/it-compare-dependencies-005/pom.xml diff --git a/src/it/it-compare-dependencies-005/test.properties b/versions-maven-plugin/src/it/it-compare-dependencies-005/test.properties similarity index 100% rename from src/it/it-compare-dependencies-005/test.properties rename to versions-maven-plugin/src/it/it-compare-dependencies-005/test.properties diff --git a/src/it/it-compare-dependencies-005/verify.bsh b/versions-maven-plugin/src/it/it-compare-dependencies-005/verify.bsh similarity index 100% rename from src/it/it-compare-dependencies-005/verify.bsh rename to versions-maven-plugin/src/it/it-compare-dependencies-005/verify.bsh diff --git a/src/it/it-dependency-updates-report-001/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-001/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-001/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-001/invoker.properties diff --git a/src/it/it-dependency-updates-report-001/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-001/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-001/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-001/pom.xml diff --git a/src/it/it-dependency-updates-report-001/src/site/site.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-001/src/site/site.xml similarity index 100% rename from src/it/it-dependency-updates-report-001/src/site/site.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-001/src/site/site.xml diff --git a/src/it/it-dependency-updates-report-001/verify.bsh b/versions-maven-plugin/src/it/it-dependency-updates-report-001/verify.bsh similarity index 100% rename from src/it/it-dependency-updates-report-001/verify.bsh rename to versions-maven-plugin/src/it/it-dependency-updates-report-001/verify.bsh diff --git a/src/it/it-dependency-updates-report-002/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-002/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-002/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-002/invoker.properties diff --git a/src/it/it-dependency-updates-report-002/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-002/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-002/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-002/pom.xml diff --git a/src/it/it-dependency-updates-report-002/src/site/site.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-002/src/site/site.xml similarity index 100% rename from src/it/it-dependency-updates-report-002/src/site/site.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-002/src/site/site.xml diff --git a/src/it/it-dependency-updates-report-002/verify.bsh b/versions-maven-plugin/src/it/it-dependency-updates-report-002/verify.bsh similarity index 100% rename from src/it/it-dependency-updates-report-002/verify.bsh rename to versions-maven-plugin/src/it/it-dependency-updates-report-002/verify.bsh diff --git a/src/it/it-dependency-updates-report-003/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-003/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-003/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-003/invoker.properties diff --git a/src/it/it-dependency-updates-report-003/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-003/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-003/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-003/pom.xml diff --git a/src/it/it-dependency-updates-report-003/src/site/site.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-003/src/site/site.xml similarity index 100% rename from src/it/it-dependency-updates-report-003/src/site/site.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-003/src/site/site.xml diff --git a/src/it/it-dependency-updates-report-003/verify.bsh b/versions-maven-plugin/src/it/it-dependency-updates-report-003/verify.bsh similarity index 100% rename from src/it/it-dependency-updates-report-003/verify.bsh rename to versions-maven-plugin/src/it/it-dependency-updates-report-003/verify.bsh diff --git a/src/it/it-dependency-updates-report-004/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-004/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-004/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-004/invoker.properties diff --git a/src/it/it-dependency-updates-report-004/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-004/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-004/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-004/pom.xml diff --git a/src/it/it-dependency-updates-report-004/src/site/site.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-004/src/site/site.xml similarity index 100% rename from src/it/it-dependency-updates-report-004/src/site/site.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-004/src/site/site.xml diff --git a/src/it/it-dependency-updates-report-004/verify.bsh b/versions-maven-plugin/src/it/it-dependency-updates-report-004/verify.bsh similarity index 100% rename from src/it/it-dependency-updates-report-004/verify.bsh rename to versions-maven-plugin/src/it/it-dependency-updates-report-004/verify.bsh diff --git a/src/it/it-dependency-updates-report-issue-684-001/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-issue-684-001/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/invoker.properties diff --git a/src/it/it-dependency-updates-report-issue-684-001/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-issue-684-001/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/pom.xml diff --git a/src/it/it-dependency-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy similarity index 100% rename from src/it/it-dependency-updates-report-issue-684-001/verify.groovy rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy diff --git a/src/it/it-dependency-updates-report-issue-755/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/invoker.properties similarity index 100% rename from src/it/it-dependency-updates-report-issue-755/invoker.properties rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/invoker.properties diff --git a/src/it/it-dependency-updates-report-issue-755/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/pom.xml similarity index 100% rename from src/it/it-dependency-updates-report-issue-755/pom.xml rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/pom.xml diff --git a/src/it/it-dependency-updates-report-issue-755/verify.groovy b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/verify.groovy similarity index 100% rename from src/it/it-dependency-updates-report-issue-755/verify.groovy rename to versions-maven-plugin/src/it/it-dependency-updates-report-issue-755/verify.groovy diff --git a/src/it/it-display-dependency-updates-001/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-001/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-001/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-001/invoker.properties diff --git a/src/it/it-display-dependency-updates-001/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-001/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-001/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-001/pom.xml diff --git a/src/it/it-display-dependency-updates-001/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-001/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-001/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-001/verify.groovy diff --git a/src/it/it-display-dependency-updates-002/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-002/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-002/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-002/invoker.properties diff --git a/src/it/it-display-dependency-updates-002/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-002/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-002/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-002/pom.xml diff --git a/src/it/it-display-dependency-updates-002/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-002/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-002/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-002/verify.bsh diff --git a/src/it/it-display-dependency-updates-003/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-003/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-003/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-003/invoker.properties diff --git a/src/it/it-display-dependency-updates-003/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-003/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-003/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-003/pom.xml diff --git a/src/it/it-display-dependency-updates-003/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-003/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-003/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-003/verify.bsh diff --git a/src/it/it-display-dependency-updates-004/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-004/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-004/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-004/invoker.properties diff --git a/src/it/it-display-dependency-updates-004/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-004/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-004/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-004/pom.xml diff --git a/src/it/it-display-dependency-updates-004/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-004/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-004/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-004/verify.bsh diff --git a/src/it/it-display-dependency-updates-005/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-005/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-005/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-005/invoker.properties diff --git a/src/it/it-display-dependency-updates-005/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-005/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-005/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-005/pom.xml diff --git a/src/it/it-display-dependency-updates-005/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-005/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-005/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-005/verify.bsh diff --git a/src/it/it-display-dependency-updates-006/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-006/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-006/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-006/invoker.properties diff --git a/src/it/it-display-dependency-updates-006/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-006/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-006/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-006/pom.xml diff --git a/src/it/it-display-dependency-updates-006/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-006/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-006/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-006/verify.bsh diff --git a/src/it/it-display-dependency-updates-007-outputFile/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-007-outputFile/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/invoker.properties diff --git a/src/it/it-display-dependency-updates-007-outputFile/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-007-outputFile/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/pom.xml diff --git a/src/it/it-display-dependency-updates-007-outputFile/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-007-outputFile/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-007-outputFile/verify.bsh diff --git a/src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/invoker.properties diff --git a/src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/pom.xml diff --git a/src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-008-outputLineWidth/verify.bsh diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/invoker.properties diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/pom.xml diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-false/verify.bsh diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/invoker.properties diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/pom.xml diff --git a/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh b/versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh similarity index 100% rename from src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh rename to versions-maven-plugin/src/it/it-display-dependency-updates-009-processDependencyManagementTransitive-true/verify.bsh diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-258-dependencyIncludesAndExcludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyExcludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes-multi/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyIncludesAndExcludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementExcludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/test.properties diff --git a/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-318-dependencyManagementIncludes/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-1/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-1/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-34-1/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-1/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-34-1/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-1/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-1/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-2/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-2/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-34-2/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-2/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-34-2/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-2/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-2/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-3/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-3/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-34-3/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-3/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-34-3/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-3/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-3/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-4/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-4/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-34-4/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-4/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-34-4/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-4/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-4/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-34-5/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-5/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-34-5/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-5/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-34-5/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-34-5/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-34-5/verify.groovy diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties similarity index 100% rename from src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/invoker.properties diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml similarity index 100% rename from src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/pom.xml diff --git a/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy b/versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy similarity index 100% rename from src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy rename to versions-maven-plugin/src/it/it-display-dependency-updates-issue-684-pom-based-rules/verify.groovy diff --git a/src/it/it-display-plugin-updates-001/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-001/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-001/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-001/invoker.properties diff --git a/src/it/it-display-plugin-updates-001/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-001/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml diff --git a/src/it/it-display-plugin-updates-001/verify.groovy b/versions-maven-plugin/src/it/it-display-plugin-updates-001/verify.groovy similarity index 100% rename from src/it/it-display-plugin-updates-001/verify.groovy rename to versions-maven-plugin/src/it/it-display-plugin-updates-001/verify.groovy diff --git a/src/it/it-display-plugin-updates-002/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-002/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-002/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-002/invoker.properties diff --git a/src/it/it-display-plugin-updates-002/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-002/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-002/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-002/pom.xml diff --git a/src/it/it-display-plugin-updates-002/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-002/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-002/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-002/verify.bsh diff --git a/src/it/it-display-plugin-updates-003/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-003/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-003/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-003/invoker.properties diff --git a/src/it/it-display-plugin-updates-003/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-003/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-003/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-003/pom.xml diff --git a/src/it/it-display-plugin-updates-003/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-003/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-003/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-003/verify.bsh diff --git a/src/it/it-display-plugin-updates-004/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-004/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-004/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-004/invoker.properties diff --git a/src/it/it-display-plugin-updates-004/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-004/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-004/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-004/pom.xml diff --git a/src/it/it-display-plugin-updates-004/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-004/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-004/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-004/verify.bsh diff --git a/src/it/it-display-plugin-updates-005/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-005/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-005/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-005/invoker.properties diff --git a/src/it/it-display-plugin-updates-005/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-005/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-005/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-005/pom.xml diff --git a/src/it/it-display-plugin-updates-005/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-005/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-005/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-005/verify.bsh diff --git a/src/it/it-display-plugin-updates-006/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-006/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-006/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-006/invoker.properties diff --git a/src/it/it-display-plugin-updates-006/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-006/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-006/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-006/pom.xml diff --git a/src/it/it-display-plugin-updates-006/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-006/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-006/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-006/verify.bsh diff --git a/src/it/it-display-plugin-updates-007/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-007/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-007/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-007/invoker.properties diff --git a/src/it/it-display-plugin-updates-007/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-007/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-007/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-007/pom.xml diff --git a/src/it/it-display-plugin-updates-007/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-007/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-007/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-007/verify.bsh diff --git a/src/it/it-display-plugin-updates-008/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-008/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-008/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-008/invoker.properties diff --git a/src/it/it-display-plugin-updates-008/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-008/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-008/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-008/pom.xml diff --git a/src/it/it-display-plugin-updates-008/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-008/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh diff --git a/src/it/it-display-plugin-updates-009-issue-422/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-009-issue-422/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/invoker.properties diff --git a/src/it/it-display-plugin-updates-009-issue-422/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-009-issue-422/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/pom.xml diff --git a/src/it/it-display-plugin-updates-009-issue-422/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-009-issue-422/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-009-issue-422/verify.bsh diff --git a/src/it/it-display-plugin-updates-010-issue-526/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-010-issue-526/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/invoker.properties diff --git a/src/it/it-display-plugin-updates-010-issue-526/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-010-issue-526/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/pom.xml diff --git a/src/it/it-display-plugin-updates-010-issue-526/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-010-issue-526/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-010-issue-526/verify.bsh diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/invoker.properties diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/parent/pom.xml diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/pom.xml diff --git a/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-011-ignore-plugin-defined-in-parent/verify.bsh diff --git a/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties diff --git a/src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/pom.xml diff --git a/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh rename to versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties similarity index 100% rename from src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties rename to versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/invoker.properties diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml similarity index 100% rename from src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml rename to versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/pom.xml diff --git a/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy b/versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy similarity index 100% rename from src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy rename to versions-maven-plugin/src/it/it-display-plugin-updates-issue-684-pom-based-rules/verify.groovy diff --git a/src/it/it-display-property-updates-001/invoker.properties b/versions-maven-plugin/src/it/it-display-property-updates-001/invoker.properties similarity index 100% rename from src/it/it-display-property-updates-001/invoker.properties rename to versions-maven-plugin/src/it/it-display-property-updates-001/invoker.properties diff --git a/src/it/it-display-property-updates-001/pom.xml b/versions-maven-plugin/src/it/it-display-property-updates-001/pom.xml similarity index 100% rename from src/it/it-display-property-updates-001/pom.xml rename to versions-maven-plugin/src/it/it-display-property-updates-001/pom.xml diff --git a/src/it/it-display-property-updates-001/verify.groovy b/versions-maven-plugin/src/it/it-display-property-updates-001/verify.groovy similarity index 100% rename from src/it/it-display-property-updates-001/verify.groovy rename to versions-maven-plugin/src/it/it-display-property-updates-001/verify.groovy diff --git a/src/it/it-display-property-updates-002-outputLineWidth/invoker.properties b/versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/invoker.properties similarity index 100% rename from src/it/it-display-property-updates-002-outputLineWidth/invoker.properties rename to versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/invoker.properties diff --git a/src/it/it-display-property-updates-002-outputLineWidth/pom.xml b/versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/pom.xml similarity index 100% rename from src/it/it-display-property-updates-002-outputLineWidth/pom.xml rename to versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/pom.xml diff --git a/src/it/it-display-property-updates-002-outputLineWidth/verify.bsh b/versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/verify.bsh similarity index 100% rename from src/it/it-display-property-updates-002-outputLineWidth/verify.bsh rename to versions-maven-plugin/src/it/it-display-property-updates-002-outputLineWidth/verify.bsh diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties b/versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties similarity index 100% rename from src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties rename to versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/invoker.properties diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml b/versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml similarity index 100% rename from src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml rename to versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/pom.xml diff --git a/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy b/versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy similarity index 100% rename from src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy rename to versions-maven-plugin/src/it/it-display-property-updates-issue-684-pom-based-rules/verify.groovy diff --git a/src/it/it-encoding-001/invoker.properties b/versions-maven-plugin/src/it/it-encoding-001/invoker.properties similarity index 100% rename from src/it/it-encoding-001/invoker.properties rename to versions-maven-plugin/src/it/it-encoding-001/invoker.properties diff --git a/src/it/it-encoding-001/pom.xml b/versions-maven-plugin/src/it/it-encoding-001/pom.xml similarity index 100% rename from src/it/it-encoding-001/pom.xml rename to versions-maven-plugin/src/it/it-encoding-001/pom.xml diff --git a/src/it/it-encoding-001/verify.bsh b/versions-maven-plugin/src/it/it-encoding-001/verify.bsh similarity index 100% rename from src/it/it-encoding-001/verify.bsh rename to versions-maven-plugin/src/it/it-encoding-001/verify.bsh diff --git a/src/it/it-parent-updates-report-001/invoker.properties b/versions-maven-plugin/src/it/it-parent-updates-report-001/invoker.properties similarity index 100% rename from src/it/it-parent-updates-report-001/invoker.properties rename to versions-maven-plugin/src/it/it-parent-updates-report-001/invoker.properties diff --git a/src/it/it-parent-updates-report-001/module/pom.xml b/versions-maven-plugin/src/it/it-parent-updates-report-001/module/pom.xml similarity index 100% rename from src/it/it-parent-updates-report-001/module/pom.xml rename to versions-maven-plugin/src/it/it-parent-updates-report-001/module/pom.xml diff --git a/src/it/it-parent-updates-report-001/pom.xml b/versions-maven-plugin/src/it/it-parent-updates-report-001/pom.xml similarity index 100% rename from src/it/it-parent-updates-report-001/pom.xml rename to versions-maven-plugin/src/it/it-parent-updates-report-001/pom.xml diff --git a/src/it/it-parent-updates-report-001/src/site/site.xml b/versions-maven-plugin/src/it/it-parent-updates-report-001/src/site/site.xml similarity index 100% rename from src/it/it-parent-updates-report-001/src/site/site.xml rename to versions-maven-plugin/src/it/it-parent-updates-report-001/src/site/site.xml diff --git a/src/it/it-parent-updates-report-001/verify.groovy b/versions-maven-plugin/src/it/it-parent-updates-report-001/verify.groovy similarity index 100% rename from src/it/it-parent-updates-report-001/verify.groovy rename to versions-maven-plugin/src/it/it-parent-updates-report-001/verify.groovy diff --git a/src/it/it-plugin-updates-report-001/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-report-001/invoker.properties similarity index 100% rename from src/it/it-plugin-updates-report-001/invoker.properties rename to versions-maven-plugin/src/it/it-plugin-updates-report-001/invoker.properties diff --git a/src/it/it-plugin-updates-report-001/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-001/pom.xml similarity index 100% rename from src/it/it-plugin-updates-report-001/pom.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-001/pom.xml diff --git a/src/it/it-plugin-updates-report-001/src/site/site.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-001/src/site/site.xml similarity index 100% rename from src/it/it-plugin-updates-report-001/src/site/site.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-001/src/site/site.xml diff --git a/src/it/it-plugin-updates-report-001/verify.bsh b/versions-maven-plugin/src/it/it-plugin-updates-report-001/verify.bsh similarity index 100% rename from src/it/it-plugin-updates-report-001/verify.bsh rename to versions-maven-plugin/src/it/it-plugin-updates-report-001/verify.bsh diff --git a/src/it/it-plugin-updates-report-002/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-report-002/invoker.properties similarity index 100% rename from src/it/it-plugin-updates-report-002/invoker.properties rename to versions-maven-plugin/src/it/it-plugin-updates-report-002/invoker.properties diff --git a/src/it/it-plugin-updates-report-002/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-002/pom.xml similarity index 100% rename from src/it/it-plugin-updates-report-002/pom.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-002/pom.xml diff --git a/src/it/it-plugin-updates-report-002/src/site/site.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-002/src/site/site.xml similarity index 100% rename from src/it/it-plugin-updates-report-002/src/site/site.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-002/src/site/site.xml diff --git a/src/it/it-plugin-updates-report-002/verify.bsh b/versions-maven-plugin/src/it/it-plugin-updates-report-002/verify.bsh similarity index 100% rename from src/it/it-plugin-updates-report-002/verify.bsh rename to versions-maven-plugin/src/it/it-plugin-updates-report-002/verify.bsh diff --git a/src/it/it-plugin-updates-report-003/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-report-003/invoker.properties similarity index 100% rename from src/it/it-plugin-updates-report-003/invoker.properties rename to versions-maven-plugin/src/it/it-plugin-updates-report-003/invoker.properties diff --git a/src/it/it-plugin-updates-report-003/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-003/pom.xml similarity index 100% rename from src/it/it-plugin-updates-report-003/pom.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-003/pom.xml diff --git a/src/it/it-plugin-updates-report-003/src/site/site.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-003/src/site/site.xml similarity index 100% rename from src/it/it-plugin-updates-report-003/src/site/site.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-003/src/site/site.xml diff --git a/src/it/it-plugin-updates-report-003/verify.bsh b/versions-maven-plugin/src/it/it-plugin-updates-report-003/verify.bsh similarity index 100% rename from src/it/it-plugin-updates-report-003/verify.bsh rename to versions-maven-plugin/src/it/it-plugin-updates-report-003/verify.bsh diff --git a/src/it/it-plugin-updates-report-issue-684-001/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/invoker.properties similarity index 100% rename from src/it/it-plugin-updates-report-issue-684-001/invoker.properties rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/invoker.properties diff --git a/src/it/it-plugin-updates-report-issue-684-001/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/pom.xml similarity index 100% rename from src/it/it-plugin-updates-report-issue-684-001/pom.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/pom.xml diff --git a/src/it/it-plugin-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy similarity index 100% rename from src/it/it-plugin-updates-report-issue-684-001/verify.groovy rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy diff --git a/src/it/it-plugin-updates-report-issue-755/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/invoker.properties similarity index 100% rename from src/it/it-plugin-updates-report-issue-755/invoker.properties rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/invoker.properties diff --git a/src/it/it-plugin-updates-report-issue-755/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/pom.xml similarity index 100% rename from src/it/it-plugin-updates-report-issue-755/pom.xml rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/pom.xml diff --git a/src/it/it-plugin-updates-report-issue-755/verify.groovy b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/verify.groovy similarity index 100% rename from src/it/it-plugin-updates-report-issue-755/verify.groovy rename to versions-maven-plugin/src/it/it-plugin-updates-report-issue-755/verify.groovy diff --git a/src/it/it-property-updates-report-001/invoker.properties b/versions-maven-plugin/src/it/it-property-updates-report-001/invoker.properties similarity index 100% rename from src/it/it-property-updates-report-001/invoker.properties rename to versions-maven-plugin/src/it/it-property-updates-report-001/invoker.properties diff --git a/src/it/it-property-updates-report-001/pom.xml b/versions-maven-plugin/src/it/it-property-updates-report-001/pom.xml similarity index 100% rename from src/it/it-property-updates-report-001/pom.xml rename to versions-maven-plugin/src/it/it-property-updates-report-001/pom.xml diff --git a/src/it/it-property-updates-report-001/src/site/site.xml b/versions-maven-plugin/src/it/it-property-updates-report-001/src/site/site.xml similarity index 100% rename from src/it/it-property-updates-report-001/src/site/site.xml rename to versions-maven-plugin/src/it/it-property-updates-report-001/src/site/site.xml diff --git a/src/it/it-property-updates-report-001/verify.bsh b/versions-maven-plugin/src/it/it-property-updates-report-001/verify.bsh similarity index 100% rename from src/it/it-property-updates-report-001/verify.bsh rename to versions-maven-plugin/src/it/it-property-updates-report-001/verify.bsh diff --git a/src/it/it-property-updates-report-002-slow/invoker.properties b/versions-maven-plugin/src/it/it-property-updates-report-002-slow/invoker.properties similarity index 100% rename from src/it/it-property-updates-report-002-slow/invoker.properties rename to versions-maven-plugin/src/it/it-property-updates-report-002-slow/invoker.properties diff --git a/src/it/it-property-updates-report-002-slow/maven-version-rules.xml b/versions-maven-plugin/src/it/it-property-updates-report-002-slow/maven-version-rules.xml similarity index 100% rename from src/it/it-property-updates-report-002-slow/maven-version-rules.xml rename to versions-maven-plugin/src/it/it-property-updates-report-002-slow/maven-version-rules.xml diff --git a/src/it/it-property-updates-report-002-slow/pom.xml b/versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml similarity index 100% rename from src/it/it-property-updates-report-002-slow/pom.xml rename to versions-maven-plugin/src/it/it-property-updates-report-002-slow/pom.xml diff --git a/src/it/it-property-updates-report-issue-684-001/invoker.properties b/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/invoker.properties similarity index 100% rename from src/it/it-property-updates-report-issue-684-001/invoker.properties rename to versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/invoker.properties diff --git a/src/it/it-property-updates-report-issue-684-001/pom.xml b/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/pom.xml similarity index 100% rename from src/it/it-property-updates-report-issue-684-001/pom.xml rename to versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/pom.xml diff --git a/src/it/it-property-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy similarity index 100% rename from src/it/it-property-updates-report-issue-684-001/verify.groovy rename to versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy diff --git a/src/it/it-resolve-ranges-001/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-001/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-001/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-001/invoker.properties diff --git a/src/it/it-resolve-ranges-001/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-001/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-001/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-001/pom.xml diff --git a/src/it/it-resolve-ranges-001/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-001/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-001/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-001/verify.bsh diff --git a/src/it/it-resolve-ranges-002/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-002/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-002/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-002/invoker.properties diff --git a/src/it/it-resolve-ranges-002/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-002/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-002/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-002/pom.xml diff --git a/src/it/it-resolve-ranges-002/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-002/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-002/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-002/verify.bsh diff --git a/src/it/it-resolve-ranges-003/child/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-003/child/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-003/child/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-003/child/pom.xml diff --git a/src/it/it-resolve-ranges-003/child2/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-003/child2/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-003/child2/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-003/child2/pom.xml diff --git a/src/it/it-resolve-ranges-003/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-003/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-003/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-003/invoker.properties diff --git a/src/it/it-resolve-ranges-003/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-003/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-003/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-003/pom.xml diff --git a/src/it/it-resolve-ranges-003/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-003/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-003/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-003/verify.bsh diff --git a/src/it/it-resolve-ranges-004/child/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-004/child/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-004/child/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-004/child/pom.xml diff --git a/src/it/it-resolve-ranges-004/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-004/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-004/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-004/invoker.properties diff --git a/src/it/it-resolve-ranges-004/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-004/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-004/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-004/pom.xml diff --git a/src/it/it-resolve-ranges-004/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-004/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-004/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-004/verify.bsh diff --git a/src/it/it-resolve-ranges-005/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-005/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-005/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-005/invoker.properties diff --git a/src/it/it-resolve-ranges-005/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-005/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-005/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-005/pom.xml diff --git a/src/it/it-resolve-ranges-005/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-005/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-005/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-005/verify.bsh diff --git a/src/it/it-resolve-ranges-006/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-006/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-006/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-006/invoker.properties diff --git a/src/it/it-resolve-ranges-006/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-006/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-006/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-006/pom.xml diff --git a/src/it/it-resolve-ranges-006/verify.bsh b/versions-maven-plugin/src/it/it-resolve-ranges-006/verify.bsh similarity index 100% rename from src/it/it-resolve-ranges-006/verify.bsh rename to versions-maven-plugin/src/it/it-resolve-ranges-006/verify.bsh diff --git a/src/it/it-resolve-ranges-issue-442/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-issue-442/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-issue-442/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-442/invoker.properties diff --git a/src/it/it-resolve-ranges-issue-442/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-issue-442/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-issue-442/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-442/pom.xml diff --git a/src/it/it-resolve-ranges-issue-442/verify.groovy b/versions-maven-plugin/src/it/it-resolve-ranges-issue-442/verify.groovy similarity index 100% rename from src/it/it-resolve-ranges-issue-442/verify.groovy rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-442/verify.groovy diff --git a/src/it/it-resolve-ranges-issue-454/invoker.properties b/versions-maven-plugin/src/it/it-resolve-ranges-issue-454/invoker.properties similarity index 100% rename from src/it/it-resolve-ranges-issue-454/invoker.properties rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-454/invoker.properties diff --git a/src/it/it-resolve-ranges-issue-454/pom.xml b/versions-maven-plugin/src/it/it-resolve-ranges-issue-454/pom.xml similarity index 100% rename from src/it/it-resolve-ranges-issue-454/pom.xml rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-454/pom.xml diff --git a/src/it/it-resolve-ranges-issue-454/verify.groovy b/versions-maven-plugin/src/it/it-resolve-ranges-issue-454/verify.groovy similarity index 100% rename from src/it/it-resolve-ranges-issue-454/verify.groovy rename to versions-maven-plugin/src/it/it-resolve-ranges-issue-454/verify.groovy diff --git a/src/it/it-revert-isssue-265/aggregate/pom.xml b/versions-maven-plugin/src/it/it-revert-isssue-265/aggregate/pom.xml similarity index 100% rename from src/it/it-revert-isssue-265/aggregate/pom.xml rename to versions-maven-plugin/src/it/it-revert-isssue-265/aggregate/pom.xml diff --git a/src/it/it-revert-isssue-265/invoker.properties b/versions-maven-plugin/src/it/it-revert-isssue-265/invoker.properties similarity index 100% rename from src/it/it-revert-isssue-265/invoker.properties rename to versions-maven-plugin/src/it/it-revert-isssue-265/invoker.properties diff --git a/src/it/it-revert-isssue-265/module-a/pom.xml b/versions-maven-plugin/src/it/it-revert-isssue-265/module-a/pom.xml similarity index 100% rename from src/it/it-revert-isssue-265/module-a/pom.xml rename to versions-maven-plugin/src/it/it-revert-isssue-265/module-a/pom.xml diff --git a/src/it/it-revert-isssue-265/module-b/pom.xml b/versions-maven-plugin/src/it/it-revert-isssue-265/module-b/pom.xml similarity index 100% rename from src/it/it-revert-isssue-265/module-b/pom.xml rename to versions-maven-plugin/src/it/it-revert-isssue-265/module-b/pom.xml diff --git a/src/it/it-revert-isssue-265/verify.groovy b/versions-maven-plugin/src/it/it-revert-isssue-265/verify.groovy similarity index 100% rename from src/it/it-revert-isssue-265/verify.groovy rename to versions-maven-plugin/src/it/it-revert-isssue-265/verify.groovy diff --git a/src/it/it-rules-via-classpath-001/invoker.properties b/versions-maven-plugin/src/it/it-rules-via-classpath-001/invoker.properties similarity index 100% rename from src/it/it-rules-via-classpath-001/invoker.properties rename to versions-maven-plugin/src/it/it-rules-via-classpath-001/invoker.properties diff --git a/src/it/it-rules-via-classpath-001/pom.xml b/versions-maven-plugin/src/it/it-rules-via-classpath-001/pom.xml similarity index 100% rename from src/it/it-rules-via-classpath-001/pom.xml rename to versions-maven-plugin/src/it/it-rules-via-classpath-001/pom.xml diff --git a/src/it/it-rules-via-classpath-001/verify.bsh b/versions-maven-plugin/src/it/it-rules-via-classpath-001/verify.bsh similarity index 100% rename from src/it/it-rules-via-classpath-001/verify.bsh rename to versions-maven-plugin/src/it/it-rules-via-classpath-001/verify.bsh diff --git a/src/it/it-rules-via-classpath-002/invoker.properties b/versions-maven-plugin/src/it/it-rules-via-classpath-002/invoker.properties similarity index 100% rename from src/it/it-rules-via-classpath-002/invoker.properties rename to versions-maven-plugin/src/it/it-rules-via-classpath-002/invoker.properties diff --git a/src/it/it-rules-via-classpath-002/pom.xml b/versions-maven-plugin/src/it/it-rules-via-classpath-002/pom.xml similarity index 100% rename from src/it/it-rules-via-classpath-002/pom.xml rename to versions-maven-plugin/src/it/it-rules-via-classpath-002/pom.xml diff --git a/src/it/it-rules-via-classpath-002/verify.bsh b/versions-maven-plugin/src/it/it-rules-via-classpath-002/verify.bsh similarity index 100% rename from src/it/it-rules-via-classpath-002/verify.bsh rename to versions-maven-plugin/src/it/it-rules-via-classpath-002/verify.bsh diff --git a/src/it/it-rules-via-classpath-003/invoker.properties b/versions-maven-plugin/src/it/it-rules-via-classpath-003/invoker.properties similarity index 100% rename from src/it/it-rules-via-classpath-003/invoker.properties rename to versions-maven-plugin/src/it/it-rules-via-classpath-003/invoker.properties diff --git a/src/it/it-rules-via-classpath-003/pom.xml b/versions-maven-plugin/src/it/it-rules-via-classpath-003/pom.xml similarity index 100% rename from src/it/it-rules-via-classpath-003/pom.xml rename to versions-maven-plugin/src/it/it-rules-via-classpath-003/pom.xml diff --git a/src/it/it-rules-via-classpath-003/verify.bsh b/versions-maven-plugin/src/it/it-rules-via-classpath-003/verify.bsh similarity index 100% rename from src/it/it-rules-via-classpath-003/verify.bsh rename to versions-maven-plugin/src/it/it-rules-via-classpath-003/verify.bsh diff --git a/src/it/it-set-001-issue-76/invoker.properties b/versions-maven-plugin/src/it/it-set-001-issue-76/invoker.properties similarity index 100% rename from src/it/it-set-001-issue-76/invoker.properties rename to versions-maven-plugin/src/it/it-set-001-issue-76/invoker.properties diff --git a/src/it/it-set-001-issue-76/pom.xml b/versions-maven-plugin/src/it/it-set-001-issue-76/pom.xml similarity index 100% rename from src/it/it-set-001-issue-76/pom.xml rename to versions-maven-plugin/src/it/it-set-001-issue-76/pom.xml diff --git a/src/it/it-set-001-issue-76/verify.groovy b/versions-maven-plugin/src/it/it-set-001-issue-76/verify.groovy similarity index 100% rename from src/it/it-set-001-issue-76/verify.groovy rename to versions-maven-plugin/src/it/it-set-001-issue-76/verify.groovy diff --git a/src/it/it-set-001/invoker.properties b/versions-maven-plugin/src/it/it-set-001/invoker.properties similarity index 100% rename from src/it/it-set-001/invoker.properties rename to versions-maven-plugin/src/it/it-set-001/invoker.properties diff --git a/src/it/it-set-001/pom.xml b/versions-maven-plugin/src/it/it-set-001/pom.xml similarity index 100% rename from src/it/it-set-001/pom.xml rename to versions-maven-plugin/src/it/it-set-001/pom.xml diff --git a/src/it/it-set-001/verify.bsh b/versions-maven-plugin/src/it/it-set-001/verify.bsh similarity index 100% rename from src/it/it-set-001/verify.bsh rename to versions-maven-plugin/src/it/it-set-001/verify.bsh diff --git a/src/it/it-set-002/child/pom.xml b/versions-maven-plugin/src/it/it-set-002/child/pom.xml similarity index 100% rename from src/it/it-set-002/child/pom.xml rename to versions-maven-plugin/src/it/it-set-002/child/pom.xml diff --git a/src/it/it-set-002/invoker.properties b/versions-maven-plugin/src/it/it-set-002/invoker.properties similarity index 100% rename from src/it/it-set-002/invoker.properties rename to versions-maven-plugin/src/it/it-set-002/invoker.properties diff --git a/src/it/it-set-002/pom.xml b/versions-maven-plugin/src/it/it-set-002/pom.xml similarity index 100% rename from src/it/it-set-002/pom.xml rename to versions-maven-plugin/src/it/it-set-002/pom.xml diff --git a/src/it/it-set-002/verify.bsh b/versions-maven-plugin/src/it/it-set-002/verify.bsh similarity index 100% rename from src/it/it-set-002/verify.bsh rename to versions-maven-plugin/src/it/it-set-002/verify.bsh diff --git a/src/it/it-set-003/child/pom.xml b/versions-maven-plugin/src/it/it-set-003/child/pom.xml similarity index 100% rename from src/it/it-set-003/child/pom.xml rename to versions-maven-plugin/src/it/it-set-003/child/pom.xml diff --git a/src/it/it-set-003/child2/pom.xml b/versions-maven-plugin/src/it/it-set-003/child2/pom.xml similarity index 100% rename from src/it/it-set-003/child2/pom.xml rename to versions-maven-plugin/src/it/it-set-003/child2/pom.xml diff --git a/src/it/it-set-003/invoker.properties b/versions-maven-plugin/src/it/it-set-003/invoker.properties similarity index 100% rename from src/it/it-set-003/invoker.properties rename to versions-maven-plugin/src/it/it-set-003/invoker.properties diff --git a/src/it/it-set-003/pom.xml b/versions-maven-plugin/src/it/it-set-003/pom.xml similarity index 100% rename from src/it/it-set-003/pom.xml rename to versions-maven-plugin/src/it/it-set-003/pom.xml diff --git a/src/it/it-set-003/verify.bsh b/versions-maven-plugin/src/it/it-set-003/verify.bsh similarity index 100% rename from src/it/it-set-003/verify.bsh rename to versions-maven-plugin/src/it/it-set-003/verify.bsh diff --git a/src/it/it-set-004/invoker.properties b/versions-maven-plugin/src/it/it-set-004/invoker.properties similarity index 100% rename from src/it/it-set-004/invoker.properties rename to versions-maven-plugin/src/it/it-set-004/invoker.properties diff --git a/src/it/it-set-004/pom.xml b/versions-maven-plugin/src/it/it-set-004/pom.xml similarity index 100% rename from src/it/it-set-004/pom.xml rename to versions-maven-plugin/src/it/it-set-004/pom.xml diff --git a/src/it/it-set-004/verify.bsh b/versions-maven-plugin/src/it/it-set-004/verify.bsh similarity index 100% rename from src/it/it-set-004/verify.bsh rename to versions-maven-plugin/src/it/it-set-004/verify.bsh diff --git a/src/it/it-set-005/invoker.properties b/versions-maven-plugin/src/it/it-set-005/invoker.properties similarity index 100% rename from src/it/it-set-005/invoker.properties rename to versions-maven-plugin/src/it/it-set-005/invoker.properties diff --git a/src/it/it-set-005/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-005/module-a1/pom.xml similarity index 100% rename from src/it/it-set-005/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-005/module-a1/pom.xml diff --git a/src/it/it-set-005/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-005/module-a2/pom.xml similarity index 100% rename from src/it/it-set-005/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-005/module-a2/pom.xml diff --git a/src/it/it-set-005/pom.xml b/versions-maven-plugin/src/it/it-set-005/pom.xml similarity index 100% rename from src/it/it-set-005/pom.xml rename to versions-maven-plugin/src/it/it-set-005/pom.xml diff --git a/src/it/it-set-005/verify.bsh b/versions-maven-plugin/src/it/it-set-005/verify.bsh similarity index 100% rename from src/it/it-set-005/verify.bsh rename to versions-maven-plugin/src/it/it-set-005/verify.bsh diff --git a/src/it/it-set-006/invoker.properties b/versions-maven-plugin/src/it/it-set-006/invoker.properties similarity index 100% rename from src/it/it-set-006/invoker.properties rename to versions-maven-plugin/src/it/it-set-006/invoker.properties diff --git a/src/it/it-set-006/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-006/module-a1/pom.xml similarity index 100% rename from src/it/it-set-006/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-006/module-a1/pom.xml diff --git a/src/it/it-set-006/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-006/module-a2/pom.xml similarity index 100% rename from src/it/it-set-006/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-006/module-a2/pom.xml diff --git a/src/it/it-set-006/module-a3/pom.xml b/versions-maven-plugin/src/it/it-set-006/module-a3/pom.xml similarity index 100% rename from src/it/it-set-006/module-a3/pom.xml rename to versions-maven-plugin/src/it/it-set-006/module-a3/pom.xml diff --git a/src/it/it-set-006/pom.xml b/versions-maven-plugin/src/it/it-set-006/pom.xml similarity index 100% rename from src/it/it-set-006/pom.xml rename to versions-maven-plugin/src/it/it-set-006/pom.xml diff --git a/src/it/it-set-006/verify.bsh b/versions-maven-plugin/src/it/it-set-006/verify.bsh similarity index 100% rename from src/it/it-set-006/verify.bsh rename to versions-maven-plugin/src/it/it-set-006/verify.bsh diff --git a/src/it/it-set-007/invoker.properties b/versions-maven-plugin/src/it/it-set-007/invoker.properties similarity index 100% rename from src/it/it-set-007/invoker.properties rename to versions-maven-plugin/src/it/it-set-007/invoker.properties diff --git a/src/it/it-set-007/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-007/module-a1/pom.xml similarity index 100% rename from src/it/it-set-007/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-007/module-a1/pom.xml diff --git a/src/it/it-set-007/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-007/module-a2/pom.xml similarity index 100% rename from src/it/it-set-007/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-007/module-a2/pom.xml diff --git a/src/it/it-set-007/pom.xml b/versions-maven-plugin/src/it/it-set-007/pom.xml similarity index 100% rename from src/it/it-set-007/pom.xml rename to versions-maven-plugin/src/it/it-set-007/pom.xml diff --git a/src/it/it-set-007/verify.bsh b/versions-maven-plugin/src/it/it-set-007/verify.bsh similarity index 100% rename from src/it/it-set-007/verify.bsh rename to versions-maven-plugin/src/it/it-set-007/verify.bsh diff --git a/src/it/it-set-008/invoker.properties b/versions-maven-plugin/src/it/it-set-008/invoker.properties similarity index 100% rename from src/it/it-set-008/invoker.properties rename to versions-maven-plugin/src/it/it-set-008/invoker.properties diff --git a/src/it/it-set-008/module-a1/module-b1/pom.xml b/versions-maven-plugin/src/it/it-set-008/module-a1/module-b1/pom.xml similarity index 100% rename from src/it/it-set-008/module-a1/module-b1/pom.xml rename to versions-maven-plugin/src/it/it-set-008/module-a1/module-b1/pom.xml diff --git a/src/it/it-set-008/module-a1/module-b2/pom.xml b/versions-maven-plugin/src/it/it-set-008/module-a1/module-b2/pom.xml similarity index 100% rename from src/it/it-set-008/module-a1/module-b2/pom.xml rename to versions-maven-plugin/src/it/it-set-008/module-a1/module-b2/pom.xml diff --git a/src/it/it-set-008/module-a1/module-b3/pom.xml b/versions-maven-plugin/src/it/it-set-008/module-a1/module-b3/pom.xml similarity index 100% rename from src/it/it-set-008/module-a1/module-b3/pom.xml rename to versions-maven-plugin/src/it/it-set-008/module-a1/module-b3/pom.xml diff --git a/src/it/it-set-008/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-008/module-a1/pom.xml similarity index 100% rename from src/it/it-set-008/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-008/module-a1/pom.xml diff --git a/src/it/it-set-008/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-008/module-a2/pom.xml similarity index 100% rename from src/it/it-set-008/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-008/module-a2/pom.xml diff --git a/src/it/it-set-008/pom.xml b/versions-maven-plugin/src/it/it-set-008/pom.xml similarity index 100% rename from src/it/it-set-008/pom.xml rename to versions-maven-plugin/src/it/it-set-008/pom.xml diff --git a/src/it/it-set-008/verify.groovy b/versions-maven-plugin/src/it/it-set-008/verify.groovy similarity index 100% rename from src/it/it-set-008/verify.groovy rename to versions-maven-plugin/src/it/it-set-008/verify.groovy diff --git a/src/it/it-set-009/alternative-pom.xml b/versions-maven-plugin/src/it/it-set-009/alternative-pom.xml similarity index 100% rename from src/it/it-set-009/alternative-pom.xml rename to versions-maven-plugin/src/it/it-set-009/alternative-pom.xml diff --git a/src/it/it-set-009/child/pom.xml b/versions-maven-plugin/src/it/it-set-009/child/pom.xml similarity index 100% rename from src/it/it-set-009/child/pom.xml rename to versions-maven-plugin/src/it/it-set-009/child/pom.xml diff --git a/src/it/it-set-009/invoker.properties b/versions-maven-plugin/src/it/it-set-009/invoker.properties similarity index 100% rename from src/it/it-set-009/invoker.properties rename to versions-maven-plugin/src/it/it-set-009/invoker.properties diff --git a/src/it/it-set-009/verify.groovy b/versions-maven-plugin/src/it/it-set-009/verify.groovy similarity index 100% rename from src/it/it-set-009/verify.groovy rename to versions-maven-plugin/src/it/it-set-009/verify.groovy diff --git a/src/it/it-set-010-issue-198/fake-api/pom.xml b/versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/pom.xml similarity index 100% rename from src/it/it-set-010-issue-198/fake-api/pom.xml rename to versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/pom.xml diff --git a/src/it/it-set-010-issue-198/fake-api/src/main/java/org/eclipse/jetty/App.java b/versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/src/main/java/org/eclipse/jetty/App.java similarity index 100% rename from src/it/it-set-010-issue-198/fake-api/src/main/java/org/eclipse/jetty/App.java rename to versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/src/main/java/org/eclipse/jetty/App.java diff --git a/src/it/it-set-010-issue-198/fake-api/src/test/java/org/eclipse/jetty/AppTest.java b/versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/src/test/java/org/eclipse/jetty/AppTest.java similarity index 100% rename from src/it/it-set-010-issue-198/fake-api/src/test/java/org/eclipse/jetty/AppTest.java rename to versions-maven-plugin/src/it/it-set-010-issue-198/fake-api/src/test/java/org/eclipse/jetty/AppTest.java diff --git a/src/it/it-set-010-issue-198/invoker.properties b/versions-maven-plugin/src/it/it-set-010-issue-198/invoker.properties similarity index 100% rename from src/it/it-set-010-issue-198/invoker.properties rename to versions-maven-plugin/src/it/it-set-010-issue-198/invoker.properties diff --git a/src/it/it-set-010-issue-198/pom.xml b/versions-maven-plugin/src/it/it-set-010-issue-198/pom.xml similarity index 100% rename from src/it/it-set-010-issue-198/pom.xml rename to versions-maven-plugin/src/it/it-set-010-issue-198/pom.xml diff --git a/src/it/it-set-010-issue-198/the-bom/pom.xml b/versions-maven-plugin/src/it/it-set-010-issue-198/the-bom/pom.xml similarity index 100% rename from src/it/it-set-010-issue-198/the-bom/pom.xml rename to versions-maven-plugin/src/it/it-set-010-issue-198/the-bom/pom.xml diff --git a/src/it/it-set-010-issue-198/verify.groovy b/versions-maven-plugin/src/it/it-set-010-issue-198/verify.groovy similarity index 100% rename from src/it/it-set-010-issue-198/verify.groovy rename to versions-maven-plugin/src/it/it-set-010-issue-198/verify.groovy diff --git a/src/it/it-set-010/invoker.properties b/versions-maven-plugin/src/it/it-set-010/invoker.properties similarity index 100% rename from src/it/it-set-010/invoker.properties rename to versions-maven-plugin/src/it/it-set-010/invoker.properties diff --git a/src/it/it-set-010/pom.xml b/versions-maven-plugin/src/it/it-set-010/pom.xml similarity index 100% rename from src/it/it-set-010/pom.xml rename to versions-maven-plugin/src/it/it-set-010/pom.xml diff --git a/src/it/it-set-010/verify.bsh b/versions-maven-plugin/src/it/it-set-010/verify.bsh similarity index 100% rename from src/it/it-set-010/verify.bsh rename to versions-maven-plugin/src/it/it-set-010/verify.bsh diff --git a/src/it/it-set-011/child/pom.xml b/versions-maven-plugin/src/it/it-set-011/child/pom.xml similarity index 100% rename from src/it/it-set-011/child/pom.xml rename to versions-maven-plugin/src/it/it-set-011/child/pom.xml diff --git a/src/it/it-set-011/invoker.properties b/versions-maven-plugin/src/it/it-set-011/invoker.properties similarity index 100% rename from src/it/it-set-011/invoker.properties rename to versions-maven-plugin/src/it/it-set-011/invoker.properties diff --git a/src/it/it-set-011/pom.xml b/versions-maven-plugin/src/it/it-set-011/pom.xml similarity index 100% rename from src/it/it-set-011/pom.xml rename to versions-maven-plugin/src/it/it-set-011/pom.xml diff --git a/src/it/it-set-011/verify.bsh b/versions-maven-plugin/src/it/it-set-011/verify.bsh similarity index 100% rename from src/it/it-set-011/verify.bsh rename to versions-maven-plugin/src/it/it-set-011/verify.bsh diff --git a/src/it/it-set-012/invoker.properties b/versions-maven-plugin/src/it/it-set-012/invoker.properties similarity index 100% rename from src/it/it-set-012/invoker.properties rename to versions-maven-plugin/src/it/it-set-012/invoker.properties diff --git a/src/it/it-set-012/pom.xml b/versions-maven-plugin/src/it/it-set-012/pom.xml similarity index 100% rename from src/it/it-set-012/pom.xml rename to versions-maven-plugin/src/it/it-set-012/pom.xml diff --git a/src/it/it-set-012/verify.bsh b/versions-maven-plugin/src/it/it-set-012/verify.bsh similarity index 100% rename from src/it/it-set-012/verify.bsh rename to versions-maven-plugin/src/it/it-set-012/verify.bsh diff --git a/src/it/it-set-013/invoker.properties b/versions-maven-plugin/src/it/it-set-013/invoker.properties similarity index 100% rename from src/it/it-set-013/invoker.properties rename to versions-maven-plugin/src/it/it-set-013/invoker.properties diff --git a/src/it/it-set-013/pom.xml b/versions-maven-plugin/src/it/it-set-013/pom.xml similarity index 100% rename from src/it/it-set-013/pom.xml rename to versions-maven-plugin/src/it/it-set-013/pom.xml diff --git a/src/it/it-set-013/verify.bsh b/versions-maven-plugin/src/it/it-set-013/verify.bsh similarity index 100% rename from src/it/it-set-013/verify.bsh rename to versions-maven-plugin/src/it/it-set-013/verify.bsh diff --git a/src/it/it-set-014/invoker.properties b/versions-maven-plugin/src/it/it-set-014/invoker.properties similarity index 100% rename from src/it/it-set-014/invoker.properties rename to versions-maven-plugin/src/it/it-set-014/invoker.properties diff --git a/src/it/it-set-014/pom.xml b/versions-maven-plugin/src/it/it-set-014/pom.xml similarity index 100% rename from src/it/it-set-014/pom.xml rename to versions-maven-plugin/src/it/it-set-014/pom.xml diff --git a/src/it/it-set-014/verify.bsh b/versions-maven-plugin/src/it/it-set-014/verify.bsh similarity index 100% rename from src/it/it-set-014/verify.bsh rename to versions-maven-plugin/src/it/it-set-014/verify.bsh diff --git a/src/it/it-set-015/invoker.properties b/versions-maven-plugin/src/it/it-set-015/invoker.properties similarity index 100% rename from src/it/it-set-015/invoker.properties rename to versions-maven-plugin/src/it/it-set-015/invoker.properties diff --git a/src/it/it-set-015/pom.xml b/versions-maven-plugin/src/it/it-set-015/pom.xml similarity index 100% rename from src/it/it-set-015/pom.xml rename to versions-maven-plugin/src/it/it-set-015/pom.xml diff --git a/src/it/it-set-015/verify.bsh b/versions-maven-plugin/src/it/it-set-015/verify.bsh similarity index 100% rename from src/it/it-set-015/verify.bsh rename to versions-maven-plugin/src/it/it-set-015/verify.bsh diff --git a/src/it/it-set-016/child/pom.xml b/versions-maven-plugin/src/it/it-set-016/child/pom.xml similarity index 100% rename from src/it/it-set-016/child/pom.xml rename to versions-maven-plugin/src/it/it-set-016/child/pom.xml diff --git a/src/it/it-set-016/invoker.properties b/versions-maven-plugin/src/it/it-set-016/invoker.properties similarity index 100% rename from src/it/it-set-016/invoker.properties rename to versions-maven-plugin/src/it/it-set-016/invoker.properties diff --git a/src/it/it-set-016/pom.xml b/versions-maven-plugin/src/it/it-set-016/pom.xml similarity index 100% rename from src/it/it-set-016/pom.xml rename to versions-maven-plugin/src/it/it-set-016/pom.xml diff --git a/src/it/it-set-016/verify.bsh b/versions-maven-plugin/src/it/it-set-016/verify.bsh similarity index 100% rename from src/it/it-set-016/verify.bsh rename to versions-maven-plugin/src/it/it-set-016/verify.bsh diff --git a/src/it/it-set-017-issue-321/invoker.properties b/versions-maven-plugin/src/it/it-set-017-issue-321/invoker.properties similarity index 100% rename from src/it/it-set-017-issue-321/invoker.properties rename to versions-maven-plugin/src/it/it-set-017-issue-321/invoker.properties diff --git a/src/it/it-set-017-issue-321/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-017-issue-321/module-a1/pom.xml similarity index 100% rename from src/it/it-set-017-issue-321/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-017-issue-321/module-a1/pom.xml diff --git a/src/it/it-set-017-issue-321/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-017-issue-321/module-a2/pom.xml similarity index 100% rename from src/it/it-set-017-issue-321/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-017-issue-321/module-a2/pom.xml diff --git a/src/it/it-set-017-issue-321/pom.xml b/versions-maven-plugin/src/it/it-set-017-issue-321/pom.xml similarity index 100% rename from src/it/it-set-017-issue-321/pom.xml rename to versions-maven-plugin/src/it/it-set-017-issue-321/pom.xml diff --git a/src/it/it-set-017-issue-321/verify.bsh b/versions-maven-plugin/src/it/it-set-017-issue-321/verify.bsh similarity index 100% rename from src/it/it-set-017-issue-321/verify.bsh rename to versions-maven-plugin/src/it/it-set-017-issue-321/verify.bsh diff --git a/src/it/it-set-018-issue-82/invoker.properties b/versions-maven-plugin/src/it/it-set-018-issue-82/invoker.properties similarity index 100% rename from src/it/it-set-018-issue-82/invoker.properties rename to versions-maven-plugin/src/it/it-set-018-issue-82/invoker.properties diff --git a/src/it/it-set-018-issue-82/module-a1/module-b1/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b1/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/module-a1/module-b1/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b1/pom.xml diff --git a/src/it/it-set-018-issue-82/module-a1/module-b2/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b2/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/module-a1/module-b2/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b2/pom.xml diff --git a/src/it/it-set-018-issue-82/module-a1/module-b3/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b3/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/module-a1/module-b3/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/module-b3/pom.xml diff --git a/src/it/it-set-018-issue-82/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/module-a1/pom.xml diff --git a/src/it/it-set-018-issue-82/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/module-a2/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/module-a2/pom.xml diff --git a/src/it/it-set-018-issue-82/pom.xml b/versions-maven-plugin/src/it/it-set-018-issue-82/pom.xml similarity index 100% rename from src/it/it-set-018-issue-82/pom.xml rename to versions-maven-plugin/src/it/it-set-018-issue-82/pom.xml diff --git a/src/it/it-set-018-issue-82/verify.groovy b/versions-maven-plugin/src/it/it-set-018-issue-82/verify.groovy similarity index 100% rename from src/it/it-set-018-issue-82/verify.groovy rename to versions-maven-plugin/src/it/it-set-018-issue-82/verify.groovy diff --git a/src/it/it-set-019-issue-426/invoker.properties b/versions-maven-plugin/src/it/it-set-019-issue-426/invoker.properties similarity index 100% rename from src/it/it-set-019-issue-426/invoker.properties rename to versions-maven-plugin/src/it/it-set-019-issue-426/invoker.properties diff --git a/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b1/pom.xml diff --git a/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b2/pom.xml diff --git a/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/module-b3/pom.xml diff --git a/src/it/it-set-019-issue-426/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/module-a1/pom.xml diff --git a/src/it/it-set-019-issue-426/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/module-a2/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/module-a2/pom.xml diff --git a/src/it/it-set-019-issue-426/pom.xml b/versions-maven-plugin/src/it/it-set-019-issue-426/pom.xml similarity index 100% rename from src/it/it-set-019-issue-426/pom.xml rename to versions-maven-plugin/src/it/it-set-019-issue-426/pom.xml diff --git a/src/it/it-set-019-issue-426/verify.groovy b/versions-maven-plugin/src/it/it-set-019-issue-426/verify.groovy similarity index 100% rename from src/it/it-set-019-issue-426/verify.groovy rename to versions-maven-plugin/src/it/it-set-019-issue-426/verify.groovy diff --git a/src/it/it-set-019-outputTimestamp/invoker.properties b/versions-maven-plugin/src/it/it-set-019-outputTimestamp/invoker.properties similarity index 100% rename from src/it/it-set-019-outputTimestamp/invoker.properties rename to versions-maven-plugin/src/it/it-set-019-outputTimestamp/invoker.properties diff --git a/src/it/it-set-019-outputTimestamp/pom.xml b/versions-maven-plugin/src/it/it-set-019-outputTimestamp/pom.xml similarity index 100% rename from src/it/it-set-019-outputTimestamp/pom.xml rename to versions-maven-plugin/src/it/it-set-019-outputTimestamp/pom.xml diff --git a/src/it/it-set-019-outputTimestamp/verify.groovy b/versions-maven-plugin/src/it/it-set-019-outputTimestamp/verify.groovy similarity index 100% rename from src/it/it-set-019-outputTimestamp/verify.groovy rename to versions-maven-plugin/src/it/it-set-019-outputTimestamp/verify.groovy diff --git a/src/it/it-set-020-outputTimestamp-disabled/invoker.properties b/versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/invoker.properties similarity index 100% rename from src/it/it-set-020-outputTimestamp-disabled/invoker.properties rename to versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/invoker.properties diff --git a/src/it/it-set-020-outputTimestamp-disabled/pom.xml b/versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/pom.xml similarity index 100% rename from src/it/it-set-020-outputTimestamp-disabled/pom.xml rename to versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/pom.xml diff --git a/src/it/it-set-020-outputTimestamp-disabled/verify.groovy b/versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/verify.groovy similarity index 100% rename from src/it/it-set-020-outputTimestamp-disabled/verify.groovy rename to versions-maven-plugin/src/it/it-set-020-outputTimestamp-disabled/verify.groovy diff --git a/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties b/versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties similarity index 100% rename from src/it/it-set-021-outputTimestampPolicy-always/invoker.properties rename to versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/invoker.properties diff --git a/src/it/it-set-021-outputTimestampPolicy-always/pom.xml b/versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/pom.xml similarity index 100% rename from src/it/it-set-021-outputTimestampPolicy-always/pom.xml rename to versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/pom.xml diff --git a/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy b/versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy similarity index 100% rename from src/it/it-set-021-outputTimestampPolicy-always/verify.groovy rename to versions-maven-plugin/src/it/it-set-021-outputTimestampPolicy-always/verify.groovy diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties b/versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties similarity index 100% rename from src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties rename to versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/invoker.properties diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml b/versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml similarity index 100% rename from src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml rename to versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/pom.xml diff --git a/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy b/versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy similarity index 100% rename from src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy rename to versions-maven-plugin/src/it/it-set-022-outputTimestampPolicy-onchange/verify.groovy diff --git a/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties b/versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties similarity index 100% rename from src/it/it-set-023-outputTimestampPolicy-never/invoker.properties rename to versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/invoker.properties diff --git a/src/it/it-set-023-outputTimestampPolicy-never/pom.xml b/versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/pom.xml similarity index 100% rename from src/it/it-set-023-outputTimestampPolicy-never/pom.xml rename to versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/pom.xml diff --git a/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy b/versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy similarity index 100% rename from src/it/it-set-023-outputTimestampPolicy-never/verify.groovy rename to versions-maven-plugin/src/it/it-set-023-outputTimestampPolicy-never/verify.groovy diff --git a/src/it/it-set-024-versionless-dependency/child/pom.xml b/versions-maven-plugin/src/it/it-set-024-versionless-dependency/child/pom.xml similarity index 100% rename from src/it/it-set-024-versionless-dependency/child/pom.xml rename to versions-maven-plugin/src/it/it-set-024-versionless-dependency/child/pom.xml diff --git a/src/it/it-set-024-versionless-dependency/invoker.properties b/versions-maven-plugin/src/it/it-set-024-versionless-dependency/invoker.properties similarity index 100% rename from src/it/it-set-024-versionless-dependency/invoker.properties rename to versions-maven-plugin/src/it/it-set-024-versionless-dependency/invoker.properties diff --git a/src/it/it-set-024-versionless-dependency/pom.xml b/versions-maven-plugin/src/it/it-set-024-versionless-dependency/pom.xml similarity index 100% rename from src/it/it-set-024-versionless-dependency/pom.xml rename to versions-maven-plugin/src/it/it-set-024-versionless-dependency/pom.xml diff --git a/src/it/it-set-property-001/invoker.properties b/versions-maven-plugin/src/it/it-set-property-001/invoker.properties similarity index 100% rename from src/it/it-set-property-001/invoker.properties rename to versions-maven-plugin/src/it/it-set-property-001/invoker.properties diff --git a/src/it/it-set-property-001/pom.xml b/versions-maven-plugin/src/it/it-set-property-001/pom.xml similarity index 100% rename from src/it/it-set-property-001/pom.xml rename to versions-maven-plugin/src/it/it-set-property-001/pom.xml diff --git a/src/it/it-set-property-001/verify.bsh b/versions-maven-plugin/src/it/it-set-property-001/verify.bsh similarity index 100% rename from src/it/it-set-property-001/verify.bsh rename to versions-maven-plugin/src/it/it-set-property-001/verify.bsh diff --git a/src/it/it-set-property-002/invoker.properties b/versions-maven-plugin/src/it/it-set-property-002/invoker.properties similarity index 100% rename from src/it/it-set-property-002/invoker.properties rename to versions-maven-plugin/src/it/it-set-property-002/invoker.properties diff --git a/src/it/it-set-property-002/pom.xml b/versions-maven-plugin/src/it/it-set-property-002/pom.xml similarity index 100% rename from src/it/it-set-property-002/pom.xml rename to versions-maven-plugin/src/it/it-set-property-002/pom.xml diff --git a/src/it/it-set-property-002/verify.bsh b/versions-maven-plugin/src/it/it-set-property-002/verify.bsh similarity index 100% rename from src/it/it-set-property-002/verify.bsh rename to versions-maven-plugin/src/it/it-set-property-002/verify.bsh diff --git a/src/it/it-set-property-003-multiple-properties/invoker.properties b/versions-maven-plugin/src/it/it-set-property-003-multiple-properties/invoker.properties similarity index 100% rename from src/it/it-set-property-003-multiple-properties/invoker.properties rename to versions-maven-plugin/src/it/it-set-property-003-multiple-properties/invoker.properties diff --git a/src/it/it-set-property-003-multiple-properties/pom.xml b/versions-maven-plugin/src/it/it-set-property-003-multiple-properties/pom.xml similarity index 100% rename from src/it/it-set-property-003-multiple-properties/pom.xml rename to versions-maven-plugin/src/it/it-set-property-003-multiple-properties/pom.xml diff --git a/src/it/it-set-property-003-multiple-properties/verify.bsh b/versions-maven-plugin/src/it/it-set-property-003-multiple-properties/verify.bsh similarity index 100% rename from src/it/it-set-property-003-multiple-properties/verify.bsh rename to versions-maven-plugin/src/it/it-set-property-003-multiple-properties/verify.bsh diff --git a/src/it/it-set-scm-tag-001/invoker.properties b/versions-maven-plugin/src/it/it-set-scm-tag-001/invoker.properties similarity index 100% rename from src/it/it-set-scm-tag-001/invoker.properties rename to versions-maven-plugin/src/it/it-set-scm-tag-001/invoker.properties diff --git a/src/it/it-set-scm-tag-001/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-001/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-001/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-001/pom.xml diff --git a/src/it/it-set-scm-tag-001/verify.groovy b/versions-maven-plugin/src/it/it-set-scm-tag-001/verify.groovy similarity index 100% rename from src/it/it-set-scm-tag-001/verify.groovy rename to versions-maven-plugin/src/it/it-set-scm-tag-001/verify.groovy diff --git a/src/it/it-set-scm-tag-002/invoker.properties b/versions-maven-plugin/src/it/it-set-scm-tag-002/invoker.properties similarity index 100% rename from src/it/it-set-scm-tag-002/invoker.properties rename to versions-maven-plugin/src/it/it-set-scm-tag-002/invoker.properties diff --git a/src/it/it-set-scm-tag-002/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-002/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-002/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-002/pom.xml diff --git a/src/it/it-set-scm-tag-003/invoker.properties b/versions-maven-plugin/src/it/it-set-scm-tag-003/invoker.properties similarity index 100% rename from src/it/it-set-scm-tag-003/invoker.properties rename to versions-maven-plugin/src/it/it-set-scm-tag-003/invoker.properties diff --git a/src/it/it-set-scm-tag-003/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-003/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-003/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-003/pom.xml diff --git a/src/it/it-set-scm-tag-004/invoker.properties b/versions-maven-plugin/src/it/it-set-scm-tag-004/invoker.properties similarity index 100% rename from src/it/it-set-scm-tag-004/invoker.properties rename to versions-maven-plugin/src/it/it-set-scm-tag-004/invoker.properties diff --git a/src/it/it-set-scm-tag-004/module-a1/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-004/module-a1/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-004/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-004/module-a1/pom.xml diff --git a/src/it/it-set-scm-tag-004/module-a2/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-004/module-a2/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-004/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-004/module-a2/pom.xml diff --git a/src/it/it-set-scm-tag-004/pom.xml b/versions-maven-plugin/src/it/it-set-scm-tag-004/pom.xml similarity index 100% rename from src/it/it-set-scm-tag-004/pom.xml rename to versions-maven-plugin/src/it/it-set-scm-tag-004/pom.xml diff --git a/src/it/it-set-scm-tag-004/verify.bsh b/versions-maven-plugin/src/it/it-set-scm-tag-004/verify.bsh similarity index 100% rename from src/it/it-set-scm-tag-004/verify.bsh rename to versions-maven-plugin/src/it/it-set-scm-tag-004/verify.bsh diff --git a/src/it/it-unlock-snapshots-001/invoker.properties b/versions-maven-plugin/src/it/it-unlock-snapshots-001/invoker.properties similarity index 100% rename from src/it/it-unlock-snapshots-001/invoker.properties rename to versions-maven-plugin/src/it/it-unlock-snapshots-001/invoker.properties diff --git a/src/it/it-unlock-snapshots-001/pom.xml b/versions-maven-plugin/src/it/it-unlock-snapshots-001/pom.xml similarity index 100% rename from src/it/it-unlock-snapshots-001/pom.xml rename to versions-maven-plugin/src/it/it-unlock-snapshots-001/pom.xml diff --git a/src/it/it-unlock-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-unlock-snapshots-001/verify.bsh similarity index 100% rename from src/it/it-unlock-snapshots-001/verify.bsh rename to versions-maven-plugin/src/it/it-unlock-snapshots-001/verify.bsh diff --git a/src/it/it-update-child-modules-001/child/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-001/child/pom.xml similarity index 100% rename from src/it/it-update-child-modules-001/child/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-001/child/pom.xml diff --git a/src/it/it-update-child-modules-001/invoker.properties b/versions-maven-plugin/src/it/it-update-child-modules-001/invoker.properties similarity index 100% rename from src/it/it-update-child-modules-001/invoker.properties rename to versions-maven-plugin/src/it/it-update-child-modules-001/invoker.properties diff --git a/src/it/it-update-child-modules-001/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-001/pom.xml similarity index 100% rename from src/it/it-update-child-modules-001/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-001/pom.xml diff --git a/src/it/it-update-child-modules-001/verify.bsh b/versions-maven-plugin/src/it/it-update-child-modules-001/verify.bsh similarity index 100% rename from src/it/it-update-child-modules-001/verify.bsh rename to versions-maven-plugin/src/it/it-update-child-modules-001/verify.bsh diff --git a/src/it/it-update-child-modules-002/child/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-002/child/pom.xml similarity index 100% rename from src/it/it-update-child-modules-002/child/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-002/child/pom.xml diff --git a/src/it/it-update-child-modules-002/child/subchild/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-002/child/subchild/pom.xml similarity index 100% rename from src/it/it-update-child-modules-002/child/subchild/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-002/child/subchild/pom.xml diff --git a/src/it/it-update-child-modules-002/child/subchild2/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-002/child/subchild2/pom.xml similarity index 100% rename from src/it/it-update-child-modules-002/child/subchild2/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-002/child/subchild2/pom.xml diff --git a/src/it/it-update-child-modules-002/child2/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-002/child2/pom.xml similarity index 100% rename from src/it/it-update-child-modules-002/child2/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-002/child2/pom.xml diff --git a/src/it/it-update-child-modules-002/invoker.properties b/versions-maven-plugin/src/it/it-update-child-modules-002/invoker.properties similarity index 100% rename from src/it/it-update-child-modules-002/invoker.properties rename to versions-maven-plugin/src/it/it-update-child-modules-002/invoker.properties diff --git a/src/it/it-update-child-modules-002/pom.xml b/versions-maven-plugin/src/it/it-update-child-modules-002/pom.xml similarity index 100% rename from src/it/it-update-child-modules-002/pom.xml rename to versions-maven-plugin/src/it/it-update-child-modules-002/pom.xml diff --git a/src/it/it-update-child-modules-002/verify.bsh b/versions-maven-plugin/src/it/it-update-child-modules-002/verify.bsh similarity index 100% rename from src/it/it-update-child-modules-002/verify.bsh rename to versions-maven-plugin/src/it/it-update-child-modules-002/verify.bsh diff --git a/src/it/it-update-parent-001/invoker.properties b/versions-maven-plugin/src/it/it-update-parent-001/invoker.properties similarity index 100% rename from src/it/it-update-parent-001/invoker.properties rename to versions-maven-plugin/src/it/it-update-parent-001/invoker.properties diff --git a/src/it/it-update-parent-001/pom.xml b/versions-maven-plugin/src/it/it-update-parent-001/pom.xml similarity index 100% rename from src/it/it-update-parent-001/pom.xml rename to versions-maven-plugin/src/it/it-update-parent-001/pom.xml diff --git a/src/it/it-update-parent-001/verify.bsh b/versions-maven-plugin/src/it/it-update-parent-001/verify.bsh similarity index 100% rename from src/it/it-update-parent-001/verify.bsh rename to versions-maven-plugin/src/it/it-update-parent-001/verify.bsh diff --git a/src/it/it-update-parent-004/invoker.properties b/versions-maven-plugin/src/it/it-update-parent-004/invoker.properties similarity index 100% rename from src/it/it-update-parent-004/invoker.properties rename to versions-maven-plugin/src/it/it-update-parent-004/invoker.properties diff --git a/src/it/it-update-parent-004/pom.xml b/versions-maven-plugin/src/it/it-update-parent-004/pom.xml similarity index 100% rename from src/it/it-update-parent-004/pom.xml rename to versions-maven-plugin/src/it/it-update-parent-004/pom.xml diff --git a/src/it/it-update-parent-004/verify.bsh b/versions-maven-plugin/src/it/it-update-parent-004/verify.bsh similarity index 100% rename from src/it/it-update-parent-004/verify.bsh rename to versions-maven-plugin/src/it/it-update-parent-004/verify.bsh diff --git a/src/it/it-update-parent-005-issue-610/invoker.properties b/versions-maven-plugin/src/it/it-update-parent-005-issue-610/invoker.properties similarity index 100% rename from src/it/it-update-parent-005-issue-610/invoker.properties rename to versions-maven-plugin/src/it/it-update-parent-005-issue-610/invoker.properties diff --git a/src/it/it-update-parent-005-issue-610/pom.xml b/versions-maven-plugin/src/it/it-update-parent-005-issue-610/pom.xml similarity index 100% rename from src/it/it-update-parent-005-issue-610/pom.xml rename to versions-maven-plugin/src/it/it-update-parent-005-issue-610/pom.xml diff --git a/src/it/it-update-parent-005-issue-610/verify.groovy b/versions-maven-plugin/src/it/it-update-parent-005-issue-610/verify.groovy similarity index 100% rename from src/it/it-update-parent-005-issue-610/verify.groovy rename to versions-maven-plugin/src/it/it-update-parent-005-issue-610/verify.groovy diff --git a/src/it/it-update-parent-005-issue-670/invoker.properties b/versions-maven-plugin/src/it/it-update-parent-005-issue-670/invoker.properties similarity index 100% rename from src/it/it-update-parent-005-issue-670/invoker.properties rename to versions-maven-plugin/src/it/it-update-parent-005-issue-670/invoker.properties diff --git a/src/it/it-update-parent-005-issue-670/pom.xml b/versions-maven-plugin/src/it/it-update-parent-005-issue-670/pom.xml similarity index 100% rename from src/it/it-update-parent-005-issue-670/pom.xml rename to versions-maven-plugin/src/it/it-update-parent-005-issue-670/pom.xml diff --git a/src/it/it-update-parent-005-issue-670/verify.groovy b/versions-maven-plugin/src/it/it-update-parent-005-issue-670/verify.groovy similarity index 100% rename from src/it/it-update-parent-005-issue-670/verify.groovy rename to versions-maven-plugin/src/it/it-update-parent-005-issue-670/verify.groovy diff --git a/src/it/it-update-parent-issue-454/invoker.properties b/versions-maven-plugin/src/it/it-update-parent-issue-454/invoker.properties similarity index 100% rename from src/it/it-update-parent-issue-454/invoker.properties rename to versions-maven-plugin/src/it/it-update-parent-issue-454/invoker.properties diff --git a/src/it/it-update-parent-issue-454/pom.xml b/versions-maven-plugin/src/it/it-update-parent-issue-454/pom.xml similarity index 100% rename from src/it/it-update-parent-issue-454/pom.xml rename to versions-maven-plugin/src/it/it-update-parent-issue-454/pom.xml diff --git a/src/it/it-update-parent-issue-454/verify.groovy b/versions-maven-plugin/src/it/it-update-parent-issue-454/verify.groovy similarity index 100% rename from src/it/it-update-parent-issue-454/verify.groovy rename to versions-maven-plugin/src/it/it-update-parent-issue-454/verify.groovy diff --git a/src/it/it-update-properties-001/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-001/invoker.properties similarity index 100% rename from src/it/it-update-properties-001/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-001/invoker.properties diff --git a/src/it/it-update-properties-001/pom.xml b/versions-maven-plugin/src/it/it-update-properties-001/pom.xml similarity index 100% rename from src/it/it-update-properties-001/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-001/pom.xml diff --git a/src/it/it-update-properties-001/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-001/verify.bsh similarity index 100% rename from src/it/it-update-properties-001/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-001/verify.bsh diff --git a/src/it/it-update-properties-002/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-002/invoker.properties similarity index 100% rename from src/it/it-update-properties-002/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-002/invoker.properties diff --git a/src/it/it-update-properties-002/pom.xml b/versions-maven-plugin/src/it/it-update-properties-002/pom.xml similarity index 100% rename from src/it/it-update-properties-002/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-002/pom.xml diff --git a/src/it/it-update-properties-002/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-002/verify.bsh similarity index 100% rename from src/it/it-update-properties-002/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-002/verify.bsh diff --git a/src/it/it-update-properties-003/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-003/invoker.properties similarity index 100% rename from src/it/it-update-properties-003/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-003/invoker.properties diff --git a/src/it/it-update-properties-003/pom.xml b/versions-maven-plugin/src/it/it-update-properties-003/pom.xml similarity index 100% rename from src/it/it-update-properties-003/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-003/pom.xml diff --git a/src/it/it-update-properties-003/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-003/verify.bsh similarity index 100% rename from src/it/it-update-properties-003/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-003/verify.bsh diff --git a/src/it/it-update-properties-004/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-004/invoker.properties similarity index 100% rename from src/it/it-update-properties-004/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-004/invoker.properties diff --git a/src/it/it-update-properties-004/pom.xml b/versions-maven-plugin/src/it/it-update-properties-004/pom.xml similarity index 100% rename from src/it/it-update-properties-004/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-004/pom.xml diff --git a/src/it/it-update-properties-004/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-004/verify.bsh similarity index 100% rename from src/it/it-update-properties-004/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-004/verify.bsh diff --git a/src/it/it-update-properties-005/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-005/invoker.properties similarity index 100% rename from src/it/it-update-properties-005/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-005/invoker.properties diff --git a/src/it/it-update-properties-005/pom.xml b/versions-maven-plugin/src/it/it-update-properties-005/pom.xml similarity index 100% rename from src/it/it-update-properties-005/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-005/pom.xml diff --git a/src/it/it-update-properties-005/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-005/verify.bsh similarity index 100% rename from src/it/it-update-properties-005/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-005/verify.bsh diff --git a/src/it/it-update-properties-006/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-006/invoker.properties similarity index 100% rename from src/it/it-update-properties-006/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-006/invoker.properties diff --git a/src/it/it-update-properties-006/pom.xml b/versions-maven-plugin/src/it/it-update-properties-006/pom.xml similarity index 100% rename from src/it/it-update-properties-006/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-006/pom.xml diff --git a/src/it/it-update-properties-006/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-006/verify.bsh similarity index 100% rename from src/it/it-update-properties-006/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-006/verify.bsh diff --git a/src/it/it-update-properties-007/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-007/invoker.properties similarity index 100% rename from src/it/it-update-properties-007/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-007/invoker.properties diff --git a/src/it/it-update-properties-007/pom.xml b/versions-maven-plugin/src/it/it-update-properties-007/pom.xml similarity index 100% rename from src/it/it-update-properties-007/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-007/pom.xml diff --git a/src/it/it-update-properties-007/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-007/verify.bsh similarity index 100% rename from src/it/it-update-properties-007/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-007/verify.bsh diff --git a/src/it/it-update-properties-008/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-008/invoker.properties similarity index 100% rename from src/it/it-update-properties-008/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-008/invoker.properties diff --git a/src/it/it-update-properties-008/pom.xml b/versions-maven-plugin/src/it/it-update-properties-008/pom.xml similarity index 100% rename from src/it/it-update-properties-008/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-008/pom.xml diff --git a/src/it/it-update-properties-008/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-008/verify.bsh similarity index 100% rename from src/it/it-update-properties-008/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-008/verify.bsh diff --git a/src/it/it-update-properties-009/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-009/invoker.properties similarity index 100% rename from src/it/it-update-properties-009/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-009/invoker.properties diff --git a/src/it/it-update-properties-009/pom.xml b/versions-maven-plugin/src/it/it-update-properties-009/pom.xml similarity index 100% rename from src/it/it-update-properties-009/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-009/pom.xml diff --git a/src/it/it-update-properties-009/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-009/verify.bsh similarity index 100% rename from src/it/it-update-properties-009/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-009/verify.bsh diff --git a/src/it/it-update-properties-010/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-010/invoker.properties similarity index 100% rename from src/it/it-update-properties-010/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-010/invoker.properties diff --git a/src/it/it-update-properties-010/pom.xml b/versions-maven-plugin/src/it/it-update-properties-010/pom.xml similarity index 100% rename from src/it/it-update-properties-010/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-010/pom.xml diff --git a/src/it/it-update-properties-010/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-010/verify.bsh similarity index 100% rename from src/it/it-update-properties-010/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-010/verify.bsh diff --git a/src/it/it-update-properties-011/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-011/invoker.properties similarity index 100% rename from src/it/it-update-properties-011/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-011/invoker.properties diff --git a/src/it/it-update-properties-011/pom.xml b/versions-maven-plugin/src/it/it-update-properties-011/pom.xml similarity index 100% rename from src/it/it-update-properties-011/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-011/pom.xml diff --git a/src/it/it-update-properties-011/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-011/verify.bsh similarity index 100% rename from src/it/it-update-properties-011/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-011/verify.bsh diff --git a/src/it/it-update-properties-012/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-012/invoker.properties similarity index 100% rename from src/it/it-update-properties-012/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-012/invoker.properties diff --git a/src/it/it-update-properties-012/pom.xml b/versions-maven-plugin/src/it/it-update-properties-012/pom.xml similarity index 100% rename from src/it/it-update-properties-012/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-012/pom.xml diff --git a/src/it/it-update-properties-012/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-012/verify.bsh similarity index 100% rename from src/it/it-update-properties-012/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-012/verify.bsh diff --git a/src/it/it-update-properties-013/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-013/invoker.properties similarity index 100% rename from src/it/it-update-properties-013/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-013/invoker.properties diff --git a/src/it/it-update-properties-013/pom.xml b/versions-maven-plugin/src/it/it-update-properties-013/pom.xml similarity index 100% rename from src/it/it-update-properties-013/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-013/pom.xml diff --git a/src/it/it-update-properties-013/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-013/verify.bsh similarity index 100% rename from src/it/it-update-properties-013/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-013/verify.bsh diff --git a/src/it/it-update-properties-014/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-014/invoker.properties similarity index 100% rename from src/it/it-update-properties-014/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-014/invoker.properties diff --git a/src/it/it-update-properties-014/pom.xml b/versions-maven-plugin/src/it/it-update-properties-014/pom.xml similarity index 100% rename from src/it/it-update-properties-014/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-014/pom.xml diff --git a/src/it/it-update-properties-014/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-014/verify.bsh similarity index 100% rename from src/it/it-update-properties-014/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-014/verify.bsh diff --git a/src/it/it-update-properties-015/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-015/invoker.properties similarity index 100% rename from src/it/it-update-properties-015/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-015/invoker.properties diff --git a/src/it/it-update-properties-015/pom.xml b/versions-maven-plugin/src/it/it-update-properties-015/pom.xml similarity index 100% rename from src/it/it-update-properties-015/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-015/pom.xml diff --git a/src/it/it-update-properties-015/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-015/verify.bsh similarity index 100% rename from src/it/it-update-properties-015/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-015/verify.bsh diff --git a/src/it/it-update-properties-016/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-016/invoker.properties similarity index 100% rename from src/it/it-update-properties-016/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-016/invoker.properties diff --git a/src/it/it-update-properties-016/pom.xml b/versions-maven-plugin/src/it/it-update-properties-016/pom.xml similarity index 100% rename from src/it/it-update-properties-016/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-016/pom.xml diff --git a/src/it/it-update-properties-016/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-016/verify.bsh similarity index 100% rename from src/it/it-update-properties-016/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-016/verify.bsh diff --git a/src/it/it-update-properties-017/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-017/invoker.properties similarity index 100% rename from src/it/it-update-properties-017/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-017/invoker.properties diff --git a/src/it/it-update-properties-017/pom.xml b/versions-maven-plugin/src/it/it-update-properties-017/pom.xml similarity index 100% rename from src/it/it-update-properties-017/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-017/pom.xml diff --git a/src/it/it-update-properties-017/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-017/verify.bsh similarity index 100% rename from src/it/it-update-properties-017/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-017/verify.bsh diff --git a/src/it/it-update-properties-018/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-018/invoker.properties similarity index 100% rename from src/it/it-update-properties-018/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-018/invoker.properties diff --git a/src/it/it-update-properties-018/pom.xml b/versions-maven-plugin/src/it/it-update-properties-018/pom.xml similarity index 100% rename from src/it/it-update-properties-018/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-018/pom.xml diff --git a/src/it/it-update-properties-018/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-018/verify.bsh similarity index 100% rename from src/it/it-update-properties-018/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-018/verify.bsh diff --git a/src/it/it-update-properties-019/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-019/invoker.properties similarity index 100% rename from src/it/it-update-properties-019/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-019/invoker.properties diff --git a/src/it/it-update-properties-019/pom.xml b/versions-maven-plugin/src/it/it-update-properties-019/pom.xml similarity index 100% rename from src/it/it-update-properties-019/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-019/pom.xml diff --git a/src/it/it-update-properties-019/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-019/verify.bsh similarity index 100% rename from src/it/it-update-properties-019/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-019/verify.bsh diff --git a/src/it/it-update-properties-020/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-020/invoker.properties similarity index 100% rename from src/it/it-update-properties-020/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-020/invoker.properties diff --git a/src/it/it-update-properties-020/pom.xml b/versions-maven-plugin/src/it/it-update-properties-020/pom.xml similarity index 100% rename from src/it/it-update-properties-020/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-020/pom.xml diff --git a/src/it/it-update-properties-020/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-020/verify.bsh similarity index 100% rename from src/it/it-update-properties-020/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-020/verify.bsh diff --git a/src/it/it-update-properties-021/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-021/invoker.properties similarity index 100% rename from src/it/it-update-properties-021/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-021/invoker.properties diff --git a/src/it/it-update-properties-021/pom.xml b/versions-maven-plugin/src/it/it-update-properties-021/pom.xml similarity index 100% rename from src/it/it-update-properties-021/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-021/pom.xml diff --git a/src/it/it-update-properties-021/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-021/verify.bsh similarity index 100% rename from src/it/it-update-properties-021/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-021/verify.bsh diff --git a/src/it/it-update-properties-022/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-022/invoker.properties similarity index 100% rename from src/it/it-update-properties-022/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-022/invoker.properties diff --git a/src/it/it-update-properties-022/pom.xml b/versions-maven-plugin/src/it/it-update-properties-022/pom.xml similarity index 100% rename from src/it/it-update-properties-022/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-022/pom.xml diff --git a/src/it/it-update-properties-022/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-022/verify.bsh similarity index 100% rename from src/it/it-update-properties-022/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-022/verify.bsh diff --git a/src/it/it-update-properties-023/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-023/invoker.properties similarity index 100% rename from src/it/it-update-properties-023/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-023/invoker.properties diff --git a/src/it/it-update-properties-023/pom.xml b/versions-maven-plugin/src/it/it-update-properties-023/pom.xml similarity index 100% rename from src/it/it-update-properties-023/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-023/pom.xml diff --git a/src/it/it-update-properties-023/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-023/verify.bsh similarity index 100% rename from src/it/it-update-properties-023/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-023/verify.bsh diff --git a/src/it/it-update-properties-issue-279-1/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-279-1/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-279-1/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-279-1/invoker.properties diff --git a/src/it/it-update-properties-issue-279-1/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-279-1/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-279-1/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-279-1/pom.xml diff --git a/src/it/it-update-properties-issue-279-1/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-279-1/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-279-1/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-279-1/verify.bsh diff --git a/src/it/it-update-properties-issue-279-2/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-279-2/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-279-2/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-279-2/invoker.properties diff --git a/src/it/it-update-properties-issue-279-2/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-279-2/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-279-2/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-279-2/pom.xml diff --git a/src/it/it-update-properties-issue-279-2/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-279-2/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-279-2/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-279-2/verify.bsh diff --git a/src/it/it-update-properties-issue-279-3/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-279-3/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-279-3/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-279-3/invoker.properties diff --git a/src/it/it-update-properties-issue-279-3/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-279-3/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-279-3/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-279-3/pom.xml diff --git a/src/it/it-update-properties-issue-279-3/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-279-3/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-279-3/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-279-3/verify.bsh diff --git a/src/it/it-update-properties-issue-279-4/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-279-4/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-279-4/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-279-4/invoker.properties diff --git a/src/it/it-update-properties-issue-279-4/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-279-4/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-279-4/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-279-4/pom.xml diff --git a/src/it/it-update-properties-issue-279-4/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-279-4/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-279-4/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-279-4/verify.bsh diff --git a/src/it/it-update-properties-issue-279-5/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-279-5/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-279-5/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-279-5/invoker.properties diff --git a/src/it/it-update-properties-issue-279-5/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-279-5/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-279-5/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-279-5/pom.xml diff --git a/src/it/it-update-properties-issue-279-5/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-279-5/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-279-5/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-279-5/verify.bsh diff --git a/src/it/it-update-properties-issue-582/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-582/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-582/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-582/invoker.properties diff --git a/src/it/it-update-properties-issue-582/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-582/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-582/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-582/pom.xml diff --git a/src/it/it-update-properties-issue-582/verify.groovy b/versions-maven-plugin/src/it/it-update-properties-issue-582/verify.groovy similarity index 100% rename from src/it/it-update-properties-issue-582/verify.groovy rename to versions-maven-plugin/src/it/it-update-properties-issue-582/verify.groovy diff --git a/src/it/it-update-properties-issue-98-1/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-98-1/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-98-1/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-98-1/invoker.properties diff --git a/src/it/it-update-properties-issue-98-1/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-98-1/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-98-1/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-98-1/pom.xml diff --git a/src/it/it-update-properties-issue-98-1/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-98-1/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-98-1/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-98-1/verify.bsh diff --git a/src/it/it-update-properties-issue-98-2/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-98-2/invoker.properties similarity index 100% rename from src/it/it-update-properties-issue-98-2/invoker.properties rename to versions-maven-plugin/src/it/it-update-properties-issue-98-2/invoker.properties diff --git a/src/it/it-update-properties-issue-98-2/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-98-2/pom.xml similarity index 100% rename from src/it/it-update-properties-issue-98-2/pom.xml rename to versions-maven-plugin/src/it/it-update-properties-issue-98-2/pom.xml diff --git a/src/it/it-update-properties-issue-98-2/verify.bsh b/versions-maven-plugin/src/it/it-update-properties-issue-98-2/verify.bsh similarity index 100% rename from src/it/it-update-properties-issue-98-2/verify.bsh rename to versions-maven-plugin/src/it/it-update-properties-issue-98-2/verify.bsh diff --git a/src/it/it-update-property-001/invoker.properties b/versions-maven-plugin/src/it/it-update-property-001/invoker.properties similarity index 100% rename from src/it/it-update-property-001/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-001/invoker.properties diff --git a/src/it/it-update-property-001/pom.xml b/versions-maven-plugin/src/it/it-update-property-001/pom.xml similarity index 100% rename from src/it/it-update-property-001/pom.xml rename to versions-maven-plugin/src/it/it-update-property-001/pom.xml diff --git a/src/it/it-update-property-001/verify.bsh b/versions-maven-plugin/src/it/it-update-property-001/verify.bsh similarity index 100% rename from src/it/it-update-property-001/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-001/verify.bsh diff --git a/src/it/it-update-property-002/invoker.properties b/versions-maven-plugin/src/it/it-update-property-002/invoker.properties similarity index 100% rename from src/it/it-update-property-002/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-002/invoker.properties diff --git a/src/it/it-update-property-002/pom.xml b/versions-maven-plugin/src/it/it-update-property-002/pom.xml similarity index 100% rename from src/it/it-update-property-002/pom.xml rename to versions-maven-plugin/src/it/it-update-property-002/pom.xml diff --git a/src/it/it-update-property-002/verify.bsh b/versions-maven-plugin/src/it/it-update-property-002/verify.bsh similarity index 100% rename from src/it/it-update-property-002/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-002/verify.bsh diff --git a/src/it/it-update-property-issue-140-1/invoker.properties b/versions-maven-plugin/src/it/it-update-property-issue-140-1/invoker.properties similarity index 100% rename from src/it/it-update-property-issue-140-1/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-issue-140-1/invoker.properties diff --git a/src/it/it-update-property-issue-140-1/pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-140-1/pom.xml similarity index 100% rename from src/it/it-update-property-issue-140-1/pom.xml rename to versions-maven-plugin/src/it/it-update-property-issue-140-1/pom.xml diff --git a/src/it/it-update-property-issue-140-1/verify.bsh b/versions-maven-plugin/src/it/it-update-property-issue-140-1/verify.bsh similarity index 100% rename from src/it/it-update-property-issue-140-1/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-issue-140-1/verify.bsh diff --git a/src/it/it-update-property-issue-140-2/invoker.properties b/versions-maven-plugin/src/it/it-update-property-issue-140-2/invoker.properties similarity index 100% rename from src/it/it-update-property-issue-140-2/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-issue-140-2/invoker.properties diff --git a/src/it/it-update-property-issue-140-2/pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-140-2/pom.xml similarity index 100% rename from src/it/it-update-property-issue-140-2/pom.xml rename to versions-maven-plugin/src/it/it-update-property-issue-140-2/pom.xml diff --git a/src/it/it-update-property-issue-140-2/verify.bsh b/versions-maven-plugin/src/it/it-update-property-issue-140-2/verify.bsh similarity index 100% rename from src/it/it-update-property-issue-140-2/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-issue-140-2/verify.bsh diff --git a/src/it/it-update-property-issue-140-3/invoker.properties b/versions-maven-plugin/src/it/it-update-property-issue-140-3/invoker.properties similarity index 100% rename from src/it/it-update-property-issue-140-3/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-issue-140-3/invoker.properties diff --git a/src/it/it-update-property-issue-140-3/pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-140-3/pom.xml similarity index 100% rename from src/it/it-update-property-issue-140-3/pom.xml rename to versions-maven-plugin/src/it/it-update-property-issue-140-3/pom.xml diff --git a/src/it/it-update-property-issue-140-3/verify.bsh b/versions-maven-plugin/src/it/it-update-property-issue-140-3/verify.bsh similarity index 100% rename from src/it/it-update-property-issue-140-3/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-issue-140-3/verify.bsh diff --git a/src/it/it-update-property-issue-140/invoker.properties b/versions-maven-plugin/src/it/it-update-property-issue-140/invoker.properties similarity index 100% rename from src/it/it-update-property-issue-140/invoker.properties rename to versions-maven-plugin/src/it/it-update-property-issue-140/invoker.properties diff --git a/src/it/it-update-property-issue-140/pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-140/pom.xml similarity index 100% rename from src/it/it-update-property-issue-140/pom.xml rename to versions-maven-plugin/src/it/it-update-property-issue-140/pom.xml diff --git a/src/it/it-update-property-issue-140/verify.bsh b/versions-maven-plugin/src/it/it-update-property-issue-140/verify.bsh similarity index 100% rename from src/it/it-update-property-issue-140/verify.bsh rename to versions-maven-plugin/src/it/it-update-property-issue-140/verify.bsh diff --git a/src/it/it-use-latest-releases-001/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-001/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-001/invoker.properties diff --git a/src/it/it-use-latest-releases-001/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-001/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-001/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-001/pom.xml diff --git a/src/it/it-use-latest-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-001/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-001/verify.bsh diff --git a/src/it/it-use-latest-releases-002/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-002/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-002/invoker.properties diff --git a/src/it/it-use-latest-releases-002/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-002/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-002/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-002/pom.xml diff --git a/src/it/it-use-latest-releases-002/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-002/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-002/verify.bsh diff --git a/src/it/it-use-latest-releases-003/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-003/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-003/invoker.properties diff --git a/src/it/it-use-latest-releases-003/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-003/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-003/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-003/pom.xml diff --git a/src/it/it-use-latest-releases-003/rule-set.xml b/versions-maven-plugin/src/it/it-use-latest-releases-003/rule-set.xml similarity index 100% rename from src/it/it-use-latest-releases-003/rule-set.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-003/rule-set.xml diff --git a/src/it/it-use-latest-releases-003/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-003/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-003/verify.bsh diff --git a/src/it/it-use-latest-releases-004/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-004/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-004/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-004/invoker.properties diff --git a/src/it/it-use-latest-releases-004/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-004/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-004/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-004/pom.xml diff --git a/src/it/it-use-latest-releases-004/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-004/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-004/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-004/verify.bsh diff --git a/src/it/it-use-latest-releases-005/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-005/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-005/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-005/invoker.properties diff --git a/src/it/it-use-latest-releases-005/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-005/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-005/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-005/pom.xml diff --git a/src/it/it-use-latest-releases-005/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-005/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-005/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-005/verify.bsh diff --git a/src/it/it-use-latest-releases-006/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-006/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-006/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-006/invoker.properties diff --git a/src/it/it-use-latest-releases-006/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-006/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-006/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-006/pom.xml diff --git a/src/it/it-use-latest-releases-006/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-006/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-006/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-006/verify.bsh diff --git a/src/it/it-use-latest-releases-007/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-007/invoker.properties similarity index 100% rename from src/it/it-use-latest-releases-007/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-releases-007/invoker.properties diff --git a/src/it/it-use-latest-releases-007/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-007/pom.xml similarity index 100% rename from src/it/it-use-latest-releases-007/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-releases-007/pom.xml diff --git a/src/it/it-use-latest-releases-007/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-releases-007/verify.bsh similarity index 100% rename from src/it/it-use-latest-releases-007/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-releases-007/verify.bsh diff --git a/src/it/it-use-latest-snapshots-001/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-001/invoker.properties similarity index 100% rename from src/it/it-use-latest-snapshots-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-snapshots-001/invoker.properties diff --git a/src/it/it-use-latest-snapshots-001/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-001/pom.xml similarity index 100% rename from src/it/it-use-latest-snapshots-001/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-snapshots-001/pom.xml diff --git a/src/it/it-use-latest-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-snapshots-001/verify.bsh similarity index 100% rename from src/it/it-use-latest-snapshots-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-snapshots-001/verify.bsh diff --git a/src/it/it-use-latest-snapshots-002/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-002/invoker.properties similarity index 100% rename from src/it/it-use-latest-snapshots-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-snapshots-002/invoker.properties diff --git a/src/it/it-use-latest-snapshots-002/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-002/pom.xml similarity index 100% rename from src/it/it-use-latest-snapshots-002/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-snapshots-002/pom.xml diff --git a/src/it/it-use-latest-snapshots-002/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-snapshots-002/verify.bsh similarity index 100% rename from src/it/it-use-latest-snapshots-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-snapshots-002/verify.bsh diff --git a/src/it/it-use-latest-snapshots-003/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-003/invoker.properties similarity index 100% rename from src/it/it-use-latest-snapshots-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-snapshots-003/invoker.properties diff --git a/src/it/it-use-latest-snapshots-003/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-003/pom.xml similarity index 100% rename from src/it/it-use-latest-snapshots-003/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-snapshots-003/pom.xml diff --git a/src/it/it-use-latest-snapshots-003/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-snapshots-003/verify.bsh similarity index 100% rename from src/it/it-use-latest-snapshots-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-snapshots-003/verify.bsh diff --git a/src/it/it-use-latest-snapshots-004/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-004/invoker.properties similarity index 100% rename from src/it/it-use-latest-snapshots-004/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-snapshots-004/invoker.properties diff --git a/src/it/it-use-latest-snapshots-004/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-004/pom.xml similarity index 100% rename from src/it/it-use-latest-snapshots-004/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-snapshots-004/pom.xml diff --git a/src/it/it-use-latest-snapshots-004/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-snapshots-004/verify.bsh similarity index 100% rename from src/it/it-use-latest-snapshots-004/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-snapshots-004/verify.bsh diff --git a/src/it/it-use-latest-snapshots-005/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-005/invoker.properties similarity index 100% rename from src/it/it-use-latest-snapshots-005/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-snapshots-005/invoker.properties diff --git a/src/it/it-use-latest-snapshots-005/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-005/pom.xml similarity index 100% rename from src/it/it-use-latest-snapshots-005/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-snapshots-005/pom.xml diff --git a/src/it/it-use-latest-snapshots-005/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-snapshots-005/verify.bsh similarity index 100% rename from src/it/it-use-latest-snapshots-005/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-snapshots-005/verify.bsh diff --git a/src/it/it-use-latest-versions-001/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-001/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-001/invoker.properties diff --git a/src/it/it-use-latest-versions-001/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-001/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-001/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-001/pom.xml diff --git a/src/it/it-use-latest-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-001/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-001/verify.bsh diff --git a/src/it/it-use-latest-versions-002/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-002/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-002/invoker.properties diff --git a/src/it/it-use-latest-versions-002/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-002/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-002/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-002/pom.xml diff --git a/src/it/it-use-latest-versions-002/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-002/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-002/verify.bsh diff --git a/src/it/it-use-latest-versions-003/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-003/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-003/invoker.properties diff --git a/src/it/it-use-latest-versions-003/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-003/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-003/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-003/pom.xml diff --git a/src/it/it-use-latest-versions-003/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-003/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-003/verify.bsh diff --git a/src/it/it-use-latest-versions-004/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-004/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-004/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-004/invoker.properties diff --git a/src/it/it-use-latest-versions-004/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-004/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-004/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-004/pom.xml diff --git a/src/it/it-use-latest-versions-004/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-004/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-004/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-004/verify.bsh diff --git a/src/it/it-use-latest-versions-005/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-005/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-005/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-005/invoker.properties diff --git a/src/it/it-use-latest-versions-005/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-005/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-005/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-005/pom.xml diff --git a/src/it/it-use-latest-versions-005/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-005/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-005/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-005/verify.bsh diff --git a/src/it/it-use-latest-versions-006/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-006/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-006/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-006/invoker.properties diff --git a/src/it/it-use-latest-versions-006/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-006/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-006/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-006/pom.xml diff --git a/src/it/it-use-latest-versions-006/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-006/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-006/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-006/verify.bsh diff --git a/src/it/it-use-latest-versions-007/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-007/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-007/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-007/invoker.properties diff --git a/src/it/it-use-latest-versions-007/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-007/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-007/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-007/pom.xml diff --git a/src/it/it-use-latest-versions-007/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-007/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-007/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-007/verify.bsh diff --git a/src/it/it-use-latest-versions-008/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-008/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-008/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-008/invoker.properties diff --git a/src/it/it-use-latest-versions-008/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-008/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-008/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-008/pom.xml diff --git a/src/it/it-use-latest-versions-008/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-008/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-008/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-008/verify.bsh diff --git a/src/it/it-use-latest-versions-009/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-009/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-009/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-009/invoker.properties diff --git a/src/it/it-use-latest-versions-009/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-009/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-009/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-009/pom.xml diff --git a/src/it/it-use-latest-versions-009/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-009/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh diff --git a/src/it/it-use-latest-versions-010/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-010/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-010/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-010/invoker.properties diff --git a/src/it/it-use-latest-versions-010/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-010/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-010/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-010/pom.xml diff --git a/src/it/it-use-latest-versions-010/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-010/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh diff --git a/src/it/it-use-latest-versions-011/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-011/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-011/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-011/invoker.properties diff --git a/src/it/it-use-latest-versions-011/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-011/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-011/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-011/pom.xml diff --git a/src/it/it-use-latest-versions-011/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-011/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh diff --git a/src/it/it-use-latest-versions-012/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-012/invoker.properties similarity index 100% rename from src/it/it-use-latest-versions-012/invoker.properties rename to versions-maven-plugin/src/it/it-use-latest-versions-012/invoker.properties diff --git a/src/it/it-use-latest-versions-012/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-012/pom.xml similarity index 100% rename from src/it/it-use-latest-versions-012/pom.xml rename to versions-maven-plugin/src/it/it-use-latest-versions-012/pom.xml diff --git a/src/it/it-use-latest-versions-012/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-012/verify.bsh similarity index 100% rename from src/it/it-use-latest-versions-012/verify.bsh rename to versions-maven-plugin/src/it/it-use-latest-versions-012/verify.bsh diff --git a/src/it/it-use-next-releases-001/invoker.properties b/versions-maven-plugin/src/it/it-use-next-releases-001/invoker.properties similarity index 100% rename from src/it/it-use-next-releases-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-releases-001/invoker.properties diff --git a/src/it/it-use-next-releases-001/pom.xml b/versions-maven-plugin/src/it/it-use-next-releases-001/pom.xml similarity index 100% rename from src/it/it-use-next-releases-001/pom.xml rename to versions-maven-plugin/src/it/it-use-next-releases-001/pom.xml diff --git a/src/it/it-use-next-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-use-next-releases-001/verify.bsh similarity index 100% rename from src/it/it-use-next-releases-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-releases-001/verify.bsh diff --git a/src/it/it-use-next-releases-002/invoker.properties b/versions-maven-plugin/src/it/it-use-next-releases-002/invoker.properties similarity index 100% rename from src/it/it-use-next-releases-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-releases-002/invoker.properties diff --git a/src/it/it-use-next-releases-002/pom.xml b/versions-maven-plugin/src/it/it-use-next-releases-002/pom.xml similarity index 100% rename from src/it/it-use-next-releases-002/pom.xml rename to versions-maven-plugin/src/it/it-use-next-releases-002/pom.xml diff --git a/src/it/it-use-next-releases-002/verify.bsh b/versions-maven-plugin/src/it/it-use-next-releases-002/verify.bsh similarity index 100% rename from src/it/it-use-next-releases-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-releases-002/verify.bsh diff --git a/src/it/it-use-next-releases-003/invoker.properties b/versions-maven-plugin/src/it/it-use-next-releases-003/invoker.properties similarity index 100% rename from src/it/it-use-next-releases-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-releases-003/invoker.properties diff --git a/src/it/it-use-next-releases-003/pom.xml b/versions-maven-plugin/src/it/it-use-next-releases-003/pom.xml similarity index 100% rename from src/it/it-use-next-releases-003/pom.xml rename to versions-maven-plugin/src/it/it-use-next-releases-003/pom.xml diff --git a/src/it/it-use-next-releases-003/verify.bsh b/versions-maven-plugin/src/it/it-use-next-releases-003/verify.bsh similarity index 100% rename from src/it/it-use-next-releases-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-releases-003/verify.bsh diff --git a/src/it/it-use-next-releases-004/invoker.properties b/versions-maven-plugin/src/it/it-use-next-releases-004/invoker.properties similarity index 100% rename from src/it/it-use-next-releases-004/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-releases-004/invoker.properties diff --git a/src/it/it-use-next-releases-004/pom.xml b/versions-maven-plugin/src/it/it-use-next-releases-004/pom.xml similarity index 100% rename from src/it/it-use-next-releases-004/pom.xml rename to versions-maven-plugin/src/it/it-use-next-releases-004/pom.xml diff --git a/src/it/it-use-next-releases-004/verify.bsh b/versions-maven-plugin/src/it/it-use-next-releases-004/verify.bsh similarity index 100% rename from src/it/it-use-next-releases-004/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-releases-004/verify.bsh diff --git a/src/it/it-use-next-snapshots-001/invoker.properties b/versions-maven-plugin/src/it/it-use-next-snapshots-001/invoker.properties similarity index 100% rename from src/it/it-use-next-snapshots-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-snapshots-001/invoker.properties diff --git a/src/it/it-use-next-snapshots-001/pom.xml b/versions-maven-plugin/src/it/it-use-next-snapshots-001/pom.xml similarity index 100% rename from src/it/it-use-next-snapshots-001/pom.xml rename to versions-maven-plugin/src/it/it-use-next-snapshots-001/pom.xml diff --git a/src/it/it-use-next-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-use-next-snapshots-001/verify.bsh similarity index 100% rename from src/it/it-use-next-snapshots-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-snapshots-001/verify.bsh diff --git a/src/it/it-use-next-snapshots-002/invoker.properties b/versions-maven-plugin/src/it/it-use-next-snapshots-002/invoker.properties similarity index 100% rename from src/it/it-use-next-snapshots-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-snapshots-002/invoker.properties diff --git a/src/it/it-use-next-snapshots-002/pom.xml b/versions-maven-plugin/src/it/it-use-next-snapshots-002/pom.xml similarity index 100% rename from src/it/it-use-next-snapshots-002/pom.xml rename to versions-maven-plugin/src/it/it-use-next-snapshots-002/pom.xml diff --git a/src/it/it-use-next-snapshots-002/verify.bsh b/versions-maven-plugin/src/it/it-use-next-snapshots-002/verify.bsh similarity index 100% rename from src/it/it-use-next-snapshots-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-snapshots-002/verify.bsh diff --git a/src/it/it-use-next-versions-001/invoker.properties b/versions-maven-plugin/src/it/it-use-next-versions-001/invoker.properties similarity index 100% rename from src/it/it-use-next-versions-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-versions-001/invoker.properties diff --git a/src/it/it-use-next-versions-001/pom.xml b/versions-maven-plugin/src/it/it-use-next-versions-001/pom.xml similarity index 100% rename from src/it/it-use-next-versions-001/pom.xml rename to versions-maven-plugin/src/it/it-use-next-versions-001/pom.xml diff --git a/src/it/it-use-next-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-use-next-versions-001/verify.bsh similarity index 100% rename from src/it/it-use-next-versions-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-versions-001/verify.bsh diff --git a/src/it/it-use-next-versions-002-snapshot/invoker.properties b/versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/invoker.properties similarity index 100% rename from src/it/it-use-next-versions-002-snapshot/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/invoker.properties diff --git a/src/it/it-use-next-versions-002-snapshot/pom.xml b/versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/pom.xml similarity index 100% rename from src/it/it-use-next-versions-002-snapshot/pom.xml rename to versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/pom.xml diff --git a/src/it/it-use-next-versions-002-snapshot/verify.bsh b/versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/verify.bsh similarity index 100% rename from src/it/it-use-next-versions-002-snapshot/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-versions-002-snapshot/verify.bsh diff --git a/src/it/it-use-next-versions-002/invoker.properties b/versions-maven-plugin/src/it/it-use-next-versions-002/invoker.properties similarity index 100% rename from src/it/it-use-next-versions-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-versions-002/invoker.properties diff --git a/src/it/it-use-next-versions-002/pom.xml b/versions-maven-plugin/src/it/it-use-next-versions-002/pom.xml similarity index 100% rename from src/it/it-use-next-versions-002/pom.xml rename to versions-maven-plugin/src/it/it-use-next-versions-002/pom.xml diff --git a/src/it/it-use-next-versions-002/verify.bsh b/versions-maven-plugin/src/it/it-use-next-versions-002/verify.bsh similarity index 100% rename from src/it/it-use-next-versions-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-versions-002/verify.bsh diff --git a/src/it/it-use-next-versions-003/invoker.properties b/versions-maven-plugin/src/it/it-use-next-versions-003/invoker.properties similarity index 100% rename from src/it/it-use-next-versions-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-next-versions-003/invoker.properties diff --git a/src/it/it-use-next-versions-003/pom.xml b/versions-maven-plugin/src/it/it-use-next-versions-003/pom.xml similarity index 100% rename from src/it/it-use-next-versions-003/pom.xml rename to versions-maven-plugin/src/it/it-use-next-versions-003/pom.xml diff --git a/src/it/it-use-next-versions-003/verify.bsh b/versions-maven-plugin/src/it/it-use-next-versions-003/verify.bsh similarity index 100% rename from src/it/it-use-next-versions-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-next-versions-003/verify.bsh diff --git a/src/it/it-use-reactor-001/invoker.properties b/versions-maven-plugin/src/it/it-use-reactor-001/invoker.properties similarity index 100% rename from src/it/it-use-reactor-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-reactor-001/invoker.properties diff --git a/src/it/it-use-reactor-001/module-a1/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-001/module-a1/pom.xml similarity index 100% rename from src/it/it-use-reactor-001/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-001/module-a1/pom.xml diff --git a/src/it/it-use-reactor-001/module-a2/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-001/module-a2/pom.xml similarity index 100% rename from src/it/it-use-reactor-001/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-001/module-a2/pom.xml diff --git a/src/it/it-use-reactor-001/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-001/pom.xml similarity index 100% rename from src/it/it-use-reactor-001/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-001/pom.xml diff --git a/src/it/it-use-reactor-001/the-grandparent/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-001/the-grandparent/pom.xml similarity index 100% rename from src/it/it-use-reactor-001/the-grandparent/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-001/the-grandparent/pom.xml diff --git a/src/it/it-use-reactor-001/the-parent/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-001/the-parent/pom.xml similarity index 100% rename from src/it/it-use-reactor-001/the-parent/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-001/the-parent/pom.xml diff --git a/src/it/it-use-reactor-001/verify.bsh b/versions-maven-plugin/src/it/it-use-reactor-001/verify.bsh similarity index 100% rename from src/it/it-use-reactor-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-reactor-001/verify.bsh diff --git a/src/it/it-use-reactor-002/invoker.properties b/versions-maven-plugin/src/it/it-use-reactor-002/invoker.properties similarity index 100% rename from src/it/it-use-reactor-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-reactor-002/invoker.properties diff --git a/src/it/it-use-reactor-002/module-a1/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-002/module-a1/pom.xml similarity index 100% rename from src/it/it-use-reactor-002/module-a1/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-002/module-a1/pom.xml diff --git a/src/it/it-use-reactor-002/module-a2/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-002/module-a2/pom.xml similarity index 100% rename from src/it/it-use-reactor-002/module-a2/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-002/module-a2/pom.xml diff --git a/src/it/it-use-reactor-002/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-002/pom.xml similarity index 100% rename from src/it/it-use-reactor-002/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-002/pom.xml diff --git a/src/it/it-use-reactor-002/the-grandparent/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-002/the-grandparent/pom.xml similarity index 100% rename from src/it/it-use-reactor-002/the-grandparent/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-002/the-grandparent/pom.xml diff --git a/src/it/it-use-reactor-002/the-parent/pom.xml b/versions-maven-plugin/src/it/it-use-reactor-002/the-parent/pom.xml similarity index 100% rename from src/it/it-use-reactor-002/the-parent/pom.xml rename to versions-maven-plugin/src/it/it-use-reactor-002/the-parent/pom.xml diff --git a/src/it/it-use-reactor-002/verify.bsh b/versions-maven-plugin/src/it/it-use-reactor-002/verify.bsh similarity index 100% rename from src/it/it-use-reactor-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-reactor-002/verify.bsh diff --git a/src/it/it-use-releases-001/invoker.properties b/versions-maven-plugin/src/it/it-use-releases-001/invoker.properties similarity index 100% rename from src/it/it-use-releases-001/invoker.properties rename to versions-maven-plugin/src/it/it-use-releases-001/invoker.properties diff --git a/src/it/it-use-releases-001/pom.xml b/versions-maven-plugin/src/it/it-use-releases-001/pom.xml similarity index 100% rename from src/it/it-use-releases-001/pom.xml rename to versions-maven-plugin/src/it/it-use-releases-001/pom.xml diff --git a/src/it/it-use-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-use-releases-001/verify.bsh similarity index 100% rename from src/it/it-use-releases-001/verify.bsh rename to versions-maven-plugin/src/it/it-use-releases-001/verify.bsh diff --git a/src/it/it-use-releases-002/invoker.properties b/versions-maven-plugin/src/it/it-use-releases-002/invoker.properties similarity index 100% rename from src/it/it-use-releases-002/invoker.properties rename to versions-maven-plugin/src/it/it-use-releases-002/invoker.properties diff --git a/src/it/it-use-releases-002/pom.xml b/versions-maven-plugin/src/it/it-use-releases-002/pom.xml similarity index 100% rename from src/it/it-use-releases-002/pom.xml rename to versions-maven-plugin/src/it/it-use-releases-002/pom.xml diff --git a/src/it/it-use-releases-002/verify.bsh b/versions-maven-plugin/src/it/it-use-releases-002/verify.bsh similarity index 100% rename from src/it/it-use-releases-002/verify.bsh rename to versions-maven-plugin/src/it/it-use-releases-002/verify.bsh diff --git a/src/it/it-use-releases-003/invoker.properties b/versions-maven-plugin/src/it/it-use-releases-003/invoker.properties similarity index 100% rename from src/it/it-use-releases-003/invoker.properties rename to versions-maven-plugin/src/it/it-use-releases-003/invoker.properties diff --git a/src/it/it-use-releases-003/pom.xml b/versions-maven-plugin/src/it/it-use-releases-003/pom.xml similarity index 100% rename from src/it/it-use-releases-003/pom.xml rename to versions-maven-plugin/src/it/it-use-releases-003/pom.xml diff --git a/src/it/it-use-releases-003/verify.bsh b/versions-maven-plugin/src/it/it-use-releases-003/verify.bsh similarity index 100% rename from src/it/it-use-releases-003/verify.bsh rename to versions-maven-plugin/src/it/it-use-releases-003/verify.bsh diff --git a/src/it/it-use-releases-issue-583/invoker.properties b/versions-maven-plugin/src/it/it-use-releases-issue-583/invoker.properties similarity index 100% rename from src/it/it-use-releases-issue-583/invoker.properties rename to versions-maven-plugin/src/it/it-use-releases-issue-583/invoker.properties diff --git a/src/it/it-use-releases-issue-583/pom.xml b/versions-maven-plugin/src/it/it-use-releases-issue-583/pom.xml similarity index 100% rename from src/it/it-use-releases-issue-583/pom.xml rename to versions-maven-plugin/src/it/it-use-releases-issue-583/pom.xml diff --git a/src/it/it-use-releases-issue-583/verify.bsh b/versions-maven-plugin/src/it/it-use-releases-issue-583/verify.bsh similarity index 100% rename from src/it/it-use-releases-issue-583/verify.bsh rename to versions-maven-plugin/src/it/it-use-releases-issue-583/verify.bsh diff --git a/src/it/prep-settings.xml b/versions-maven-plugin/src/it/prep-settings.xml similarity index 100% rename from src/it/prep-settings.xml rename to versions-maven-plugin/src/it/prep-settings.xml diff --git a/src/it/settings.xml b/versions-maven-plugin/src/it/settings.xml similarity index 100% rename from src/it/settings.xml rename to versions-maven-plugin/src/it/settings.xml diff --git a/src/it/setup-provide-rules-in-jar/invoker.properties b/versions-maven-plugin/src/it/setup-provide-rules-in-jar/invoker.properties similarity index 100% rename from src/it/setup-provide-rules-in-jar/invoker.properties rename to versions-maven-plugin/src/it/setup-provide-rules-in-jar/invoker.properties diff --git a/src/it/setup-provide-rules-in-jar/pom.xml b/versions-maven-plugin/src/it/setup-provide-rules-in-jar/pom.xml similarity index 100% rename from src/it/setup-provide-rules-in-jar/pom.xml rename to versions-maven-plugin/src/it/setup-provide-rules-in-jar/pom.xml diff --git a/src/it/setup-provide-rules-in-jar/src/main/resources/package/foo/bar/rules.xml b/versions-maven-plugin/src/it/setup-provide-rules-in-jar/src/main/resources/package/foo/bar/rules.xml similarity index 100% rename from src/it/setup-provide-rules-in-jar/src/main/resources/package/foo/bar/rules.xml rename to versions-maven-plugin/src/it/setup-provide-rules-in-jar/src/main/resources/package/foo/bar/rules.xml diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java diff --git a/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/CommitMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/CommitMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/LinkItem.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/LinkItem.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java diff --git a/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java diff --git a/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java diff --git a/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/Property.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/Property.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/Property.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/Property.java diff --git a/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/RevertMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/SetMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java similarity index 97% rename from src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index addeab5dce..b11d51d33a 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -1,160 +1,160 @@ -package org.codehaus.mojo.versions; - -import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.model.Scm; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; - -import static org.apache.commons.lang3.StringUtils.isAllBlank; -import static org.apache.commons.lang3.StringUtils.isBlank; - -/** - * Updates the current project's SCM tag. - * - * @author Anton Johansson - * @since 2.5 - */ -@Mojo( name = "set-scm-tag", aggregator = true, threadSafe = true ) -public class SetScmTagMojo extends AbstractVersionsUpdaterMojo -{ - - /** - * The new SCM tag to set. - * - * @since 2.5 - */ - @Parameter( property = "newTag" ) - private String newTag; - - /** - * The new SCM connection property - * - * @since 2.12.0 - */ - @Parameter( property = "connection" ) - private String connection; - - /** - * The new SCM developerConnection property - * - * @since 2.12.0 - */ - @Parameter( property = "developerConnection" ) - private String developerConnection; - - /** - * The new SCM url property - * - * @since 2.12.0 - */ - @Parameter( property = "url" ) - private String url; - - @Inject - public SetScmTagMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) - { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); - } - - /** - * Called when this mojo is executed. - * - * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. - */ - @Override - public void execute() throws MojoExecutionException, MojoFailureException - { - if ( isAllBlank( newTag, connection, developerConnection, url ) ) - { - throw new MojoFailureException( - "One of: \"newTag\", \"connection\", \"developerConnection\", \"url\" should be provided." ); - } - - super.execute(); - } - - @Override - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException - { - try - { - Scm scm = PomHelper.getRawModel( pom ).getScm(); - if ( scm == null ) - { - throw new MojoFailureException( "No was present" ); - } - - List failures = new ArrayList<>(); - if ( !isBlank( newTag ) ) - { - getLog().info( "Updating tag: " + ( scm != null && scm.getTag() != null - ? scm.getTag() : "(empty)" ) + " -> " + newTag ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "tag", newTag ) ) - { - failures.add( "tag: " + newTag ); - } - } - if ( !isBlank( connection ) ) - { - getLog().info( "Updating connection: " + ( scm != null && scm.getConnection() != null - ? scm.getConnection() : "(empty)" ) + " -> " + connection ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "connection", connection ) ) - { - failures.add( "connection: " + connection ); - } - } - if ( !isBlank( developerConnection ) ) - { - getLog().info( "Updating developerConnection: " - + ( scm != null && scm.getDeveloperConnection() != null - ? scm.getDeveloperConnection() : "(empty)" ) + " -> " - + developerConnection ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "developerConnection", - developerConnection ) ) - { - failures.add( "developerConnection: " + developerConnection ); - } - } - if ( !isBlank( url ) ) - { - getLog().info( "Updating url: " + ( scm != null && scm.getUrl() != null - ? scm.getUrl() : "(empty)" ) + " -> " + url ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "url", url ) ) - { - failures.add( "url: " + url ); - } - } - if ( !failures.isEmpty() ) - { - throw new MojoFailureException( "Could not update one or more SCM elements: " + String.join( ", ", - failures ) + ". Please make sure they are present in the original POM. " ); - } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - } -} +package org.codehaus.mojo.versions; + +import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.model.Scm; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; + +import static org.apache.commons.lang3.StringUtils.isAllBlank; +import static org.apache.commons.lang3.StringUtils.isBlank; + +/** + * Updates the current project's SCM tag. + * + * @author Anton Johansson + * @since 2.5 + */ +@Mojo( name = "set-scm-tag", aggregator = true, threadSafe = true ) +public class SetScmTagMojo extends AbstractVersionsUpdaterMojo +{ + + /** + * The new SCM tag to set. + * + * @since 2.5 + */ + @Parameter( property = "newTag" ) + private String newTag; + + /** + * The new SCM connection property + * + * @since 2.12.0 + */ + @Parameter( property = "connection" ) + private String connection; + + /** + * The new SCM developerConnection property + * + * @since 2.12.0 + */ + @Parameter( property = "developerConnection" ) + private String developerConnection; + + /** + * The new SCM url property + * + * @since 2.12.0 + */ + @Parameter( property = "url" ) + private String url; + + @Inject + public SetScmTagMojo( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + + /** + * Called when this mojo is executed. + * + * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. + * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException + { + if ( isAllBlank( newTag, connection, developerConnection, url ) ) + { + throw new MojoFailureException( + "One of: \"newTag\", \"connection\", \"developerConnection\", \"url\" should be provided." ); + } + + super.execute(); + } + + @Override + protected void update( ModifiedPomXMLEventReader pom ) + throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + { + try + { + Scm scm = PomHelper.getRawModel( pom ).getScm(); + if ( scm == null ) + { + throw new MojoFailureException( "No was present" ); + } + + List failures = new ArrayList<>(); + if ( !isBlank( newTag ) ) + { + getLog().info( "Updating tag: " + ( scm != null && scm.getTag() != null + ? scm.getTag() : "(empty)" ) + " -> " + newTag ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "tag", newTag ) ) + { + failures.add( "tag: " + newTag ); + } + } + if ( !isBlank( connection ) ) + { + getLog().info( "Updating connection: " + ( scm != null && scm.getConnection() != null + ? scm.getConnection() : "(empty)" ) + " -> " + connection ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "connection", connection ) ) + { + failures.add( "connection: " + connection ); + } + } + if ( !isBlank( developerConnection ) ) + { + getLog().info( "Updating developerConnection: " + + ( scm != null && scm.getDeveloperConnection() != null + ? scm.getDeveloperConnection() : "(empty)" ) + " -> " + + developerConnection ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "developerConnection", + developerConnection ) ) + { + failures.add( "developerConnection: " + developerConnection ); + } + } + if ( !isBlank( url ) ) + { + getLog().info( "Updating url: " + ( scm != null && scm.getUrl() != null + ? scm.getUrl() : "(empty)" ) + " -> " + url ); + if ( !PomHelper.setElementValue( pom, "/project/scm", "url", url ) ) + { + failures.add( "url: " + url ); + } + } + if ( !failures.isEmpty() ) + { + throw new MojoFailureException( "Could not update one or more SCM elements: " + String.join( ", ", + failures ) + ". Please make sure they are present in the original POM. " ); + } + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } + } +} diff --git a/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/PomHelper.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/Segment.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/Segment.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/Segment.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java diff --git a/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/VersionChange.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java diff --git a/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java diff --git a/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java diff --git a/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java diff --git a/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java diff --git a/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java diff --git a/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java similarity index 100% rename from src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java rename to versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java diff --git a/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml b/versions-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml similarity index 100% rename from src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml rename to versions-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml diff --git a/src/main/resources/dependency-updates-report.properties b/versions-maven-plugin/src/main/resources/dependency-updates-report.properties similarity index 100% rename from src/main/resources/dependency-updates-report.properties rename to versions-maven-plugin/src/main/resources/dependency-updates-report.properties diff --git a/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd b/versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd similarity index 100% rename from src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd rename to versions-maven-plugin/src/main/resources/org/codehaus/mojo/versions/recording/schema-1.0.xsd diff --git a/src/main/resources/parent-updates-report.properties b/versions-maven-plugin/src/main/resources/parent-updates-report.properties similarity index 100% rename from src/main/resources/parent-updates-report.properties rename to versions-maven-plugin/src/main/resources/parent-updates-report.properties diff --git a/src/main/resources/plugin-updates-report.properties b/versions-maven-plugin/src/main/resources/plugin-updates-report.properties similarity index 100% rename from src/main/resources/plugin-updates-report.properties rename to versions-maven-plugin/src/main/resources/plugin-updates-report.properties diff --git a/src/main/resources/property-updates-report.properties b/versions-maven-plugin/src/main/resources/property-updates-report.properties similarity index 100% rename from src/main/resources/property-updates-report.properties rename to versions-maven-plugin/src/main/resources/property-updates-report.properties diff --git a/src/site/markdown/examples/advancing-dependency-versions.md.vm b/versions-maven-plugin/src/site/markdown/examples/advancing-dependency-versions.md.vm similarity index 100% rename from src/site/markdown/examples/advancing-dependency-versions.md.vm rename to versions-maven-plugin/src/site/markdown/examples/advancing-dependency-versions.md.vm diff --git a/src/site/markdown/examples/compare-dependencies.md b/versions-maven-plugin/src/site/markdown/examples/compare-dependencies.md similarity index 100% rename from src/site/markdown/examples/compare-dependencies.md rename to versions-maven-plugin/src/site/markdown/examples/compare-dependencies.md diff --git a/src/site/markdown/examples/display-dependency-updates.md b/versions-maven-plugin/src/site/markdown/examples/display-dependency-updates.md similarity index 100% rename from src/site/markdown/examples/display-dependency-updates.md rename to versions-maven-plugin/src/site/markdown/examples/display-dependency-updates.md diff --git a/src/site/markdown/examples/display-plugin-updates.md b/versions-maven-plugin/src/site/markdown/examples/display-plugin-updates.md similarity index 100% rename from src/site/markdown/examples/display-plugin-updates.md rename to versions-maven-plugin/src/site/markdown/examples/display-plugin-updates.md diff --git a/src/site/markdown/examples/display-property-updates.md b/versions-maven-plugin/src/site/markdown/examples/display-property-updates.md similarity index 100% rename from src/site/markdown/examples/display-property-updates.md rename to versions-maven-plugin/src/site/markdown/examples/display-property-updates.md diff --git a/src/site/markdown/examples/lock-snapshots.md b/versions-maven-plugin/src/site/markdown/examples/lock-snapshots.md similarity index 100% rename from src/site/markdown/examples/lock-snapshots.md rename to versions-maven-plugin/src/site/markdown/examples/lock-snapshots.md diff --git a/src/site/markdown/examples/recording-changes.md b/versions-maven-plugin/src/site/markdown/examples/recording-changes.md similarity index 100% rename from src/site/markdown/examples/recording-changes.md rename to versions-maven-plugin/src/site/markdown/examples/recording-changes.md diff --git a/src/site/markdown/examples/resolve-ranges.md b/versions-maven-plugin/src/site/markdown/examples/resolve-ranges.md similarity index 100% rename from src/site/markdown/examples/resolve-ranges.md rename to versions-maven-plugin/src/site/markdown/examples/resolve-ranges.md diff --git a/src/site/markdown/examples/set.md b/versions-maven-plugin/src/site/markdown/examples/set.md similarity index 100% rename from src/site/markdown/examples/set.md rename to versions-maven-plugin/src/site/markdown/examples/set.md diff --git a/src/site/markdown/examples/setaggregator.md b/versions-maven-plugin/src/site/markdown/examples/setaggregator.md similarity index 100% rename from src/site/markdown/examples/setaggregator.md rename to versions-maven-plugin/src/site/markdown/examples/setaggregator.md diff --git a/src/site/markdown/examples/unlock-snapshots.md b/versions-maven-plugin/src/site/markdown/examples/unlock-snapshots.md similarity index 100% rename from src/site/markdown/examples/unlock-snapshots.md rename to versions-maven-plugin/src/site/markdown/examples/unlock-snapshots.md diff --git a/src/site/markdown/examples/update-child-modules.md b/versions-maven-plugin/src/site/markdown/examples/update-child-modules.md similarity index 100% rename from src/site/markdown/examples/update-child-modules.md rename to versions-maven-plugin/src/site/markdown/examples/update-child-modules.md diff --git a/src/site/markdown/examples/update-parent.md b/versions-maven-plugin/src/site/markdown/examples/update-parent.md similarity index 100% rename from src/site/markdown/examples/update-parent.md rename to versions-maven-plugin/src/site/markdown/examples/update-parent.md diff --git a/src/site/markdown/examples/update-properties.md.vm b/versions-maven-plugin/src/site/markdown/examples/update-properties.md.vm similarity index 100% rename from src/site/markdown/examples/update-properties.md.vm rename to versions-maven-plugin/src/site/markdown/examples/update-properties.md.vm diff --git a/src/site/markdown/examples/use-releases.md b/versions-maven-plugin/src/site/markdown/examples/use-releases.md similarity index 100% rename from src/site/markdown/examples/use-releases.md rename to versions-maven-plugin/src/site/markdown/examples/use-releases.md diff --git a/src/site/markdown/faq.md b/versions-maven-plugin/src/site/markdown/faq.md similarity index 100% rename from src/site/markdown/faq.md rename to versions-maven-plugin/src/site/markdown/faq.md diff --git a/src/site/markdown/index.md b/versions-maven-plugin/src/site/markdown/index.md similarity index 100% rename from src/site/markdown/index.md rename to versions-maven-plugin/src/site/markdown/index.md diff --git a/src/site/markdown/usage.md.vm b/versions-maven-plugin/src/site/markdown/usage.md.vm similarity index 100% rename from src/site/markdown/usage.md.vm rename to versions-maven-plugin/src/site/markdown/usage.md.vm diff --git a/src/site/markdown/version-rules.md.vm b/versions-maven-plugin/src/site/markdown/version-rules.md.vm similarity index 100% rename from src/site/markdown/version-rules.md.vm rename to versions-maven-plugin/src/site/markdown/version-rules.md.vm diff --git a/versions-maven-plugin/src/site/markdown/xsd/index.md.vm b/versions-maven-plugin/src/site/markdown/xsd/index.md.vm new file mode 100644 index 0000000000..8b3c483ca2 --- /dev/null +++ b/versions-maven-plugin/src/site/markdown/xsd/index.md.vm @@ -0,0 +1,20 @@ +title: XML schemas +author: Slawomir Jaranowski +date: 2022-10-17 + + + +Versions - XML schemas +====================== + +dependency-updates-report.xsd +----------------------------- + - [dependency-updates-report-${modelloNamespaceVersion}.xsd](../../model-report/xsd/dependency-updates-report-${modelloNamespaceVersion}.xsd) + +plugin-updates-report.xsd +------------------------- + - [plugin-updates-report-${modelloNamespaceVersion}.xsd](../../model-report/xsd/plugin-updates-report-${modelloNamespaceVersion}.xsd) + +rule.xsd +-------- + - [rule-${modelloNamespaceVersion}.xsd](../../model/xsd/rule-${modelloNamespaceVersion}.xsd) diff --git a/versions-maven-plugin/src/site/site.xml b/versions-maven-plugin/src/site/site.xml new file mode 100644 index 0000000000..8dbee51232 --- /dev/null +++ b/versions-maven-plugin/src/site/site.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java diff --git a/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/SetMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java diff --git a/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java diff --git a/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java diff --git a/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java similarity index 100% rename from src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java rename to versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java diff --git a/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-dependency-updates/ruleset/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml similarity index 62% rename from src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml index 19213f0c01..a59c116191 100644 --- a/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-dependency-updates/version-interpolation/pom.xml @@ -1,3 +1,22 @@ + + 4.0.0 diff --git a/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-plugin-updates/ruleset/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/aggregate/pom.xml.versionsBackup diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-a/pom.xml.versionsBackup diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup similarity index 100% rename from src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/revert/issue-265/module-b/pom.xml.versionsBackup diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/set-scm-tag/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/versionless-01/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml diff --git a/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/use-dep-version/issue-637/pom.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/api/rules.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/rules.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/api/rules.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/rules.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml diff --git a/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties similarity index 100% rename from src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties rename to versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties From c9c1396f8cbbe8f369d73ceae2f18b30a51f66bd Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 30 Oct 2022 16:56:10 +0100 Subject: [PATCH 196/441] Work on site output --- model-report/pom.xml | 34 +----- {model => model-ruleset}/pom.xml | 40 +------ .../src/main/mdo/rule.mdo | 2 +- model-ruleset/src/site/markdown/xsd/index.md | 12 ++ model-ruleset/src/site/site.xml | 13 +++ pom.xml | 110 +++++++++++++++--- src/site/site.xml | 32 +---- versions-maven-plugin/pom.xml | 14 +-- .../src/site/markdown/version-rules.md.vm | 4 +- .../src/site/markdown/xsd/index.md.vm | 20 ---- versions-maven-plugin/src/site/site.xml | 10 +- 11 files changed, 146 insertions(+), 145 deletions(-) rename {model => model-ruleset}/pom.xml (67%) rename {model => model-ruleset}/src/main/mdo/rule.mdo (98%) create mode 100644 model-ruleset/src/site/markdown/xsd/index.md create mode 100644 model-ruleset/src/site/site.xml delete mode 100644 versions-maven-plugin/src/site/markdown/xsd/index.md.vm diff --git a/model-report/pom.xml b/model-report/pom.xml index a8220b7376..6b7c918785 100644 --- a/model-report/pom.xml +++ b/model-report/pom.xml @@ -11,6 +11,9 @@ model-report + Versions reports model + Modello model for reports + org.codehaus.plexus @@ -60,14 +63,7 @@ src/main/mdo/dependency-updates-report.mdo src/main/mdo/plugin-updates-report.mdo - ${modelloNamespaceVersion} - - - - - maven-javadoc-plugin - - true + ${modelloNamespaceReportVersion} @@ -79,28 +75,8 @@ - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - check-java18 - test - - check - - - - org.codehaus.mojo.signature - java18 - 1.0 - - - - - - \ No newline at end of file +
    diff --git a/model/pom.xml b/model-ruleset/pom.xml similarity index 67% rename from model/pom.xml rename to model-ruleset/pom.xml index 98406b4e19..dcb473b22c 100644 --- a/model/pom.xml +++ b/model-ruleset/pom.xml @@ -9,7 +9,10 @@ 4.0.0 - model + model-ruleset + + Versions ruleSet model + Modello model for ruleSet @@ -31,8 +34,6 @@ xpp3-reader - - xpp3-writer java @@ -59,14 +60,7 @@ src/main/mdo/rule.mdo - ${modelloNamespaceVersion} - - - - - maven-javadoc-plugin - - true + ${modelloNamespaceRuleVersion} @@ -77,29 +71,7 @@ true - - - org.codehaus.mojo - animal-sniffer-maven-plugin - - - check-java18 - test - - check - - - - org.codehaus.mojo.signature - java18 - 1.0 - - - - - - -
    \ No newline at end of file +
    diff --git a/model/src/main/mdo/rule.mdo b/model-ruleset/src/main/mdo/rule.mdo similarity index 98% rename from model/src/main/mdo/rule.mdo rename to model-ruleset/src/main/mdo/rule.mdo index d86917ae49..c4c9c27095 100644 --- a/model/src/main/mdo/rule.mdo +++ b/model-ruleset/src/main/mdo/rule.mdo @@ -22,7 +22,7 @@ under the License. + xml.schemaLocation="https://www.mojohaus.org/versions/model-ruleset/xsd/rule-${version}.xsd"> rule Rule diff --git a/model-ruleset/src/site/markdown/xsd/index.md b/model-ruleset/src/site/markdown/xsd/index.md new file mode 100644 index 0000000000..3df2653a53 --- /dev/null +++ b/model-ruleset/src/site/markdown/xsd/index.md @@ -0,0 +1,12 @@ +title: XML schemas for ruleSet +author: Slawomir Jaranowski +date: 2022-10-17 + + + +Versions - XML schemas for ruleSet +====================== + +- [rule-2.1.0.xsd](rule-2.1.0.xsd) +- [rule-2.0.0.xsd](https://www.mojohaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd) + diff --git a/model-ruleset/src/site/site.xml b/model-ruleset/src/site/site.xml new file mode 100644 index 0000000000..1c0969b142 --- /dev/null +++ b/model-ruleset/src/site/site.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 2fe60a985f..3b9a9f2c85 100644 --- a/pom.xml +++ b/pom.xml @@ -14,12 +14,10 @@ 2.14.0-SNAPSHOT pom - Versions Maven Plugin - https://www.mojohaus.org/versions-maven-plugin/ + Versions + Managing Maven versions in projects. + https://www.mojohaus.org/versions/ - - Versions Plugin for Maven. The Versions Plugin updates the versions of components in the POM. - 2008 @@ -97,23 +95,29 @@ - - ${mavenVersion} - - - - scm:git:https://github.com/mojohaus/versions-maven-plugin.git - scm:git:ssh://git@github.com/mojohaus/versions-maven-plugin.git - https://github.com/mojohaus/versions-maven-plugin/tree/master - 2.13.0 - - versions-maven-plugin - model + model-ruleset model-report + + scm:git:https://github.com/mojohaus/versions.git + scm:git:ssh://git@github.com/mojohaus/versions.git + https://github.com/mojohaus/versions/tree/master + HEAD + + + + GitHub + https://github.com/mojohaus/versions/issues + + + + GitHub + https://github.com/mojohaus/versions/actions + + 1.8 ${mojo.java.target} @@ -124,7 +128,9 @@ 1.11.1 ${project.version} 3.7 - 2.0.0 + 2.1.0 + 2.0.0 + ${project.build.directory}/staging 2022-10-23T15:41:47Z @@ -219,4 +225,72 @@ + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + true + + + + + + org.apache.maven.plugins + maven-jxr-plugin + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + + + + true + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + + + + true + + + + + + org.codehaus.mojo + taglist-maven-plugin + ${taglist-maven-plugin.version} + + + + + + + + + diff --git a/src/site/site.xml b/src/site/site.xml index d9443a64dc..f2f2bbeecb 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -4,34 +4,12 @@ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd"> - - org.apache.maven.skins - maven-fluido-skin - 1.8 - - - - - - mojohaus/versions-maven-plugin - right - gray - - - - - - - - - - -
    - Apache ${project.name}, ${project.name}, Apache, the Apache feather logo, and the Apache ${project.name} project logos are trademarks of The Apache Software Foundation.

    - ]]> -
    + + + + + diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 28483c340d..7469b884e4 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -11,10 +11,13 @@ versions-maven-plugin maven-plugin + Versions Maven Plugin + The Versions Maven Plugin is used when you want to manage the versions of artifacts in a project's POM. + org.codehaus.mojo.versions - model + model-ruleset ${project.version} @@ -204,13 +207,8 @@ - maven-javadoc-plugin - - ${mojo.java.target} - - - - maven-invoker-plugin + org.apache.maven.plugins + maven-plugin-plugin diff --git a/versions-maven-plugin/src/site/markdown/version-rules.md.vm b/versions-maven-plugin/src/site/markdown/version-rules.md.vm index 89c617702e..f564ef959f 100644 --- a/versions-maven-plugin/src/site/markdown/version-rules.md.vm +++ b/versions-maven-plugin/src/site/markdown/version-rules.md.vm @@ -58,7 +58,7 @@ it otherwise. Rules.xml --------- -To specify the version schemes to use, you may define a [rule-set xml file](./model/rule.html), use the `ruleSet` +To specify the version schemes to use, you may define a [rule-set xml file](../model-ruleset/rule.html), use the `ruleSet` element in the `versions-maven-plugin` plugin configuration, or specify ignored versions via the `maven.version.ignore` property. @@ -69,7 +69,7 @@ The `rules.xml` file should conform to the xsd specified in the example below. ```xml + xsi:schemaLocation="https://www.mojohaus.org/VERSIONS/RULE/2.1.0 https://www.mojohaus.org/versions/model-ruleset/xsd/rule-2.1.0.xsd"> diff --git a/versions-maven-plugin/src/site/markdown/xsd/index.md.vm b/versions-maven-plugin/src/site/markdown/xsd/index.md.vm deleted file mode 100644 index 8b3c483ca2..0000000000 --- a/versions-maven-plugin/src/site/markdown/xsd/index.md.vm +++ /dev/null @@ -1,20 +0,0 @@ -title: XML schemas -author: Slawomir Jaranowski -date: 2022-10-17 - - - -Versions - XML schemas -====================== - -dependency-updates-report.xsd ------------------------------ - - [dependency-updates-report-${modelloNamespaceVersion}.xsd](../../model-report/xsd/dependency-updates-report-${modelloNamespaceVersion}.xsd) - -plugin-updates-report.xsd -------------------------- - - [plugin-updates-report-${modelloNamespaceVersion}.xsd](../../model-report/xsd/plugin-updates-report-${modelloNamespaceVersion}.xsd) - -rule.xsd --------- - - [rule-${modelloNamespaceVersion}.xsd](../../model/xsd/rule-${modelloNamespaceVersion}.xsd) diff --git a/versions-maven-plugin/src/site/site.xml b/versions-maven-plugin/src/site/site.xml index 8dbee51232..bdd343679d 100644 --- a/versions-maven-plugin/src/site/site.xml +++ b/versions-maven-plugin/src/site/site.xml @@ -1,10 +1,6 @@ - - - - @@ -32,9 +28,11 @@ - - + + + + From 715f0a98f574d5cdcf7cf3c2811ac105c3af48d4 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 31 Oct 2022 07:38:53 +0100 Subject: [PATCH 197/441] Resolves #359: XML Property Updates Report --- .github/workflows/maven.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4a11acbbd5..6f2a086b8f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,6 +27,13 @@ jobs: ff-maven: "3.8.6" # Maven version for fail-fast-build maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds + install: + name: Install + run: mvn -DskipTests install + with: + ff-maven: "3.8.6" # Maven version for fail-fast-build + maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds + deploy: name: Deploy needs: build From 4c0d8af6c38c0980b52bd96884d1ede1f5ae2584 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 31 Oct 2022 07:46:03 +0100 Subject: [PATCH 198/441] Resolves #359: XML Property Updates Report --- .github/workflows/maven.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6f2a086b8f..934c8d3c68 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,10 +29,9 @@ jobs: install: name: Install - run: mvn -DskipTests install - with: - ff-maven: "3.8.6" # Maven version for fail-fast-build - maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds + steps: + name: Install + run: mvn -DskipTests install deploy: name: Deploy From 5fb0d40da03a62399a06bcbd6d03b8dc5941b952 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 31 Oct 2022 07:46:55 +0100 Subject: [PATCH 199/441] Resolves #359: XML Property Updates Report --- .github/workflows/maven.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 934c8d3c68..4a11acbbd5 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -27,12 +27,6 @@ jobs: ff-maven: "3.8.6" # Maven version for fail-fast-build maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds - install: - name: Install - steps: - name: Install - run: mvn -DskipTests install - deploy: name: Deploy needs: build From 780cf6e1a42057273c568cc1c7cd9d743fdb5084 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 31 Oct 2022 09:04:05 +0100 Subject: [PATCH 200/441] Use install during first build --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4a11acbbd5..8e9fa94060 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,6 +24,7 @@ jobs: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 with: + ff-goal: '-P run-its install' ff-maven: "3.8.6" # Maven version for fail-fast-build maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds From 8c13de22cae85419588adbcd4f532d0fa2b0dec2 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 26 Oct 2022 18:38:07 +0200 Subject: [PATCH 201/441] Resolves #794: Do not change versions where oldVersion does not match the POM version --- .../org/codehaus/mojo/versions/SetMojo.java | 52 +++++------ .../codehaus/mojo/versions/SetMojoTest.java | 91 +++++++++++++------ .../org/codehaus/mojo/set/issue-794/pom.xml | 7 ++ 3 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-794/pom.xml diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 0305a2968c..fef10ea975 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -33,6 +33,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.SortedMap; import java.util.TimeZone; @@ -336,15 +337,9 @@ public void execute() throws MojoExecutionException, MojoFailureException try { - final MavenProject project; - if ( processFromLocalAggregationRoot ) - { - project = PomHelper.getLocalRoot( projectBuilder, getProject(), localRepository, null, getLog() ); - } - else - { - project = getProject(); - } + final MavenProject project = processFromLocalAggregationRoot + ? PomHelper.getLocalRoot( projectBuilder, getProject(), localRepository, null, getLog() ) + : getProject(); getLog().info( "Local aggregation root: " + project.getBasedir() ); Map reactorModels = PomHelper.getReactorModels( project, getLog() ); @@ -363,7 +358,7 @@ public void execute() throws MojoExecutionException, MojoFailureException Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); Pattern oldVersionIdRegex = Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); - boolean found = false; + for ( Model m : reactor.values() ) { final String mGroupId = PomHelper.getGroupId( m ); @@ -375,16 +370,20 @@ public void execute() throws MojoExecutionException, MojoFailureException && oldVersionIdRegex.matcher( mVersion ).matches() && !newVersion.equals( mVersion ) ) { - found = true; - // if the change is not one we have swept up already applyChange( project, reactor, files, mGroupId, m.getArtifactId(), StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : mVersion ); } } - if ( !found && RegexUtils.getWildcardScore( groupId ) == 0 && RegexUtils.getWildcardScore( artifactId ) == 0 - && RegexUtils.getWildcardScore( oldVersion ) == 0 ) + + if ( "always".equals( updateBuildOutputTimestampPolicy ) ) { - applyChange( project, reactor, files, groupId, artifactId, oldVersion ); + reactor.values().parallelStream() + .map( m -> PomHelper.getModelEntry( reactor, PomHelper.getGroupId( m ), + PomHelper.getArtifactId( m ) ) ) + .filter( Objects::nonNull ) + .map( Map.Entry::getKey ) + .map( f -> getModuleProjectFile( project, f ) ) + .forEach( files::add ); } // now process all the updates @@ -453,7 +452,7 @@ private void applyChange( MavenProject project, SortedMap reactor if ( current != null ) { current.getValue().setVersion( newVersion ); - addFile( files, project, current.getKey() ); + files.add( getModuleProjectFile( project, current.getKey() ) ); } for ( Map.Entry sourceEntry : reactor.entrySet() ) @@ -483,7 +482,7 @@ private void applyChange( MavenProject project, SortedMap reactor continue; } - addFile( files, project, sourcePath ); + files.add( getModuleProjectFile( project, sourcePath ) ); getLog().debug( "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) @@ -540,29 +539,22 @@ private void applyChange( MavenProject project, SortedMap reactor } } - private void addFile( Set files, MavenProject project, String relativePath ) + private static File getModuleProjectFile( MavenProject project, String relativePath ) { final File moduleDir = new File( project.getBasedir(), relativePath ); final File projectBaseDir = project.getBasedir(); - final File moduleProjectFile; - if ( projectBaseDir.equals( moduleDir ) ) { - moduleProjectFile = project.getFile(); + return project.getFile(); } else if ( moduleDir.isDirectory() ) { - moduleProjectFile = new File( moduleDir, "pom.xml" ); - } - else - { - // i don't think this should ever happen... but just in case - // the module references the file-name - moduleProjectFile = moduleDir; + return new File( moduleDir, "pom.xml" ); } - - files.add( moduleProjectFile ); + // i don't think this should ever happen... but just in case + // the module references the file-name + return moduleDir; } /** diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index 162679afd5..bce9eaa048 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -1,11 +1,10 @@ package org.codehaus.mojo.versions; import java.io.File; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Objects; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.model.Model; @@ -14,6 +13,9 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.utils.TestUtils; +import org.junit.After; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -21,12 +23,28 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; public class SetMojoTest extends AbstractMojoTestCase { @Rule public MojoRule mojoRule = new MojoRule( this ); + private Path tempDir; + + @Before + public void setUp() throws Exception + { + super.setUp(); + tempDir = TestUtils.createTempDir( "set" ); + } + + @After + public void tearDown() throws IOException + { + TestUtils.tearDownTempDir( tempDir ); + } + @Test public void testGetIncrementedVersion() throws MojoExecutionException { @@ -118,33 +136,46 @@ public void testVersionlessDependency() throws Exception public void testRemoveSnapshotIdempotency() throws Exception { - Path pomDir = Files.createTempDirectory( "set-" ); - try - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - - SetMojo firstRun = (SetMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set" ); - firstRun.execute(); - assertThat( String.join( "", Files.readAllLines( Paths.get( pomDir.toString(), "pom.xml" ) ) ), - containsString( "1.0" ) ); - - // no exception should be thrown, the file should stay with version "1.0" - SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set" ); - MavenExecutionRequest request = - (MavenExecutionRequest) getVariableValueFromObject( secondRun.settings, "request" ); - setVariableValueToObject( request, "interactiveMode", false ); - secondRun.execute(); - assertThat( String.join( "", Files.readAllLines( Paths.get( pomDir.toString(), "pom.xml" ) ) ), - containsString( "1.0" ) ); - } - finally - { - if ( pomDir != null && pomDir.toFile().exists() ) - { - Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); - pomDir.toFile().delete(); - } - } + Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml" ), + Paths.get( tempDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + + SetMojo firstRun = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); + firstRun.execute(); + assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), + containsString( "1.0" ) ); + + // no exception should be thrown, the file should stay with version "1.0" + SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); + MavenExecutionRequest request = + (MavenExecutionRequest) getVariableValueFromObject( secondRun.settings, "request" ); + setVariableValueToObject( request, "interactiveMode", false ); + secondRun.execute(); + assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), + containsString( "1.0" ) ); + } + + @Test + public void testSetOldVersionMismatch() throws Exception + { + TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set/issue-794" ), tempDir ); + SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); + setVariableValueToObject( mojo, "oldVersion", "foo" ); + setVariableValueToObject( mojo, "newVersion", "bar" ); + mojo.execute(); + assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), + not( containsString( "bar" ) ) ); + } + + @Test + public void testSetOldVersionMismatchProcessAllModules() throws Exception + { + TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set/issue-794" ), tempDir ); + SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); + setVariableValueToObject( mojo, "oldVersion", "foo" ); + setVariableValueToObject( mojo, "newVersion", "bar" ); + setVariableValueToObject( mojo, "processAllModules", true ); + mojo.execute(); + assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), + not( containsString( "bar" ) ) ); } } diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-794/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-794/pom.xml new file mode 100644 index 0000000000..77f1540e8a --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/set/issue-794/pom.xml @@ -0,0 +1,7 @@ + + 4.0.0 + default-group + default-artifact + 1.0.0 + pom + \ No newline at end of file From 96deb8e6f2d9b6498bfe58520ed1c3b74fa4e05b Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Wed, 2 Nov 2022 20:08:07 +0100 Subject: [PATCH 202/441] Resolves #505: getReactorModels using correct module paths when the module name includes pom.xml --- .../it/it-set-issue-505/invoker.properties | 2 + .../it-set-issue-505/moduleA/moduleB/pom.xml | 13 ++ .../src/it/it-set-issue-505/moduleA/pom.xml | 18 +++ .../src/it/it-set-issue-505/pom.xml | 13 ++ .../src/it/it-set-issue-505/verify.groovy | 3 + .../codehaus/mojo/versions/api/PomHelper.java | 139 ++++-------------- .../mojo/versions/api/PomHelperTest.java | 28 +++- .../api/issue-505/moduleA/moduleA.xml | 18 +++ .../api/issue-505/moduleA/moduleB/pom.xml | 13 ++ .../mojo/versions/api/issue-505/pom.xml | 27 ++++ 10 files changed, 156 insertions(+), 118 deletions(-) create mode 100644 versions-maven-plugin/src/it/it-set-issue-505/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-set-issue-505/moduleA/moduleB/pom.xml create mode 100644 versions-maven-plugin/src/it/it-set-issue-505/moduleA/pom.xml create mode 100644 versions-maven-plugin/src/it/it-set-issue-505/pom.xml create mode 100644 versions-maven-plugin/src/it/it-set-issue-505/verify.groovy create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml diff --git a/versions-maven-plugin/src/it/it-set-issue-505/invoker.properties b/versions-maven-plugin/src/it/it-set-issue-505/invoker.properties new file mode 100644 index 0000000000..f21410e6a3 --- /dev/null +++ b/versions-maven-plugin/src/it/it-set-issue-505/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:set +invoker.mavenOpts = -DnewVersion=TEST diff --git a/versions-maven-plugin/src/it/it-set-issue-505/moduleA/moduleB/pom.xml b/versions-maven-plugin/src/it/it-set-issue-505/moduleA/moduleB/pom.xml new file mode 100644 index 0000000000..92023f8d5f --- /dev/null +++ b/versions-maven-plugin/src/it/it-set-issue-505/moduleA/moduleB/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + + + default-group + moduleA + 1.0-SNAPSHOT + + + moduleB + + diff --git a/versions-maven-plugin/src/it/it-set-issue-505/moduleA/pom.xml b/versions-maven-plugin/src/it/it-set-issue-505/moduleA/pom.xml new file mode 100644 index 0000000000..123b5c733c --- /dev/null +++ b/versions-maven-plugin/src/it/it-set-issue-505/moduleA/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + + default-group + default-artifact + 1.0-SNAPSHOT + + + moduleA + pom + + + moduleB/pom.xml + + + diff --git a/versions-maven-plugin/src/it/it-set-issue-505/pom.xml b/versions-maven-plugin/src/it/it-set-issue-505/pom.xml new file mode 100644 index 0000000000..c2a9983323 --- /dev/null +++ b/versions-maven-plugin/src/it/it-set-issue-505/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + default-group + default-artifact + 1.0-SNAPSHOT + pom + + + moduleA/pom.xml + + + diff --git a/versions-maven-plugin/src/it/it-set-issue-505/verify.groovy b/versions-maven-plugin/src/it/it-set-issue-505/verify.groovy new file mode 100644 index 0000000000..4ebd952101 --- /dev/null +++ b/versions-maven-plugin/src/it/it-set-issue-505/verify.groovy @@ -0,0 +1,3 @@ +assert new File( basedir, "pom.xml" ).text.contains( 'TEST' ) +assert new File( basedir, "moduleA/pom.xml" ).text.contains( 'TEST' ) +assert new File( basedir, "moduleA/moduleB/pom.xml" ).text.contains( 'TEST' ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 557f0eac0c..bf9b8e9591 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -46,7 +46,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -500,67 +499,6 @@ public static boolean setProjectParentVersion( final ModifiedPomXMLEventReader p return madeReplacement; } - /** - * Gets the parent artifact from the pom. - * - * @param pom The pom. - * @param helper The helper (used to create the artifact). - * @return The parent artifact or null if no parent is specified. - * @throws XMLStreamException if something went wrong. - */ - public static Artifact getProjectParent( final ModifiedPomXMLEventReader pom, VersionsHelper helper ) - throws XMLStreamException - { - Stack stack = new Stack<>(); - String path = ""; - final Pattern matchScopeRegex = Pattern.compile( "/project/parent((/groupId)|(/artifactId)|(/version))" ); - String groupId = null; - String artifactId = null; - String version = null; - - pom.rewind(); - - while ( pom.hasNext() ) - { - XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); - final String elementName = event.asStartElement().getName().getLocalPart(); - path = path + "/" + elementName; - - if ( matchScopeRegex.matcher( path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { - groupId = pom.getElementText().trim(); - path = stack.pop(); - } - else if ( "artifactId".equals( elementName ) ) - { - artifactId = pom.getElementText().trim(); - path = stack.pop(); - } - else if ( "version".equals( elementName ) ) - { - version = pom.getElementText().trim(); - path = stack.pop(); - } - } - } - if ( event.isEndElement() ) - { - path = stack.pop(); - } - } - if ( groupId == null || artifactId == null || version == null ) - { - return null; - } - return helper.createDependencyArtifact( groupId, artifactId, version, "pom", - null, null ); - } - /** * Searches the pom re-defining the specified dependency to the specified version. * @@ -1432,18 +1370,6 @@ public static void debugModules( Log logger, String message, Collection } } - /** - * Modifies the collection of child modules removing those which cannot be found relative to the parent. - * - * @param logger The logger to log to. - * @param project the project. - * @param childModules the child modules. - */ - public static void removeMissingChildModules( Log logger, MavenProject project, Collection childModules ) - { - removeMissingChildModules( logger, project.getBasedir(), childModules ); - } - /** * Modifies the collection of child modules removing those which cannot be found relative to the parent. * @@ -1619,51 +1545,42 @@ public static Map getReactorModels( MavenProject project, Log log private static Map getReactorModels( String path, Model model, MavenProject project, Log logger ) throws IOException { - if ( path.length() > 0 && !path.endsWith( "/" ) ) - { - path += '/'; - } Map result = new LinkedHashMap<>(); Map childResults = new LinkedHashMap<>(); - - File baseDir = path.length() > 0 ? new File( project.getBasedir(), path ) : project.getBasedir(); - Set childModules = getAllChildModules( model, logger ); + File baseDir = path.length() > 0 + ? new File( project.getBasedir(), path ) + : project.getBasedir(); removeMissingChildModules( logger, baseDir, childModules ); - for ( String moduleName : childModules ) - { - String modulePath = path + moduleName; - - File moduleDir = new File( baseDir, moduleName ); - - File moduleProjectFile; + childModules.stream() + .map( moduleName -> new File( baseDir, moduleName ) ) + .filter( File::exists ) + .forEach( moduleFile -> + { + File pomFile = moduleFile.isDirectory() + ? new File( moduleFile, "/pom.xml" ) + : moduleFile; + String modulePath = ( !path.isEmpty() && !path.endsWith( "/" ) + ? path + "/" + : path ) + + pomFile.getParentFile().getName(); - if ( moduleDir.isDirectory() ) - { - moduleProjectFile = new File( moduleDir, "pom.xml" ); - } - else - { - // i don't think this should ever happen... but just in case - // the module references the file-name - moduleProjectFile = moduleDir; - } + try + { + // the aim of this goal is to fix problems when the project cannot be parsed by Maven, + // so we have to work with the raw model and not the interpolated parsed model from maven + Model moduleModel = getRawModel( pomFile ); + result.put( modulePath, moduleModel ); + childResults.putAll( getReactorModels( modulePath, moduleModel, project, logger ) ); + } + catch ( IOException e ) + { + logger.debug( "Could not parse " + pomFile.getPath(), e ); + } + } ); - try - { - // the aim of this goal is to fix problems when the project cannot be parsed by Maven - // so we have to work with the raw model and not the interpolated parsed model from maven - Model moduleModel = getRawModel( moduleProjectFile ); - result.put( modulePath, moduleModel ); - childResults.putAll( getReactorModels( modulePath, moduleModel, project, logger ) ); - } - catch ( IOException e ) - { - logger.debug( "Could not parse " + moduleProjectFile.getPath(), e ); - } - } result.putAll( childResults ); // more efficient update order if all children are added after siblings return result; } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index e447355b39..9e472005f3 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -7,34 +7,39 @@ import java.io.StringReader; import java.net.URL; import java.util.List; +import java.util.Map; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.MojoRule; +import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.stax2.XMLInputFactory2; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; import static org.codehaus.mojo.versions.utils.ModifiedPomXMLEventReaderUtils.matches; import static org.codehaus.stax2.XMLInputFactory2.P_PRESERVE_LOCATION; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; /** * Tests the methods of {@link PomHelper}. */ -public class PomHelperTest +public class PomHelperTest extends AbstractMojoTestCase { + @Rule + public MojoRule mojoRule = new MojoRule( this ); + private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory2.newInstance(); @BeforeClass - public static void setUp() + public static void setUpClass() { INPUT_FACTORY.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); } @@ -265,4 +270,13 @@ public void testSetProjectValueNewValueNonEmptyParent() throws XMLStreamExceptio assertThat( xmlEventReader, matches( "value" ) ); } + + @Test + public void testIssue505ChildModules() throws Exception + { + MavenProject project = mojoRule.readMavenProject( + new File( "src/test/resources/org/codehaus/mojo/versions/api/issue-505" ) ); + Map reactorModels = PomHelper.getReactorModels( project, new SystemStreamLog() ); + assertThat( reactorModels.keySet(), hasSize( 3 ) ); + } } diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml new file mode 100644 index 0000000000..123b5c733c --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + + default-group + default-artifact + 1.0-SNAPSHOT + + + moduleA + pom + + + moduleB/pom.xml + + + diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml new file mode 100644 index 0000000000..92023f8d5f --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml @@ -0,0 +1,13 @@ + + 4.0.0 + + + default-group + moduleA + 1.0-SNAPSHOT + + + moduleB + + diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml new file mode 100644 index 0000000000..4cb7712ea5 --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + default-group + default-artifact + 1.0-SNAPSHOT + pom + + + moduleA/moduleA.xml + + + + + + org.codehaus.mojo + versions-maven-plugin + + set + + + TEST + + + + + From e07ec6851aafb10c6c7e18b1618e05efb4e08613 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 28 Oct 2022 15:34:34 +0200 Subject: [PATCH 203/441] Resolves #359: XML Property Updates Report --- model-report/pom.xml | 1 + .../main/mdo/dependency-updates-report.mdo | 1 - .../src/main/mdo/plugin-updates-report.mdo | 1 - .../src/main/mdo/property-updates-report.mdo | 171 ++++++++++++++++++ .../invoker.properties | 2 + .../pom.xml | 45 +++++ .../verify.groovy | 13 ++ .../versions/DependencyUpdatesReportMojo.java | 3 +- .../versions/PropertyUpdatesReportMojo.java | 40 +++- .../versions/reporting/OverviewStats.java | 7 +- .../reporting/PluginOverviewStats.java | 5 +- .../PropertyUpdatesReportRenderer.java | 26 +-- .../xml/CommonXmlReportRendererUtils.java | 59 ++++++ .../DependencyUpdatesXmlReportRenderer.java | 23 +-- .../xml/PluginUpdatesXmlReportRenderer.java | 24 +-- .../xml/PropertyUpdatesXmlReportRenderer.java | 134 ++++++++++++++ .../PropertyUpdatesReportMojoTest.java | 2 +- 17 files changed, 479 insertions(+), 78 deletions(-) create mode 100644 model-report/src/main/mdo/property-updates-report.mdo create mode 100644 versions-maven-plugin/src/it/it-xml-property-updates-report-001/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-xml-property-updates-report-001/pom.xml create mode 100644 versions-maven-plugin/src/it/it-xml-property-updates-report-001/verify.groovy create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java diff --git a/model-report/pom.xml b/model-report/pom.xml index 6b7c918785..cb4f5a59a1 100644 --- a/model-report/pom.xml +++ b/model-report/pom.xml @@ -62,6 +62,7 @@ src/main/mdo/dependency-updates-report.mdo src/main/mdo/plugin-updates-report.mdo + src/main/mdo/property-updates-report.mdo ${modelloNamespaceReportVersion} diff --git a/model-report/src/main/mdo/dependency-updates-report.mdo b/model-report/src/main/mdo/dependency-updates-report.mdo index c8f41b2d8d..ea30dcaceb 100644 --- a/model-report/src/main/mdo/dependency-updates-report.mdo +++ b/model-report/src/main/mdo/dependency-updates-report.mdo @@ -85,7 +85,6 @@ under the License. nextIncrementalAvailable - 1.0.0+ true String diff --git a/model-report/src/main/mdo/plugin-updates-report.mdo b/model-report/src/main/mdo/plugin-updates-report.mdo index 685d75e3d0..f311d2edcf 100644 --- a/model-report/src/main/mdo/plugin-updates-report.mdo +++ b/model-report/src/main/mdo/plugin-updates-report.mdo @@ -85,7 +85,6 @@ under the License. nextIncrementalAvailable - 1.0.0+ true String diff --git a/model-report/src/main/mdo/property-updates-report.mdo b/model-report/src/main/mdo/property-updates-report.mdo new file mode 100644 index 0000000000..0f9a2df326 --- /dev/null +++ b/model-report/src/main/mdo/property-updates-report.mdo @@ -0,0 +1,171 @@ + + + + + + property-updates-report + PropertyUpdatesReport + + XML version of the Property Updates Report + + + + + package + org.codehaus.mojo.versions.reporting.model + + + + + namespace + + + + + + PropertyUpdatesReport + + + summary + true + + PropertyReportSummary + 1 + + + + properties + + PropertyInfo + * + + + + + + + PropertyReportSummary + + + usingLastVersion + true + String + + + nextVersionAvailable + true + String + + + nextIncrementalAvailable + true + String + + + nextMinorAvailable + true + String + + + nextMajorAvailable + true + String + + + + + + PropertyInfo + + + propertyName + true + String + + + propertyAssociations + + PropertyAssociation + * + + + + currentVersion + String + + + lastVersion + String + + + any + + String + * + + + + incrementals + + String + * + + + + minors + + String + * + + + + majors + + String + * + + + + status + true + String + + + + + + PropertyAssociation + + + groupId + String + + + artifactId + String + + + + + + diff --git a/versions-maven-plugin/src/it/it-xml-property-updates-report-001/invoker.properties b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/invoker.properties new file mode 100644 index 0000000000..fdf91e0dd6 --- /dev/null +++ b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:property-updates-report +invoker.mavenOpts = -DpropertyUpdatesReportFormats=xml diff --git a/versions-maven-plugin/src/it/it-xml-property-updates-report-001/pom.xml b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/pom.xml new file mode 100644 index 0000000000..ebba6d39b1 --- /dev/null +++ b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + localhost + it-xml-property-updates-report-001 + 1.0 + + + 1.0 + 2.0 + 3.0 + + + + + localhost + dummy-api + [${api-version},2.1-!) + + + localhost + dummy-impl + ${impl-version} + + + + + + + localhost + dummy-maven-plugin + ${plugin-version} + + + localhost + dummy-api + ${plugin-version} + + + + + + + diff --git a/versions-maven-plugin/src/it/it-xml-property-updates-report-001/verify.groovy b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/verify.groovy new file mode 100644 index 0000000000..dcaae22494 --- /dev/null +++ b/versions-maven-plugin/src/it/it-xml-property-updates-report-001/verify.groovy @@ -0,0 +1,13 @@ +def pom = new XmlSlurper() + .parse( new File( basedir, 'target/property-updates-report.xml' ) ) + +assert pom.summary.usingLastVersion == 1 +assert pom.summary.nextIncrementalAvailable == 1 +assert pom.summary.nextMinorAvailable == 1 + +assert pom.properties.property.find { node -> node.propertyName == 'api-version' } + .status == 'incremental available' +assert pom.properties.property.find { node -> node.propertyName == 'impl-version' } + .status == 'minor available' +assert pom.properties.property.find { node -> node.propertyName == 'plugin-version' } + .status == 'no new available' diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index f7c1a30c99..69c5a66e67 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -224,10 +224,9 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! .collect( Collectors.joining( ", " ) ) ) ); } + DependencyUpdatesModel model = new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); for ( String format : formats ) { - DependencyUpdatesModel model = - new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); if ( "html".equals( format ) ) { rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 60f758678c..480949fefd 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -21,6 +21,10 @@ import javax.inject.Inject; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Locale; import java.util.Map; import java.util.TreeMap; @@ -40,6 +44,7 @@ import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; import org.codehaus.mojo.versions.utils.PropertyComparator; +import org.codehaus.mojo.versions.xml.PropertyUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; /** @@ -93,6 +98,14 @@ public class PropertyUpdatesReportMojo extends AbstractVersionsReport subclass of {@linkplain ArtifactVersions} * @return instance of the {@linkplain OverviewStats} */ - public static T fromUpdates( Collection updates, - ArtifactVersionsCache cache ) + public static + T fromUpdates( Collection updates, ArtifactVersionsCache cache ) { OverviewStats stats = new OverviewStats(); updates.forEach( details -> @@ -93,7 +94,7 @@ else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) return (T) stats; } - protected static ArtifactVersion getNewestUpdate( ArtifactVersionsCache cache, + protected static ArtifactVersion getNewestUpdate( ArtifactVersionsCache cache, V details, Optional segment ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 2d215b75cf..81dea82dd6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -22,6 +22,7 @@ import java.util.Optional; import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; @@ -60,8 +61,8 @@ public void incrementDependencies() * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information */ - public static T fromUpdates( Collection updates, - ArtifactVersionsCache cache ) + public static + T fromUpdates( Collection updates, ArtifactVersionsCache cache ) { PluginOverviewStats stats = new PluginOverviewStats(); updates.forEach( details -> diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index ddb7287e82..1ca1730906 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -396,31 +396,7 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) @Override protected OverviewStats computeOverviewStats() { - OverviewStats stats = new OverviewStats(); - model.getAllUpdates().values().forEach( details -> - { - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - stats.incrementAny(); - } - else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - stats.incrementIncremental(); - } - else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { - stats.incrementMinor(); - } - else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - stats.incrementMajor(); - } - else - { - stats.incrementUpToDate(); - } - } ); - return stats; + return OverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); } private void renderPropertyDetail( Property property, PropertyVersions details ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java new file mode 100644 index 0000000000..e828d3d785 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java @@ -0,0 +1,59 @@ +package org.codehaus.mojo.versions.xml; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.codehaus.mojo.versions.api.AbstractVersionDetails; +import org.codehaus.mojo.versions.api.Segment; + +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; + +/** + * Common utils for Xml report renderers + */ +class CommonXmlReportRendererUtils +{ + static void setSection( AbstractVersionDetails versions, Segment segment, Consumer> setterFunction ) + { + ofNullable( versions.getAllUpdates( of( segment ) ) ) + .map( v -> Arrays.stream( v ) + .map( ArtifactVersion::toString ) + .collect( Collectors.toList() ) ) + .ifPresent( setterFunction ); + } + + static String statusFor( String lastVersion, Collection incrementals, Collection minors ) + { + return lastVersion == null + ? "no new available" + : incrementals != null && !incrementals.isEmpty() + ? "incremental available" + : minors != null && !minors.isEmpty() + ? "minor available" + : "major available"; + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java index dee099f597..d360a92ab1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java @@ -24,10 +24,8 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.function.Consumer; import java.util.stream.Collectors; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -36,7 +34,6 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.api.ReportRenderer; -import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.reporting.OverviewStats; import org.codehaus.mojo.versions.reporting.model.DependencyInfo; import org.codehaus.mojo.versions.reporting.model.DependencyReportSummary; @@ -45,11 +42,12 @@ import org.codehaus.mojo.versions.reporting.model.io.xpp3.DependencyUpdatesReportXpp3Writer; import static java.util.Optional.empty; -import static java.util.Optional.of; import static java.util.Optional.ofNullable; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; import static org.codehaus.mojo.versions.api.Segment.MAJOR; import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.xml.CommonXmlReportRendererUtils.setSection; +import static org.codehaus.mojo.versions.xml.CommonXmlReportRendererUtils.statusFor; /** * XML renderer for DependencyUpdatesReport creates an xml file in target directory and writes report about available @@ -106,15 +104,6 @@ public void render() } } - private static void setSection( ArtifactVersions versions, Segment segment, Consumer> setterFunction ) - { - ofNullable( versions.getAllUpdates( of( segment ) ) ) - .map( v -> Arrays.stream( v ) - .map( ArtifactVersion::toString ) - .collect( Collectors.toList() ) ) - .ifPresent( setterFunction ); - } - private static List createDependencyInfo( Map versions ) { return versions.entrySet().stream().map( e -> @@ -134,13 +123,7 @@ private static List createDependencyInfo( Map> setterFunction ) - { - ofNullable( versions.getAllUpdates( of( segment ) ) ) - .map( v -> Arrays.stream( v ) - .map( ArtifactVersion::toString ) - .collect( Collectors.toList() ) ) - .ifPresent( setterFunction ); - } - private static List createPluginInfo( Map versions ) { return versions.entrySet().stream().map( e -> @@ -136,13 +124,7 @@ private static List createPluginInfo( Map createPropertyInfo( Map versions ) + { + return versions.entrySet().stream().map( e -> + new PropertyInfo() + {{ + setPropertyName( e.getKey().getName() ); + if ( e.getValue().getAssociations() != null + && e.getValue().getAssociations().length != 0 ) + { + setPropertyAssociations( Arrays.stream( e.getValue().getAssociations() ) + .map( a -> + { + PropertyAssociation pa = new PropertyAssociation(); + pa.setGroupId( a.getGroupId() ); + pa.setArtifactId( a.getArtifactId() ); + return pa; + } ).collect( Collectors.toList() ) ); + } + setCurrentVersion( e.getKey().getVersion() ); + ofNullable( e.getValue().getNewestUpdate( empty() ) ) + .map( ArtifactVersion::toString ).ifPresent( this::setLastVersion ); + + setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); + setSection( e.getValue(), MINOR, this::setMinors ); + setSection( e.getValue(), MAJOR, this::setMajors ); + + setStatus( statusFor( getLastVersion(), getIncrementals(), getMinors() ) ); + }} ).collect( Collectors.toList() ); + } +} diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java index 4d498592d4..f0adb37f64 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java @@ -74,7 +74,7 @@ public void testIncludeParentTrueShouldContainProperty() throws Exception } @Test - public void testIncludeParentFalseShouldNotCountainProperty() throws Exception + public void testIncludeParentFalseShouldNotContainProperty() throws Exception { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); From 6a950e255d977af48327911e900bf1fea333f33b Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 4 Nov 2022 16:19:54 +0100 Subject: [PATCH 204/441] Resolves #807 - Abstracting a common base for UseLatestVersionsMojo and UseLatestReleasesMojo. - Elaborating on the difference between a "release" and a "version" --- ...AbstractVersionsDependencyUpdaterMojo.java | 1 - .../mojo/versions/UseLatestReleasesMojo.java | 132 ++++++---------- .../mojo/versions/UseLatestVersionsMojo.java | 93 +++-------- .../versions/UseLatestVersionsMojoBase.java | 147 ++++++++++++++++++ .../versions/api/AbstractVersionDetails.java | 26 ++++ .../mojo/versions/api/VersionDetails.java | 17 ++ .../src/site/markdown/index.md | 3 +- .../versions/UseLatestVersionsMojoTest.java | 55 +++++++ 8 files changed, 308 insertions(+), 166 deletions(-) create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 89fa4fc2dd..571fbdc015 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -507,5 +507,4 @@ private int findFirstChar( final String includeString, final String chars ) } return nextRangeStartDelimiterIndex; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index d0464d1f40..8c248d1222 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -22,11 +22,9 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; -import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; -import java.util.List; import java.util.Optional; -import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; @@ -37,7 +35,6 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -46,8 +43,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -55,16 +50,20 @@ import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; +import static java.util.Optional.empty; /** - * Replaces any release versions with the latest release version. + * Replaces any release versions (i.e. versions that are not snapshots and do not + * have a year-month-day suffix) with the latest release version. This goal + * will not replace versions of dependencies which use snapshots + * or versions with a year-month-day suffix. * * @author Stephen Connolly * @since 1.0-alpha-3 */ @Mojo( name = "use-latest-releases", threadSafe = true ) public class UseLatestReleasesMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { // ------------------------------ FIELDS ------------------------------ @@ -80,7 +79,7 @@ public class UseLatestReleasesMojo * @since 1.2 */ @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) - protected boolean allowMajorUpdates; + protected boolean allowMajorUpdates = true; /** *

    Whether to allow the minor version number to be changed.

    @@ -90,7 +89,7 @@ public class UseLatestReleasesMojo * @since 1.2 */ @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) - protected boolean allowMinorUpdates; + protected boolean allowMinorUpdates = true; /** *

    Whether to allow the incremental version number to be changed.

    @@ -101,7 +100,7 @@ public class UseLatestReleasesMojo * @since 1.2 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) - protected boolean allowIncrementalUpdates; + protected boolean allowIncrementalUpdates = true; // ------------------------------ METHODS -------------------------- @@ -151,94 +150,51 @@ protected void update( ModifiedPomXMLEventReader pom ) } } + @SuppressWarnings( "unchecked" ) private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); - if ( !versionMatcher.matches() ) - { - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - ArtifactVersion selectedVersion = new DefaultArtifactVersion( version ); - getLog().debug( "Selected version: " + selectedVersion ); - - getLog().debug( "Looking for newer versions of " + toString( dep ) ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - try + useLatestVersions( pom, dependencies, + ( dep, versions ) -> { - // TODO consider creating a search + filter in the Details services to get latest release. - ArtifactVersion[] newer = versions.getNewerVersions( version, unchangedSegment, false, false ); - ArtifactVersion[] filteredVersions = filterVersionsWithIncludes( newer, artifact ); - if ( filteredVersions.length > 0 ) + try { - String newVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) - { - if ( artifact.getId().equals( getProject().getParentArtifact().getId() ) - && isProcessingParent() ) - { - if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) - { - getLog().debug( "Made parent update from " + version + " to " + newVersion ); - } - } - } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useLatestReleases", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); - } + return getLastFiltered( versions.getNewerVersions( dep.getVersion(), unchangedSegment, + false, false ), dep ); } - } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), - dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); - } - } - } + catch ( InvalidSegmentException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + } + return empty(); + }, "useLatestReleases", + dep -> !matchSnapshotRegex.matcher( dep.getVersion() ).matches() ); } - private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact ) + /** + * Returns the last element of the given {@link ArtifactVersion} array such as every version of the array + * is included in the {@code includes} and excluded by the {@code excludes} filters + * + * @param newer array of {@link ArtifactVersion} with newer versions + * @param dependency dependency prototype to create the artifacts from + * @return the newest version fulfilling the criteria + */ + private Optional getLastFiltered( ArtifactVersion[] newer, Dependency dependency ) { - List filteredNewer = new ArrayList<>( newer.length ); - for ( ArtifactVersion artifactVersion : newer ) - { - Artifact artefactWithNewVersion = - new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), - VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(), - artifact.getType(), null, new DefaultArtifactHandler(), false ); - if ( isIncluded( artefactWithNewVersion ) ) - { - filteredNewer.add( artifactVersion ); - } - } - return filteredNewer.toArray( new ArtifactVersion[0] ); + return Arrays.stream( newer ) + .filter( version -> + { + Artifact artefactWithNewVersion = + new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), + VersionRange.createFromVersion( version.toString() ), dependency.getScope(), + dependency.getType(), null, new DefaultArtifactHandler(), false ); + return isIncluded( artefactWithNewVersion ); + } ) + .reduce( ( v1, v2 ) -> v2 ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 8b9b234301..f5009dc2ee 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -26,13 +26,10 @@ import java.util.Collection; import java.util.Optional; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -41,7 +38,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -50,16 +46,17 @@ import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; +import static java.util.Optional.empty; /** - * Replaces any version with the latest version. + * Replaces any version with the latest version found in the artifactory. * * @author Stephen Connolly * @since 1.0-alpha-3 */ @Mojo( name = "use-latest-versions", threadSafe = true ) public class UseLatestVersionsMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { /** * Whether to allow the major version number to be changed. @@ -67,7 +64,7 @@ public class UseLatestVersionsMojo * @since 1.2 */ @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) - private boolean allowMajorUpdates; + private boolean allowMajorUpdates = true; /** * Whether to allow the minor version number to be changed. @@ -76,7 +73,7 @@ public class UseLatestVersionsMojo * @since 1.2 */ @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) - private boolean allowMinorUpdates; + private boolean allowMinorUpdates = true; /** * Whether to allow the incremental version number to be changed. @@ -86,7 +83,7 @@ public class UseLatestVersionsMojo * @since 1.2 */ @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) - private boolean allowIncrementalUpdates; + private boolean allowIncrementalUpdates = true; /** *

    Whether to downgrade a snapshot dependency if allowSnapshots is false @@ -162,81 +159,27 @@ protected void update( ModifiedPomXMLEventReader pom ) } } + @SuppressWarnings( "unchecked" ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - ArtifactVersion selectedVersion = new DefaultArtifactVersion( version ); - getLog().debug( "Selected version:" + selectedVersion ); - - getLog().debug( "Looking for newer versions of " + toString( dep ) ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - - try - { - ArtifactVersion[] newerVersions = versions.getNewerVersions( version, unchangedSegment, allowSnapshots, - allowDowngrade ); - - //ArtifactVersion[] filteredVersions = filter( unchangedSegment, selectedVersion, newerVersions ); - ArtifactVersion[] filteredVersions = newerVersions; - if ( filteredVersions.length > 0 ) + useLatestVersions( pom, dependencies, + ( dep, versions ) -> { - String newVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + try { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) - { - if ( PomHelper.setProjectParentVersion( pom, newVersion ) ) - { - getLog().debug( "Made parent update from " + version + " to " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useLatestVersions", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), version, - newVersion ); - } - } + return versions.getNewestVersion( dep.getVersion(), unchangedSegment, allowSnapshots, + allowDowngrade ); } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, - getProject().getModel() ) ) + catch ( InvalidSegmentException e ) { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useLatestVersions", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); + getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); } - } - } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", dep.getGroupId(), - dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); - } - } + return empty(); + }, "useLatestVersions" ); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java new file mode 100644 index 0000000000..05a657a623 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -0,0 +1,147 @@ +package org.codehaus.mojo.versions; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import javax.xml.stream.XMLStreamException; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.function.Predicate; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; + +/** + * Common base class for {@link UseLatestVersionsMojo} + * and {@link UseLatestReleasesMojo} + */ +public abstract class UseLatestVersionsMojoBase + extends AbstractVersionsDependencyUpdaterMojo +{ + public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver ) + { + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + } + + /** + * Updates the pom, given a set of dependencies, a function retrieving the newest version, + * and an optional array of filters against which the input dependencies are matched. + * + * @param pom POM to be modified + * @param dependencies collection of dependencies with the dependency versions before the change + * @param newestVersionProducer function providing the newest version given a dependency and + * an {@link ArtifactVersions} instance + * @param changeRecorderTitle title for the change recorder records + * @param filters optional array of filters + * @throws XMLStreamException thrown if the POM update doesn't succeed + * @throws ArtifactMetadataRetrievalException thrown if an artifact cannot be retried + */ + @SafeVarargs + protected final void useLatestVersions( ModifiedPomXMLEventReader pom, + Collection dependencies, + BiFunction> + newestVersionProducer, + String changeRecorderTitle, + Predicate... filters ) + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + { + for ( Dependency dep : dependencies ) + { + if ( !Arrays.stream( filters ) + .map( f -> f.test( dep ) ) + .reduce( Boolean::logicalAnd ) + .orElse( true ) ) + { + continue; + } + + if ( isExcludeReactor() && isProducedByReactor( dep ) ) + { + getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + continue; + } + + if ( isHandledByProperty( dep ) ) + { + getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + continue; + } + + Artifact artifact = toArtifact( dep ); + if ( !isIncluded( artifact ) ) + { + continue; + } + + ArtifactVersion selectedVersion = new DefaultArtifactVersion( dep.getVersion() ); + getLog().debug( "Selected version:" + selectedVersion ); + + getLog().debug( "Looking for newer versions of " + toString( dep ) ); + ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); + Optional newestVer = newestVersionProducer.apply( dep, versions ); + if ( newestVer.isPresent() ) + { + String verStr = newestVer.get().toString(); + if ( getProject().getParent() != null ) + { + final Artifact parentArtifact = getProject().getParentArtifact(); + if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) + { + if ( PomHelper.setProjectParentVersion( pom, verStr ) ) + { + getLog().debug( "Made parent update from " + dep.getVersion() + " to " + verStr ); + + this.getChangeRecorder().recordUpdate( changeRecorderTitle, parentArtifact.getGroupId(), + parentArtifact.getArtifactId(), dep.getVersion(), + verStr ); + } + } + } + if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), + verStr, + getProject().getModel() ) ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + verStr ); + + this.getChangeRecorder().recordUpdate( changeRecorderTitle, dep.getGroupId(), + dep.getArtifactId(), dep.getVersion(), verStr ); + } + } + } + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 1d3f9665fd..1b1a5a080c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -255,6 +255,32 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional< return getVersions( restriction, includeSnapshots ); } + @Override + public Optional getNewestVersion( String versionString, Optional upperBoundSegment, + boolean includeSnapshots, boolean allowDowngrade ) + throws InvalidSegmentException + { + ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); + ArtifactVersion lowerBound = allowDowngrade + ? getLowerBound( currentVersion, upperBoundSegment ) + .map( DefaultArtifactVersion::new ) + .orElse( null ) + : currentVersion; + ArtifactVersion upperBound = + upperBoundSegment + .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, + s.isMajorTo( SUBINCREMENTAL ) + ? Segment.of( s.value() + 1 ) + : s ) ) + .orElse( null ); + + Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); + return Arrays.stream( getVersions( includeSnapshots ) ) + .filter( candidate -> isVersionInRestriction( restriction, candidate ) ) + .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) + .max( getVersionComparator() ); + } + @Override public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 265b4fcfaa..542130619e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -229,6 +229,23 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up */ ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ); + /** + * Returns the latest version, newer than the given version, given the upper bound segment and whether snapshots + * should be included. + * + * @param versionString current version + * @param upperBoundSegment the upper bound segment; empty() means no upper bound + * @param includeSnapshots whether snapshot versions should be included + * @param allowDowngrade whether to allow downgrading if the current version is a snapshots and snapshots + * are disallowed + * @return newer version or {@link Optional#empty()} if none can be found + * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than + * the segment count) + */ + Optional getNewestVersion( String versionString, Optional upperBoundSegment, + boolean includeSnapshots, boolean allowDowngrade ) + throws InvalidSegmentException; + /** * Returns the newest version newer than the specified current version, but within the specified update scope or * null if no such version exists. diff --git a/versions-maven-plugin/src/site/markdown/index.md b/versions-maven-plugin/src/site/markdown/index.md index cf780e9359..f008eb1a60 100644 --- a/versions-maven-plugin/src/site/markdown/index.md +++ b/versions-maven-plugin/src/site/markdown/index.md @@ -59,8 +59,7 @@ The Versions Plugin has the following goals. released and replaces them with the corresponding release version. * [versions:use-next-releases](./use-next-releases-mojo.html) searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the next release version. -* [versions:use-latest-releases](./use-latest-releases-mojo.html) searches the pom for all non-SNAPSHOT versions which - have been a newer release and replaces them with the latest release version. +* [versions:use-latest-releases](./use-latest-releases-mojo.html) searches the pom for all dependencies using *release* versions (i.e. not SNAPSHOT and not versions ending with a year-month-day suffix) and replaces them with the latest *release* version. * [versions:use-next-snapshots](./use-next-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions which have been a newer -SNAPSHOT version and replaces them with the next -SNAPSHOT version. * [versions:use-latest-snapshots](./use-latest-snapshots-mojo.html) searches the pom for all non-SNAPSHOT versions diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index e5b0ac4e1d..ac0a033d92 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -31,6 +31,8 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.not; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; @@ -60,6 +62,7 @@ public void setUp() throws Exception "1.0.0-SNAPSHOT", "0.9.0"} ); put( "poison-artifact", new String[] {"1.1.1.1-SNAPSHOT", "1.1.1.0", "1.1.1.0-SNAPSHOT", "1.0.0.0", "1.0.0.0-SNAPSHOT", "0.9.0.0"} ); + put( "other-artifact", new String[] {"1.0", "2.0"} ); }} ); mojo = new UseLatestVersionsMojo( repositorySystemMock, @@ -263,4 +266,56 @@ public void testIgnoredVersions() } assertThat( changeRecorder.getChanges(), Is.is( empty() ) ); } + + @Test + public void testIncludeFilter() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + mojo.getProject().getModel().setDependencies( Arrays.asList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", + "default", "pom", SCOPE_COMPILE ), + DependencyBuilder.dependencyWith( "default-group", "other-artifact", "1.0", + "default", "pom", SCOPE_COMPILE ) + ) ); + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "includes", new String[] {"default-group:other-artifact"} ); + + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "other-artifact", "1.0", + "2.0" ) ) ); + } + + @Test + public void testExcludeFilter() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + mojo.getProject().getModel().setDependencies( Arrays.asList( + DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", + "default", "pom", SCOPE_COMPILE ), + DependencyBuilder.dependencyWith( "default-group", "other-artifact", "1.0", + "default", "pom", SCOPE_COMPILE ) + ) ); + setVariableValueToObject( mojo, "processDependencies", true ); + setVariableValueToObject( mojo, "excludes", new String[] {"default-group:other-artifact"} ); + + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); + assertThat( changeRecorder.getChanges(), + not( hasItem( new VersionChange( "default-group", "other-artifact", "1.0", + "2.0" ) ) ) ); + } } From 540f3aeda4860cc651beab378af065b4de5e703d Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 5 Nov 2022 08:15:56 +0100 Subject: [PATCH 205/441] Resolves #809: Extract the apis and common services to a separate module --- pom.xml | 1 + versions-common/pom.xml | 123 ++++++++++ .../versions/api/AbstractVersionDetails.java | 0 .../versions/api/ArtifactAssociation.java | 0 .../mojo/versions/api/ArtifactVersions.java | 0 .../versions/api/ArtifactVersionsCache.java | 0 .../api/DefaultArtifactAssociation.java | 0 .../versions/api/DefaultVersionsHelper.java | 2 - .../versions/api}/PluginUpdatesDetails.java | 3 +- .../codehaus/mojo/versions/api/PomHelper.java | 0 .../codehaus/mojo/versions/api}/Property.java | 2 +- .../mojo/versions/api/PropertyVersions.java | 1 - .../versions/api/PropertyVersionsBuilder.java | 0 .../mojo/versions/api/ReportRenderer.java | 0 .../codehaus/mojo/versions/api/Segment.java | 0 .../mojo/versions/api/VersionDetails.java | 0 .../mojo/versions/api/VersionsHelper.java | 8 +- .../change/AbstractVersionChanger.java | 0 .../change/CompositeVersionChanger.java | 0 .../change/DependencyVersionChanger.java | 0 .../versions/change/ParentVersionChanger.java | 0 .../versions/change/PluginVersionChanger.java | 0 .../change/ProjectVersionChanger.java | 0 .../mojo/versions/change/VersionChange.java | 0 .../mojo/versions/change/VersionChanger.java | 0 .../change/VersionChangerFactory.java | 0 .../versions/filtering/DependencyFilter.java | 19 ++ .../filtering/NullAwareWildcardMatcher.java | 41 ++++ .../versions/filtering/TokenizedMatcher.java | 0 .../versions/filtering/WildcardMatcher.java | 0 .../ordering/AbstractVersionComparator.java | 0 .../ordering/BoundArtifactVersion.java | 0 .../versions/ordering/ComparableVersion.java | 0 .../ordering/InvalidSegmentException.java | 0 .../ordering/MavenVersionComparator.java | 0 .../ordering/MercuryVersionComparator.java | 0 .../ordering/NumericVersionComparator.java | 0 .../ordering/ReactorDepthComparator.java | 0 .../versions/ordering/VersionComparator.java | 0 .../versions/ordering/VersionComparators.java | 0 .../versions/recording/ChangeRecorder.java | 0 .../recording/ChangeRecorderNull.java | 0 .../versions/recording/ChangeRecorderXML.java | 0 .../rewriting/ModifiedPomXMLEventReader.java | 0 .../mojo/versions/utils/ContextualLog.java | 0 .../utils/DelegatingContextualLog.java | 0 .../versions/utils/DependencyBuilder.java | 0 .../versions/utils/DependencyComparator.java | 0 .../mojo/versions/utils/MiscUtils.java | 0 .../mojo/versions/utils/PluginComparator.java | 0 .../utils/PropertiesVersionsFileReader.java | 40 +++- .../versions/utils/PropertyComparator.java | 2 +- .../mojo/versions/utils/RegexUtils.java | 0 .../mojo/versions/utils/SegmentUtils.java | 0 .../utils/VersionsExpressionEvaluator.java | 0 .../mojo/versions/utils/WagonUtils.java | 0 .../versions/api/ArtifactVersionsTest.java | 0 .../api/DefaultVersionsHelperTest.java | 1 - .../mojo/versions/api/PomHelperTest.java | 30 ++- .../filtering/DependencyFilterTest.java | 89 ++++--- .../versions/filtering}/HasGAVMatcher.java | 21 +- .../filtering/TokenizedMatcherTest.java | 0 .../filtering/WildcardMatcherTest.java | 0 .../ordering/BoundArtifactVersionTest.java | 21 +- .../ordering/MavenVersionComparatorTest.java | 0 .../MercuryVersionComparatorTest.java | 0 .../NumericVersionComparatorTest.java | 0 .../ordering/VersionComparatorTestBase.java | 0 .../recording/ChangeRecorderXMLTest.java | 0 .../ModifiedPomXMLEventReaderTest.java | 0 .../utils/ModifiedPomXMLEventReaderUtils.java | 0 .../PropertiesVersionsFileReaderTest.java | 19 ++ .../mojo/versions/utils/SegmentUtilsTest.java | 0 ...elperTest.dependencyManagementBOMs.pom.xml | 0 .../PomHelperTest.noGroupIdOnChild.pom.xml | 0 .../PomHelperTest.testLongProperties.pom.xml | 0 .../api/issue-505/moduleA/moduleA.xml | 0 .../api/issue-505/moduleA/moduleB/pom.xml | 0 .../mojo/versions/api/issue-505/pom.xml | 0 .../org/codehaus/mojo/versions/api/rules.xml | 0 .../mojo/versions/recording/expectedFile.xml | 0 .../testPropertiesVersionsFile.properties | 0 versions-maven-plugin/pom.xml | 24 +- .../versions/AbstractVersionsUpdaterMojo.java | 1 + .../versions/CompareDependenciesMojo.java | 1 + .../versions/DisplayPropertyUpdatesMojo.java | 1 + .../org/codehaus/mojo/versions/LinkItem.java | 222 ------------------ .../versions/PluginUpdatesReportMojo.java | 1 + .../versions/PropertyUpdatesReportMojo.java | 1 + .../mojo/versions/ResolveRangesMojo.java | 1 + .../mojo/versions/SetPropertyMojo.java | 1 + .../mojo/versions/UpdatePropertiesMojo.java | 1 + .../mojo/versions/UpdatePropertyMojo.java | 1 + .../filtering/NullAwareWildcardMatcher.java | 22 -- .../reporting/PluginOverviewStats.java | 4 +- .../PluginUpdatesReportRenderer.java | 2 +- .../PropertyUpdatesReportRenderer.java | 2 +- .../reporting/model/PluginUpdatesModel.java | 7 +- .../reporting/model/PropertyUpdatesModel.java | 2 +- .../xml/PluginUpdatesXmlReportRenderer.java | 2 +- .../xml/PropertyUpdatesXmlReportRenderer.java | 2 +- .../PluginUpdatesXmlRendererTest.java | 1 + 102 files changed, 391 insertions(+), 331 deletions(-) create mode 100644 versions-common/pom.xml rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java (99%) rename {versions-maven-plugin/src/main/java/org/codehaus/mojo/versions => versions-common/src/main/java/org/codehaus/mojo/versions/api}/PluginUpdatesDetails.java (96%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java (100%) rename {versions-maven-plugin/src/main/java/org/codehaus/mojo/versions => versions-common/src/main/java/org/codehaus/mojo/versions/api}/Property.java (99%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java (99%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/Segment.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java (97%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java (70%) create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java (53%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java (97%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java (100%) rename {versions-maven-plugin => versions-common}/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java (99%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java (89%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java (63%) rename {versions-maven-plugin/src/test/java/org/codehaus/mojo/versions => versions-common/src/test/java/org/codehaus/mojo/versions/filtering}/HasGAVMatcher.java (62%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java (89%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java (100%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java (63%) rename {versions-maven-plugin => versions-common}/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/api/rules.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml (100%) rename {versions-maven-plugin => versions-common}/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties (100%) delete mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java delete mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java diff --git a/pom.xml b/pom.xml index 3b9a9f2c85..d2955b8d05 100644 --- a/pom.xml +++ b/pom.xml @@ -99,6 +99,7 @@ versions-maven-plugin model-ruleset model-report + versions-common diff --git a/versions-common/pom.xml b/versions-common/pom.xml new file mode 100644 index 0000000000..dffbe388bc --- /dev/null +++ b/versions-common/pom.xml @@ -0,0 +1,123 @@ + + + + versions + org.codehaus.mojo.versions + 2.14.0-SNAPSHOT + + 4.0.0 + + versions-common + + Versions Common + Common components for the Versions Maven Plugin + + + + org.codehaus.mojo.versions + model-ruleset + ${project.version} + + + + org.apache.maven + maven-artifact + ${mavenVersion} + provided + + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.apache.maven + maven-compat + ${mavenVersion} + provided + + + org.apache.maven + maven-model + ${mavenVersion} + provided + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + provided + + + org.apache.maven + maven-settings + ${mavenVersion} + provided + + + org.apache.maven.wagon + wagon-provider-api + ${wagonVersion} + provided + + + + com.fasterxml.woodstox + woodstox-core + test + + + + org.apache.maven.wagon + wagon-file + ${wagonVersion} + test + + + org.apache.commons + commons-lang3 + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + org.mockito + mockito-inline + test + + + org.hamcrest + hamcrest + test + + + org.slf4j + slf4j-simple + test + + + + diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java similarity index 99% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index a4d6d3f7fe..4f425ff300 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -74,8 +74,6 @@ import org.apache.maven.wagon.Wagon; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; -import org.codehaus.mojo.versions.PluginUpdatesDetails; -import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java similarity index 96% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java index 84842b57ef..6376f5c2d6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java @@ -1,4 +1,4 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.api; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -24,7 +24,6 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.api.ArtifactVersions; import static java.util.Optional.empty; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/Property.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java similarity index 99% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/Property.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java index d270f38cc1..09b5f56125 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/Property.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java @@ -1,4 +1,4 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.api; /* * Licensed to the Apache Software Foundation (ASF) under one diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java similarity index 99% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index fb4867604d..119e6192c3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -40,7 +40,6 @@ import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.project.MavenProject; -import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.VersionComparator; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/Segment.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java similarity index 97% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index beabeabd5e..bd803639d6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -34,8 +34,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; -import org.codehaus.mojo.versions.PluginUpdatesDetails; -import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.ordering.VersionComparator; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; @@ -188,7 +186,7 @@ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePlug * * @param plugins The set of {@link Plugin} instances to look up. * @param allowSnapshots Include snapshots in the list of updates. - * @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.PluginUpdatesDetails}. + * @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.api.PluginUpdatesDetails}. * @throws ArtifactMetadataRetrievalException When things go wrong. * @since 1.0-beta-1 */ @@ -218,12 +216,12 @@ PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots /** * Returns a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by - * {@link org.codehaus.mojo.versions.Property} instances consisting of the properties defined in the project which + * {@link Property} instances consisting of the properties defined in the project which * are associated with version information. * * @param request {@link VersionPropertiesMapRequest} instance containing the arguments * @return a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by - * {@link org.codehaus.mojo.versions.Property} instances. + * {@link Property} instances. * @throws MojoExecutionException if something goes wrong. */ Map getVersionPropertiesMap( VersionPropertiesMapRequest request ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java similarity index 70% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java index 07bf61617e..e31a0481a5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java @@ -1,5 +1,24 @@ package org.codehaus.mojo.versions.filtering; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.util.List; import java.util.Set; import java.util.TreeSet; diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java new file mode 100644 index 0000000000..1db96c0d99 --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java @@ -0,0 +1,41 @@ +package org.codehaus.mojo.versions.filtering; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class NullAwareWildcardMatcher extends WildcardMatcher +{ + public static final String NULL_KEYWORD = "null"; + + public NullAwareWildcardMatcher( String pattern ) + { + super( pattern ); + } + + @Override + public boolean test( String token ) + { + if ( NULL_KEYWORD.equals( getPattern() ) ) + { + return token == null; + } + + return super.test( token ); + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java b/versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java similarity index 53% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java index 98fcaa40a9..95dc0b654a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java @@ -1,5 +1,24 @@ package org.codehaus.mojo.versions.utils; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; @@ -9,8 +28,11 @@ import java.util.Properties; import java.util.stream.Collectors; -import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.Property; +/** + * Reader class for reading property files + */ public class PropertiesVersionsFileReader { @@ -23,11 +45,19 @@ public class PropertiesVersionsFileReader private String propertyFilePath; + /** + * Creates an instance of the object with the given path to the property file + * @param filePath path to the property file + */ public PropertiesVersionsFileReader( String filePath ) { propertyFilePath = filePath; } + /** + * Reads the property file + * @throws IOException thrown if an I/O exception occurs during the read operation + */ public void read() throws IOException { try ( InputStream input = Files.newInputStream( Paths.get( propertyFilePath ) ) ) @@ -55,11 +85,19 @@ public void read() throws IOException } } + /** + * Returns the string contents of the property file + * @return contents of the property file + */ public String getProperties() { return propertiesCsv; } + /** + * Returns the array of {@link Property} objects + * @return array of properties + */ public Property[] getPropertiesConfig() { return propertiesConfig; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java similarity index 97% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java index 676df82494..8459950159 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java @@ -22,7 +22,7 @@ import java.util.Comparator; import org.apache.commons.lang3.StringUtils; -import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.Property; /** * A comparator used to sort {@link Property} instances. diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java similarity index 100% rename from versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java similarity index 99% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 0ccf473e9f..047bc3f421 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -44,7 +44,6 @@ import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; -import org.codehaus.mojo.versions.Property; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java similarity index 89% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index 9e472005f3..460883f855 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -1,5 +1,24 @@ package org.codehaus.mojo.versions.api; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; @@ -18,6 +37,7 @@ import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.stax2.XMLInputFactory2; +import org.hamcrest.MatcherAssert; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -218,7 +238,7 @@ public void testSetElementValueExistingValue() throws XMLStreamException assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", "child", "value" ), is( true ) ); - assertThat( xmlEventReader, + MatcherAssert.assertThat( xmlEventReader, matches( "value" ) ); } @@ -230,7 +250,7 @@ public void testSetElementValueEmptyChild() throws XMLStreamException assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", "child", "value" ), is( true ) ); - assertThat( xmlEventReader, + MatcherAssert.assertThat( xmlEventReader, matches( "value" ) ); } @@ -242,7 +262,7 @@ public void testSetElementValueNewValueEmptyParent() throws XMLStreamException assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", "child", "value" ), is( true ) ); - assertThat( xmlEventReader, + MatcherAssert.assertThat( xmlEventReader, matches( "value" ) ); } @@ -254,7 +274,7 @@ public void testSetElementValueNewValueNoChild() throws XMLStreamException assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", "child", "value" ), is( true ) ); - assertThat( xmlEventReader, + MatcherAssert.assertThat( xmlEventReader, matches( "value" ) ); } @@ -267,7 +287,7 @@ public void testSetProjectValueNewValueNonEmptyParent() throws XMLStreamExceptio assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", "child", "value" ), is( true ) ); - assertThat( xmlEventReader, + MatcherAssert.assertThat( xmlEventReader, matches( "value" ) ); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java similarity index 63% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java index 956facfb62..422323bebd 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -1,18 +1,37 @@ package org.codehaus.mojo.versions.filtering; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.util.Collections; import java.util.HashSet; import java.util.Set; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import static java.util.Arrays.asList; -import static org.codehaus.mojo.versions.HasGAVMatcher.hasGAV; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.empty; class DependencyFilterTest @@ -35,11 +54,11 @@ void removesExcludedDepsWithExactMatch() Set actual = exclusions.removingFrom( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "foo", "bar", "1" ), + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) ) ); } @@ -52,11 +71,11 @@ void removesExcludedDepsWithWildcardInVersion() Set actual = exclusions.removingFrom( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "foo", "bar", "1" ), + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) ) ); } @@ -68,10 +87,10 @@ void removesExcludedDepsWithWildcardInGroupId() Set actual = exclusions.removingFrom( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "foo", "bar", "1" ) ) ); } @@ -99,10 +118,10 @@ void removesMultiplePatterns() Set actual = exclusions.removingFrom( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "foo", "bar", "1" ) ) ); } @@ -126,10 +145,10 @@ void retainsOnlyDepsWithExactMatch() Set actual = exclusions.retainingIn( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "localhost", "my-impl", "3" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) ) ); } @@ -142,10 +161,10 @@ void retainsOnlyDepsMatchingWildcardInVersion() Set actual = exclusions.retainingIn( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) ) ); } @@ -157,11 +176,11 @@ void retainsOnlyDepsWithMultipleWildcards() Set actual = exclusions.retainingIn( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), + HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) ) ); } @@ -173,12 +192,12 @@ void retainsAllOnAllWildcards() Set actual = exclusions.retainingIn( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "foo", "bar", "1" ), - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "foo", "bar", "1" ), + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), + HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) ) ); } @@ -194,11 +213,11 @@ void retainsMultiplePatterns() Set actual = exclusions.retainingIn( input ); - assertThat( + MatcherAssert.assertThat( actual, - containsInAnyOrder( - hasGAV( "localhost", "my-api", "2" ), - hasGAV( "localhost", "my-impl", "3" ) + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), + HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) ) ); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java similarity index 62% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java index dda261a64f..e9dd54321f 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/HasGAVMatcher.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java @@ -1,4 +1,23 @@ -package org.codehaus.mojo.versions; +package org.codehaus.mojo.versions.filtering; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ import java.util.Objects; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java similarity index 89% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java index d62e972303..32b4f3db14 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java @@ -20,9 +20,12 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.codehaus.mojo.versions.api.Segment; import org.junit.Test; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.lessThan; @@ -36,7 +39,7 @@ public class BoundArtifactVersionTest public void testMajorUpperBoundGreaterThanNextMajor() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3" ), - Segment.MAJOR ); + MAJOR ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "2.0.0" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -45,7 +48,7 @@ public void testMajorUpperBoundGreaterThanNextMajor() public void testSubIncrementalUpperBoundGreaterThanNextSubIncremental() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3-2" ), - Segment.SUBINCREMENTAL ); + SUBINCREMENTAL ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.2.3-3" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -54,7 +57,7 @@ public void testSubIncrementalUpperBoundGreaterThanNextSubIncremental() public void testVersionShorterThanSegment() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - Segment.INCREMENTAL ); + INCREMENTAL ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -63,7 +66,7 @@ public void testVersionShorterThanSegment() public void testVersionBoundArtifactVersionShorterThanConcreteVersionAndSegment() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - Segment.SUBINCREMENTAL ); + SUBINCREMENTAL ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); assertThat( bound.compareTo( artifactVersion ), lessThan( 0 ) ); } @@ -72,7 +75,7 @@ public void testVersionBoundArtifactVersionShorterThanConcreteVersionAndSegment( public void testVersionSubIncrementalBoundGreaterThanSubIncremental() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - Segment.SUBINCREMENTAL ); + SUBINCREMENTAL ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.0-2" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -81,7 +84,7 @@ public void testVersionSubIncrementalBoundGreaterThanSubIncremental() public void testVersionSubIncrementalBoundGreaterThanIncremental() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - Segment.INCREMENTAL ); + INCREMENTAL ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -90,7 +93,7 @@ public void testVersionSubIncrementalBoundGreaterThanIncremental() public void testVersionSubIncrementalBoundGreaterThanMinor() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - Segment.MINOR ); + MINOR ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.3" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } @@ -99,7 +102,7 @@ public void testVersionSubIncrementalBoundGreaterThanMinor() public void testSnapshotWithSubIncremental() { BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), - Segment.MINOR ); + MINOR ); ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.0.0" ); assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java similarity index 63% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java index cc0e880cc5..2041c82e9c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java @@ -1,5 +1,24 @@ package org.codehaus.mojo.versions.utils; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.IOException; import java.util.Arrays; import java.util.HashSet; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java rename to versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.noGroupIdOnChild.pom.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.testLongProperties.pom.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleA.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/moduleA/moduleB/pom.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/issue-505/pom.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/rules.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/rules.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/api/rules.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/api/rules.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml rename to versions-common/src/test/resources/org/codehaus/mojo/versions/recording/expectedFile.xml diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties b/versions-common/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties similarity index 100% rename from versions-maven-plugin/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties rename to versions-common/src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 7469b884e4..3881b4f003 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -27,6 +27,12 @@ ${project.version} + + org.codehaus.mojo.versions + versions-common + ${project.version} + + org.apache.maven.plugin-tools maven-plugin-annotations @@ -69,10 +75,6 @@ ${mavenVersion} provided - - org.apache.maven.reporting - maven-reporting-api - org.apache.maven.reporting maven-reporting-impl @@ -81,17 +83,7 @@ org.apache.maven.shared maven-common-artifact-filters - - org.apache.maven.wagon - wagon-provider-api - ${wagonVersion} - provided - - - org.apache.maven.wagon - wagon-file - ${wagonVersion} - + @@ -116,10 +108,12 @@ org.codehaus.plexus plexus-interactivity-api + com.fasterxml.woodstox woodstox-core + org.apache.commons commons-lang3 diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index ca59f3755f..9a526ca644 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -55,6 +55,7 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index eb7d80d8b7..807ebd4c36 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -46,6 +46,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index f0f11a7a5a..65a183dc48 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -40,6 +40,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java deleted file mode 100644 index 6f604dfc39..0000000000 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LinkItem.java +++ /dev/null @@ -1,222 +0,0 @@ -package org.codehaus.mojo.versions; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * LinkItem represents information specified for a linked artifact version manged through a property. - * - * @author Stephen Connolly - * @since 1.0-alpha-1 - */ -public class LinkItem -{ - - // ------------------------------ FIELDS ------------------------------ - - /** - * Group Id of the Artifact. - * - * @parameter - * @required - * @since 1.0-alpha-1 - */ - private String groupId; - - /** - * Artifact Id of the Artifact. - * - * @parameter - * @required - * @since 1.0-alpha-1 - */ - private String artifactId; - - /** - * The property that defines the version of the artifact to use. - * - * @parameter - * @required - * @since 1.0-alpha-1 - */ - private String property; - - /** - * Version specification to control artifact resolution. - * - * @parameter - * @since 1.0-alpha-1 - */ - private String version = null; - - /** - * Override snapshot permisibility. - * - * @parameter - * @since 1.0-alpha-1 - */ - private Boolean allowSnapshots = null; - - // --------------------------- CONSTRUCTORS --------------------------- - - /** - * Constructs a new LinkItem. - * - * @since 1.0-alpha-1 - */ - public LinkItem() - { - } - - // --------------------- GETTER / SETTER METHODS --------------------- - - /** - * Getter for property 'allowSnapshots'. - * - * @return Value for property 'allowSnapshots'. - * @since 1.0-alpha-1 - */ - public Boolean getAllowSnapshots() - { - return allowSnapshots; - } - - /** - * Setter for property 'allowSnapshots'. - * - * @param allowSnapshots Value to set for property 'allowSnapshots'. - * @since 1.0-alpha-1 - */ - public void setAllowSnapshots( Boolean allowSnapshots ) - { - this.allowSnapshots = allowSnapshots; - } - - /** - * Getter for property 'artifactId'. - * - * @return Value for property 'artifactId'. - * @since 1.0-alpha-1 - */ - public String getArtifactId() - { - return artifactId; - } - - /** - * Setter for property 'artifactId'. - * - * @param artifactId Value to set for property 'artifactId'. - * @since 1.0-alpha-1 - */ - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - /** - * Getter for property 'groupId'. - * - * @return Value for property 'groupId'. - * @since 1.0-alpha-1 - */ - public String getGroupId() - { - return groupId; - } - - /** - * Setter for property 'groupId'. - * - * @param groupId Value to set for property 'groupId'. - * @since 1.0-alpha-1 - */ - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - /** - * Getter for property 'property'. - * - * @return Value for property 'property'. - * @since 1.0-alpha-1 - */ - public String getProperty() - { - return property; - } - - /** - * Setter for property 'property'. - * - * @param property Value to set for property 'property'. - * @since 1.0-alpha-1 - */ - public void setProperty( String property ) - { - this.property = property; - } - - /** - * Getter for property 'version'. - * - * @return Value for property 'version'. - * @since 1.0-alpha-1 - */ - public String getVersion() - { - return version; - } - - /** - * Setter for property 'version'. - * - * @param version Value to set for property 'version'. - * @since 1.0-alpha-1 - */ - public void setVersion( String version ) - { - this.version = version; - } - - // ------------------------ CANONICAL METHODS ------------------------ - - /** - * {@inheritDoc} - * - * @since 1.0-alpha-1 - */ - public String toString() - { - StringBuilder buf = new StringBuilder( "${" ); - buf.append( property ); - buf.append( "} = " ); - buf.append( groupId ); - buf.append( ':' ); - buf.append( artifactId ); - if ( version != null ) - { - buf.append( ':' ); - buf.append( version ); - } - return buf.toString(); - } - -} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 05b9bdbfe2..717dec32a1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -41,6 +41,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.mojo.versions.utils.PluginComparator; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 480949fefd..4469b1da37 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -39,6 +39,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 5c05c8b083..7729cba15a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -44,6 +44,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index da046d430d..f2e6787122 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -36,6 +36,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index bd692db5a3..8211e28179 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index ed9d279617..9e22942623 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -37,6 +37,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java deleted file mode 100644 index dfa8fef64c..0000000000 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.codehaus.mojo.versions.filtering; - -public class NullAwareWildcardMatcher extends WildcardMatcher -{ - public static final String NULL_KEYWORD = "null"; - - public NullAwareWildcardMatcher( String pattern ) - { - super( pattern ); - } - - @Override - public boolean test( String token ) - { - if ( NULL_KEYWORD.equals( getPattern() ) ) - { - return token == null; - } - - return super.test( token ); - } -} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 81dea82dd6..25494f7869 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -21,10 +21,10 @@ import java.util.Collection; import java.util.Optional; -import org.codehaus.mojo.versions.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import static java.util.Optional.of; @@ -58,7 +58,7 @@ public void incrementDependencies() * @param cache if not null, cache to retrieve the version information, initialised with * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param always equal to {@linkplain PluginOverviewStats} - * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} + * @param always equal to {@linkplain PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information */ public static diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 6d0713cd41..c878110a8c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -29,8 +29,8 @@ import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.plexus.i18n.I18N; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index 1ca1730906..c68656e6c6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -31,7 +31,7 @@ import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.sink.SinkEventAttributes; import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; -import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java index 1846624a53..fd3186aa27 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java @@ -22,7 +22,7 @@ import java.util.Map; import org.apache.maven.model.Plugin; -import org.codehaus.mojo.versions.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.utils.DependencyBuilder; /** @@ -30,6 +30,11 @@ */ public class PluginUpdatesModel extends AbstractUpdatesModel { + /** + * Creates a new instance + * @param pluginUpdates map of plugin updates per plugin + * @param pluginManagementUpdates map of plugin management updates per plugin + */ public PluginUpdatesModel( Map pluginUpdates, Map pluginManagementUpdates ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java index 9a5d36cfc0..c2a6aa4606 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.TreeMap; -import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.utils.PropertyComparator; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java index fa04791c9a..42173d048b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java @@ -30,9 +30,9 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; -import org.codehaus.mojo.versions.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.ReportRenderer; import org.codehaus.mojo.versions.reporting.PluginOverviewStats; import org.codehaus.mojo.versions.reporting.model.PluginInfo; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java index a9d9c882ba..2042858614 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java @@ -30,7 +30,7 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.codehaus.mojo.versions.Property; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.api.PropertyVersions; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java index f39a880cc9..a0b9cb2e15 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java @@ -29,6 +29,7 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Plugin; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyBuilder; From c50851f9984a6fb2cc8525736de44f5f5fb68f4f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 13:04:53 +0000 Subject: [PATCH 206/441] Bump plexus-utils from 3.4.2 to 3.5.0 Bumps [plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.4.2 to 3.5.0. - [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases) - [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.4.2...plexus-utils-3.5.0) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-utils dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- model-report/pom.xml | 2 +- model-ruleset/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/model-report/pom.xml b/model-report/pom.xml index cb4f5a59a1..ef30e642ac 100644 --- a/model-report/pom.xml +++ b/model-report/pom.xml @@ -18,7 +18,7 @@ org.codehaus.plexus plexus-utils - 3.4.2 + 3.5.0 diff --git a/model-ruleset/pom.xml b/model-ruleset/pom.xml index dcb473b22c..c4ef287788 100644 --- a/model-ruleset/pom.xml +++ b/model-ruleset/pom.xml @@ -18,7 +18,7 @@ org.codehaus.plexus plexus-utils - 3.4.2 + 3.5.0 From 2c78f43dc257acfd544a801e01032ae22c90e54c Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 7 Nov 2022 17:46:22 +0100 Subject: [PATCH 207/441] Resolves #289: Handle processParent in mojos which support it. Also: - added failIfNotReplaced to ForceReleasesMojo as a first steps towards converging with UseReleasesMojo - enhanced documentation on UseReleasesMojo#allowRangeMatching - streamlined UseReleasesMojo in order to converge it with ForceReleasesMojo and then fold further with other similar mojos - added unit tests and integration tests - some refactoring --- .gitignore | 1 + .../mojo/versions/api/ArtifactVersions.java | 1 + .../versions/api/ArtifactVersionsCache.java | 2 + .../mojo/versions/api/PropertyVersions.java | 1 + .../recording/ChangeRecorderNull.java | 20 +- .../versions/recording/ChangeRecorderXML.java | 18 +- .../versions/utils/DependencyBuilder.java | 9 + .../recording/ChangeRecorderXMLTest.java | 2 +- .../src/it-repo/dummy-with-parent.pom | 15 ++ .../invoker.properties | 2 + .../it-compare-dependencies-issue-289/pom.xml | 15 ++ .../verify.groovy | 2 + .../it/it-use-latest-versions-009/verify.bsh | 33 --- .../it-use-latest-versions-009/verify.groovy | 2 + .../it/it-use-latest-versions-010/verify.bsh | 62 ------ .../it-use-latest-versions-010/verify.groovy | 2 + .../it/it-use-latest-versions-011/verify.bsh | 33 --- .../it-use-latest-versions-011/verify.groovy | 2 + ...AbstractVersionsDependencyUpdaterMojo.java | 87 +++++++- .../mojo/versions/AbstractVersionsReport.java | 20 +- .../versions/AbstractVersionsUpdaterMojo.java | 35 +-- .../versions/CompareDependenciesMojo.java | 73 ++++--- .../DisplayDependencyUpdatesMojo.java | 4 +- .../mojo/versions/ForceReleasesMojo.java | 44 ++-- .../mojo/versions/LockSnapshotsMojo.java | 6 +- .../mojo/versions/UnlockSnapshotsMojo.java | 6 +- .../mojo/versions/UseDepVersionMojo.java | 20 +- .../mojo/versions/UseLatestReleasesMojo.java | 17 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 131 ++---------- .../mojo/versions/UseLatestVersionsMojo.java | 9 +- .../versions/UseLatestVersionsMojoBase.java | 28 +-- .../mojo/versions/UseNextReleasesMojo.java | 62 ++---- .../mojo/versions/UseNextSnapshotsMojo.java | 105 +++------ .../mojo/versions/UseNextVersionsMojo.java | 56 ++--- .../mojo/versions/UseReleasesMojo.java | 192 ++++------------- .../AbstractVersionsReportRenderer.java | 4 - .../reporting/ReportRendererFactory.java | 1 + .../mojo/versions/ForceReleasesMojoTest.java | 199 ++++++++++++++++++ .../versions/UseLatestReleasesMojoTest.java | 2 + .../versions/UseLatestVersionsMojoTest.java | 8 +- .../mojo/versions/UseReleasesMojoTest.java | 155 ++++++++++++++ 41 files changed, 716 insertions(+), 770 deletions(-) create mode 100644 versions-maven-plugin/src/it-repo/dummy-with-parent.pom create mode 100644 versions-maven-plugin/src/it/it-compare-dependencies-issue-289/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-compare-dependencies-issue-289/pom.xml create mode 100644 versions-maven-plugin/src/it/it-compare-dependencies-issue-289/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-009/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-010/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-011/verify.groovy create mode 100644 versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java create mode 100644 versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java diff --git a/.gitignore b/.gitignore index 8f164d2f9a..2a91b82853 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ target .project *.iml .idea +.checkstyle /.factorypath diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index ec624f677b..6a398891b1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -253,4 +253,5 @@ public String toString() return "ArtifactVersions" + "{artifact=" + artifact + ", versions=" + versions + ", versionComparator=" + versionComparator + '}'; } + } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java index e5aa2e384b..9966d9a1c2 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java @@ -52,6 +52,8 @@ public ArtifactVersionsCache( BiFunction concrete implementation of {@linkplain AbstractVersionDetails} + * @param return type of the cached function * @param artifactVersions {@linkplain ArtifactVersions} object referring to the given dependency * @param updateScope update scope * @return last retrieved update information diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 119e6192c3..825be779e2 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -492,4 +492,5 @@ public int getSegmentCount( ArtifactVersion v ) return result; } } + } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index b3c3c2c67b..dc8c013c1d 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -20,7 +20,6 @@ */ import java.io.OutputStream; -import java.util.Objects; /** * A recorder that ignores updates. @@ -29,35 +28,20 @@ public class ChangeRecorderNull implements ChangeRecorder { /** - * Create a new change recorder that serializes to XML. - * - * @return A new change recorder + * Creates a new instance */ - - public static ChangeRecorder create() - { - return new ChangeRecorderNull(); - } - - private ChangeRecorderNull() + public ChangeRecorderNull() { - } @Override public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) { - Objects.requireNonNull( kind, "kind" ); - Objects.requireNonNull( groupId, "groupId" ); - Objects.requireNonNull( artifactId, "artifactId" ); - Objects.requireNonNull( oldVersion, "oldVersion" ); - Objects.requireNonNull( newVersion, "newVersion" ); } @Override public final void serialize( final OutputStream outputStream ) { - } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java index d6b62526df..6fa2a82c41 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -53,21 +53,17 @@ public class ChangeRecorderXML implements ChangeRecorder private final Element root; /** - * Create a new change recorder that serializes to XML. - * - * @return A new change recorder + * Creates a new instance */ - - public static ChangeRecorder create() + public ChangeRecorderXML() { try { final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); - final Document document = documentBuilder.newDocument(); - final Element root = document.createElementNS( CHANGES_NAMESPACE, "updates" ); + document = documentBuilder.newDocument(); + root = document.createElementNS( CHANGES_NAMESPACE, "updates" ); document.appendChild( root ); - return new ChangeRecorderXML( document, root ); } catch ( final ParserConfigurationException | DOMException e ) { @@ -75,12 +71,6 @@ public static ChangeRecorder create() } } - private ChangeRecorderXML( final Document document, final Element root ) - { - this.document = Objects.requireNonNull( document, "document" ); - this.root = Objects.requireNonNull( root, "root" ); - } - @Override public final void recordUpdate( final String kind, final String groupId, final String artifactId, final String oldVersion, final String newVersion ) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java index dfab65532b..24ad4df5a8 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java @@ -144,6 +144,9 @@ public static DependencyBuilder newBuilder() /** * Convenience builder method + * @param groupId groupId of the dependency + * @param artifactId artifactId of the dependency + * @param version version of the dependency * @return new instance of {@linkplain Dependency} */ public static Dependency dependencyWith( String groupId, String artifactId, String version ) @@ -157,6 +160,12 @@ public static Dependency dependencyWith( String groupId, String artifactId, Stri /** * Convenience builder method + * @param groupId groupId of the dependency + * @param artifactId artifactId of the dependency + * @param version version of the dependency + * @param type type of the dependency + * @param classifier classifier of the dependency + * @param scope scope of the dependency * @return new instance of {@linkplain Dependency} */ public static Dependency dependencyWith( String groupId, String artifactId, String version, String type, diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java index c5cb59a076..32c602805c 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -64,7 +64,7 @@ public void testChanges() throws Exception copyResource( "expectedFile.xml", file0 ); - final ChangeRecorder recorder = ChangeRecorderXML.create(); + final ChangeRecorder recorder = new ChangeRecorderXML(); recorder.recordUpdate( "exampleKind", "org.codehaus", "example0", "0.0.1", "0.0.2" ); recorder.recordUpdate( "exampleKind", "org.codehaus", "example1", "1.0.0", "2.0.0" ); diff --git a/versions-maven-plugin/src/it-repo/dummy-with-parent.pom b/versions-maven-plugin/src/it-repo/dummy-with-parent.pom new file mode 100644 index 0000000000..ee67ab6786 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-with-parent.pom @@ -0,0 +1,15 @@ + + 4.0.0 + + + localhost + dummy-parent2 + 2.0 + + + dummy-with-parent + 1.0 + pom + + diff --git a/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/invoker.properties b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/invoker.properties new file mode 100644 index 0000000000..3ad4536e87 --- /dev/null +++ b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:compare-dependencies +invoker.mavenOpts = -DremotePom=localhost:dummy-with-parent:1.0 -DreportMode=false -DprocessParent=true diff --git a/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/pom.xml b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/pom.xml new file mode 100644 index 0000000000..389dd2b739 --- /dev/null +++ b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/pom.xml @@ -0,0 +1,15 @@ + + 4.0.0 + + + localhost + dummy-parent2 + 1.0 + + + dummy-with-parent + 1.0-SNAPSHOT + pom + + diff --git a/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/verify.groovy b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/verify.groovy new file mode 100644 index 0000000000..3271a1899f --- /dev/null +++ b/versions-maven-plugin/src/it/it-compare-dependencies-issue-289/verify.groovy @@ -0,0 +1,2 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) +assert project.parent.version == '2.0' diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh deleted file mode 100644 index afc3f9b043..0000000000 --- a/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.bsh +++ /dev/null @@ -1,33 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E.*\\Q\\E\\s*3\\.0\\s*\\Q\\E.*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not update parent to version 3.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.groovy new file mode 100644 index 0000000000..954f1b2145 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-009/verify.groovy @@ -0,0 +1,2 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) +assert project.parent.version == '3.0' diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh deleted file mode 100644 index 204a0b8153..0000000000 --- a/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.bsh +++ /dev/null @@ -1,62 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E.*\\Q\\E\\s*3\\.0\\s*\\Q\\E.*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not update parent to version 3.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E\\s*3\\.0\\s*\\Q\\E.*\\Qpom\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not update to version 3.0" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.groovy new file mode 100644 index 0000000000..954f1b2145 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-010/verify.groovy @@ -0,0 +1,2 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) +assert project.parent.version == '3.0' diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh b/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh deleted file mode 100644 index c93c575322..0000000000 --- a/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.bsh +++ /dev/null @@ -1,33 +0,0 @@ -import java.io.*; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "pom.xml" ); - - BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) ); - StringBuilder buf = new StringBuilder(); - String line = in.readLine(); - while ( line != null ) - { - buf.append( line ); - buf.append( " " ); - line = in.readLine(); - } - - Pattern p = Pattern.compile( "\\Q\\E.*\\Q\\E\\s*1\\.0\\.0\\s*\\Q\\E.*\\Q\\E" ); - Matcher m = p.matcher( buf.toString() ); - if ( !m.find() ) - { - System.out.println( "Did not update parent to version 1.0.0 from 1.0.0-SNAPSHOT" ); - return false; - } - System.out.println( m.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.groovy new file mode 100644 index 0000000000..09e552dd5d --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-011/verify.groovy @@ -0,0 +1,2 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) +assert project.parent.version == '1.0.0' diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 571fbdc015..9b8cc5c5cd 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -20,11 +20,13 @@ */ import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; @@ -41,7 +43,11 @@ import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.DependencyComparator; /** * Base class for a mojo that updates dependency versions. @@ -53,11 +59,16 @@ public abstract class AbstractVersionsDependencyUpdaterMojo extends AbstractVersionsUpdaterMojo { - private static final String END_RANGE_CHARS = "])"; private static final String START_RANGE_CHARS = "[("; + /** + * Pattern to match snapshot versions + */ + protected static final Pattern SNAPSHOT_REGEX = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + + /** * A comma separated list of artifact patterns to include. Follows the pattern * "groupId:artifactId:type:classifier:version". Designed to allow specifying the set of includes from the command @@ -104,7 +115,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * @since 1.0-alpha-3 */ @Parameter( property = "processDependencies", defaultValue = "true" ) - private boolean processDependencies; + private boolean processDependencies = true; /** * Whether to process the dependencyManagement section of the project. @@ -112,7 +123,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * @since 1.0-alpha-3 */ @Parameter( property = "processDependencyManagement", defaultValue = "true" ) - private boolean processDependencyManagement; + private boolean processDependencyManagement = true; /** * Whether to process the parent section of the project. If not set will default to false. @@ -142,7 +153,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * @since 1.0-alpha-3 */ @Parameter( property = "excludeReactor", defaultValue = "true" ) - private boolean excludeReactor; + private boolean excludeReactor = true; @Inject protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, @@ -266,6 +277,20 @@ protected Artifact toArtifact( Parent model ) .build() ); } + /** + * Returns the {@link Dependency} instance for the parent project + * @return {@link Dependency} object for the parent + */ + protected Dependency getParentDependency() + { + return DependencyBuilder.newBuilder() + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withVersion( getProject().getParent().getVersion() ) + .withType( "pom" ) + .build(); + } + protected String toString( MavenProject project ) { StringBuilder buf = new StringBuilder(); @@ -507,4 +532,58 @@ private int findFirstChar( final String includeString, final String chars ) } return nextRangeStartDelimiterIndex; } + + /** + * Attempts to update the dependency {@code dep} to the given {@code newVersion}. The dependency can either + * be the parent project or any given dependency. + * + * @param pom {@link ModifiedPomXMLEventReader} instance to update the POM XML document + * @param dep dependency to be updated (can also be a dependency made from the parent) + * @param newVersion new version to update the dependency to + * @param changeRecorderTitle title for the {@link ChangeRecorder} log + * @return {@code true} if an update has been made, {@code false} otherwise + * @throws XMLStreamException thrown if updating the XML doesn't succeed + */ + protected boolean updateDependencyVersion( ModifiedPomXMLEventReader pom, Dependency dep, + String newVersion, String changeRecorderTitle ) + throws XMLStreamException + { + boolean updated = false; + if ( isProcessingParent() + && getProject().getParent() != null + && DependencyComparator.INSTANCE.compare( dep, DependencyBuilder.newBuilder() + .withGroupId( getProject().getParentArtifact().getGroupId() ) + .withArtifactId( getProject().getParentArtifact().getArtifactId() ) + .withVersion( getProject().getParentArtifact().getVersion() ) + .build() ) == 0 + && PomHelper.setProjectParentVersion( pom, newVersion ) ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Made parent update from " + dep.getVersion() + " to " + newVersion ); + } + getChangeRecorder().recordUpdate( changeRecorderTitle, + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), + newVersion ); + updated = true; + } + + if ( PomHelper.setDependencyVersion( pom, + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), + newVersion, getProject().getModel() ) ) + { + if ( getLog().isInfoEnabled() ) + { + getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + } + getChangeRecorder().recordUpdate( changeRecorderTitle, + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), + newVersion ); + updated = true; + } + + return updated; + } + + // TODO: add an updatePropertyVersion as well??? (like in CompareDependenciesMojo) } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 336febe831..26b993dd34 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -301,17 +301,13 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver } } - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getProject() - */ + @Override protected MavenProject getProject() { return project; } - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory() - */ + @Override protected String getOutputDirectory() { if ( !outputDirectory.isAbsolute() ) @@ -322,25 +318,19 @@ protected String getOutputDirectory() return outputDirectory.getAbsolutePath(); } - /** - * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer() - */ + @Override protected Renderer getSiteRenderer() { return siteRenderer; } - /** - * @see org.apache.maven.reporting.MavenReport#getDescription(java.util.Locale) - */ + @Override public String getDescription( Locale locale ) { return getText( locale, "report.description" ); } - /** - * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale) - */ + @Override public String getName( Locale locale ) { return getText( locale, "report.title" ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 9a526ca644..ad4bbf6425 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -205,6 +205,7 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( property = "changeRecorderOutputFile", defaultValue = "${project.build.directory}/versions-changes.xml" ) private File changeRecorderOutputFile; + /** * The change recorder implementation. */ @@ -317,12 +318,25 @@ public String getVersion() public void execute() throws MojoExecutionException, MojoFailureException { + validateInput(); File outFile = project.getFile(); process( outFile ); } // -------------------------- OTHER METHODS -------------------------- + /** + * Validates input parameters + * + * @throws MojoExecutionException thrown if any of input parameters is invalid + */ + protected void validateInput() throws MojoExecutionException + { + if ( !"none".equals( changeRecorderFormat ) && !"xml".equals( changeRecorderFormat ) ) + { + throw new MojoExecutionException( "Only 'xml' or 'none' formats are supported for change recordings" ); + } + } /** * Finds the latest version of the specified artifact that matches the version range. * @@ -560,25 +574,16 @@ else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.ge * Configure and return the change recorder. * * @return The change recorder - * @throws MojoExecutionException If the provided change recorder format is not valid */ - - protected ChangeRecorder getChangeRecorder() throws MojoExecutionException + protected ChangeRecorder getChangeRecorder() { if ( changeRecorder == null ) { - if ( "none".equals( this.changeRecorderFormat ) ) - { - changeRecorder = ChangeRecorderNull.create(); - } - else if ( "xml".equals( this.changeRecorderFormat ) ) - { - changeRecorder = ChangeRecorderXML.create(); - } - else - { - throw new MojoExecutionException( "Only 'xml' or 'none' formats are supported for change recordings" ); - } + changeRecorder = "none".equals( this.changeRecorderFormat ) + ? new ChangeRecorderNull() + : "xml".equals( this.changeRecorderFormat ) + ? new ChangeRecorderXML() + : null; } return changeRecorder; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 807ebd4c36..1182945f14 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -52,6 +52,8 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; +import static java.util.Collections.singletonList; + /** * Compare dependency versions of the current project to dependencies or dependency management of a remote repository * project. Can optionally update locally the project instead of reporting the comparison @@ -182,36 +184,56 @@ protected void update( ModifiedPomXMLEventReader pom ) Map remoteDepsMap = new HashMap<>(); if ( !ignoreRemoteDependencyManagement ) { - List remoteProjectDepMgmtDeps = ( remoteMavenProject.getDependencyManagement() == null ) ? null - : remoteMavenProject.getDependencyManagement().getDependencies(); - mapDependencies( remoteDepsMap, remoteProjectDepMgmtDeps ); + List remoteProjectDepMgmtDeps = remoteMavenProject.getDependencyManagement() == null + ? null + : remoteMavenProject.getDependencyManagement().getDependencies(); + if ( remoteProjectDepMgmtDeps != null ) + { + remoteProjectDepMgmtDeps.forEach( dep -> remoteDepsMap.putIfAbsent( dep.getManagementKey(), dep ) ); + } } - if ( !ignoreRemoteDependencies ) + if ( !ignoreRemoteDependencies && remoteMavenProject.getDependencies() != null ) { - List remoteProjectDeps = remoteMavenProject.getDependencies(); - mapDependencies( remoteDepsMap, remoteProjectDeps ); + remoteMavenProject.getDependencies().forEach( dep -> + remoteDepsMap.putIfAbsent( dep.getManagementKey(), dep ) ); } List totalDiffs = new ArrayList<>(); List propertyDiffs = new ArrayList<>(); if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) { - List depManDiffs = - compareVersions( pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap ); - totalDiffs.addAll( depManDiffs ); + totalDiffs.addAll( + compareVersions( pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap ) ); } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - List depDiffs = compareVersions( pom, getProject().getDependencies(), remoteDepsMap ); - totalDiffs.addAll( depDiffs ); + totalDiffs.addAll( compareVersions( pom, getProject().getDependencies(), remoteDepsMap ) ); } if ( updatePropertyVersions ) { Map versionProperties = this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() .withMavenProject( getProject() ).build() ); - List diff = updatePropertyVersions( pom, versionProperties, remoteDepsMap ); - propertyDiffs.addAll( diff ); + propertyDiffs.addAll( updatePropertyVersions( pom, versionProperties, remoteDepsMap ) ); + } + if ( getProject().getParent() != null + && remoteMavenProject.getParent() != null + && isProcessingParent() ) + { + Dependency parent = DependencyBuilder.newBuilder() + .withGroupId( remoteMavenProject.getParentArtifact().getGroupId() ) + .withArtifactId( remoteMavenProject.getParentArtifact().getArtifactId() ) + .withVersion( remoteMavenProject.getParentArtifact().getVersion() ) + .withType( remoteMavenProject.getParentArtifact().getType() ) + .withScope( remoteMavenProject.getParentArtifact().getScope() ) + .withClassifier( remoteMavenProject.getParentArtifact().getClassifier() ) + .build(); + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Processing parent dependency: " + parent ); + } + remoteDepsMap.putIfAbsent( parent.getManagementKey(), parent ); + totalDiffs.addAll( compareVersions( pom, singletonList( getParentDependency() ), remoteDepsMap ) ); } if ( reportMode ) @@ -271,19 +293,13 @@ private List compareVersions( ModifiedPomXMLEventReader pom, List map, List deps ) - { - if ( deps != null ) - { - for ( Dependency nextDep : deps ) - { - map.put( nextDep.getManagementKey(), nextDep ); - } - } - } - /** * Creates a key that is similar to what {@link Dependency#getManagementKey()} generates for a dependency. */ diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index da5b9a0b8a..75edfbb470 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -488,7 +488,6 @@ public void execute() throws MojoExecutionException, MojoFailureException { logInit(); - validateInput(); Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); @@ -599,7 +598,8 @@ public void execute() } } - private void validateInput() throws MojoExecutionException + @Override + protected void validateInput() throws MojoExecutionException { validateGAVList( dependencyIncludes, 6, "dependencyIncludes" ); validateGAVList( dependencyExcludes, 6, "dependencyExcludes" ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 56c9812643..564817c333 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -32,16 +31,19 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static java.util.Collections.singletonList; + /** * Replaces any -SNAPSHOT versions with a release version, older if necessary (if there has been a release). * @@ -52,13 +54,13 @@ public class ForceReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { - - // ------------------------------ FIELDS ------------------------------ - /** - * Pattern to match a snapshot version. + * Whether to fail if a SNAPSHOT could not be replaced + * + * @since 2.14.0 */ - private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + @Parameter( property = "failIfNotReplaced", defaultValue = "false" ) + protected boolean failIfNotReplaced; // ------------------------------ METHODS -------------------------- @@ -92,6 +94,10 @@ protected void update( ModifiedPomXMLEventReader pom ) { useReleases( pom, getProject().getDependencies() ); } + if ( getProject().getParent() != null && isProcessingParent() ) + { + useReleases( pom, singletonList( getParentDependency() ) ); + } } catch ( ArtifactMetadataRetrievalException e ) { @@ -116,8 +122,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection continue; } - String version = dep.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); + Matcher versionMatcher = SNAPSHOT_REGEX.matcher( dep.getVersion() ); if ( versionMatcher.matches() ) { String releaseVersion = versionMatcher.group( 1 ); @@ -131,23 +136,24 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); if ( versions.containsVersion( releaseVersion ) ) { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - releaseVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + releaseVersion ); - } + updateDependencyVersion( pom, dep, releaseVersion, "forceReleases" ); } else { - ArtifactVersion[] v = versions.getVersions( false ); - if ( v.length == 0 ) + ArtifactVersion newestRelease = versions.getNewestVersion( (VersionRange) null, null, + false, true ); + if ( newestRelease == null ) { getLog().info( "No release of " + toString( dep ) + " to force." ); + if ( failIfNotReplaced ) + { + throw new MojoExecutionException( "No matching release of " + toString( dep ) + + " found for update." ); + } } - else if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - v[v.length - 1].toString(), getProject().getModel() ) ) + else { - getLog().info( "Reverted " + toString( dep ) + " to version " + v[v.length - 1].toString() ); + updateDependencyVersion( pom, dep, newestRelease.toString(), "forceReleases" ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 9e17a35942..1e57f49ba2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -59,7 +59,7 @@ public class LockSnapshotsMojo /** * Pattern to match a timestamped snapshot version. For example 1.0-20090128.202731-1 */ - private final Pattern matchSnapshotRegex = Pattern.compile( "-" + Artifact.SNAPSHOT_VERSION ); + private static final Pattern TIMESTAMPED_SNAPSHOT_REGEX = Pattern.compile( "-" + Artifact.SNAPSHOT_VERSION ); // ------------------------------ METHODS -------------------------- @@ -120,7 +120,7 @@ private void lockSnapshots( ModifiedPomXMLEventReader pom, Collection de } String version = dep.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( version ); if ( versionMatcher.find() && versionMatcher.end() == version.length() ) { String unlockedVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); @@ -153,7 +153,7 @@ private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject p Artifact parentArtifact = parent.getArtifact(); String parentVersion = parentArtifact.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( parentVersion ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( parentVersion ); if ( versionMatcher.find() && versionMatcher.end() == parentVersion.length() ) { String unlockedParentVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index ccd389e0ad..9c6b649c0e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -37,9 +37,10 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static java.util.Collections.singletonList; + /** * Updates a dependency to a specific version. * This can be useful if you have to manage versions for a very large (100+ module) projects where you can’t always use @@ -107,6 +108,11 @@ protected void update( ModifiedPomXMLEventReader pom ) { useDepVersion( pom, getProject().getDependencies() ); } + + if ( getProject().getParent() != null && isProcessingParent() ) + { + useDepVersion( pom, singletonList( getParentDependency() ) ); + } } catch ( ArtifactMetadataRetrievalException e ) { @@ -146,17 +152,7 @@ private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { @@ -172,7 +159,7 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection !matchSnapshotRegex.matcher( dep.getVersion() ).matches() ); + dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 8e64ab4915..0e4249a178 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -22,21 +22,15 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.Optional; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -44,16 +38,13 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; -import org.codehaus.mojo.versions.ordering.VersionComparator; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; +import static java.util.Optional.empty; /** * Replaces any release versions with the latest snapshot version (if it has been deployed). @@ -63,7 +54,7 @@ */ @Mojo( name = "use-latest-snapshots", threadSafe = true ) public class UseLatestSnapshotsMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { /** @@ -93,13 +84,6 @@ public class UseLatestSnapshotsMojo @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) protected boolean allowIncrementalUpdates; - // ------------------------------ FIELDS ------------------------------ - - /** - * Pattern to match a snapshot version. - */ - private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); - // ------------------------------ METHODS -------------------------- @Inject @@ -134,12 +118,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - useLatestSnapshots( pom, singletonList( DependencyBuilder.newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( getProject().getParent().getVersion() ) - .withType( "pom" ) - .build() ) ); + useLatestSnapshots( pom, singletonList( getParentDependency() ) ); } } catch ( ArtifactMetadataRetrievalException e ) @@ -149,101 +128,27 @@ protected void update( ModifiedPomXMLEventReader pom ) } private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); - if ( !versionMatcher.matches() ) - { - getLog().debug( "Looking for latest snapshot of " + toString( dep ) ); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - ArtifactVersion selectedVersion = new DefaultArtifactVersion( version ); - - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - final VersionComparator versionComparator = versions.getVersionComparator(); - final DefaultArtifactVersion lowerBound = new DefaultArtifactVersion( version ); - if ( unchangedSegment.isPresent() - && unchangedSegment.get().value() >= versionComparator.getSegmentCount( lowerBound ) ) - { - getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); - continue; - } - ArtifactVersion upperBound = unchangedSegment - .map( s -> - (ArtifactVersion) new BoundArtifactVersion( lowerBound, Segment.of( s.value() + 1 ) ) ) - .orElse( null ); - - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - ArtifactVersion[] newer = versions.getVersions( restriction, true ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - - // TODO consider creating a search + filter in the Details services to get latest snapshot. - String latestVersion; - ArrayList snapshotsOnly = new ArrayList<>(); - - for ( ArtifactVersion artifactVersion : newer ) - { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) - { - snapshotsOnly.add( artifactVersion ); - } - } - ArtifactVersion[] filteredVersions = snapshotsOnly.toArray( - new ArtifactVersion[snapshotsOnly.size()] ); - if ( filteredVersions.length > 0 ) + useLatestVersions( pom, dependencies, + ( dep, versions ) -> { - latestVersion = filteredVersions[filteredVersions.length - 1].toString(); - if ( getProject().getParent() != null ) + try { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) - { - if ( PomHelper.setProjectParentVersion( pom, latestVersion ) ) - { - getLog().debug( "Made parent update from " + version + " to " + latestVersion ); - - this.getChangeRecorder() - .recordUpdate( "useLatestSnapshots", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), version, latestVersion ); - } - } + return Arrays.stream( versions.getNewerVersions( dep.getVersion(), unchangedSegment, + true, false ) ) + .filter( v -> SNAPSHOT_REGEX.matcher( v.toString() ).matches() ) + .max( Comparator.naturalOrder() ); } - - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - latestVersion, getProject().getModel() ) ) + catch ( InvalidSegmentException e ) { - getLog().info( "Updated " + toString( dep ) + " to version " + latestVersion ); - - this.getChangeRecorder().recordUpdate( "useLatestSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, latestVersion ); + getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); + return empty(); } - } - } - } + }, + "useLatestSnapshots", dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index f5009dc2ee..d5fb92067a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -42,7 +42,6 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.SegmentUtils; import static java.util.Collections.singletonList; @@ -145,12 +144,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - useLatestVersions( pom, singletonList( DependencyBuilder.newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( getProject().getParent().getVersion() ) - .withType( "pom" ) - .build() ) ); + useLatestVersions( pom, singletonList( getParentDependency() ) ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -159,7 +153,6 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - @SuppressWarnings( "unchecked" ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 05a657a623..90f0deb7ac 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -39,7 +39,6 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -110,37 +109,12 @@ protected final void useLatestVersions( ModifiedPomXMLEventReader pom, ArtifactVersion selectedVersion = new DefaultArtifactVersion( dep.getVersion() ); getLog().debug( "Selected version:" + selectedVersion ); - getLog().debug( "Looking for newer versions of " + toString( dep ) ); ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); Optional newestVer = newestVersionProducer.apply( dep, versions ); if ( newestVer.isPresent() ) { - String verStr = newestVer.get().toString(); - if ( getProject().getParent() != null ) - { - final Artifact parentArtifact = getProject().getParentArtifact(); - if ( artifact.getId().equals( parentArtifact.getId() ) && isProcessingParent() ) - { - if ( PomHelper.setProjectParentVersion( pom, verStr ) ) - { - getLog().debug( "Made parent update from " + dep.getVersion() + " to " + verStr ); - - this.getChangeRecorder().recordUpdate( changeRecorderTitle, parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), dep.getVersion(), - verStr ); - } - } - } - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - verStr, - getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + verStr ); - - this.getChangeRecorder().recordUpdate( changeRecorderTitle, dep.getGroupId(), - dep.getArtifactId(), dep.getVersion(), verStr ); - } + updateDependencyVersion( pom, dep, newestVer.get().toString(), changeRecorderTitle ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 149cc23f0f..0045193de5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -23,25 +23,23 @@ import javax.xml.stream.XMLStreamException; import java.util.Collection; -import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static java.util.Collections.singletonList; +import static java.util.Optional.of; + /** * Replaces any release versions with the next release version (if it has been released). * @@ -50,7 +48,7 @@ */ @Mojo( name = "use-next-releases", threadSafe = true ) public class UseNextReleasesMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { // ------------------------------ FIELDS ------------------------------ @@ -90,53 +88,17 @@ protected void update( ModifiedPomXMLEventReader pom ) { useNextReleases( pom, getProject().getDependencies() ); } + if ( getProject().getParent() != null && isProcessingParent() ) + { + useNextReleases( pom, singletonList( getParentDependency() ) ); + } } private void useNextReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Matcher versionMatcher = MATCH_SNAPSHOT_REGEX.matcher( version ); - if ( !versionMatcher.matches() ) - { - getLog().debug( "Looking for newer versions of " + toString( dep ) ); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - ArtifactVersion[] newer = versions.getNewerVersions( version, false ); - if ( newer.length > 0 ) - { - String newVersion = newer[0].toString(); - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) - - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useNextReleases", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); - } - } - } - } + useLatestVersions( pom, dependencies, + ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), false )[0] ), + "useNextReleases", dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index b7482490ca..3546193a89 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -25,17 +25,11 @@ import java.util.Arrays; import java.util.Collection; import java.util.Optional; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -43,14 +37,14 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; -import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; -import org.codehaus.mojo.versions.ordering.VersionComparator; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; +import static java.util.Collections.singletonList; +import static java.util.Optional.empty; + /** * Replaces any release versions with the next snapshot version (if it has been deployed). * @@ -59,7 +53,7 @@ */ @Mojo( name = "use-next-snapshots", threadSafe = true ) public class UseNextSnapshotsMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { /** @@ -89,13 +83,6 @@ public class UseNextSnapshotsMojo @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) private boolean allowIncrementalUpdates; - // ------------------------------ FIELDS ------------------------------ - - /** - * Pattern to match a snapshot version. - */ - private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); - // ------------------------------ METHODS -------------------------- @Inject @@ -106,6 +93,8 @@ public UseNextSnapshotsMojo( RepositorySystem repositorySystem, ArtifactResolver artifactResolver ) { super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots + allowSnapshots = true; } /** @@ -128,6 +117,10 @@ protected void update( ModifiedPomXMLEventReader pom ) { useNextSnapshots( pom, getProject().getDependencies() ); } + if ( getProject().getParent() != null && isProcessingParent() ) + { + useNextSnapshots( pom, singletonList( getParentDependency() ) ); + } } catch ( ArtifactMetadataRetrievalException e ) { @@ -136,74 +129,28 @@ protected void update( ModifiedPomXMLEventReader pom ) } private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); - if ( !versionMatcher.matches() ) - { - getLog().debug( "Looking for next snapshot of " + toString( dep ) ); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - final VersionComparator versionComparator = versions.getVersionComparator(); - final DefaultArtifactVersion lowerBound = new DefaultArtifactVersion( version ); - if ( unchangedSegment.isPresent() - && unchangedSegment.get().value() >= versionComparator.getSegmentCount( lowerBound ) ) - { - getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); - continue; - } - - ArtifactVersion upperBound = unchangedSegment - .map( s -> - (ArtifactVersion) new BoundArtifactVersion( lowerBound, Segment.of( s.value() + 1 ) ) ) - .orElse( null ); - - getLog().info( "Upper bound: " + ( upperBound == null ? "none" : upperBound.toString() ) ); - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - ArtifactVersion[] newer = versions.getVersions( restriction, true ); - getLog().debug( "Candidate versions " + Arrays.asList( newer ) ); - for ( ArtifactVersion artifactVersion : newer ) + useLatestVersions( pom, dependencies, + ( dep, versions ) -> { - String newVersion = artifactVersion.toString(); - if ( matchSnapshotRegex.matcher( newVersion ).matches() ) + try { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - newVersion, getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useNextSnapshots", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); - } - break; + return Arrays.stream( versions.getNewerVersions( dep.getVersion(), unchangedSegment, + true, false ) ) + .filter( v -> SNAPSHOT_REGEX.matcher( v.toString() ).matches() ) + .findFirst(); } - } - } - } + catch ( InvalidSegmentException e ) + { + getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); + return empty(); + } + }, + "useNextSnapshots", dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index ba0223cf98..81c9fbaa50 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -24,22 +24,21 @@ import java.util.Collection; -import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import static java.util.Collections.singletonList; +import static java.util.Optional.of; + /** * Replaces any version with the latest version. * @@ -48,7 +47,7 @@ */ @Mojo( name = "use-next-versions", threadSafe = true ) public class UseNextVersionsMojo - extends AbstractVersionsDependencyUpdaterMojo + extends UseLatestVersionsMojoBase { // ------------------------------ METHODS -------------------------- @@ -83,6 +82,10 @@ protected void update( ModifiedPomXMLEventReader pom ) { useNextVersions( pom, getProject().getDependencies() ); } + if ( getProject().getParent() != null && isProcessingParent() ) + { + useNextVersions( pom, singletonList( getParentDependency() ) ); + } } catch ( ArtifactMetadataRetrievalException e ) { @@ -91,45 +94,10 @@ protected void update( ModifiedPomXMLEventReader pom ) } private void useNextVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); - continue; - } - - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); - continue; - } - - String version = dep.getVersion(); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { - continue; - } - - getLog().debug( "Looking for newer versions of " + toString( dep ) ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - ArtifactVersion[] newer = versions.getNewerVersions( version, Boolean.TRUE.equals( allowSnapshots ) ); - if ( newer.length > 0 ) - { - String newVersion = newer[0].toString(); - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, newVersion, - getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); - - this.getChangeRecorder().recordUpdate( "useNextVersions", dep.getGroupId(), - dep.getArtifactId(), version, newVersion ); - } - } - } + useLatestVersions( pom, dependencies, + ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), allowSnapshots )[0] ), + "useNextVersions" ); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 6e71ff0aaa..eac9aac15e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -22,10 +22,10 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.util.Arrays; import java.util.Collection; -import java.util.NoSuchElementException; +import java.util.Optional; import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -38,13 +38,13 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.DependencyBuilder; + +import static java.util.Collections.singletonList; /** * Replaces any -SNAPSHOT versions with the corresponding release version (if it has been released). @@ -58,7 +58,11 @@ public class UseReleasesMojo { /** - * Whether to check for releases within the range. + *

    When set to {@code true}, will use the highest found release version matching a string + * starting with the current version string without {@code -SNAPSHOT}.

    + *

    For example, if the current version is {@code 1.1-SNAPSHOT}, will match all versions + * starting with {@code 1.1}, i.e. {@code 1.1}, {@code 1.1.1}, {@code 1.1.2}, {@code 1.1.3.1}, etc., + * and will select the highest found version, i.e. {@code 1.1.3.1}.

    * * @since 2.3 */ @@ -71,14 +75,7 @@ public class UseReleasesMojo * @since 2.3 */ @Parameter( property = "failIfNotReplaced", defaultValue = "false" ) - private boolean failIfNotReplaced; - - // ------------------------------ FIELDS ------------------------------ - - /** - * Pattern to match a snapshot version. - */ - private final Pattern matchSnapshotRegex = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + protected boolean failIfNotReplaced; // ------------------------------ METHODS -------------------------- @@ -104,11 +101,6 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getParent() != null && isProcessingParent() ) - { - useReleases( pom, getProject().getParent() ); - } - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) { useReleases( pom, PomHelper.readImportedPOMsFromDependencyManagementSection( pom ) ); @@ -118,6 +110,10 @@ protected void update( ModifiedPomXMLEventReader pom ) { useReleases( pom, getProject().getDependencies() ); } + if ( getProject().getParent() != null && isProcessingParent() ) + { + useReleases( pom, singletonList( getParentDependency() ) ); + } } catch ( ArtifactMetadataRetrievalException e ) { @@ -125,86 +121,6 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useReleases( ModifiedPomXMLEventReader pom, MavenProject project ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException - { - String version = project.getVersion(); - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); - if ( versionMatcher.matches() ) - { - String releaseVersion = versionMatcher.group( 1 ); - - final MavenProject parent = getProject().getParent(); - - Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( parent.getGroupId() ) - .withArtifactId( parent.getArtifactId() ) - .withVersion( releaseVersion ) - .withType( "pom" ) - .build() ); - if ( !isIncluded( artifact ) ) - { - return; - } - - getLog().debug( "Looking for a release of " + toString( project ) ); - // Force releaseVersion version because org.apache.maven.artifact.metadata.MavenMetadataSource does not - // retrieve release version if provided snapshot version. - artifact.setVersion( releaseVersion ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - if ( !allowRangeMatching ) // standard behaviour - { - if ( versions.containsVersion( releaseVersion ) ) - { - if ( PomHelper.setProjectParentVersion( pom, releaseVersion ) ) - { - getLog().info( "Updated " + toString( project ) + " to version " + releaseVersion ); - } - } - else if ( failIfNotReplaced ) - { - throw new NoSuchElementException( "No matching release of " + toString( project ) - + " found for update." ); - } - } - else - { - ArtifactVersion finalVersion = null; - for ( ArtifactVersion proposedVersion : versions.getVersions( false ) ) - { - if ( proposedVersion.toString().startsWith( releaseVersion ) ) - { - getLog().debug( "Found matching version for " + toString( project ) + " to version " - + releaseVersion ); - finalVersion = proposedVersion; - } - } - - if ( finalVersion != null ) - { - if ( PomHelper.setProjectParentVersion( pom, finalVersion.toString() ) ) - { - getLog().info( "Updated " + toString( project ) + " to version " + finalVersion ); - - this.getChangeRecorder().recordUpdate( "useReleases", parent.getGroupId(), - parent.getArtifactId(), version, - finalVersion.toString() ); - } - } - else - { - getLog().info( "No matching release of " + toString( project ) + " to update via rangeMatching." ); - if ( failIfNotReplaced ) - { - throw new NoSuchElementException( "No matching release of " + toString( project ) - + " found for update via rangeMatching." ); - } - } - - } - } - } - private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { @@ -228,7 +144,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection getLog().info( "Ignoring dependency with no version: " + toString( dep ) ); continue; } - Matcher versionMatcher = matchSnapshotRegex.matcher( version ); + Matcher versionMatcher = SNAPSHOT_REGEX.matcher( version ); if ( versionMatcher.matches() ) { String releaseVersion = versionMatcher.group( 1 ); @@ -242,72 +158,36 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection // Force releaseVersion version because org.apache.maven.artifact.metadata.MavenMetadataSource does not // retrieve release version if provided snapshot version. artifact.setVersion( releaseVersion ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - if ( !allowRangeMatching ) // standard behaviour + Optional targetVersion = findReleaseVersion( pom, dep, version, releaseVersion, + getHelper().lookupArtifactVersions( artifact, false ) ); + if ( targetVersion.isPresent() ) { - noRangeMatching( pom, dep, version, releaseVersion, versions ); + updateDependencyVersion( pom, dep, targetVersion.get(), "useReleases" ); } else { - rangeMatching( pom, dep, version, releaseVersion, versions ); + getLog().info( "No matching release of " + toString( dep ) + " to update." ); + if ( failIfNotReplaced ) + { + throw new MojoExecutionException( "No matching release of " + toString( dep ) + + " found for update" ); + } } } } } - private void rangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, String version, String releaseVersion, - ArtifactVersions versions ) throws XMLStreamException, MojoExecutionException + private Optional findReleaseVersion( ModifiedPomXMLEventReader pom, Dependency dep, String version, + String releaseVersion, ArtifactVersions versions ) { - ArtifactVersion finalVersion = null; - for ( ArtifactVersion proposedVersion : versions.getVersions( false ) ) - { - if ( proposedVersion.toString().startsWith( releaseVersion ) ) - { - getLog().debug( "Found matching version for " + toString( dep ) + " to version " + releaseVersion ); - finalVersion = proposedVersion; - } - } - - if ( finalVersion != null ) - { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - finalVersion.toString(), getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + finalVersion ); - - this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), - dep.getArtifactId(), version, finalVersion.toString() ); - } - } - else - { - getLog().info( "No matching release of " + toString( dep ) + " to update via rangeMatching." ); - if ( failIfNotReplaced ) - { - throw new NoSuchElementException( "No matching release of " + toString( dep ) - + " found for update via rangeMatching." ); - } - } + return !allowRangeMatching + ? versions.containsVersion( releaseVersion ) + ? Optional.of( releaseVersion ) + : Optional.empty() + : Arrays.stream( versions.getVersions( false ) ) + .sorted( ( v1, v2 ) -> -( v1.compareTo( v2 ) ) ) + .filter( v -> v.toString().startsWith( releaseVersion ) ) + .findFirst() + .map( ArtifactVersion::toString ); } - - private void noRangeMatching( ModifiedPomXMLEventReader pom, Dependency dep, String version, String releaseVersion, - ArtifactVersions versions ) throws XMLStreamException, MojoExecutionException - { - if ( versions.containsVersion( releaseVersion ) ) - { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, releaseVersion, - getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + releaseVersion ); - - this.getChangeRecorder().recordUpdate( "useReleases", dep.getGroupId(), - dep.getArtifactId(), version, releaseVersion ); - } - } - else if ( failIfNotReplaced ) - { - throw new NoSuchElementException( "No matching release of " + toString( dep ) + " found for update." ); - } - } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 2193ddef18..a43033af52 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -64,10 +64,6 @@ public abstract class AbstractVersionsReportRenderer extends VersionsReportRe protected ArtifactVersionsCache allUpdatesCache = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); - /** - * Constructor to be called by the dependency injection framework - * @param i18n i18n object to be injected - */ protected AbstractVersionsReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, T model ) { super( sink, i18n, locale, bundleName ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java index c762b2efb8..1b977ecc5c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java @@ -32,6 +32,7 @@ public interface ReportRendererFactory /** * Creates a new {@linkplain ReportRenderer} instance for the given report renderer name. * + * @param class of the model being rendered * @param concrete class of the report renderer * @param reportName name of the report to generate * @param sink sink to use for rendering diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java new file mode 100644 index 0000000000..e1af267f61 --- /dev/null +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -0,0 +1,199 @@ +package org.codehaus.mojo.versions; + +import javax.xml.stream.XMLStreamException; + +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.ArtifactStubFactory; +import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; +import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.startsWith; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mockStatic; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Unit tests for {@link ForceReleasesMojo} + */ +public class ForceReleasesMojoTest extends AbstractMojoTestCase +{ + private TestChangeRecorder changeRecorder; + private ForceReleasesMojo mojo; + + @Before + public void setUp() throws IllegalAccessException + { + changeRecorder = new TestChangeRecorder(); + mojo = new ForceReleasesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource(), + null, new StubArtifactResolver( new ArtifactStubFactory(), + false, false ) ); + setVariableValueToObject( mojo, "reactorProjects", emptyList() ); + setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); + mojo.project = new MavenProject() + {{ + setModel( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "default-artifact" ); + setVersion( "1.0.0" ); + }} ); + }}; + } + + @Test + public void testProcessParent() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processParent", true ); + mojo.getProject().setParent( new MavenProject( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "artifactA" ); + setVersion( "1.0.0-SNAPSHOT" ); + }} ) ); + mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "artifactA", + "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + } + + @Test + public void testReplaceSnapshotWithRelease() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "artifactA" ) + .withVersion( "1.0.0-SNAPSHOT" ) + .build() ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + } + + @Test + public void testUpgrade() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "artifactA" ) + .withVersion( "1.1.0-SNAPSHOT" ) + .build() ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "1.1.0-SNAPSHOT", "2.0.0" ) ) ); + } + + @Test + public void testDowngrade() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "artifactA" ) + .withVersion( "2.1.0-SNAPSHOT" ) + .build() ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "2.1.0-SNAPSHOT", "2.0.0" ) ) ); + } + + @Test + public void testFailIfNotReplaced() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.artifactMetadataSource = mockArtifactMetadataSource( singletonMap( "test-artifact", + new String[] {} ) ); + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "test-artifact" ) + .withVersion( "1.0.0-SNAPSHOT" ) + .build() ) ); + mojo.failIfNotReplaced = true; + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + fail( "MojoExecutionException is expected" ); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), startsWith( "No matching" ) ); + } + } +} diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index beb93a2b89..5e880c70ed 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import org.mockito.MockedStatic; +import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; @@ -59,6 +60,7 @@ public void setUp() throws Exception null, null ) {{ + reactorProjects = emptyList(); MavenProject project = new MavenProject() {{ setModel( new Model() diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index ac0a033d92..98c5a34f1a 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.mockito.MockedStatic; +import static java.util.Collections.emptyList; import static java.util.Collections.singleton; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; @@ -71,6 +72,7 @@ public void setUp() throws Exception null, null ) {{ + reactorProjects = emptyList(); MavenProject project = new MavenProject() {{ setModel( new Model() @@ -90,10 +92,10 @@ public void setUp() throws Exception }} ); }}; setProject( project ); - - changeRecorder = new TestChangeRecorder(); - setVariableValueToObject( this, "changeRecorder", changeRecorder ); }}; + changeRecorder = new TestChangeRecorder(); + setVariableValueToObject( mojo, "processDependencyManagement", false ); + setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java new file mode 100644 index 0000000000..d59da171ab --- /dev/null +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -0,0 +1,155 @@ +package org.codehaus.mojo.versions; + +import javax.xml.stream.XMLStreamException; + +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.ArtifactStubFactory; +import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; +import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.utils.DependencyBuilder; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockedStatic; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; +import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; +import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.startsWith; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mockStatic; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Unit tests for {@link UseReleasesMojo} + */ +public class UseReleasesMojoTest extends AbstractMojoTestCase +{ + private TestChangeRecorder changeRecorder; + private UseReleasesMojo mojo; + + @Before + public void setUp() throws IllegalAccessException + { + changeRecorder = new TestChangeRecorder(); + mojo = new UseReleasesMojo( mockRepositorySystem(), + null, mockArtifactMetadataSource(), + null, new StubArtifactResolver( new ArtifactStubFactory(), + false, false ) ); + setVariableValueToObject( mojo, "reactorProjects", emptyList() ); + setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); + mojo.project = new MavenProject() + {{ + setModel( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "default-artifact" ); + setVersion( "1.0.0" ); + }} ); + }}; + } + + @Test + public void testProcessParent() + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + { + setVariableValueToObject( mojo, "processParent", true ); + mojo.getProject().setParent( new MavenProject( new Model() + {{ + setGroupId( "default-group" ); + setArtifactId( "artifactA" ); + setVersion( "1.0.0-SNAPSHOT" ); + }} ) ); + mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "artifactA", + "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + } + + @Test + public void testReplaceSnapshotWithRelease() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "artifactA" ) + .withVersion( "1.0.0-SNAPSHOT" ) + .build() ) ); + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + } + assertThat( changeRecorder.getChanges(), + hasItem( new VersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + } + + @Test + public void testFailIfNotReplaced() + throws MojoExecutionException, XMLStreamException, MojoFailureException + { + mojo.artifactMetadataSource = mockArtifactMetadataSource( singletonMap( "test-artifact", + new String[] {} ) ); + mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() + .withGroupId( "default-group" ) + .withArtifactId( "test-artifact" ) + .withVersion( "1.0.0-SNAPSHOT" ) + .build() ) ); + mojo.failIfNotReplaced = true; + + try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) + { + pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), + anyString(), any( Model.class ) ) ) + .thenReturn( true ); + mojo.update( null ); + fail( "MojoExecutionException is expected" ); + } + catch ( MojoExecutionException e ) + { + assertThat( e.getMessage(), startsWith( "No matching" ) ); + } + } +} From 823043401cf0fbfaad65c0d0e894a9927af67ebd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 13:03:05 +0000 Subject: [PATCH 208/441] Bump mockito-inline from 4.8.1 to 4.9.0 Bumps [mockito-inline](https://github.com/mockito/mockito) from 4.8.1 to 4.9.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.8.1...v4.9.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-inline dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d2955b8d05..5f2072ff36 100644 --- a/pom.xml +++ b/pom.xml @@ -182,7 +182,7 @@ org.mockito mockito-inline - 4.8.1 + 4.9.0 org.hamcrest From 02d88b877aaa2c883089035a23941676f2e66230 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sat, 19 Nov 2022 10:33:16 +0100 Subject: [PATCH 209/441] Make includeParent false by default to retain backward compatibility. --- .../codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java | 4 ++-- .../org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java | 4 ++-- .../mojo/versions/DisplayPropertyUpdatesMojoTest.java | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 65a183dc48..c39f11ac1e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -131,11 +131,11 @@ public class DisplayPropertyUpdatesMojo private boolean allowIncrementalUpdates; /** - *

    Whether to include property updates from parent.

    + *

    Whether to include property updates from parent. Default: {@code false}

    * * @since 2.14.0 */ - @Parameter( property = "includeParent", defaultValue = "true" ) + @Parameter( property = "includeParent", defaultValue = "false" ) protected boolean includeParent = true; // -------------------------- STATIC METHODS -------------------------- diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 4469b1da37..d106eb8fda 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -92,11 +92,11 @@ public class PropertyUpdatesReportMojo extends AbstractVersionsReportWhether to include property updates from parent.

    + *

    Whether to include property updates from parent. Default: {@code false}

    * * @since 2.14.0 */ - @Parameter( property = "includeParent", defaultValue = "true" ) + @Parameter( property = "includeParent", defaultValue = "false" ) private boolean includeParent = true; /** diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java index f306faed95..c9f896a110 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java @@ -81,6 +81,7 @@ public void testPropertiesFromParent() throws Exception mojo.outputFile = tempFile.toFile(); mojo.setPluginContext( new HashMap<>() ); mojo.artifactMetadataSource = MockUtils.mockArtifactMetadataSource(); + mojo.includeParent = true; mojo.execute(); assertThat( String.join( "", Files.readAllLines( tempFile ) ), From 61c1f9703281cd402ba0604e992a46386ed877da Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 11 Nov 2022 08:28:36 +0100 Subject: [PATCH 210/441] Issue #134: Removing the patch: no longer needed; PomHelper.getRawModel can be used instead. Adding more integration tests. --- .../codehaus/mojo/versions/api/PomHelper.java | 75 ------------------- .../mojo/versions/api/PomHelperTest.java | 35 --------- ...elperTest.dependencyManagementBOMs.pom.xml | 37 --------- .../dummy-api-3.4.0-20090311.051742-1.pom | 49 ++++++++++++ .../src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom | 2 +- .../src/it-repo/dummy-bom-pom-2.0.pom | 26 +++++++ .../src/it-repo/dummy-bom2-1.0.0-SNAPSHOT.pom | 12 +++ .../src/it-repo/dummy-bom2-1.0.0.pom | 12 +++ .../src/it-repo/dummy-bom2-1.1.0.pom | 12 +++ .../src/it-repo/dummy-bom2-2.0.0.pom | 12 +++ .../src/it-repo/dummy-bom2-3.0.0-SNAPSHOT.pom | 12 +++ .../invoker.properties | 1 + .../it/it-force-releases-issue-134/pom.xml | 22 ++++++ .../it-force-releases-issue-134/verify.groovy | 4 + .../invoker.properties | 1 + .../it/it-unlock-snapshots-issue-134/pom.xml | 22 ++++++ .../verify.groovy | 4 + .../invoker.properties | 2 + .../it/it-use-dep-version-issue-134/pom.xml | 23 ++++++ .../verify.groovy | 4 + .../invoker.properties | 1 + .../it-use-latest-releases-issue-134/pom.xml | 23 ++++++ .../verify.groovy | 4 + .../invoker.properties | 2 + .../it-use-latest-snapshots-issue-134/pom.xml | 22 ++++++ .../verify.groovy | 4 + .../invoker.properties | 1 + .../it-use-latest-versions-issue-134/pom.xml | 23 ++++++ .../verify.groovy | 4 + .../invoker.properties | 1 + .../it/it-use-next-releases-issue-134/pom.xml | 23 ++++++ .../verify.groovy | 4 + .../invoker.properties | 2 + .../it-use-next-snapshots-issue-134/pom.xml | 22 ++++++ .../verify.groovy | 5 ++ .../invoker.properties | 1 + .../src/it/it-use-releases-issue-134/pom.xml | 22 ++++++ .../it-use-releases-issue-134/verify.groovy | 4 + .../mojo/versions/ForceReleasesMojo.java | 14 +++- .../mojo/versions/LockSnapshotsMojo.java | 30 ++++++-- .../mojo/versions/UnlockSnapshotsMojo.java | 19 ++++- .../mojo/versions/UseDepVersionMojo.java | 14 +++- .../mojo/versions/UseLatestReleasesMojo.java | 14 +++- .../mojo/versions/UseLatestSnapshotsMojo.java | 14 +++- .../mojo/versions/UseLatestVersionsMojo.java | 2 +- .../mojo/versions/UseNextReleasesMojo.java | 24 +++++- .../mojo/versions/UseNextSnapshotsMojo.java | 11 ++- .../mojo/versions/UseNextVersionsMojo.java | 14 +++- .../mojo/versions/UseReactorMojo.java | 13 +++- .../mojo/versions/UseReleasesMojo.java | 14 +++- .../mojo/versions/ForceReleasesMojoTest.java | 10 +++ .../versions/UseLatestReleasesMojoTest.java | 2 + .../mojo/versions/UseReleasesMojoTest.java | 6 ++ 53 files changed, 547 insertions(+), 189 deletions(-) delete mode 100644 versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml create mode 100644 versions-maven-plugin/src/it-repo/dummy-api-3.4.0-20090311.051742-1.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom-pom-2.0.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0-SNAPSHOT.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom2-1.1.0.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom2-2.0.0.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-bom2-3.0.0-SNAPSHOT.pom create mode 100644 versions-maven-plugin/src/it/it-force-releases-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-force-releases-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-force-releases-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-dep-version-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-dep-version-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-dep-version-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-latest-releases-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-latest-releases-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-latest-releases-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-latest-versions-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-next-releases-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-next-releases-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-next-releases-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-use-releases-issue-134/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-use-releases-issue-134/pom.xml create mode 100644 versions-maven-plugin/src/it/it-use-releases-issue-134/verify.groovy diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index bf9b8e9591..938ba9ee19 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -29,7 +29,6 @@ import java.io.Reader; import java.io.StringReader; import java.nio.file.Files; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -62,7 +61,6 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.RegexUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; @@ -1689,77 +1687,4 @@ public static String getGAV( Model model ) { return getGroupId( model ) + ":" + getArtifactId( model ) + ":" + getVersion( model ); } - - /** - * Reads imported POMs from the dependency management section. - * - * @param pom POM - * @return a non-null list of {@link Dependency} for each imported POM - * @throws XMLStreamException XML stream exception - * @see bug #134 - * @since 2.4 - */ - public static List readImportedPOMsFromDependencyManagementSection( ModifiedPomXMLEventReader pom ) - throws XMLStreamException - { - List importedPOMs = new ArrayList<>(); - Stack stack = new Stack<>(); - - String groupIdElement = "groupId"; - String artifactIdElement = "artifactId"; - String versionElement = "version"; - String typeElement = "type"; - String scopeElement = "scope"; - Set recognizedElements = - new HashSet<>( Arrays.asList( groupIdElement, artifactIdElement, versionElement, typeElement, - scopeElement ) ); - Map depData = new HashMap<>(); - - pom.rewind(); - - String depMgmtDependencyPath = "/project/dependencyManagement/dependencies/dependency"; - - while ( pom.hasNext() ) - { - XMLEvent event = pom.nextEvent(); - - if ( event.isStartElement() ) - { - final String elementName = event.asStartElement().getName().getLocalPart(); - String parent = ""; - if ( !stack.isEmpty() ) - { - parent = stack.peek(); - } - String currentPath = parent + "/" + elementName; - stack.push( currentPath ); - - if ( currentPath.startsWith( depMgmtDependencyPath ) && recognizedElements.contains( elementName ) ) - { - final String elementText = pom.getElementText().trim(); - depData.put( elementName, elementText ); - stack.pop(); - } - } - if ( event.isEndElement() ) - { - String path = stack.pop(); - if ( depMgmtDependencyPath.equals( path ) ) - { - if ( "pom".equals( depData.get( typeElement ) ) && "import".equals( depData.get( scopeElement ) ) ) - { - importedPOMs.add( DependencyBuilder.newBuilder() - .withGroupId( depData.get( groupIdElement ) ) - .withArtifactId( depData.get( artifactIdElement ) ) - .withVersion( depData.get( versionElement ) ) - .withType( depData.get( typeElement ) ) - .withScope( depData.get( scopeElement ) ) - .build() ); - } - depData.clear(); - } - } - } - return importedPOMs; - } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index 460883f855..4e50637ec6 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -25,10 +25,8 @@ import java.io.File; import java.io.StringReader; import java.net.URL; -import java.util.List; import java.util.Map; -import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.logging.SystemStreamLog; @@ -64,39 +62,6 @@ public static void setUpClass() INPUT_FACTORY.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); } - /** - * Tests if imported POMs are properly read from dependency management section. Such logic is required to resolve - * bug #134 - * - * @throws Exception if the test fails. - */ - @Test - public void testImportedPOMsRetrievedFromDependencyManagement() - throws Exception - { - URL url = getClass().getResource( "PomHelperTest.dependencyManagementBOMs.pom.xml" ); - assert url != null; - File file = new File( url.getPath() ); - StringBuilder input = PomHelper.readXmlFile( file ); - - XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); - - ModifiedPomXMLEventReader pom = new ModifiedPomXMLEventReader( input, inputFactory, file.getAbsolutePath() ); - - List dependencies = PomHelper.readImportedPOMsFromDependencyManagementSection( pom ); - - assertNotNull( dependencies ); - assertEquals( 1, dependencies.size() ); - - Dependency dependency = dependencies.get( 0 ); - assertEquals( "org.group1", dependency.getGroupId() ); - assertEquals( "artifact-pom", dependency.getArtifactId() ); - assertEquals( "1.0-SNAPSHOT", dependency.getVersion() ); - assertEquals( "import", dependency.getScope() ); - assertEquals( "pom", dependency.getType() ); - } - /** * Tests what happens when changing a long property substitution pattern, e.g. * MVERSIONS-44 diff --git a/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml b/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml deleted file mode 100644 index a3d776cb8e..0000000000 --- a/versions-common/src/test/resources/org/codehaus/mojo/versions/api/PomHelperTest.dependencyManagementBOMs.pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - 4.0.0 - - org.myorg - myorg-parent - 3.0-SNAPSHOT - - bug-79 - jar - extracts BOMs from dependency management - - - - org.group1 - artifact-pom - 1.0-SNAPSHOT - pom - import - - - org.group1 - artifact-jar - 1.0-SNAPSHOT - jar - import - - - org.group1 - artifact-pom-standard - 1.0-SNAPSHOT - pom - - - - diff --git a/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-20090311.051742-1.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-20090311.051742-1.pom new file mode 100644 index 0000000000..42ca02dd5f --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-20090311.051742-1.pom @@ -0,0 +1,49 @@ + + 4.0.0 + + localhost + dummy-api + 3.4.0-20090311.051742-1 + jar + + + + + + maven-clean-plugin + 2.2 + + + maven-compiler-plugin + 2.0.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-surefire-plugin + 2.4.2 + + + + + + diff --git a/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom index 6031608461..fe4859f8c2 100644 --- a/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom +++ b/versions-maven-plugin/src/it-repo/dummy-api-3.4.0-SNAPSHOT.pom @@ -4,7 +4,7 @@ localhost dummy-api - 3.1.5-SNAPSHOT + 3.4.0-SNAPSHOT jar diff --git a/versions-maven-plugin/src/it-repo/dummy-bom-pom-2.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom-pom-2.0.pom new file mode 100644 index 0000000000..a8505b22b7 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom-pom-2.0.pom @@ -0,0 +1,26 @@ + + 4.0.0 + + localhost + dummy-bom-pom + 2.0 + pom + + + + + org.apache.maven + maven-artifact + 2.0.9 + + + junit + junit + 4.1 + + + + + + diff --git a/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0-SNAPSHOT.pom new file mode 100644 index 0000000000..7df8fa659d --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0-SNAPSHOT.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + localhost + dummy-bom2 + 1.0.0-SNAPSHOT + pom + + diff --git a/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0.pom new file mode 100644 index 0000000000..b255aaf959 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom2-1.0.0.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + localhost + dummy-bom2 + 1.0.0 + pom + + diff --git a/versions-maven-plugin/src/it-repo/dummy-bom2-1.1.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom2-1.1.0.pom new file mode 100644 index 0000000000..f2742a8734 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom2-1.1.0.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + localhost + dummy-bom2 + 1.1.0 + pom + + diff --git a/versions-maven-plugin/src/it-repo/dummy-bom2-2.0.0.pom b/versions-maven-plugin/src/it-repo/dummy-bom2-2.0.0.pom new file mode 100644 index 0000000000..ed99f6f7c2 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom2-2.0.0.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + localhost + dummy-bom2 + 2.0.0 + pom + + diff --git a/versions-maven-plugin/src/it-repo/dummy-bom2-3.0.0-SNAPSHOT.pom b/versions-maven-plugin/src/it-repo/dummy-bom2-3.0.0-SNAPSHOT.pom new file mode 100644 index 0000000000..28b3d482fb --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-bom2-3.0.0-SNAPSHOT.pom @@ -0,0 +1,12 @@ + + + 4.0.0 + + localhost + dummy-bom2 + 3.0.0-SNAPSHOT + pom + + diff --git a/versions-maven-plugin/src/it/it-force-releases-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-force-releases-issue-134/invoker.properties new file mode 100644 index 0000000000..dc5a148e5f --- /dev/null +++ b/versions-maven-plugin/src/it/it-force-releases-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:force-releases diff --git a/versions-maven-plugin/src/it/it-force-releases-issue-134/pom.xml b/versions-maven-plugin/src/it/it-force-releases-issue-134/pom.xml new file mode 100644 index 0000000000..f65bc49375 --- /dev/null +++ b/versions-maven-plugin/src/it/it-force-releases-issue-134/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134-001 + 1.0 + pom + Check if boms are upated from snapshots + + + + + localhost + dummy-bom2 + 1.0.0-SNAPSHOT + import + + + + + diff --git a/versions-maven-plugin/src/it/it-force-releases-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-force-releases-issue-134/verify.groovy new file mode 100644 index 0000000000..3dd9dee67e --- /dev/null +++ b/versions-maven-plugin/src/it/it-force-releases-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '1.0.0' diff --git a/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/invoker.properties new file mode 100644 index 0000000000..bcc6fac2b2 --- /dev/null +++ b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:unlock-snapshots diff --git a/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/pom.xml b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/pom.xml new file mode 100644 index 0000000000..e05afd56c0 --- /dev/null +++ b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134 + 1.0 + pom + Check if boms are upated + + + + + localhost + dummy-api + 3.4.0-20090311.051742-1 + import + + + + + diff --git a/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/verify.groovy new file mode 100644 index 0000000000..08dd0bfdf7 --- /dev/null +++ b/versions-maven-plugin/src/it/it-unlock-snapshots-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '3.4.0-SNAPSHOT' diff --git a/versions-maven-plugin/src/it/it-use-dep-version-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/invoker.properties new file mode 100644 index 0000000000..64df452751 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-dep-version +invoker.mavenOpts = -DdepVersion=2.0.0 -Dincludes=localhost:dummy-bom2 diff --git a/versions-maven-plugin/src/it/it-use-dep-version-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/pom.xml new file mode 100644 index 0000000000..722f1ed5ae --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134 + 1.0 + pom + Check if boms are upated + + + + + localhost + dummy-bom2 + 1.0.0 + pom + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-dep-version-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/verify.groovy new file mode 100644 index 0000000000..b45ebad17c --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-dep-version-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '2.0.0' diff --git a/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/invoker.properties new file mode 100644 index 0000000000..4f292723b5 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases diff --git a/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/pom.xml new file mode 100644 index 0000000000..722f1ed5ae --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134 + 1.0 + pom + Check if boms are upated + + + + + localhost + dummy-bom2 + 1.0.0 + pom + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/verify.groovy new file mode 100644 index 0000000000..b45ebad17c --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-releases-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '2.0.0' diff --git a/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/invoker.properties new file mode 100644 index 0000000000..f08807aca2 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-latest-snapshots +invoker.mavenOpts = -DallowMajorUpdates=true -DallowMinorUpdates=true -DallowIncrementalUpdates=true diff --git a/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/pom.xml new file mode 100644 index 0000000000..2a7f216136 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134-001 + 1.0 + pom + Check if boms are upated from snapshots + + + + + localhost + dummy-bom2 + 1.0.0 + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/verify.groovy new file mode 100644 index 0000000000..b3f3e21cb0 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-snapshots-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '3.0.0-SNAPSHOT' diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/invoker.properties new file mode 100644 index 0000000000..4f292723b5 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-latest-releases diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/pom.xml new file mode 100644 index 0000000000..722f1ed5ae --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134 + 1.0 + pom + Check if boms are upated + + + + + localhost + dummy-bom2 + 1.0.0 + pom + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/verify.groovy new file mode 100644 index 0000000000..b45ebad17c --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-latest-versions-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '2.0.0' diff --git a/versions-maven-plugin/src/it/it-use-next-releases-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/invoker.properties new file mode 100644 index 0000000000..91990633ca --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-next-releases diff --git a/versions-maven-plugin/src/it/it-use-next-releases-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/pom.xml new file mode 100644 index 0000000000..b6cc63ad94 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134-001 + 1.0 + pom + Check if boms are upated from snapshots + + + + + localhost + dummy-bom2 + 1.0.0 + pom + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-next-releases-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/verify.groovy new file mode 100644 index 0000000000..6bbc4ba6ab --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-releases-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '1.1.0' diff --git a/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/invoker.properties new file mode 100644 index 0000000000..16012c01fd --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:use-next-snapshots +invoker.mavenOpts = -DallowMajorUpdates=true -DallowMinorUpdates=true -DallowIncrementalUpdates=true diff --git a/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/pom.xml new file mode 100644 index 0000000000..8c2f71d5af --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-use-releases-issue-134-001 + 1.0 + pom + Check if boms are upated from snapshots + + + + + localhost + dummy-bom2 + 0.9.0 + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/verify.groovy new file mode 100644 index 0000000000..080a7ed855 --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-next-snapshots-issue-134/verify.groovy @@ -0,0 +1,5 @@ +def project = new XmlSlurper() + .parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '1.0.0-SNAPSHOT' diff --git a/versions-maven-plugin/src/it/it-use-releases-issue-134/invoker.properties b/versions-maven-plugin/src/it/it-use-releases-issue-134/invoker.properties new file mode 100644 index 0000000000..dc5a148e5f --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-releases-issue-134/invoker.properties @@ -0,0 +1 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:force-releases diff --git a/versions-maven-plugin/src/it/it-use-releases-issue-134/pom.xml b/versions-maven-plugin/src/it/it-use-releases-issue-134/pom.xml new file mode 100644 index 0000000000..8907c2373d --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-releases-issue-134/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + localhost + it-force-releases-issue-134-001 + 1.0 + pom + Check if boms are upated from snapshots + + + + + localhost + dummy-bom2 + 1.0.0-SNAPSHOT + import + + + + + diff --git a/versions-maven-plugin/src/it/it-use-releases-issue-134/verify.groovy b/versions-maven-plugin/src/it/it-use-releases-issue-134/verify.groovy new file mode 100644 index 0000000000..3dd9dee67e --- /dev/null +++ b/versions-maven-plugin/src/it/it-use-releases-issue-134/verify.groovy @@ -0,0 +1,4 @@ +def project = new XmlSlurper().parse( new File( basedir, 'pom.xml' ) ) + +assert project.dependencyManagement.dependencies.'*'.size() == 1 +assert project.dependencyManagement.dependencies.dependency.version == '1.0.0' diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 564817c333..abd249228b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import java.util.regex.Matcher; @@ -33,6 +34,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -40,6 +42,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -86,9 +89,14 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useReleases( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useReleases( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -99,7 +107,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useReleases( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 1e57f49ba2..2749037519 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -31,6 +32,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -83,17 +85,29 @@ public LockSnapshotsMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) - { - lockSnapshots( pom, getProject().getDependencyManagement().getDependencies() ); - } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) + try { - lockSnapshots( pom, getProject().getDependencies() ); + if ( isProcessingDependencyManagement() ) + { + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + lockSnapshots( pom, dependencyManagement.getDependencies() ); + } + } + if ( getProject().getDependencies() != null && isProcessingDependencies() ) + { + lockSnapshots( pom, getProject().getDependencies() ); + } + if ( getProject().getParent() != null && isProcessingParent() ) + { + lockParentSnapshot( pom, getProject().getParent() ); + } } - if ( getProject().getParent() != null && isProcessingParent() ) + catch ( IOException e ) { - lockParentSnapshot( pom, getProject().getParent() ); + throw new MojoExecutionException( e.getMessage(), e ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 91c3635994..408cec4349 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -31,6 +32,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -82,10 +84,16 @@ public UnlockSnapshotsMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + try + { + if ( isProcessingDependencyManagement() ) { - unlockSnapshots( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + unlockSnapshots( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -95,6 +103,11 @@ protected void update( ModifiedPomXMLEventReader pom ) { unlockParentSnapshot( pom, getProject().getParent() ); } + } + catch ( IOException e ) + { + throw new MojoExecutionException( e.getMessage(), e ); + } } private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 9c6b649c0e..bfbc42d9eb 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import org.apache.maven.artifact.Artifact; @@ -30,6 +31,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -37,6 +39,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -99,9 +102,14 @@ protected void update( ModifiedPomXMLEventReader pom ) try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useDepVersion( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useDepVersion( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) @@ -114,7 +122,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useDepVersion( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 1394abce62..5c80e70909 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Optional; @@ -36,12 +37,14 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -119,9 +122,14 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useLatestReleases( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useLatestReleases( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -132,7 +140,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useLatestReleases( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 0e4249a178..33d1785553 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; @@ -32,12 +33,14 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -108,9 +111,14 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useLatestSnapshots( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useLatestSnapshots( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -121,7 +129,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useLatestSnapshots( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index d5fb92067a..57235889ca 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -129,7 +129,7 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { DependencyManagement dependencyManagement = PomHelper.getRawModel( getProject() ).getDependencyManagement(); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 0045193de5..05705f90dc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import java.util.regex.Pattern; @@ -30,11 +31,13 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -80,13 +83,26 @@ public UseNextReleasesMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + try { - useNextReleases( pom, getProject().getDependencyManagement().getDependencies() ); + if ( isProcessingDependencyManagement() ) + { + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useNextReleases( pom, dependencyManagement.getDependencies() ); + } + } + + if ( getProject().getDependencies() != null && isProcessingDependencies() ) + { + useNextReleases( pom, getProject().getDependencies() ); + } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { - useNextReleases( pom, getProject().getDependencies() ); + throw new MojoExecutionException( e.getMessage(), e ); } if ( getProject().getParent() != null && isProcessingParent() ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 3546193a89..afaf413029 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Optional; @@ -31,12 +32,14 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -109,9 +112,11 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) { - useNextSnapshots( pom, getProject().getDependencyManagement().getDependencies() ); + useNextSnapshots( pom, dependencyManagement.getDependencies() ); } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -122,7 +127,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useNextSnapshots( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 81c9fbaa50..529e983e40 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import org.apache.maven.artifact.manager.WagonManager; @@ -29,11 +30,13 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -74,9 +77,14 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useNextVersions( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useNextVersions( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -87,7 +95,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useNextVersions( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index b4d2b91f81..a8333cb370 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Collection; import org.apache.commons.lang3.StringUtils; @@ -31,6 +32,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -79,16 +81,21 @@ protected void update( ModifiedPomXMLEventReader pom ) { useReactor( pom, getProject().getParent() ); } - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useReactor( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useReactor( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { useReactor( pom, getProject().getDependencies() ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index eac9aac15e..1a4704f8f2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -22,6 +22,7 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Optional; @@ -34,6 +35,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -101,10 +103,14 @@ protected void update( ModifiedPomXMLEventReader pom ) { try { - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) + if ( isProcessingDependencyManagement() ) { - useReleases( pom, PomHelper.readImportedPOMsFromDependencyManagementSection( pom ) ); - useReleases( pom, getProject().getDependencyManagement().getDependencies() ); + DependencyManagement dependencyManagement = + PomHelper.getRawModel( getProject() ).getDependencyManagement(); + if ( dependencyManagement != null ) + { + useReleases( pom, dependencyManagement.getDependencies() ); + } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { @@ -115,7 +121,7 @@ protected void update( ModifiedPomXMLEventReader pom ) useReleases( pom, singletonList( getParentDependency() ) ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( ArtifactMetadataRetrievalException | IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index e1af267f61..983fa90629 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -97,6 +97,8 @@ public void testProcessParent() { pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -119,6 +121,8 @@ public void testReplaceSnapshotWithRelease() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -141,6 +145,8 @@ public void testUpgrade() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -163,6 +169,8 @@ public void testDowngrade() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -188,6 +196,8 @@ public void testFailIfNotReplaced() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); fail( "MojoExecutionException is expected" ); } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index 5e880c70ed..72fd58f2d5 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -101,6 +101,8 @@ public void testDontUpgradeToBeta() { pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), Matchers.empty() ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index d59da171ab..6e2b40bfbf 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -97,6 +97,8 @@ public void testProcessParent() { pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -119,6 +121,8 @@ public void testReplaceSnapshotWithRelease() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); } assertThat( changeRecorder.getChanges(), @@ -144,6 +148,8 @@ public void testFailIfNotReplaced() pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), anyString(), any( Model.class ) ) ) .thenReturn( true ); + pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) + .thenReturn( mojo.getProject().getModel() ); mojo.update( null ); fail( "MojoExecutionException is expected" ); } From 7e7ed2163fc84038c32fc35ac2489f43b84d32d8 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 19 Nov 2022 15:22:40 +0100 Subject: [PATCH 211/441] Site build - gitHub ribbon, stage site - gitHub ribbon from parent project use artifact name, not valid for multi module - stage site during build - one less a manual goal --- README.md | 5 ++++- pom.xml | 15 +++++++++++++++ src/site/site.xml | 26 ++++++++++++++++++-------- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index aaf2a4a62d..b2512e9a37 100644 --- a/README.md +++ b/README.md @@ -53,5 +53,8 @@ For publishing the site do the following: ``` cd target/checkout -../mvnw verify site site:stage scm-publish:publish-scm +../mvnw site +../mvnw scm-publish:publish-scm ``` + +for multi module site - we need two executions diff --git a/pom.xml b/pom.xml index 5f2072ff36..14c99efdc4 100644 --- a/pom.xml +++ b/pom.xml @@ -223,6 +223,21 @@ + + + org.apache.maven.plugins + maven-site-plugin + + + default-site + site + + site + stage + + + + diff --git a/src/site/site.xml b/src/site/site.xml index f2f2bbeecb..3c8eff68ca 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -2,14 +2,24 @@ + https://maven.apache.org/xsd/decoration-1.8.0.xsd"> - - - - - + + + + mojohaus/versions + right + gray + + + - - + + + + + + + + From acc5dbd603f41b3e2daa34e1ca63bfc653ac92dd Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 20 Nov 2022 17:28:01 +0100 Subject: [PATCH 212/441] GH build improvement - skip one build in matrix We need the same goal for first build and for build in the matrix in order to skip the same build. --- .github/workflows/maven.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 8e9fa94060..39d6743a49 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,8 +24,9 @@ jobs: name: Verify uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 with: - ff-goal: '-P run-its install' + ff-goal: '-P run-its install' # site use project version for reporting ff-maven: "3.8.6" # Maven version for fail-fast-build + verify-goal: '-P run-its install' # should be the same as for first build maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds deploy: From 98db65921c26c5d1e5f36b791e940c921a2b7545 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 20 Nov 2022 16:46:52 +0100 Subject: [PATCH 213/441] Introduce Plugin API for ChangeRecorder --- pom.xml | 26 ++++- versions-api/pom.xml | 17 +++ .../versions/api/change/VersionChange.java | 52 +++++++++ .../versions/api/recording/ChangeRecord.java | 66 +++++++++++ .../api/recording/ChangeRecorder.java | 52 +++++++++ .../src/site/markdown/change-recorder.md.vm | 88 ++++++++++++++ versions-api/src/site/markdown/index.md.vm | 108 ++++++++++++++++++ versions-api/src/site/site.xml | 15 +++ versions-common/pom.xml | 13 +++ .../change/CompositeVersionChanger.java | 2 + ...nChange.java => DefaultVersionChange.java} | 10 +- .../change/DependencyVersionChanger.java | 1 + .../versions/change/ParentVersionChanger.java | 1 + .../versions/change/PluginVersionChanger.java | 1 + .../change/ProjectVersionChanger.java | 1 + .../mojo/versions/change/VersionChanger.java | 2 + .../versions/recording/ChangeRecorder.java | 51 --------- .../recording/ChangeRecorderNull.java | 14 ++- .../versions/recording/ChangeRecorderXML.java | 55 ++++++--- .../recording/DefaultChangeRecord.java | 104 +++++++++++++++++ .../recording/ChangeRecorderXMLTest.java | 79 ++++++++----- versions-maven-plugin/pom.xml | 4 + .../verify.bsh | 2 +- .../verify.bsh | 2 +- .../verify.bsh | 2 +- .../verify.bsh | 2 +- .../verify.bsh | 2 +- .../verify.bsh | 2 +- ...AbstractVersionsDependencyUpdaterMojo.java | 39 ++++--- .../versions/AbstractVersionsDisplayMojo.java | 8 +- .../versions/AbstractVersionsUpdaterMojo.java | 62 +++------- .../versions/CompareDependenciesMojo.java | 22 ++-- .../DisplayDependencyUpdatesMojo.java | 13 ++- .../versions/DisplayParentUpdatesMojo.java | 15 ++- .../versions/DisplayPluginUpdatesMojo.java | 7 +- .../versions/DisplayPropertyUpdatesMojo.java | 13 ++- .../mojo/versions/ForceReleasesMojo.java | 30 +++-- .../mojo/versions/LockSnapshotsMojo.java | 14 ++- .../mojo/versions/ResolveRangesMojo.java | 13 ++- .../org/codehaus/mojo/versions/SetMojo.java | 23 ++-- .../mojo/versions/SetPropertyMojo.java | 13 ++- .../codehaus/mojo/versions/SetScmTagMojo.java | 14 ++- .../mojo/versions/UnlockSnapshotsMojo.java | 34 ++++-- .../mojo/versions/UpdateChildModulesMojo.java | 13 ++- .../mojo/versions/UpdateParentMojo.java | 26 +++-- .../mojo/versions/UpdatePropertiesMojo.java | 25 ++-- .../mojo/versions/UpdatePropertyMojo.java | 18 ++- .../mojo/versions/UseDepVersionMojo.java | 28 +++-- .../mojo/versions/UseLatestReleasesMojo.java | 32 ++++-- .../mojo/versions/UseLatestSnapshotsMojo.java | 30 +++-- .../mojo/versions/UseLatestVersionsMojo.java | 30 +++-- .../versions/UseLatestVersionsMojoBase.java | 21 ++-- .../mojo/versions/UseNextReleasesMojo.java | 25 ++-- .../mojo/versions/UseNextSnapshotsMojo.java | 25 ++-- .../mojo/versions/UseNextVersionsMojo.java | 24 ++-- .../mojo/versions/UseReactorMojo.java | 14 ++- .../mojo/versions/UseReleasesMojo.java | 28 +++-- versions-maven-plugin/src/site/site.xml | 1 + .../DisplayDependencyUpdatesMojoTest.java | 73 +++++++----- .../mojo/versions/ForceReleasesMojoTest.java | 25 ++-- ...ratePatternsForIncludesAnExcludesTest.java | 2 +- .../codehaus/mojo/versions/SetMojoTest.java | 8 +- .../mojo/versions/UpdateParentMojoTest.java | 34 +++--- .../versions/UpdatePropertiesMojoTest.java | 14 +-- .../UpdatePropertiesMojoTestBase.java | 9 +- .../mojo/versions/UpdatePropertyMojoTest.java | 14 +-- .../versions/UseLatestReleasesMojoTest.java | 14 +-- .../versions/UseLatestVersionsMojoTest.java | 47 ++++---- .../mojo/versions/UseReleasesMojoTest.java | 17 ++- .../versions/utils/TestChangeRecorder.java | 27 +++-- 70 files changed, 1228 insertions(+), 490 deletions(-) create mode 100644 versions-api/pom.xml create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java create mode 100644 versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java create mode 100644 versions-api/src/site/markdown/change-recorder.md.vm create mode 100644 versions-api/src/site/markdown/index.md.vm create mode 100644 versions-api/src/site/site.xml rename versions-common/src/main/java/org/codehaus/mojo/versions/change/{VersionChange.java => DefaultVersionChange.java} (86%) delete mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java diff --git a/pom.xml b/pom.xml index 14c99efdc4..7336f447ab 100644 --- a/pom.xml +++ b/pom.xml @@ -96,10 +96,11 @@ - versions-maven-plugin - model-ruleset model-report + model-ruleset + versions-api versions-common + versions-maven-plugin @@ -133,6 +134,7 @@ 2.0.0 ${project.build.directory}/staging 2022-10-23T15:41:47Z + 0.9.0.M1 @@ -198,6 +200,26 @@ + + + + + org.eclipse.sisu + sisu-maven-plugin + ${sisu-maven-plugin-version} + + + generate-index + + main-index + test-index + + + + + + + org.apache.maven.plugins diff --git a/versions-api/pom.xml b/versions-api/pom.xml new file mode 100644 index 0000000000..72458be0d6 --- /dev/null +++ b/versions-api/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + + + versions-api + Versions API + Extension API for Versions Plugin + + diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java new file mode 100644 index 0000000000..656d42aa0b --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java @@ -0,0 +1,52 @@ +package org.codehaus.mojo.versions.api.change; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * Represents a change of an item's version. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface VersionChange +{ + /** + * @return a groupId of changed item + * @since 2.14.0 + */ + String getGroupId(); + + /** + * @return an ArtifactId of change item + * @since 2.14.0 + */ + String getArtifactId(); + + /** + * @return an old version of changed item + * @since 2.14.0 + */ + String getOldVersion(); + + /** + * @return a new version of changed item + * @since 2.14.0 + */ + String getNewVersion(); + +} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java new file mode 100644 index 0000000000..18ab668071 --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java @@ -0,0 +1,66 @@ +package org.codehaus.mojo.versions.api.recording; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import org.codehaus.mojo.versions.api.change.VersionChange; + +/** + * Represents a change record of an item's version. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface ChangeRecord +{ + /** + * Describe where version item is updated. + */ + enum ChangeKind + { + DEPENDENCY( "dependency-update" ), + DEPENDENCY_MANAGEMENT( "dependency-management-update" ), + PARENT( "parent-update" ), + PLUGIN( "plugin-update" ), + PLUGIN_MANAGEMENT( "plugin-management-update" ), + PROPERTY( "property-update" ); + + private final String label; + + ChangeKind( String label ) + { + this.label = label; + } + + public String getLabel() + { + return label; + } + } + + /** + * @return a version item change kind + * @since 2.14.0 + */ + ChangeKind getKind(); + + /** + * @return a details about changed item + * @since 2.14.0 + */ + VersionChange getVersionChange(); +} diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java new file mode 100644 index 0000000000..42d961357c --- /dev/null +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java @@ -0,0 +1,52 @@ +package org.codehaus.mojo.versions.api.recording; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import java.io.IOException; +import java.nio.file.Path; + +/** + * Interface for implement a recorder of version changes. + * + * @author Slawomir Jaranowski + * @since 2.14.0 + */ +public interface ChangeRecorder +{ + /** + * Record that a dependency was updated. + * + * @param changeRecord a record described change + * @since 2.14.0 + */ + void recordChange( ChangeRecord changeRecord ); + + /** + * Write the current set of changes to the given output path. + *

    + * Implementation is responsible for creating all missing directories. + *

    + * Output should not be created for empty record sets. + * + * @param outputPath The output path, can be null, provided by changeRecorderOutputFile + * plugin parameters + * @throws IOException On write and/or I/O errors + * @since 2.14.0 + */ + void writeReport( Path outputPath ) throws IOException; +} diff --git a/versions-api/src/site/markdown/change-recorder.md.vm b/versions-api/src/site/markdown/change-recorder.md.vm new file mode 100644 index 0000000000..2b6e0b37fc --- /dev/null +++ b/versions-api/src/site/markdown/change-recorder.md.vm @@ -0,0 +1,88 @@ +title: Writing a own ChangeRecorder +author: Slawomir Jaranowski +date: 2022-11-20 + +Writing an own ChangeRecorder +============================ + +In order to create an own ChangeRecorder you must implement [ChangeRecorder](apidocs/org/codehaus/mojo/versions/api/recording/ChangeRecorder.html) interface. + +Write code +---------- + +```java +import javax.inject.Named; + +import java.nio.file.Path; + +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; + +@Named( "my-recorder" ) +public class MyChangeRecorder implements ChangeRecorder +{ + @Override + public final void recordChange( ChangeRecord changeRecord ) + { + // your code + } + + @Override + public final void writeReport( Path outputPath ) + { + // your code + } +} +``` + +`Changerecoder` is stateful component, so you must not add `Singleton` annotation to it. + +Using extension +--------------- + +Plugin configuration: + +```xml + + + 4.0.0 + + your.group + your-project + + + + + + org.codehaus.mojo + versions-maven-plugin + ${project.version} + + + my-recorder + \${project.build.directory}/my-versions-changes.txt + + + + + your.group + your-extension + ext.version + + + + + + + +``` + +Now execution like: + +``` +mvn versions:update-properties +``` + +will generate your custom report. diff --git a/versions-api/src/site/markdown/index.md.vm b/versions-api/src/site/markdown/index.md.vm new file mode 100644 index 0000000000..bfc08446bd --- /dev/null +++ b/versions-api/src/site/markdown/index.md.vm @@ -0,0 +1,108 @@ +title: Writing an extensions for Versions Plugin +author: Slawomir Jaranowski +date: 2022-11-20 + +Writing an extensions for Versions Plugin +======================================== + +`Versions API` allow you write extension for `Versions Plugin`. + +Project template for extensions +------------------------------- + +Your Maven project should look like: + +```xml + + + 4.0.0 + + your.group + your-extension + ext.version + + + + org.codehaus.mojo.versions + versions-api + ${project.version} + provided + + + javax.inject + javax.inject + 1 + provided + + + + + + + + org.eclipse.sisu + sisu-maven-plugin + ${sisu-maven-plugin-version} + + + generate-index + + main-index + + + + + + + + +``` + +Note that the classloader is shared with the `versions-maven-plugin` [plugin classloader](https://maven.apache.org/guides/mini/guide-maven-classloading.html#plugin-classloaders) + +The artifacts `org.codehaus.mojo.versions:versions-api` and `javax.inject:javax.inject` are always loaded in the same version as used `versions-maven-plugin` use. + +Extension artifact should therefore only depend on them with `provided` scope. + + +Using extensions with Version Maven Plugin +------------------------------------------ + +You need to add your extension as plugin dependency: + +```xml + + + 4.0.0 + + your.group + your-project + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${project.version} + + + + your.group + your-extension + ext.version + + + + + + + +``` + +General information about [JSR 330](https://maven.apache.org/maven-jsr330.html) in Maven ecosystem. diff --git a/versions-api/src/site/site.xml b/versions-api/src/site/site.xml new file mode 100644 index 0000000000..3b68aaf989 --- /dev/null +++ b/versions-api/src/site/site.xml @@ -0,0 +1,15 @@ + + + +

    + + + + + + + + + + diff --git a/versions-common/pom.xml b/versions-common/pom.xml index dffbe388bc..365dba0074 100644 --- a/versions-common/pom.xml +++ b/versions-common/pom.xml @@ -15,6 +15,11 @@ Common components for the Versions Maven Plugin + + org.codehaus.mojo.versions + versions-api + 2.14.0-SNAPSHOT + org.codehaus.mojo.versions model-ruleset @@ -120,4 +125,12 @@ + + + + org.eclipse.sisu + sisu-maven-plugin + + + diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java index 26ee76a7cb..b0bb3b9421 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java @@ -25,6 +25,8 @@ import java.util.Arrays; import java.util.List; +import org.codehaus.mojo.versions.api.change.VersionChange; + /** * Created by IntelliJ IDEA. * diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java similarity index 86% rename from versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java rename to versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java index 753f3c81a6..f0f43ba25e 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChange.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java @@ -21,13 +21,15 @@ import java.util.Objects; +import org.codehaus.mojo.versions.api.change.VersionChange; + /** * Represents a change of an artifact's version. * * @author Stephen Connolly * @since 15-Sep-2010 14:48:10 */ -public final class VersionChange +public final class DefaultVersionChange implements VersionChange { private final String groupId; @@ -37,7 +39,7 @@ public final class VersionChange private final String newVersion; - public VersionChange( String groupId, String artifactId, String oldVersion, String newVersion ) + public DefaultVersionChange( String groupId, String artifactId, String oldVersion, String newVersion ) { this.groupId = groupId; this.artifactId = artifactId; @@ -76,7 +78,7 @@ public boolean equals( Object o ) return false; } - VersionChange versionChange = (VersionChange) o; + DefaultVersionChange versionChange = (DefaultVersionChange) o; if ( !Objects.equals( artifactId, versionChange.artifactId ) ) { @@ -104,6 +106,6 @@ public int hashCode() public String toString() { - return "VersionChange(" + groupId + ':' + artifactId + ":" + oldVersion + "-->" + newVersion + ')'; + return "DefaultVersionChange(" + groupId + ':' + artifactId + ":" + oldVersion + "-->" + newVersion + ')'; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java index 2ae7173224..a106150773 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java @@ -24,6 +24,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.change.VersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java index 7d39e15a07..a0220049b1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java @@ -24,6 +24,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.change.VersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java index 8c2f80ea11..60ddce5831 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java @@ -24,6 +24,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.change.VersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java index 17fc8b9c85..64e8a87605 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java @@ -24,6 +24,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.change.VersionChange; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java index ae3a62d717..dd86e8e8b1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java @@ -21,6 +21,8 @@ import javax.xml.stream.XMLStreamException; +import org.codehaus.mojo.versions.api.change.VersionChange; + /** * Created by IntelliJ IDEA. * diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java deleted file mode 100644 index 32483c4906..0000000000 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorder.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.codehaus.mojo.versions.recording; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; -import java.io.OutputStream; - -/** - * A recorder of version updates. - */ - -public interface ChangeRecorder -{ - /** - * Record that a dependency was updated. - * - * @param kind The kind of version change - * @param groupId The dependency group ID - * @param artifactId The dependency artifact ID - * @param oldVersion The old version of the dependency - * @param newVersion The new version of the dependency - */ - - void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ); - - /** - * Serialize the current set of changes to the given output stream. - * - * @param outputStream The output stream - * @throws IOException On serialization and/or I/O errors - */ - - void serialize( OutputStream outputStream ) throws IOException; -} diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index dc8c013c1d..46f1f798cb 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -19,12 +19,17 @@ * under the License. */ -import java.io.OutputStream; +import javax.inject.Named; + +import java.nio.file.Path; + +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; /** * A recorder that ignores updates. */ - +@Named( "none" ) public class ChangeRecorderNull implements ChangeRecorder { /** @@ -35,13 +40,12 @@ public ChangeRecorderNull() } @Override - public final void recordUpdate( final String kind, final String groupId, final String artifactId, - final String oldVersion, final String newVersion ) + public final void recordChange( ChangeRecord changeRecord ) { } @Override - public final void serialize( final OutputStream outputStream ) + public final void writeReport( final Path outputPath ) { } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java index 6fa2a82c41..19051c5438 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.inject.Named; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -31,16 +33,24 @@ import java.io.IOException; import java.io.OutputStream; -import java.util.Objects; +import java.nio.file.Files; +import java.nio.file.Path; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.w3c.dom.DOMException; import org.w3c.dom.Document; import org.w3c.dom.Element; +import static java.nio.file.StandardOpenOption.CREATE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.nio.file.StandardOpenOption.WRITE; + /** * A recorder of version updates. */ +@Named( "xml" ) public class ChangeRecorderXML implements ChangeRecorder { /** @@ -72,31 +82,40 @@ public ChangeRecorderXML() } @Override - public final void recordUpdate( final String kind, final String groupId, final String artifactId, - final String oldVersion, final String newVersion ) + public final void recordChange( ChangeRecord changeRecord ) { - Objects.requireNonNull( kind, "kind" ); - Objects.requireNonNull( groupId, "groupId" ); - Objects.requireNonNull( artifactId, "artifactId" ); - Objects.requireNonNull( oldVersion, "oldVersion" ); - Objects.requireNonNull( newVersion, "newVersion" ); - final Element update = this.document.createElementNS( CHANGES_NAMESPACE, "update" ); - update.setAttribute( "kind", kind ); - update.setAttribute( "groupId", groupId ); - update.setAttribute( "artifactId", artifactId ); - update.setAttribute( "oldVersion", oldVersion ); - update.setAttribute( "newVersion", newVersion ); + update.setAttribute( "kind", changeRecord.getKind().getLabel() ); + update.setAttribute( "groupId", changeRecord.getVersionChange().getGroupId() ); + update.setAttribute( "artifactId", changeRecord.getVersionChange().getArtifactId() ); + update.setAttribute( "oldVersion", changeRecord.getVersionChange().getOldVersion() ); + update.setAttribute( "newVersion", changeRecord.getVersionChange().getNewVersion() ); this.root.appendChild( update ); } @Override - public final void serialize( final OutputStream outputStream ) throws IOException + public final void writeReport( final Path outputPath ) throws IOException { - try + if ( outputPath == null ) + { + throw new IOException( "changeRecorderOutputFile not provided" ); + } + + if ( root.getChildNodes().getLength() == 0 ) + { + // don't generate empty file + return; + } + + Files.createDirectories( outputPath.getParent() ); + + try ( OutputStream outputStream = Files.newOutputStream( outputPath, CREATE, TRUNCATE_EXISTING, WRITE ) ) { - final Transformer transformer = TransformerFactory.newInstance().newTransformer(); - final Source source = new DOMSource( this.document ); + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + transformerFactory.setAttribute( XMLConstants.ACCESS_EXTERNAL_DTD, "" ); + transformerFactory.setAttribute( XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "" ); + Transformer transformer = transformerFactory.newTransformer(); + Source source = new DOMSource( this.document ); transformer.transform( source, new StreamResult( outputStream ) ); outputStream.flush(); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java new file mode 100644 index 0000000000..a3c8d82d7d --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java @@ -0,0 +1,104 @@ +package org.codehaus.mojo.versions.recording; + +import java.util.Objects; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.model.Dependency; +import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.change.DefaultVersionChange; + +public class DefaultChangeRecord implements ChangeRecord +{ + private final ChangeKind kind; + private final VersionChange versionChange; + + private DefaultChangeRecord( ChangeKind kind, VersionChange versionChange ) + { + this.kind = Objects.requireNonNull( kind, "kind must not be null" ); + this.versionChange = Objects.requireNonNull( versionChange, "versionChange must not be null" ); + + } + + @Override + public ChangeKind getKind() + { + return kind; + } + + @Override + public VersionChange getVersionChange() + { + return versionChange; + } + + + public static Builder builder() + { + return new Builder(); + } + + public static class Builder + { + + private ChangeKind kind; + private String groupId; + private String artifactId; + private String oldVersion; + private String newVersion; + + public Builder withKind( ChangeKind kind ) + { + this.kind = kind; + return this; + } + + public Builder withGroupId( String groupId ) + { + this.groupId = groupId; + return this; + } + + public Builder withArtifactId( String artifactId ) + { + this.artifactId = artifactId; + return this; + } + + public Builder withOldVersion( String oldVersion ) + { + this.oldVersion = oldVersion; + return this; + } + + public Builder withNewVersion( String newVersion ) + { + this.newVersion = newVersion; + return this; + } + + public Builder withDependency( Dependency dependency ) + { + groupId = dependency.getGroupId(); + artifactId = dependency.getArtifactId(); + oldVersion = dependency.getVersion(); + return this; + } + + public Builder withArtifact( Artifact artifact ) + { + groupId = artifact.getGroupId(); + artifactId = artifact.getArtifactId(); + oldVersion = artifact.getVersion(); + return this; + } + + public ChangeRecord build() + { + return new DefaultChangeRecord( kind, + new DefaultVersionChange( groupId, artifactId, oldVersion, newVersion ) ); + } + } + + +} diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java index 32c602805c..b852179d1b 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -23,12 +23,14 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; -import org.apache.commons.io.IOUtils; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.junit.Assert; import org.junit.Test; import org.w3c.dom.Document; @@ -38,43 +40,52 @@ public final class ChangeRecorderXMLTest { - private static void copyResource( final String name, final File output ) throws IOException + private static void copyResource( final String name, final Path output ) throws IOException { - try ( FileOutputStream outputStream = new FileOutputStream( output ) ) + try ( InputStream inputStream = ChangeRecorderXMLTest.class.getResourceAsStream( name ) ) { - try ( InputStream inputStream = ChangeRecorderXMLTest.class.getResourceAsStream( name ) ) - { - IOUtils.copy( inputStream, outputStream ); - } + Files.copy( inputStream, output, StandardCopyOption.REPLACE_EXISTING ); } } - private static Document parseXML( final File file ) throws ParserConfigurationException, IOException, SAXException + private static Document parseXML( final Path path ) throws ParserConfigurationException, IOException, SAXException { final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); - return documentBuilder.parse( file ); + return documentBuilder.parse( path.toFile() ); } @Test public void testChanges() throws Exception { - final File file0 = File.createTempFile( "ChangeRecorderTest", ".xml" ); - final File file1 = File.createTempFile( "ChangeRecorderTest", ".xml" ); + final Path path0 = Files.createTempFile( "ChangeRecorderTest", ".xml" ); + final Path path1 = Files.createTempDirectory( "ChangeRecorderTest" ) + .resolve( "subDirectory" ) + .resolve( "ChangeRecorderTest.xml" ); - copyResource( "expectedFile.xml", file0 ); + copyResource( "expectedFile.xml", path0 ); final ChangeRecorder recorder = new ChangeRecorderXML(); - recorder.recordUpdate( "exampleKind", "org.codehaus", "example0", "0.0.1", "0.0.2" ); - recorder.recordUpdate( "exampleKind", "org.codehaus", "example1", "1.0.0", "2.0.0" ); + recorder.recordChange( DefaultChangeRecord.builder() + .withKind( ChangeRecord.ChangeKind.DEPENDENCY ) + .withGroupId( "org.codehaus" ) + .withArtifactId( "example0" ) + .withOldVersion( "0.0.1" ) + .withNewVersion( "0.0.2" ) + .build() ); - try ( FileOutputStream outputStream = new FileOutputStream( file1 ) ) - { - recorder.serialize( outputStream ); - } + recorder.recordChange( DefaultChangeRecord.builder() + .withKind( ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ) + .withGroupId( "org.codehaus" ) + .withArtifactId( "example1" ) + .withOldVersion( "1.0.0" ) + .withNewVersion( "2.0.0" ) + .build() ); + + recorder.writeReport( path1 ); - final Document document0 = parseXML( file0 ); - final Document document1 = parseXML( file1 ); + final Document document0 = parseXML( path0 ); + final Document document1 = parseXML( path1 ); final NodeList elements0 = document0.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); final NodeList elements1 = document1.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); @@ -87,13 +98,29 @@ public void testChanges() throws Exception final Element element1 = (Element) elements1.item( index ); Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ) ); + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ) ); Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ) ); + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ) ); Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ) ); + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ) ); Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ) ); + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ) ); + + // FIXME - looks like assertions not working + Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "kind" ), + element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "kind" ) ); } } + + @Test + public void emptyResultShouldNotGenerateReports() throws Exception + { + Path path = Files.createTempDirectory( "ChangeRecorderTest" ).resolve( "ChangeRecorderTest.xml" ); + + ChangeRecorder recorder = new ChangeRecorderXML(); + recorder.writeReport( path ); + + Assert.assertFalse( "File should not be created", Files.isRegularFile( path ) ); + + } } diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 3881b4f003..71519af212 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -159,6 +159,10 @@ + + org.eclipse.sisu + sisu-maven-plugin + org.apache.maven.plugins maven-invoker-plugin diff --git a/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh index 29363fa9d6..296bf76ed6 100644 --- a/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-update-parent-001/verify.bsh @@ -7,7 +7,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh index f1c83a4db1..d0cedff849 100644 --- a/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-update-properties-001/verify.bsh @@ -6,7 +6,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh index 8a1cf60042..80f6400beb 100644 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-releases-001/verify.bsh @@ -6,7 +6,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh index c8050feffc..6aa68bf4f7 100644 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-snapshots-001/verify.bsh @@ -6,7 +6,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh index 9ce59b8bb8..80f6400beb 100644 --- a/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-use-latest-versions-001/verify.bsh @@ -6,7 +6,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh index 659cbeff01..3775f4ca4d 100644 --- a/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh +++ b/versions-maven-plugin/src/it/it-changerecord-use-next-versions-001/verify.bsh @@ -6,7 +6,7 @@ try File file = new File( basedir, "target/versions-changes.xml" ); String buf = FileUtils.fileRead( file, "UTF-8" ); - if ( buf.indexOf( "" ) < 0 ) + if ( buf.indexOf( "" ) < 0 ) { System.err.println( "Version change recorded" ); return false; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 9b8cc5c5cd..42a46b92dd 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; @@ -44,7 +45,9 @@ import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.DependencyComparator; @@ -157,12 +160,14 @@ public abstract class AbstractVersionsDependencyUpdaterMojo @Inject protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -540,13 +545,13 @@ private int findFirstChar( final String includeString, final String chars ) * @param pom {@link ModifiedPomXMLEventReader} instance to update the POM XML document * @param dep dependency to be updated (can also be a dependency made from the parent) * @param newVersion new version to update the dependency to - * @param changeRecorderTitle title for the {@link ChangeRecorder} log + * @param changeKind title for the {@link ChangeRecorder} log * @return {@code true} if an update has been made, {@code false} otherwise * @throws XMLStreamException thrown if updating the XML doesn't succeed */ protected boolean updateDependencyVersion( ModifiedPomXMLEventReader pom, Dependency dep, - String newVersion, String changeRecorderTitle ) - throws XMLStreamException + String newVersion, ChangeRecord.ChangeKind changeKind ) + throws XMLStreamException, MojoExecutionException { boolean updated = false; if ( isProcessingParent() @@ -562,9 +567,11 @@ && getProject().getParent() != null { getLog().debug( "Made parent update from " + dep.getVersion() + " to " + newVersion ); } - getChangeRecorder().recordUpdate( changeRecorderTitle, - dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - newVersion ); + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( changeKind ) + .withDependency( dep ) + .withNewVersion( newVersion ) + .build() ); updated = true; } @@ -576,9 +583,11 @@ && getProject().getParent() != null { getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); } - getChangeRecorder().recordUpdate( changeRecorderTitle, - dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - newVersion ); + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( changeKind ) + .withDependency( dep ) + .withNewVersion( newVersion ) + .build() ); updated = true; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 47057ffd46..fd01229369 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -26,6 +26,7 @@ import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; @@ -35,6 +36,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; /** * Abstract base class for the Display___ mojos. @@ -88,9 +90,11 @@ protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } @SuppressWarnings( "unchecked" ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index ad4bbf6425..4b7aace6e6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -24,10 +24,10 @@ import javax.xml.stream.XMLStreamException; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.Writer; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; @@ -59,11 +59,9 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.recording.ChangeRecorder; -import org.codehaus.mojo.versions.recording.ChangeRecorderNull; -import org.codehaus.mojo.versions.recording.ChangeRecorderXML; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; @@ -194,8 +192,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 2.11 */ - @Parameter( property = "changeRecorderFormat", - defaultValue = "none" ) + @Parameter( property = "changeRecorderFormat", defaultValue = "none" ) private String changeRecorderFormat = "none"; /** * The output file used to record changes. @@ -207,9 +204,9 @@ public abstract class AbstractVersionsUpdaterMojo private File changeRecorderOutputFile; /** - * The change recorder implementation. + * The change recorders implementation. */ - private ChangeRecorder changeRecorder; + private Map changeRecorders; /** *

    Allows specifying the {@linkplain RuleSet} object describing rules @@ -242,16 +239,18 @@ public abstract class AbstractVersionsUpdaterMojo @Inject protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { this.repositorySystem = repositorySystem; this.projectBuilder = projectBuilder; this.artifactMetadataSource = artifactMetadataSource; this.wagonManager = wagonManager; this.artifactResolver = artifactResolver; + this.changeRecorders = changeRecorders; } public VersionsHelper getHelper() throws MojoExecutionException @@ -332,10 +331,6 @@ public void execute() */ protected void validateInput() throws MojoExecutionException { - if ( !"none".equals( changeRecorderFormat ) && !"xml".equals( changeRecorderFormat ) ) - { - throw new MojoExecutionException( "Only 'xml' or 'none' formats are supported for change recordings" ); - } } /** * Finds the latest version of the specified artifact that matches the version range. @@ -575,17 +570,14 @@ else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.ge * * @return The change recorder */ - protected ChangeRecorder getChangeRecorder() + protected ChangeRecorder getChangeRecorder() throws MojoExecutionException { + ChangeRecorder changeRecorder = changeRecorders.get( changeRecorderFormat ); if ( changeRecorder == null ) { - changeRecorder = "none".equals( this.changeRecorderFormat ) - ? new ChangeRecorderNull() - : "xml".equals( this.changeRecorderFormat ) - ? new ChangeRecorderXML() - : null; + throw new MojoExecutionException( "Only " + changeRecorders.keySet() + + " formats are supported for change recordings" ); } - return changeRecorder; } @@ -595,28 +587,12 @@ protected ChangeRecorder getChangeRecorder() * @throws IOException On I/O errors */ - protected void saveChangeRecorderResults() throws IOException + protected void saveChangeRecorderResults() throws IOException, MojoExecutionException { - /* - * Nobody did anything that required a change recorder. - */ - - if ( this.changeRecorder == null ) - { - return; - } - - if ( "none".equals( this.changeRecorderFormat ) ) - { - return; - } this.getLog().debug( "writing change record to " + this.changeRecorderOutputFile ); - - this.changeRecorderOutputFile.getParentFile().mkdirs(); - try ( FileOutputStream outputStream = new FileOutputStream( this.changeRecorderOutputFile ) ) - { - this.changeRecorder.serialize( outputStream ); - } + getChangeRecorder().writeReport( Optional.ofNullable( changeRecorderOutputFile ) + .map( File::toPath ) + .orElse( null ) ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 1182945f14..22a54c5520 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -49,6 +49,8 @@ import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -130,9 +132,11 @@ public CompareDependenciesMojo( RepositorySystem repositorySystem, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, - MavenProjectBuilder mavenProjectBuilder ) + MavenProjectBuilder mavenProjectBuilder, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); this.mavenProjectBuilder = mavenProjectBuilder; } @@ -203,11 +207,13 @@ protected void update( ModifiedPomXMLEventReader pom ) if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) { totalDiffs.addAll( - compareVersions( pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap ) ); + compareVersions( pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap, + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ) ); } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - totalDiffs.addAll( compareVersions( pom, getProject().getDependencies(), remoteDepsMap ) ); + totalDiffs.addAll( compareVersions( pom, getProject().getDependencies(), remoteDepsMap, + ChangeRecord.ChangeKind.DEPENDENCY ) ); } if ( updatePropertyVersions ) { @@ -233,7 +239,8 @@ && isProcessingParent() ) getLog().debug( "Processing parent dependency: " + parent ); } remoteDepsMap.putIfAbsent( parent.getManagementKey(), parent ); - totalDiffs.addAll( compareVersions( pom, singletonList( getParentDependency() ), remoteDepsMap ) ); + totalDiffs.addAll( compareVersions( pom, singletonList( getParentDependency() ), remoteDepsMap, + ChangeRecord.ChangeKind.PARENT ) ); } if ( reportMode ) @@ -277,7 +284,8 @@ && isProcessingParent() ) * @throws XMLStreamException */ private List compareVersions( ModifiedPomXMLEventReader pom, List dependencies, - Map remoteDependencies ) + Map remoteDependencies, + ChangeRecord.ChangeKind changeKind ) throws MojoExecutionException, XMLStreamException { List updates = new ArrayList<>(); @@ -299,7 +307,7 @@ private List compareVersions( ModifiedPomXMLEventReader pom, List changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 066aab7e2b..c07dd91c74 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -22,6 +22,8 @@ import javax.inject.Inject; import javax.xml.stream.XMLStreamException; +import java.util.Map; + import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -35,6 +37,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -53,12 +56,14 @@ public class DisplayParentUpdatesMojo @Inject public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index fe15039f7c..85e64ea4ca 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -94,6 +94,7 @@ import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -171,9 +172,11 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, LifecycleExecutor lifecycleExecutor, ModelInterpolator modelInterpolator, PluginManager pluginManager, - RuntimeInformation runtimeInformation ) + RuntimeInformation runtimeInformation, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; this.pluginManager = pluginManager; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index c39f11ac1e..8b81d31be6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -44,6 +44,7 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -144,12 +145,14 @@ public class DisplayPropertyUpdatesMojo @Inject public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } public void execute() diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index abd249228b..419c458e89 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import java.util.regex.Matcher; import org.apache.maven.artifact.Artifact; @@ -42,6 +43,8 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -69,12 +72,14 @@ public class ForceReleasesMojo @Inject public ForceReleasesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -95,16 +100,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useReleases( pom, dependencyManagement.getDependencies() ); + useReleases( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useReleases( pom, getProject().getDependencies() ); + useReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useReleases( pom, singletonList( getParentDependency() ) ); + useReleases( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -113,7 +120,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { for ( Dependency dep : dependencies ) @@ -144,7 +152,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); if ( versions.containsVersion( releaseVersion ) ) { - updateDependencyVersion( pom, dep, releaseVersion, "forceReleases" ); + updateDependencyVersion( pom, dep, releaseVersion, changeKind ); } else { @@ -161,7 +169,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection } else { - updateDependencyVersion( pom, dep, newestRelease.toString(), "forceReleases" ); + updateDependencyVersion( pom, dep, newestRelease.toString(), changeKind ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 2749037519..992105005b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -40,6 +41,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -67,12 +69,14 @@ public class LockSnapshotsMojo @Inject public LockSnapshotsMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 7729cba15a..3119770446 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -48,6 +48,7 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -128,12 +129,14 @@ public class ResolveRangesMojo @Inject public ResolveRangesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index fef10ea975..595f4d30d3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -54,7 +54,8 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.change.VersionChanger; import org.codehaus.mojo.versions.change.VersionChangerFactory; import org.codehaus.mojo.versions.ordering.ReactorDepthComparator; @@ -243,17 +244,19 @@ public class SetMojo extends AbstractVersionsUpdaterMojo /** * The changes to module coordinates. Guarded by this. */ - private final transient List sourceChanges = new ArrayList<>(); + private final transient List sourceChanges = new ArrayList<>(); @Inject public SetMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver, - Prompter prompter ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders, + Prompter prompter ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); this.prompter = prompter; } @@ -261,7 +264,7 @@ private synchronized void addChange( String groupId, String artifactId, String o { if ( !newVersion.equals( oldVersion ) ) { - sourceChanges.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) ); + sourceChanges.add( new DefaultVersionChange( groupId, artifactId, oldVersion, newVersion ) ); } } @@ -583,7 +586,7 @@ protected synchronized void update( ModifiedPomXMLEventReader pom ) versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, processPlugins ); - for ( VersionChange versionChange : sourceChanges ) + for ( DefaultVersionChange versionChange : sourceChanges ) { changer.apply( versionChange ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index f2e6787122..804339fc76 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -39,6 +39,7 @@ import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.PropertiesVersionsFileReader; @@ -92,12 +93,14 @@ public class SetPropertyMojo @Inject public SetPropertyMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index b11d51d33a..32d5e3f8bc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -6,6 +6,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -19,6 +20,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static org.apache.commons.lang3.StringUtils.isAllBlank; @@ -68,12 +70,14 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo @Inject public SetScmTagMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 408cec4349..7f6a8a591d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -40,6 +41,9 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -69,9 +73,11 @@ public UnlockSnapshotsMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -92,12 +98,13 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - unlockSnapshots( pom, dependencyManagement.getDependencies() ); + unlockSnapshots( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - unlockSnapshots( pom, getProject().getDependencies() ); + unlockSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { @@ -110,7 +117,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies ) + private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException { for ( Dependency dep : dependencies ) @@ -140,8 +148,12 @@ private void unlockSnapshots( ModifiedPomXMLEventReader pom, List de if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), unlockedVersion, getProject().getModel() ) ) { - getChangeRecorder().recordUpdate( "unlockSnapshot", dep.getGroupId(), dep.getArtifactId(), - dep.getVersion(), unlockedVersion ); + + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( changeKind ) + .withDependency( dep ) + .withNewVersion( unlockedVersion ) + .build() ); getLog().info( "Unlocked " + toString( dep ) + " to version " + unlockedVersion ); } } @@ -174,9 +186,11 @@ private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject p { getLog().info( "Unlocked parent " + parentArtifact + " to version " + unlockedParentVersion ); - getChangeRecorder().recordUpdate( "unlockParentVersion", parentArtifact.getGroupId(), - parentArtifact.getArtifactId(), parentArtifact.getVersion(), - unlockedParentVersion ); + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( ChangeRecord.ChangeKind.PARENT ) + .withArtifact( parentArtifact ) + .withNewVersion( unlockedParentVersion ) + .build() ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index be50bbeb08..dc52b603bd 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -40,6 +40,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -71,12 +72,14 @@ public class UpdateChildModulesMojo @Inject public UpdateChildModulesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index caa60b4ce8..73d1fd0799 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.Collections; +import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; @@ -45,7 +46,10 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -137,12 +141,14 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Inject public UpdateParentMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -193,9 +199,13 @@ protected void update( ModifiedPomXMLEventReader pom ) getLog().debug( "Made an update from " + getProject().getParent().getVersion() + " to " + artifactVersion ); } - getChangeRecorder().recordUpdate( "updateParent", getProject().getParent().getGroupId(), - getProject().getParent().getArtifactId(), getProject().getParent().getVersion(), - artifactVersion.toString() ); + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( ChangeRecord.ChangeKind.PARENT ) + .withGroupId( getProject().getParent().getGroupId() ) + .withArtifactId( getProject().getParent().getArtifactId() ) + .withOldVersion( getProject().getParent().getVersion() ) + .withNewVersion( artifactVersion.toString() ) + .build() ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 8211e28179..7816f0b619 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -41,7 +41,10 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; @@ -139,12 +142,14 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UpdatePropertiesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -207,9 +212,13 @@ protected void update( ModifiedPomXMLEventReader pom ) { if ( ( isIncluded( association.getArtifact() ) ) ) { - this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, - targetVersion.toString() ); + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( + ChangeRecord.ChangeKind.PROPERTY ) + .withArtifact( association.getArtifact() ) + .withOldVersion( currentVersion ) + .withNewVersion( targetVersion.toString() ) + .build() ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 9e22942623..1cc59dd2dc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -41,7 +41,10 @@ import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -141,9 +144,11 @@ public UpdatePropertyMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -190,9 +195,12 @@ protected void update( ModifiedPomXMLEventReader pom ) { for ( final ArtifactAssociation association : version.getAssociations() ) { - this.getChangeRecorder().recordUpdate( "updateProperty", association.getGroupId(), - association.getArtifactId(), currentVersion, - targetVersion.toString() ); + this.getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( ChangeRecord.ChangeKind.PROPERTY ) + .withArtifact( association.getArtifact() ) + .withOldVersion( currentVersion ) + .withNewVersion( targetVersion.toString() ) + .build() ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index bfbc42d9eb..bedc8533be 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; @@ -40,6 +41,8 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -73,12 +76,14 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UseDepVersionMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } @Override @@ -108,18 +113,20 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useDepVersion( pom, dependencyManagement.getDependencies() ); + useDepVersion( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useDepVersion( pom, getProject().getDependencies() ); + useDepVersion( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useDepVersion( pom, singletonList( getParentDependency() ) ); + useDepVersion( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -128,7 +135,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException { for ( Dependency dep : dependencies ) @@ -160,7 +168,7 @@ private void useDepVersion( ModifiedPomXMLEventReader pom, Collection changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -128,16 +133,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useLatestReleases( pom, dependencyManagement.getDependencies() ); + useLatestReleases( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useLatestReleases( pom, getProject().getDependencies() ); + useLatestReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useLatestReleases( pom, singletonList( getParentDependency() ) ); + useLatestReleases( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -146,14 +153,15 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); useLatestVersions( pom, dependencies, - ( dep, versions ) -> + ( dep, versions ) -> { try { @@ -166,8 +174,8 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + }, + changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 33d1785553..9173a53c7e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Comparator; +import java.util.Map; import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; @@ -42,6 +43,8 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -91,12 +94,14 @@ public class UseLatestSnapshotsMojo @Inject public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -117,16 +122,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useLatestSnapshots( pom, dependencyManagement.getDependencies() ); + useLatestSnapshots( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useLatestSnapshots( pom, getProject().getDependencies() ); + useLatestSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useLatestSnapshots( pom, singletonList( getParentDependency() ) ); + useLatestSnapshots( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -135,14 +142,15 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); useLatestVersions( pom, dependencies, - ( dep, versions ) -> + ( dep, versions ) -> { try { @@ -157,6 +165,6 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 57235889ca..095f68b855 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; @@ -40,6 +41,8 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -99,12 +102,14 @@ public class UseLatestVersionsMojo @Inject public UseLatestVersionsMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } @Override @@ -135,16 +140,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useLatestVersions( pom, dependencyManagement.getDependencies() ); + useLatestVersions( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useLatestVersions( pom, getProject().getDependencies() ); + useLatestVersions( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useLatestVersions( pom, singletonList( getParentDependency() ) ); + useLatestVersions( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -153,14 +160,15 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); useLatestVersions( pom, dependencies, - ( dep, versions ) -> + ( dep, versions ) -> { try { @@ -173,6 +181,6 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -65,7 +70,7 @@ public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, * @param dependencies collection of dependencies with the dependency versions before the change * @param newestVersionProducer function providing the newest version given a dependency and * an {@link ArtifactVersions} instance - * @param changeRecorderTitle title for the change recorder records + * @param changeKind title for the change recorder records * @param filters optional array of filters * @throws XMLStreamException thrown if the POM update doesn't succeed * @throws ArtifactMetadataRetrievalException thrown if an artifact cannot be retried @@ -75,7 +80,7 @@ protected final void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies, BiFunction> newestVersionProducer, - String changeRecorderTitle, + ChangeRecord.ChangeKind changeKind, Predicate... filters ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { @@ -114,7 +119,7 @@ protected final void useLatestVersions( ModifiedPomXMLEventReader pom, Optional newestVer = newestVersionProducer.apply( dep, versions ); if ( newestVer.isPresent() ) { - updateDependencyVersion( pom, dep, newestVer.get().toString(), changeRecorderTitle ); + updateDependencyVersion( pom, dep, newestVer.get().toString(), changeKind ); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 05705f90dc..eb703c3138 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import java.util.regex.Pattern; import org.apache.maven.artifact.manager.WagonManager; @@ -37,6 +38,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -68,9 +71,11 @@ public UseNextReleasesMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -91,13 +96,14 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useNextReleases( pom, dependencyManagement.getDependencies() ); + useNextReleases( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useNextReleases( pom, getProject().getDependencies() ); + useNextReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -106,15 +112,18 @@ protected void update( ModifiedPomXMLEventReader pom ) } if ( getProject().getParent() != null && isProcessingParent() ) { - useNextReleases( pom, singletonList( getParentDependency() ) ); + useNextReleases( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } - private void useNextReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useNextReleases( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { useLatestVersions( pom, dependencies, - ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), false )[0] ), - "useNextReleases", dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), false )[0] ), + changeKind, + dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index afaf413029..f1bef54ca3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.Map; import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; @@ -41,6 +42,8 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -93,9 +96,11 @@ public UseNextSnapshotsMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } @@ -116,15 +121,17 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useNextSnapshots( pom, dependencyManagement.getDependencies() ); + useNextSnapshots( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useNextSnapshots( pom, getProject().getDependencies() ); + useNextSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useNextSnapshots( pom, singletonList( getParentDependency() ) ); + useNextSnapshots( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -133,7 +140,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { Optional @@ -141,7 +149,7 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection + ( dep, versions ) -> { try { @@ -155,7 +163,6 @@ private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + }, changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 529e983e40..ab2629cff9 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; @@ -36,6 +37,8 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -60,9 +63,11 @@ public UseNextVersionsMojo( RepositorySystem repositorySystem, MavenProjectBuilder projectBuilder, ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, - ArtifactResolver artifactResolver ) + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -83,16 +88,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useNextVersions( pom, dependencyManagement.getDependencies() ); + useNextVersions( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useNextVersions( pom, getProject().getDependencies() ); + useNextVersions( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useNextVersions( pom, singletonList( getParentDependency() ) ); + useNextVersions( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -101,11 +108,12 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useNextVersions( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useNextVersions( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { useLatestVersions( pom, dependencies, - ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), allowSnapshots )[0] ), - "useNextVersions" ); + ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), allowSnapshots )[0] ), + changeKind ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index a8333cb370..c2b5802978 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.util.Collection; +import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; @@ -40,6 +41,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; /** @@ -57,12 +59,14 @@ public class UseReactorMojo @Inject public UseReactorMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 1a4704f8f2..295f14b4f1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; @@ -44,6 +45,8 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -83,12 +86,14 @@ public class UseReleasesMojo @Inject public UseReleasesMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver ) + MavenProjectBuilder projectBuilder, + ArtifactMetadataSource artifactMetadataSource, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver ); + super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -109,16 +114,18 @@ protected void update( ModifiedPomXMLEventReader pom ) PomHelper.getRawModel( getProject() ).getDependencyManagement(); if ( dependencyManagement != null ) { - useReleases( pom, dependencyManagement.getDependencies() ); + useReleases( pom, dependencyManagement.getDependencies(), + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); } } if ( getProject().getDependencies() != null && isProcessingDependencies() ) { - useReleases( pom, getProject().getDependencies() ); + useReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } if ( getProject().getParent() != null && isProcessingParent() ) { - useReleases( pom, singletonList( getParentDependency() ) ); + useReleases( pom, singletonList( getParentDependency() ), + ChangeRecord.ChangeKind.PARENT ); } } catch ( ArtifactMetadataRetrievalException | IOException e ) @@ -127,7 +134,8 @@ protected void update( ModifiedPomXMLEventReader pom ) } } - private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies ) + private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, + ChangeRecord.ChangeKind changeKind ) throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException { for ( Dependency dep : dependencies ) @@ -168,7 +176,7 @@ private void useReleases( ModifiedPomXMLEventReader pom, Collection getHelper().lookupArtifactVersions( artifact, false ) ); if ( targetVersion.isPresent() ) { - updateDependencyVersion( pom, dep, targetVersion.get(), "useReleases" ); + updateDependencyVersion( pom, dep, targetVersion.get(), changeKind ); } else { diff --git a/versions-maven-plugin/src/site/site.xml b/versions-maven-plugin/src/site/site.xml index bdd343679d..30922de522 100644 --- a/versions-maven-plugin/src/site/site.xml +++ b/versions-maven-plugin/src/site/site.xml @@ -8,6 +8,7 @@ +

    diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 25250b203d..6c0207ec2d 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -157,12 +157,16 @@ public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", - "2.0.0-rc1"} ); - }} ), null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", + new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", + "2.0.0-rc1"} ); + }} ), + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -200,11 +204,14 @@ public void testAllowMajorUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); - }} ), null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); + }} ), + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -241,11 +248,15 @@ public void testAllowMinorUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", + new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -283,11 +294,15 @@ public void testAllowIncrementalUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", + new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -326,12 +341,16 @@ public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", - "1.9.0-rc1"} ); - }} ), null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ) ) + null, + mockArtifactMetadataSource( new HashMap() + {{ + put( "default-dependency", + new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", + "1.9.0-rc1"} ); + }} ), + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 983fa90629..3bdf537f95 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -11,7 +11,7 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -63,11 +63,10 @@ public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); mojo = new ForceReleasesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource(), - null, new StubArtifactResolver( new ArtifactStubFactory(), - false, false ) ); + null, mockArtifactMetadataSource(), + null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); - setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); mojo.project = new MavenProject() {{ setModel( new Model() @@ -102,8 +101,8 @@ public void testProcessParent() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); } @Test @@ -126,8 +125,8 @@ public void testReplaceSnapshotWithRelease() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); } @Test @@ -150,8 +149,8 @@ public void testUpgrade() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "1.1.0-SNAPSHOT", "2.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "1.1.0-SNAPSHOT", "2.0.0" ) ) ); } @Test @@ -174,8 +173,8 @@ public void testDowngrade() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "2.1.0-SNAPSHOT", "2.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "2.1.0-SNAPSHOT", "2.0.0" ) ) ); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index f17e63817c..5605952eb2 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -21,7 +21,7 @@ public class SeparatePatternsForIncludesAnExcludesTest public void setUp() throws Exception { - mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null ) + mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null, null ) { protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index bce9eaa048..3a34edd890 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -48,7 +48,7 @@ public void tearDown() throws IOException @Test public void testGetIncrementedVersion() throws MojoExecutionException { - new SetMojo( null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null, null ) { { assertThat( getIncrementedVersion( "1.0.0", null ), is( "1.0.1-SNAPSHOT" ) ); @@ -63,7 +63,7 @@ public void testGetIncrementedVersion() throws MojoExecutionException @Test public void testNextSnapshotIndexLowerBound() { - new SetMojo( null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null, null ) { { try @@ -83,7 +83,7 @@ public void testNextSnapshotIndexLowerBound() @Test public void testNextSnapshotIndexUpperBound() { - new SetMojo( null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null, null ) { { try @@ -105,7 +105,7 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti { try { - new SetMojo( null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null, null ) { { project = new MavenProject(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 0350f8c684..27b9724589 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -20,7 +20,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -76,14 +76,14 @@ public void setUp() throws IllegalAccessException artifactResolver = mock( ArtifactResolver.class ); mojo = new UpdateParentMojo( repositorySystem, - null, - artifactMetadataSource, - null, - artifactResolver ) + null, + artifactMetadataSource, + null, + artifactResolver, + changeRecorder.asTestMap() ) {{ setProject( createProject() ); reactorProjects = Collections.emptyList(); - setVariableValueToObject( this, "changeRecorder", changeRecorder ); }}; } @@ -159,8 +159,8 @@ public void testParentDowngradeAllowed() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "parent-artifact", "1.0.1-SNAPSHOT", - "1.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "parent-artifact", "1.0.1-SNAPSHOT", + "1.0.0" ) ) ); } @Test @@ -240,9 +240,9 @@ public void testAllowSnapshotsWithParentVersion() .thenReturn( true ); mojo.update( null ); } - assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", - "issue-670-artifact", "0.0.1-1", - "0.0.1-1-impl-SNAPSHOT" ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( new DefaultVersionChange( "default-group", + "issue-670-artifact", "0.0.1-1", + "0.0.1-1-impl-SNAPSHOT" ) ) ); } @Test @@ -299,8 +299,8 @@ private void testSkipResolution( String version ) throw new RuntimeException( e ); } - assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group", - "parent-artifact", "1.0.0", version ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( + new DefaultVersionChange( "default-group", "parent-artifact", "1.0.0", version ) ) ); } @Test @@ -320,8 +320,8 @@ public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStre mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "parent-artifact", "0.9.0", - "1.0.1-SNAPSHOT" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "parent-artifact", "0.9.0", + "1.0.1-SNAPSHOT" ) ) ); } @Test @@ -382,8 +382,8 @@ public void testParentVersionRange() throws MojoExecutionException, XMLStreamExc mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dummy-parent2", "1.0", - "2.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "dummy-parent2", "1.0", + "2.0" ) ) ); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java index 3877397f16..62c034b105 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java @@ -21,7 +21,7 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.hamcrest.Matchers; import org.junit.Test; @@ -39,8 +39,8 @@ public void testAllowMajorUpdates() throws Exception Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); setUpMojo( "update-properties" ).execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); } @Test @@ -51,8 +51,8 @@ public void testAllowMinorUpdates() throws Exception UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); mojo.allowMajorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); } @Test @@ -64,7 +64,7 @@ public void testAllowIncrementalUpdates() throws Exception mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java index 431bc30906..afcb78fe8c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java @@ -20,12 +20,14 @@ import java.nio.file.Path; import java.util.HashMap; +import java.util.Map; import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.After; import org.junit.Before; @@ -51,7 +53,6 @@ public void setUp() throws Exception { super.setUp(); pomDir = createTempDir( "update-property" ); - changeRecorder = new TestChangeRecorder(); artifactMetadataSource = mockArtifactMetadataSource( new HashMap() {{ put( "default-artifact", new String[] {"1.0.0", "1.0.1-rc1", "1.1.0-alpha", "2.0.0-M1"} ); @@ -77,8 +78,12 @@ protected T setUpMojo( String goal ) throws Exception T mojo = (T) mojoRule.lookupConfiguredMojo( pomDir.toFile(), goal ); setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( pomDir.toString() ) ); setVariableValueToObject( mojo, "artifactMetadataSource", artifactMetadataSource ); - setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); setVariableValueToObject( mojo, "generateBackupPoms", false ); + setVariableValueToObject( mojo, "changeRecorderFormat", "test" ); + changeRecorder = (TestChangeRecorder) + ( (Map) getVariableValueFromObject( mojo, "changeRecorders" ) ) + .get( "test" ); + return (T) mojo; } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java index 8e1ec84eab..1a63831a8d 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java @@ -21,7 +21,7 @@ import java.nio.file.Files; import java.nio.file.Paths; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.hamcrest.Matchers; import org.junit.Test; @@ -41,8 +41,8 @@ public void testAllowMajorUpdates() throws Exception UpdatePropertyMojo mojo = setUpMojo( "update-property" ); mojo.property = "artifact-version"; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); } @Test @@ -54,8 +54,8 @@ public void testAllowMinorUpdates() throws Exception mojo.property = "artifact-version"; mojo.allowMajorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); } @Test @@ -68,7 +68,7 @@ public void testAllowIncrementalUpdates() throws Exception mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( new VersionChange( "default-group", - "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); + assertThat( changeRecorder.getChanges(), Matchers.hasItem( + new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index 72fd58f2d5..82446fda07 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -54,11 +54,14 @@ public void setUp() throws Exception put( "dependency-artifact", new String[] {"0.9.0", "1.0.0-beta"} ); }} ); + changeRecorder = new TestChangeRecorder(); + mojo = new UseLatestReleasesMojo( repositorySystemMock, - null, - artifactMetadataSourceMock, - null, - null ) + null, + artifactMetadataSourceMock, + null, + null, + changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); MavenProject project = new MavenProject() @@ -81,9 +84,6 @@ public void setUp() throws Exception }} ); }}; setProject( project ); - - changeRecorder = new TestChangeRecorder(); - setVariableValueToObject( this, "changeRecorder", changeRecorder ); }}; } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 98c5a34f1a..ed0b35723e 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -16,7 +16,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.core.Is; @@ -66,11 +66,14 @@ public void setUp() throws Exception put( "other-artifact", new String[] {"1.0", "2.0"} ); }} ); + changeRecorder = new TestChangeRecorder(); + mojo = new UseLatestVersionsMojo( repositorySystemMock, - null, - artifactMetadataSourceMock, - null, - null ) + null, + artifactMetadataSourceMock, + null, + null, + changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); MavenProject project = new MavenProject() @@ -93,9 +96,7 @@ public void setUp() throws Exception }}; setProject( project ); }}; - changeRecorder = new TestChangeRecorder(); setVariableValueToObject( mojo, "processDependencyManagement", false ); - setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); } @Test @@ -115,8 +116,8 @@ public void testDependenciesDowngradeIncremental() .thenReturn( true ); mojo.update( null ); } - assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( + new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -141,8 +142,8 @@ public void testDependenciesDowngradeMinor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", - "1.1.0-SNAPSHOT", "1.1.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "dependency-artifact", + "1.1.0-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -163,8 +164,8 @@ public void testDependenciesDowngradeMajor() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", - "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "dependency-artifact", + "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -186,8 +187,8 @@ public void testDependencyManagementDowngrade() .thenReturn( true ); mojo.update( null ); } - assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( + new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -218,8 +219,8 @@ public void testParentDowngrade() .thenReturn( true ); mojo.update( null ); } - assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( + new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -248,9 +249,8 @@ public void testPoisonDependencyVersion() } // So, the regular update should take place despite an irregular, or — if I may — "poison", dependency // being present in the dependency list - assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "1.1.0" ) ) ); + assertThat( changeRecorder.getChanges(), hasItem( + new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); } @Test @@ -291,8 +291,7 @@ public void testIncludeFilter() } assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "other-artifact", "1.0", - "2.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "other-artifact", "1.0", "2.0" ) ) ); } @Test @@ -317,7 +316,7 @@ public void testExcludeFilter() } assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); assertThat( changeRecorder.getChanges(), - not( hasItem( new VersionChange( "default-group", "other-artifact", "1.0", - "2.0" ) ) ) ); + not( hasItem( new DefaultVersionChange( "default-group", "other-artifact", "1.0", + "2.0" ) ) ) ); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index 6e2b40bfbf..fe28fdf43a 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -11,7 +11,7 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; -import org.codehaus.mojo.versions.change.VersionChange; +import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.Before; @@ -63,11 +63,10 @@ public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); mojo = new UseReleasesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource(), - null, new StubArtifactResolver( new ArtifactStubFactory(), - false, false ) ); + null, mockArtifactMetadataSource(), + null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); - setVariableValueToObject( mojo, "changeRecorder", changeRecorder ); mojo.project = new MavenProject() {{ setModel( new Model() @@ -102,8 +101,8 @@ public void testProcessParent() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); } @Test @@ -126,8 +125,8 @@ public void testReplaceSnapshotWithRelease() mojo.update( null ); } assertThat( changeRecorder.getChanges(), - hasItem( new VersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + hasItem( new DefaultVersionChange( "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0" ) ) ); } @Test diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java index 2966cafe6e..93dad6ec69 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java @@ -19,25 +19,31 @@ * under the License. */ -import java.io.OutputStream; +import javax.inject.Named; + +import java.nio.file.Path; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; -import org.codehaus.mojo.versions.change.VersionChange; -import org.codehaus.mojo.versions.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.change.VersionChange; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +@Named( "test" ) public class TestChangeRecorder implements ChangeRecorder { private final List changes = new LinkedList<>(); @Override - public void recordUpdate( String kind, String groupId, String artifactId, String oldVersion, String newVersion ) + public void recordChange( ChangeRecord changeRecord ) { - changes.add( new VersionChange( groupId, artifactId, oldVersion, newVersion ) ); + changes.add( changeRecord.getVersionChange() ); } @Override - public void serialize( OutputStream outputStream ) + public void writeReport( Path outputPath ) { } @@ -45,4 +51,11 @@ public List getChanges() { return changes; } -} \ No newline at end of file + + public Map asTestMap() + { + HashMap map = new HashMap<>(); + map.put( "none", this ); + return map; + } +} From 44883ad7c50fc990b61f1b177cfd1e993fa64dec Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 20 Nov 2022 11:29:37 +0100 Subject: [PATCH 214/441] #704: Removing ArtifactMetadataSource --- pom.xml | 5 + .../versions/api/DefaultVersionsHelper.java | 215 +++++++----------- .../mojo/versions/api/PropertyVersions.java | 5 +- .../versions/api/PropertyVersionsBuilder.java | 3 +- .../api/VersionRetrievalException.java | 85 +++++++ .../mojo/versions/api/VersionsHelper.java | 21 +- .../api/DefaultVersionsHelperTest.java | 99 ++++---- .../mojo/versions/utils/VersionStub.java | 76 +++++++ ...AbstractVersionsDependencyUpdaterMojo.java | 7 +- .../versions/AbstractVersionsDisplayMojo.java | 7 +- .../mojo/versions/AbstractVersionsReport.java | 23 +- .../versions/AbstractVersionsUpdaterMojo.java | 45 ++-- .../versions/CompareDependenciesMojo.java | 9 +- .../versions/DependencyUpdatesReportMojo.java | 10 +- .../DisplayDependencyUpdatesMojo.java | 16 +- .../versions/DisplayParentUpdatesMojo.java | 13 +- .../versions/DisplayPluginUpdatesMojo.java | 15 +- .../versions/DisplayPropertyUpdatesMojo.java | 11 +- .../mojo/versions/ForceReleasesMojo.java | 15 +- .../mojo/versions/LockSnapshotsMojo.java | 9 +- .../versions/ParentUpdatesReportMojo.java | 14 +- .../versions/PluginUpdatesReportMojo.java | 14 +- .../versions/PropertyUpdatesReportMojo.java | 9 +- .../mojo/versions/ResolveRangesMojo.java | 15 +- .../org/codehaus/mojo/versions/SetMojo.java | 9 +- .../mojo/versions/SetPropertyMojo.java | 15 +- .../codehaus/mojo/versions/SetScmTagMojo.java | 10 +- .../mojo/versions/UnlockSnapshotsMojo.java | 9 +- .../mojo/versions/UpdateChildModulesMojo.java | 9 +- .../mojo/versions/UpdateParentMojo.java | 17 +- .../mojo/versions/UpdatePropertiesMojo.java | 9 +- .../mojo/versions/UpdatePropertyMojo.java | 15 +- .../mojo/versions/UseDepVersionMojo.java | 15 +- .../mojo/versions/UseLatestReleasesMojo.java | 15 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 15 +- .../mojo/versions/UseLatestVersionsMojo.java | 15 +- .../versions/UseLatestVersionsMojoBase.java | 21 +- .../mojo/versions/UseNextReleasesMojo.java | 25 +- .../mojo/versions/UseNextSnapshotsMojo.java | 21 +- .../mojo/versions/UseNextVersionsMojo.java | 15 +- .../mojo/versions/UseReactorMojo.java | 17 +- .../mojo/versions/UseReleasesMojo.java | 15 +- .../DependencyUpdatesReportMojoTest.java | 67 +++--- .../DisplayDependencyUpdatesMojoTest.java | 107 +++++---- .../DisplayPropertyUpdatesMojoTest.java | 6 +- .../mojo/versions/ForceReleasesMojoTest.java | 25 +- .../versions/ParentUpdatesReportMojoTest.java | 15 +- .../versions/PluginUpdatesReportMojoTest.java | 24 +- .../PropertyUpdatesReportMojoTest.java | 9 +- ...ratePatternsForIncludesAnExcludesTest.java | 6 +- .../mojo/versions/SetPropertyMojoTest.java | 44 ++-- .../mojo/versions/UpdateParentMojoTest.java | 68 +++--- .../UpdatePropertiesMojoTestBase.java | 9 +- .../versions/UseLatestReleasesMojoTest.java | 28 ++- .../versions/UseLatestVersionsMojoTest.java | 51 +++-- .../mojo/versions/UseReleasesMojoTest.java | 24 +- .../mojo/versions/utils/MockUtils.java | 61 +++-- .../mojo/versions/utils/VersionStub.java | 76 +++++++ 58 files changed, 922 insertions(+), 706 deletions(-) create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java create mode 100644 versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java create mode 100644 versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java diff --git a/pom.xml b/pom.xml index 7336f447ab..8e37806153 100644 --- a/pom.xml +++ b/pom.xml @@ -196,6 +196,11 @@ slf4j-simple 1.7.36 + + org.apache.commons + commons-text + 1.9 + diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 4f425ff300..1ee58570b6 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -47,11 +47,10 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -90,6 +89,8 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResolutionException; /** * Helper class that provides common functionality required by both the mojos and the reports. @@ -115,13 +116,6 @@ public class DefaultVersionsHelper */ private RuleSet ruleSet; - /** - * The artifact metadata source to use. - * - * @since 1.0-alpha-3 - */ - private ArtifactMetadataSource artifactMetadataSource; - /** * The local repository to consult. * @@ -129,22 +123,10 @@ public class DefaultVersionsHelper */ private ArtifactRepository localRepository; - /** - * The remote artifact repositories to consult. - * - * @since 1.0-alpha-3 - */ - private List remoteArtifactRepositories; - - /** - * The remote plugin repositories to consult. - * - * @since 1.0-alpha-3 - */ - private List remotePluginRepositories; - private RepositorySystem repositorySystem; + private org.eclipse.aether.RepositorySystem aetherRepositorySystem; + /** * The {@link Log} to send log messages to. * @@ -388,61 +370,65 @@ public Log getLog() @Override public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { - List remoteRepositories = usePluginRepositories - ? remotePluginRepositories : remoteArtifactRepositories; - final List versions = - artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository, remoteRepositories ); - final List ignoredVersions = getIgnoredVersions( artifact ); - if ( !ignoredVersions.isEmpty() ) + try { - if ( getLog().isDebugEnabled() ) + Collection ignoredVersions = getIgnoredVersions( artifact ); + if ( !ignoredVersions.isEmpty() && getLog().isDebugEnabled() ) { - getLog().debug( "Found ignored versions: " + showIgnoredVersions( ignoredVersions ) ); - } - - final Iterator i = versions.iterator(); - while ( i.hasNext() ) - { - final String version = i.next().toString(); - for ( final IgnoreVersion ignoreVersion : ignoredVersions ) - { - if ( TYPE_REGEX.equals( ignoreVersion.getType() ) ) - { - Pattern p = Pattern.compile( ignoreVersion.getVersion() ); - if ( p.matcher( version ).matches() ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Version " + version + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) - + " found on ignore list: " - + ignoreVersion ); - } - i.remove(); - break; - } - } - else if ( TYPE_EXACT.equals( ignoreVersion.getType() ) ) - { - if ( version.equals( ignoreVersion.getVersion() ) ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Version " + version + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) - + " found on ignore list: " - + ignoreVersion ); - } - i.remove(); - break; - } - } - } + getLog().debug( "Found ignored versions: " + ignoredVersions.stream() + .map( IgnoreVersion::toString ).collect( Collectors.joining( ", " ) ) ); } + return new ArtifactVersions( artifact, + aetherRepositorySystem.resolveVersionRange( mavenSession.getRepositorySession(), + new VersionRangeRequest( + RepositoryUtils.toArtifact( artifact ).setVersion( "(,)" ), + usePluginRepositories + ? mavenSession.getCurrentProject().getRemotePluginRepositories() + : mavenSession.getCurrentProject().getRemoteProjectRepositories(), + "lookupArtifactVersions" ) ) + .getVersions() + .parallelStream() + .filter( v -> ignoredVersions.stream() + .noneMatch( i -> + { + if ( TYPE_REGEX.equals( i.getType() ) + && Pattern.compile( i.getVersion() ).matcher( v.toString() ).matches() ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Version " + v + " for artifact " + + ArtifactUtils.versionlessKey( artifact ) + + " found on ignore list: " + + i ); + } + return true; + } + + if ( TYPE_EXACT.equals( i.getType() ) + && i.getVersion().equals( v.toString() ) ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Version " + v + " for artifact " + + ArtifactUtils.versionlessKey( artifact ) + + " found on ignore list: " + + i ); + } + return true; + } + + return false; + } ) ) + .map( v -> new DefaultArtifactVersion( v.toString() ) ) + .collect( Collectors.toList() ), + getVersionComparator( artifact ) ); + } + catch ( VersionRangeResolutionException e ) + { + throw new VersionRetrievalException( e.getMessage(), e ); } - return new ArtifactVersions( artifact, versions, getVersionComparator( artifact ) ); } /** @@ -491,35 +477,15 @@ private List getIgnoredVersions( Artifact artifact ) return ret; } - /** - * Pretty print a list of ignored versions. - * - * @param ignoredVersions A list of ignored versions - * @return A String representation of the list - */ - private String showIgnoredVersions( List ignoredVersions ) - { - StringBuilder buf = new StringBuilder(); - Iterator iterator = ignoredVersions.iterator(); - while ( iterator.hasNext() ) - { - IgnoreVersion ignoreVersion = iterator.next(); - buf.append( ignoreVersion ); - if ( iterator.hasNext() ) - { - buf.append( ", " ); - } - } - return buf.toString(); - } - @Override public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException { - List remoteRepositories = - usePluginRepositories ? remotePluginRepositories : remoteArtifactRepositories; - artifactResolver.resolve( artifact, remoteRepositories, localRepository ); + artifactResolver.resolve( artifact, + usePluginRepositories + ? mavenSession.getCurrentProject().getPluginArtifactRepositories() + : mavenSession.getCurrentProject().getRemoteArtifactRepositories(), + localRepository ); } @Override @@ -674,12 +640,11 @@ public ArtifactVersion createArtifactVersion( String version ) * @param dependencies The set of {@link Dependency} instances to look up. * @param usePluginRepositories Search the plugin repositories. * @return map containing the ArtifactVersions object per dependency - * @throws ArtifactMetadataRetrievalException if the lookup does not succeed */ @Override public Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try @@ -699,8 +664,8 @@ public Map lookupDependenciesUpdates( Set lookupDependenciesUpdates( Set lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); try @@ -740,8 +705,8 @@ public Map lookupPluginsUpdates( Set plugi } catch ( ExecutionException | InterruptedException ie ) { - throw new ArtifactMetadataRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " - + ie.getMessage(), ie, null ); + throw new VersionRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " + + ie.getMessage(), ie ); } finally { @@ -751,7 +716,7 @@ public Map lookupPluginsUpdates( Set plugi @Override public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { String version = plugin.getVersion() != null ? plugin.getVersion() @@ -885,7 +850,7 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr .getProperty( property.getName() ) ); propertyVersions.put( property, versions ); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -918,9 +883,6 @@ public static class Builder { private RepositorySystem repositorySystem; private ArtifactResolver artifactResolver; - private ArtifactMetadataSource artifactMetadataSource; - private List remoteArtifactRepositories; - private List remotePluginRepositories; private ArtifactRepository localRepository; private Collection ignoredVersions; private RuleSet ruleSet; @@ -931,6 +893,7 @@ public static class Builder private Log log; private MavenSession mavenSession; private MojoExecution mojoExecution; + private org.eclipse.aether.RepositorySystem aetherRepositorySystem; public Builder() { @@ -948,26 +911,6 @@ public Builder withArtifactResolver( ArtifactResolver artifactResolver ) return this; } - public Builder withArtifactMetadataSource( ArtifactMetadataSource artifactMetadataSource ) - { - this.artifactMetadataSource = artifactMetadataSource; - return this; - } - - public Builder withRemoteArtifactRepositories( - List remoteArtifactRepositories ) - { - this.remoteArtifactRepositories = remoteArtifactRepositories; - return this; - } - - public Builder withRemotePluginRepositories( - List remotePluginRepositories ) - { - this.remotePluginRepositories = remotePluginRepositories; - return this; - } - public Builder withLocalRepository( ArtifactRepository localRepository ) { this.localRepository = localRepository; @@ -1028,6 +971,12 @@ public Builder withMojoExecution( MojoExecution mojoExecution ) return this; } + public Builder withAetherRepositorySystem( org.eclipse.aether.RepositorySystem aetherRepositorySystem ) + { + this.aetherRepositorySystem = aetherRepositorySystem; + return this; + } + /** * Builds the constructed {@linkplain DefaultVersionsHelper} object * @return constructed {@linkplain DefaultVersionsHelper} @@ -1061,10 +1010,8 @@ public DefaultVersionsHelper build() throws MojoExecutionException { instance.ruleSet = enrichRuleSet( ignoredVersions, instance.ruleSet ); } - instance.artifactMetadataSource = artifactMetadataSource; + instance.aetherRepositorySystem = aetherRepositorySystem; instance.localRepository = localRepository; - instance.remoteArtifactRepositories = remoteArtifactRepositories; - instance.remotePluginRepositories = remotePluginRepositories; instance.log = log; return instance; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index 825be779e2..cfef7f9cd4 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -32,7 +32,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -74,7 +73,7 @@ public class PropertyVersions private final PropertyVersions.PropertyVersionComparator comparator; PropertyVersions( String profileId, String name, VersionsHelper helper, Set associations ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { this.profileId = profileId; this.name = name; @@ -88,7 +87,7 @@ public class PropertyVersions private static SortedSet resolveAssociatedVersions( VersionsHelper helper, Set associations, VersionComparator versionComparator ) - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { SortedSet versions = null; for ( ArtifactAssociation association : associations ) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java index 2e3c7a7312..2fe8963834 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java @@ -26,7 +26,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.codehaus.mojo.versions.ordering.VersionComparator; @@ -91,7 +90,7 @@ public ArtifactAssociation[] getAssociations() } public PropertyVersions newPropertyVersions() - throws ArtifactMetadataRetrievalException + throws VersionRetrievalException { return new PropertyVersions( profileId, name, helper, associations ); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java new file mode 100644 index 0000000000..c1f1a4138e --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java @@ -0,0 +1,85 @@ +package org.codehaus.mojo.versions.api; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Exception thrown if version information cannot be retrieved + */ +public class VersionRetrievalException extends Exception +{ + /** + * Constructs a new exception with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + */ + public VersionRetrievalException() + { + super(); + } + + /** + * Constructs a new exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public VersionRetrievalException( String message ) + { + super( message ); + } + + /** + * Constructs a new exception with the specified cause and a detail + * message of {@code (cause==null ? null : cause.toString())} (which + * typically contains the class and detail message of {@code cause}). + * This constructor is useful for exceptions that are little more than + * wrappers for other throwables (for example, {@link + * java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public VersionRetrievalException( Throwable cause ) + { + super( cause ); + } + + /** + * Constructs a new exception with the specified detail message and + * cause.

    Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public VersionRetrievalException( String message, Throwable cause ) + { + super( message, cause ); + } +} diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index bd803639d6..28a11879dd 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -25,7 +25,6 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -150,11 +149,11 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @param usePluginRepositories true will consult the pluginRepositories, while false will * consult the repositories for normal dependencies. * @return The details of the available artifact versions. - * @throws ArtifactMetadataRetrievalException When things go wrong. + * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-alpha-3 */ ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException; + throws VersionRetrievalException; /** * Looks up the updates for a set of dependencies. @@ -162,12 +161,12 @@ ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRep * @param dependencies The set of {@link Dependency} instances to look up. * @param usePluginRepositories Search the plugin repositories. * @return A map, keyed by dependency, with values of type {@link org.codehaus.mojo.versions.api.ArtifactVersions}. - * @throws ArtifactMetadataRetrievalException When things go wrong. + * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ Map lookupDependenciesUpdates( Set dependencies, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException; + throws VersionRetrievalException; /** * Creates an {@link org.codehaus.mojo.versions.api.ArtifactVersions} instance from a dependency. @@ -175,11 +174,11 @@ Map lookupDependenciesUpdates( Set dep * @param dependency The dependency. * @param usePluginRepositories Search the plugin repositories. * @return The details of updates to the dependency. - * @throws ArtifactMetadataRetrievalException When things go wrong. + * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException; + throws VersionRetrievalException; /** * Looks up the updates for a set of plugins. @@ -187,11 +186,11 @@ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePlug * @param plugins The set of {@link Plugin} instances to look up. * @param allowSnapshots Include snapshots in the list of updates. * @return A map, keyed by plugin, with values of type {@link org.codehaus.mojo.versions.api.PluginUpdatesDetails}. - * @throws ArtifactMetadataRetrievalException When things go wrong. + * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ Map lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException; + throws VersionRetrievalException; /** * Looks up the updates for a plugin. @@ -199,11 +198,9 @@ Map lookupPluginsUpdates( Set plugins, boo * @param plugin The {@link Plugin} instance to look up. * @param allowSnapshots Include snapshots in the list of updates. * @return The plugin update details. - * @throws ArtifactMetadataRetrievalException When things go wrong. * @since 1.0-beta-1 */ - PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) - throws ArtifactMetadataRetrievalException; + PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) throws VersionRetrievalException; /** * Returns an {@link ExpressionEvaluator} for the specified project. diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 047bc3f421..b442516370 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -23,35 +23,37 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.plugin.testing.AbstractMojoTestCase; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.MavenMetadataSource; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.VersionComparators; +import org.codehaus.mojo.versions.utils.VersionStub; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResult; +import org.eclipse.aether.version.Version; import org.hamcrest.CoreMatchers; import org.junit.Test; -import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -59,9 +61,7 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsIterableContaining.hasItems; import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyList; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.same; import static org.mockito.Mockito.when; /** @@ -73,64 +73,68 @@ public class DefaultVersionsHelperTest extends AbstractMojoTestCase @Test public void testPerRuleVersionsIgnored() throws Exception { - final ArtifactMetadataSource metadataSource = mock( ArtifactMetadataSource.class ); + final org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); final Artifact artifact = mock( Artifact.class ); when( artifact.getGroupId() ).thenReturn( "com.mycompany.maven" ); when( artifact.getArtifactId() ).thenReturn( "artifact-one" ); - - final List artifactVersions = new ArrayList<>(); - - artifactVersions.add( new DefaultArtifactVersion( "one" ) ); - artifactVersions.add( new DefaultArtifactVersion( "two" ) ); - final ArtifactVersion three = new DefaultArtifactVersion( "three" ); - artifactVersions.add( three ); - final ArtifactVersion oneTwoHundred = new DefaultArtifactVersion( "1.200" ); - artifactVersions.add( oneTwoHundred ); - final ArtifactVersion illegal = new DefaultArtifactVersion( "illegalVersion" ); - artifactVersions.add( illegal ); - - when( metadataSource.retrieveAvailableVersions( same( artifact ), any( ArtifactRepository.class ), anyList() ) ) - .thenReturn( artifactVersions ); - - VersionsHelper helper = createHelper( metadataSource ); + when( artifact.getType() ).thenReturn( "jar" ); + when( artifact.getArtifactHandler() ).thenReturn( new DefaultArtifactHandlerStub( "default" ) ); + when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) + .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) + .setVersions( Arrays.asList( + new VersionStub( "one" ), + new VersionStub( "two" ), + new VersionStub( "three" ), + new VersionStub( "1.200" ), + new VersionStub( "illegalVersion" ) ) ) ); + + VersionsHelper helper = createHelper( repositorySystem ); final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); - final List actual = asList( versions.getVersions( true ) ); + final List actual = Arrays.stream( versions.getVersions( true ) ) + .map( ArtifactVersion::toString ) + .collect( Collectors.toList() ); assertEquals( 3, actual.size() ); - assertThat( actual, hasItems( three, oneTwoHundred, illegal ) ); + assertThat( actual, hasItems( "three", "1.200", "illegalVersion" ) ); } @Test public void testGlobalRuleVersionsIgnored() throws Exception { - final ArtifactMetadataSource metadataSource = mock( ArtifactMetadataSource.class ); + final org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); final Artifact artifact = mock( Artifact.class ); when( artifact.getGroupId() ).thenReturn( "other.company" ); when( artifact.getArtifactId() ).thenReturn( "artifact-two" ); + when( artifact.getType() ).thenReturn( "jar" ); + when( artifact.getArtifactHandler() ).thenReturn( new DefaultArtifactHandlerStub( "default" ) ); - final List artifactVersions = new ArrayList<>(); + final List artifactVersions = new ArrayList<>(); - final ArtifactVersion one = new DefaultArtifactVersion( "one" ); - final ArtifactVersion two = new DefaultArtifactVersion( "two" ); - final ArtifactVersion three = new DefaultArtifactVersion( "three" ); + final Version one = new VersionStub( "one" ); + final Version two = new VersionStub( "two" ); + final Version three = new VersionStub( "three" ); artifactVersions.add( one ); artifactVersions.add( two ); - artifactVersions.add( new DefaultArtifactVersion( "three-alpha" ) ); - artifactVersions.add( new DefaultArtifactVersion( "three-beta" ) ); + artifactVersions.add( new VersionStub( "three-alpha" ) ); + artifactVersions.add( new VersionStub( "three-beta" ) ); artifactVersions.add( three ); - final ArtifactVersion illegal = new DefaultArtifactVersion( "illegalVersion" ); + final Version illegal = new VersionStub( "illegalVersion" ); artifactVersions.add( illegal ); - when( metadataSource.retrieveAvailableVersions( same( artifact ), any( ArtifactRepository.class ), anyList() ) ) - .thenReturn( artifactVersions ); + when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) + .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) + .setVersions( artifactVersions ) ); - VersionsHelper helper = createHelper( metadataSource ); + VersionsHelper helper = createHelper( repositorySystem ); final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); - final List actual = asList( versions.getVersions( true ) ); + final List actual = Arrays.stream( versions.getVersions( true ) ) + .map( ArtifactVersion::toString ) + .map( VersionStub::new ) + .collect( Collectors.toList() ); assertEquals( 4, actual.size() ); assertThat( actual, hasItems( one, two, three, illegal ) ); @@ -214,19 +218,24 @@ public void testIsClasspathUriDetectsThatItIsDifferentProtocol() throws Exceptio private DefaultVersionsHelper createHelper() throws Exception { - return createHelper( new MavenMetadataSource() ); + return createHelper( null ); } - private DefaultVersionsHelper createHelper( ArtifactMetadataSource metadataSource ) throws Exception + private DefaultVersionsHelper createHelper( org.eclipse.aether.RepositorySystem aetherRepositorySystem ) + throws Exception { final String resourcePath = "/" + getClass().getPackage().getName().replace( '.', '/' ) + "/rules.xml"; - final String rulesUri = getClass().getResource( resourcePath ).toExternalForm(); + final String rulesUri = Objects.requireNonNull( getClass().getResource( resourcePath ) ).toExternalForm(); + MavenSession mavenSession = mock( MavenSession.class ); + when( mavenSession.getCurrentProject() ).thenReturn( mock( MavenProject.class ) ); + when( mavenSession.getCurrentProject().getRemotePluginRepositories() ) + .thenReturn( emptyList() ); + when( mavenSession.getCurrentProject().getRemotePluginRepositories() ) + .thenReturn( emptyList() ); return new DefaultVersionsHelper.Builder() .withRepositorySystem( lookup( RepositorySystem.class ) ) .withArtifactResolver( new DefaultArtifactResolver() ) - .withArtifactMetadataSource( metadataSource ) - .withRemoteArtifactRepositories( new ArrayList<>() ) - .withRemotePluginRepositories( new ArrayList<>() ) + .withAetherRepositorySystem( aetherRepositorySystem ) .withLocalRepository( new DefaultArtifactRepository( "", "", new DefaultRepositoryLayout() ) ) .withWagonManager( lookup( WagonManager.class ) ) @@ -234,7 +243,7 @@ private DefaultVersionsHelper createHelper( ArtifactMetadataSource metadataSourc .withServerId( "" ) .withRulesUri( rulesUri ) .withLog( mock( Log.class ) ) - .withMavenSession( mock( MavenSession.class ) ) + .withMavenSession( mavenSession ) .withMojoExecution( mock( MojoExecution.class ) ).build(); } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java new file mode 100644 index 0000000000..699644eeca --- /dev/null +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java @@ -0,0 +1,76 @@ +package org.codehaus.mojo.versions.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.eclipse.aether.version.Version; + +/** + * Stubs the {@link org.eclipse.aether.version.Version} + */ +public class VersionStub implements Version +{ + private final String version; + + /** + * Creates a new instance with the given version string + * @param version version to be set + */ + public VersionStub( String version ) + { + assert version != null; + this.version = version; + } + + @Override + public String toString() + { + return version; + } + + @Override + public int compareTo( Version o ) + { + return o != null + ? version.compareTo( o.toString() ) + : 1; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + + if ( !( o instanceof Version ) ) + { + return false; + } + + return version.equals( o.toString() ); + } + + @Override + public int hashCode() + { + return version.hashCode(); + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 42a46b92dd..5bee054503 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Dependency; @@ -160,14 +159,14 @@ public abstract class AbstractVersionsDependencyUpdaterMojo @Inject protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index fd01229369..98a6779361 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -31,7 +31,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; @@ -87,14 +86,14 @@ public abstract class AbstractVersionsDisplayMojo @Inject protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } @SuppressWarnings( "unchecked" ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 26b993dd34..45e0b1654f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -26,8 +26,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -45,6 +43,7 @@ import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; @@ -78,11 +77,9 @@ public abstract class AbstractVersionsReport private boolean skip; /** - * The artifact metadata source to use. - * - * @since 1.0-alpha-1 + * The (injected) {@link org.eclipse.aether.RepositorySystem aetherRepositorySystem} instance. */ - protected ArtifactMetadataSource artifactMetadataSource; + protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; /** * @since 1.0-alpha-3 @@ -197,14 +194,16 @@ public abstract class AbstractVersionsReport // --------------------- GETTER / SETTER METHODS --------------------- - protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + ArtifactResolver artifactResolver, + WagonManager wagonManager, ReportRendererFactory rendererFactory ) { this.i18n = i18n; this.repositorySystem = repositorySystem; + this.aetherRepositorySystem = aetherRepositorySystem; this.artifactResolver = artifactResolver; - this.artifactMetadataSource = artifactMetadataSource; this.wagonManager = wagonManager; this.rendererFactory = rendererFactory; } @@ -219,9 +218,7 @@ public VersionsHelper getHelper() helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) .withArtifactResolver( artifactResolver ) - .withArtifactMetadataSource( artifactMetadataSource ) - .withRemoteArtifactRepositories( remoteArtifactRepositories ) - .withRemotePluginRepositories( remotePluginRepositories ) + .withAetherRepositorySystem( aetherRepositorySystem ) .withLocalRepository( localRepository ) .withWagonManager( wagonManager ) .withSettings( settings ) @@ -295,7 +292,7 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); return artifactVersions.getNewestVersion( versionRange, includeSnapshots ); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MavenReportException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 4b7aace6e6..4b69512ba5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -33,8 +33,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -58,6 +56,7 @@ import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.model.RuleSet; @@ -87,25 +86,29 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${project}", required = true, readonly = true ) protected MavenProject project; - protected RepositorySystem repositorySystem; + /** + * The (injected) {@link RepositorySystem} instance. + */ + protected final RepositorySystem repositorySystem; /** - * @since 1.0-alpha-1 + * The (injected) {@link org.eclipse.aether.RepositorySystem} instance. */ - protected MavenProjectBuilder projectBuilder; + protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; + /** + * The (injected) {@link MavenProjectBuilder} instance. + */ /** * @since 1.0-alpha-1 */ - @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) - protected List reactorProjects; + protected final MavenProjectBuilder projectBuilder; /** - * The artifact metadata source to use. - * * @since 1.0-alpha-1 */ - protected ArtifactMetadataSource artifactMetadataSource; + @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) + protected List reactorProjects; /** * @since 1.0-alpha-3 @@ -126,9 +129,9 @@ public abstract class AbstractVersionsUpdaterMojo protected ArtifactRepository localRepository; /** - * @since 1.0-alpha-3 + * The (injected) {@link WagonManager} instance. */ - private WagonManager wagonManager; + private final WagonManager wagonManager; /** * @since 1.0-alpha-3 @@ -239,15 +242,15 @@ public abstract class AbstractVersionsUpdaterMojo @Inject protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { this.repositorySystem = repositorySystem; + this.aetherRepositorySystem = aetherRepositorySystem; this.projectBuilder = projectBuilder; - this.artifactMetadataSource = artifactMetadataSource; this.wagonManager = wagonManager; this.artifactResolver = artifactResolver; this.changeRecorders = changeRecorders; @@ -260,9 +263,7 @@ public VersionsHelper getHelper() throws MojoExecutionException helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) .withArtifactResolver( artifactResolver ) - .withArtifactMetadataSource( artifactMetadataSource ) - .withRemoteArtifactRepositories( remoteArtifactRepositories ) - .withRemotePluginRepositories( remotePluginRepositories ) + .withAetherRepositorySystem( aetherRepositorySystem ) .withLocalRepository( localRepository ) .withWagonManager( wagonManager ) .withSettings( settings ) @@ -341,13 +342,13 @@ protected void validateInput() throws MojoExecutionException * @param usePluginRepositories Use plugin repositories * @return The latest version of the specified artifact that matches the specified version range or * null if no matching version could be found. - * @throws ArtifactMetadataRetrievalException If the artifact metadata could not be found. + * @throws VersionRetrievalException If the artifact metadata could not be found. * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-1 */ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories ) - throws ArtifactMetadataRetrievalException, MojoExecutionException + throws MojoExecutionException, VersionRetrievalException { boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); @@ -414,7 +415,7 @@ protected void process( File outFile ) { getLog().error( e ); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -467,11 +468,11 @@ protected final void writeFile( File outFile, StringBuilder input ) * @throws MojoExecutionException If things go wrong. * @throws MojoFailureException If things go wrong. * @throws javax.xml.stream.XMLStreamException If things go wrong. - * @throws ArtifactMetadataRetrievalException if something goes wrong. + * @throws VersionRetrievalException if version retrieval goes wrong * @since 1.0-alpha-1 */ protected abstract void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException; + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException; /** * @param artifact The artifact. diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 22a54c5520..a955c8555b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -33,7 +33,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -128,15 +127,15 @@ public class CompareDependenciesMojo @Inject public CompareDependenciesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, MavenProjectBuilder mavenProjectBuilder, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); this.mavenProjectBuilder = mavenProjectBuilder; } @@ -148,7 +147,7 @@ public CompareDependenciesMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { if ( this.ignoreRemoteDependencies && this.ignoreRemoteDependencyManagement ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 69c5a66e67..5ed1df38b9 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -33,8 +33,6 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; @@ -45,6 +43,7 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyComparator; @@ -111,11 +110,12 @@ public class DependencyUpdatesReportMojo extends AbstractVersionsReport changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) @@ -595,7 +593,7 @@ public void execute() logUpdates( getHelper().lookupDependenciesUpdates( pluginDependencies, false ), "Plugin Dependencies" ); } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -791,15 +789,11 @@ private void logUpdates( Map updates, String secti /** * @param pom the pom to update. - * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong - * @throws org.apache.maven.plugin.MojoFailureException when things go wrong in a very bad way - * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException { // do nothing } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index c07dd91c74..a932c5aa28 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -20,14 +20,11 @@ */ import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -37,6 +34,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -56,14 +54,14 @@ public class DisplayParentUpdatesMojo @Inject public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } @Override @@ -108,7 +106,7 @@ public void execute() { artifactVersion = findLatestVersion( artifact, versionRange, null, false ); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -156,7 +154,6 @@ public void execute() @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 85e64ea4ca..41840c2785 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -50,8 +50,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -94,6 +92,7 @@ import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -165,8 +164,8 @@ public class DisplayPluginUpdatesMojo @Inject @SuppressWarnings( "checkstyle:ParameterNumber" ) public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, LifecycleExecutor lifecycleExecutor, @@ -175,8 +174,8 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, RuntimeInformation runtimeInformation, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; this.pluginManager = pluginManager; @@ -538,7 +537,7 @@ public void execute() } } } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -1821,14 +1820,10 @@ private Map getReportPlugins( Model model, boolean onlyIncludeIn /** * @param pom the pom to update. - * @throws MojoExecutionException when things go wrong - * @throws MojoFailureException when things go wrong in a very bad way - * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException { // do nothing } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 8b81d31be6..7bf8d69256 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -20,7 +20,6 @@ */ import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; import java.util.ArrayList; import java.util.List; @@ -29,8 +28,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -145,14 +142,14 @@ public class DisplayPropertyUpdatesMojo @Inject public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } public void execute() @@ -261,8 +258,8 @@ else if ( updates.isEmpty() ) logLine( false, "" ); } + @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException { } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 419c458e89..256c979469 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -29,8 +29,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; @@ -46,6 +44,7 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -72,14 +71,14 @@ public class ForceReleasesMojo @Inject public ForceReleasesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -90,7 +89,7 @@ public ForceReleasesMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -114,7 +113,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -122,7 +121,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for ( Dependency dep : dependencies ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 992105005b..735c43244e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -69,14 +68,14 @@ public class LockSnapshotsMojo @Inject public LockSnapshotsMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -87,7 +86,7 @@ public LockSnapshotsMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { try { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index 54adc31619..83bb2ab4b5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -25,8 +25,6 @@ import java.util.Locale; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Mojo; @@ -36,6 +34,7 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.ParentUpdatesModel; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -55,11 +54,14 @@ public class ParentUpdatesReportMojo extends AbstractVersionsReport reactorProjects; @Inject - protected ParentUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, ArtifactResolver artifactResolver, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, + protected ParentUpdatesReportMojo( I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + ArtifactResolver artifactResolver, + WagonManager wagonManager, ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, artifactResolver, artifactMetadataSource, wagonManager, rendererFactory ); + super( i18n, repositorySystem, aetherRepositorySystem, artifactResolver, wagonManager, rendererFactory ); } /** @@ -115,7 +117,7 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx .build(), artifactVersions ) ) .render(); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRetrievalException e ) { throw new MavenReportException( e.getMessage(), e ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 717dec32a1..40427c1962 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -31,8 +31,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; @@ -42,6 +40,7 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.mojo.versions.utils.PluginComparator; @@ -85,11 +84,14 @@ public class PluginUpdatesReportMojo extends AbstractVersionsReport changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -147,7 +146,7 @@ public ResolveRangesMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { // Note we have to get the dependencies from the model because the dependencies in the // project may have already had their range resolved [MNG-4138] @@ -190,7 +189,7 @@ private boolean hasDependencyManagement() } private void resolveRangesInParent( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, ArtifactMetadataRetrievalException, XMLStreamException + throws MojoExecutionException, VersionRetrievalException, XMLStreamException { Matcher versionMatcher = matchRangeRegex.matcher( getProject().getModel().getParent().getVersion() ); @@ -236,7 +235,7 @@ private void resolveRangesInParent( ModifiedPomXMLEventReader pom ) } private void resolveRanges( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for ( Dependency dep : dependencies ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 595f4d30d3..4924289303 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -42,7 +42,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; @@ -248,15 +247,15 @@ public class SetMojo extends AbstractVersionsUpdaterMojo @Inject public SetMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders, Prompter prompter ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); this.prompter = prompter; } @@ -569,7 +568,7 @@ else if ( moduleDir.isDirectory() ) * @throws javax.xml.stream.XMLStreamException when things go wrong. */ protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { ContextualLog log = new DelegatingContextualLog( getLog() ); try diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 804339fc76..6abca80b7c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -27,7 +27,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -93,14 +92,14 @@ public class SetPropertyMojo @Inject public SetPropertyMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + MavenProjectBuilder projectBuilder, + WagonManager wagonManager, + ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -111,7 +110,7 @@ public SetPropertyMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { Property[] propertiesConfig; String properties; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 32d5e3f8bc..777ec9287e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -9,8 +9,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; @@ -70,14 +68,14 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo @Inject public SetScmTagMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -100,7 +98,7 @@ public void execute() throws MojoExecutionException, MojoFailureException @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, MojoFailureException, XMLStreamException { try { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 7f6a8a591d..e3c18336ba 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -70,14 +69,14 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UnlockSnapshotsMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -88,7 +87,7 @@ public UnlockSnapshotsMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { try { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index dc52b603bd..0cd87fa827 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; @@ -72,14 +71,14 @@ public class UpdateChildModulesMojo @Inject public UpdateChildModulesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -212,7 +211,7 @@ else if ( d1 > d2 ) * @throws XMLStreamException when things go wrong. */ protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { getLog().debug( "Updating parent to " + sourceVersion ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 73d1fd0799..1dac708177 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -30,8 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; @@ -46,6 +44,7 @@ import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -141,14 +140,14 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Inject public UpdateParentMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -160,7 +159,7 @@ public UpdateParentMojo( RepositorySystem repositorySystem, * @since 1.0-alpha-1 */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { if ( getProject().getParent() == null ) { @@ -213,10 +212,6 @@ protected void update( ModifiedPomXMLEventReader pom ) { throw new MojoExecutionException( "Invalid version range specification: " + initialVersion, e ); } - catch ( ArtifactMetadataRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } catch ( InvalidSegmentException e ) { throw new MojoExecutionException( "Invalid segment specification for version " + initialVersion, e ); @@ -224,7 +219,7 @@ protected void update( ModifiedPomXMLEventReader pom ) } protected ArtifactVersion resolveTargetVersion( String initialVersion ) - throws MojoExecutionException, ArtifactMetadataRetrievalException, InvalidVersionSpecificationException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 7816f0b619..a5c5d8a094 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -26,7 +26,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -142,14 +141,14 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UpdatePropertiesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -161,7 +160,7 @@ public UpdatePropertiesMojo( RepositorySystem repositorySystem, * @since 1.0-alpha-1 */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { Map propertyVersions = getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 1cc59dd2dc..abef1cf509 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -26,7 +26,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -141,14 +140,14 @@ public class UpdatePropertyMojo @Inject public UpdatePropertyMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + MavenProjectBuilder projectBuilder, + WagonManager wagonManager, + ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -160,7 +159,7 @@ public UpdatePropertyMojo( RepositorySystem repositorySystem, * @since 1.0-alpha-1 */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException { Property propertyConfig = new Property( property ); propertyConfig.setVersion( newVersion ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index bedc8533be..c895e14680 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -28,8 +28,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -41,6 +39,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -76,19 +75,19 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UseDepVersionMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { if ( depVersion == null || depVersion.equals( "" ) ) @@ -129,7 +128,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -137,7 +136,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws MojoExecutionException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, XMLStreamException, VersionRetrievalException { for ( Dependency dep : dependencies ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index c106e8c1c1..f0f8d9a2aa 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -32,8 +32,6 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; @@ -47,6 +45,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -105,14 +104,14 @@ public class UseLatestReleasesMojo @Inject public UseLatestReleasesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -123,7 +122,7 @@ public UseLatestReleasesMojo( RepositorySystem repositorySystem, * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -147,7 +146,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -155,7 +154,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 9173a53c7e..96f183b654 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -30,8 +30,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -43,6 +41,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -94,14 +93,14 @@ public class UseLatestSnapshotsMojo @Inject public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -112,7 +111,7 @@ public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -136,7 +135,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -144,7 +143,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 095f68b855..d7d018d906 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -28,8 +28,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -43,6 +41,7 @@ import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -102,14 +101,14 @@ public class UseLatestVersionsMojo @Inject public UseLatestVersionsMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } @Override @@ -130,7 +129,7 @@ public void execute() throws MojoExecutionException, MojoFailureException * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -154,7 +153,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -162,7 +161,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 341a3fdb93..da94696cd4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -30,8 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; @@ -40,6 +38,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -52,14 +51,14 @@ public abstract class UseLatestVersionsMojoBase extends AbstractVersionsDependencyUpdaterMojo { public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver, - Map changeRecorders ) + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + MavenProjectBuilder projectBuilder, + WagonManager wagonManager, + ArtifactResolver artifactResolver, + Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -73,7 +72,7 @@ public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, * @param changeKind title for the change recorder records * @param filters optional array of filters * @throws XMLStreamException thrown if the POM update doesn't succeed - * @throws ArtifactMetadataRetrievalException thrown if an artifact cannot be retried + * @throws VersionRetrievalException thrown if an artifact versions cannot be retrieved */ @SafeVarargs protected final void useLatestVersions( ModifiedPomXMLEventReader pom, @@ -82,7 +81,7 @@ protected final void useLatestVersions( ModifiedPomXMLEventReader pom, newestVersionProducer, ChangeRecord.ChangeKind changeKind, Predicate... filters ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for ( Dependency dep : dependencies ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index eb703c3138..64ab6c8b5e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -28,8 +28,6 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -41,6 +39,7 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -68,14 +67,14 @@ public class UseNextReleasesMojo @Inject public UseNextReleasesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -86,7 +85,7 @@ public UseNextReleasesMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, ArtifactMetadataRetrievalException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -105,21 +104,21 @@ protected void update( ModifiedPomXMLEventReader pom ) { useNextReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); } + + if ( getProject().getParent() != null && isProcessingParent() ) + { + useNextReleases( pom, singletonList( getParentDependency() ), ChangeRecord.ChangeKind.PARENT ); + } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useNextReleases( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); - } } private void useNextReleases( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { useLatestVersions( pom, dependencies, ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), false )[0] ), diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index f1bef54ca3..ced9081288 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -29,8 +29,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -42,6 +40,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; @@ -93,14 +92,14 @@ public class UseNextSnapshotsMojo @Inject public UseNextSnapshotsMojo( RepositorySystem repositorySystem, - MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, - WagonManager wagonManager, - ArtifactResolver artifactResolver, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + MavenProjectBuilder projectBuilder, + WagonManager wagonManager, + ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } @@ -113,7 +112,7 @@ public UseNextSnapshotsMojo( RepositorySystem repositorySystem, * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -134,7 +133,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -142,7 +141,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index ab2629cff9..925ca661c6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -27,8 +27,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -40,6 +38,7 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -60,14 +59,14 @@ public class UseNextVersionsMojo @Inject public UseNextVersionsMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -78,7 +77,7 @@ public UseNextVersionsMojo( RepositorySystem repositorySystem, * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -102,7 +101,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -110,7 +109,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useNextVersions( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { useLatestVersions( pom, dependencies, ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), allowSnapshots )[0] ), diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index c2b5802978..f583ce2287 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -29,8 +29,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -41,6 +39,7 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -59,14 +58,14 @@ public class UseReactorMojo @Inject public UseReactorMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -77,7 +76,7 @@ public UseReactorMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -99,14 +98,14 @@ protected void update( ModifiedPomXMLEventReader pom ) useReactor( pom, getProject().getDependencies() ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } } private void useReactor( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for ( Dependency dep : dependencies ) @@ -136,7 +135,7 @@ private void useReactor( ModifiedPomXMLEventReader pom, Collection d } private void useReactor( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, ArtifactMetadataRetrievalException + throws XMLStreamException, VersionRetrievalException { for ( MavenProject project : reactorProjects ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 295f14b4f1..e1a69d156e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -31,8 +31,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; @@ -45,6 +43,7 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -86,14 +85,14 @@ public class UseReleasesMojo @Inject public UseReleasesMojo( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, - ArtifactMetadataSource artifactMetadataSource, WagonManager wagonManager, ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, projectBuilder, artifactMetadataSource, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, + changeRecorders ); } /** @@ -104,7 +103,7 @@ public UseReleasesMojo( RepositorySystem repositorySystem, * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { try { @@ -128,7 +127,7 @@ protected void update( ModifiedPomXMLEventReader pom ) ChangeRecord.ChangeKind.PARENT ); } } - catch ( ArtifactMetadataRetrievalException | IOException e ) + catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } @@ -136,7 +135,7 @@ protected void update( ModifiedPomXMLEventReader pom ) private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { for ( Dependency dep : dependencies ) { diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index b7e853e788..4443242d70 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -28,8 +28,6 @@ import java.util.Locale; import java.util.Set; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Dependency; @@ -37,7 +35,6 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; -import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.reporting.ReportRendererFactoryImpl; import org.codehaus.mojo.versions.utils.DependencyBuilder; @@ -47,17 +44,16 @@ import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.matchesPattern; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * Basic tests for {@linkplain DependencyUpdatesReportMojo}. @@ -72,7 +68,7 @@ private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesRe TestDependencyUpdatesReportMojo() { - super( MOCK_I18N, mockRepositorySystem(), null, mockArtifactMetadataSource(), + super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), null, null, new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); @@ -80,6 +76,8 @@ private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesRe project.setOriginalModel( new Model() ); project.getOriginalModel().setDependencyManagement( new DependencyManagement() ); project.getModel().setDependencyManagement( new DependencyManagement() ); + + session = mockMavenSession(); } public TestDependencyUpdatesReportMojo withDependencies( Dependency... dependencies ) @@ -88,10 +86,10 @@ public TestDependencyUpdatesReportMojo withDependencies( Dependency... dependenc return this; } - public TestDependencyUpdatesReportMojo withArtifactMetadataSource( - ArtifactMetadataSource artifactMetadataSource ) + public TestDependencyUpdatesReportMojo withAetherRepositorySystem( + org.eclipse.aether.RepositorySystem repositorySystem ) { - this.artifactMetadataSource = artifactMetadataSource; + this.aetherRepositorySystem = repositorySystem; return this; } @@ -160,20 +158,6 @@ public TestDependencyUpdatesReportMojo withOriginalProperty( String name, String project.getOriginalModel().getProperties().put( name, value ); return this; } - - private static RepositorySystem mockRepositorySystem() - { - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( - invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier(), null ); - } ); - return repositorySystem; - } } private static Dependency dependencyOf( String artifactId ) @@ -189,13 +173,13 @@ private static Dependency dependencyOf( String artifactId, String version ) } @Test - public void testOnlyUpgradableDependencies() throws IOException, MavenReportException + public void testOnlyUpgradableDependencies() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() .withOnlyUpgradable( true ) - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); put( "artifactB", new String[] { "1.0.0" } ); @@ -214,7 +198,8 @@ public void testOnlyUpgradableDependencies() throws IOException, MavenReportExce } @Test - public void testOnlyUpgradableWithOriginalDependencyManagement() throws IOException, MavenReportException + public void testOnlyUpgradableWithOriginalDependencyManagement() + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -231,7 +216,8 @@ public void testOnlyUpgradableWithOriginalDependencyManagement() throws IOExcept } @Test - public void testOnlyUpgradableWithTransitiveDependencyManagement() throws IOException, MavenReportException + public void testOnlyUpgradableWithTransitiveDependencyManagement() + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -250,7 +236,7 @@ public void testOnlyUpgradableWithTransitiveDependencyManagement() throws IOExce } @Test - public void testOnlyProjectDependencies() throws IOException, MavenReportException + public void testOnlyProjectDependencies() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -268,7 +254,8 @@ public void testOnlyProjectDependencies() throws IOException, MavenReportExcepti } @Test - public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, MavenReportException + public void testOnlyProjectDependenciesWithIgnoredVersions() + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -289,12 +276,12 @@ public void testOnlyProjectDependenciesWithIgnoredVersions() throws IOException, * Dependencies should be rendered in alphabetical order */ @Test - public void testDependenciesInAlphabeticalOrder() throws IOException, MavenReportException + public void testDependenciesInAlphabeticalOrder() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "amstrad", new String[] {"1.0.0", "2.0.0"} ); put( "atari", new String[] {"1.0.0", "2.0.0"} ); @@ -313,7 +300,8 @@ public void testDependenciesInAlphabeticalOrder() throws IOException, MavenRepor * Dependency updates for dependency should override those for dependency management */ @Test - public void testDependenciesShouldOverrideDependencyManagement() throws IOException, MavenReportException + public void testDependenciesShouldOverrideDependencyManagement() + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -330,7 +318,7 @@ public void testDependenciesShouldOverrideDependencyManagement() throws IOExcept } @Test - public void testWrongReportBounds() throws IOException, MavenReportException + public void testWrongReportBounds() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -338,7 +326,7 @@ public void testWrongReportBounds() throws IOException, MavenReportException .withOnlyUpgradable( true ) .withDependencies( dependencyOf( "test-artifact" ) ) - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "test-artifact", new String[] { "1.0.0", "2.0.0-M1" } ); }} ) ) @@ -351,7 +339,7 @@ public void testWrongReportBounds() throws IOException, MavenReportException } @Test - public void testIt001Overview() throws IOException, MavenReportException + public void testIt001Overview() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); @@ -359,7 +347,7 @@ public void testIt001Overview() throws IOException, MavenReportException .withOnlyUpgradable( true ) .withDependencies( dependencyOf( "test-artifact", "1.1" ) ) - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "test-artifact", new String[] { "1.1.0-2", "1.1", "1.1.1", "1.1.1-2", "1.1.2", "1.1.3", "1.2", "1.2.1", "1.2.2", "1.3", "2.0", "2.1", "3.0"} ); @@ -375,7 +363,8 @@ public void testIt001Overview() throws IOException, MavenReportException } @Test - public void testResolvedVersionsWithoutTransitiveDependencyManagement() throws IOException, MavenReportException + public void testResolvedVersionsWithoutTransitiveDependencyManagement() + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 6c0207ec2d..f399589147 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -47,7 +47,8 @@ import static java.util.Collections.singletonList; import static org.codehaus.mojo.versions.model.TestIgnoreVersions.TYPE_REGEX; import static org.codehaus.mojo.versions.model.TestIgnoreVersions.matches; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; @@ -112,7 +113,7 @@ public void testRuleSetPresentAndWorking() throws Exception // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() {{ put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); }} ); @@ -157,16 +158,15 @@ public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, - mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", - new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", - "2.0.0-rc1"} ); - }} ), - null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - null ) + mockAetherRepositorySystem( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", + "2.0.0-rc1"} ); + }} ), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -178,6 +178,8 @@ public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() this.allowSnapshots = true; this.outputFile = tempFile; setPluginContext( new HashMap<>() ); + + session = mockMavenSession(); }}.execute(); assertThat( String.join( "", Files.readAllLines( tempPath ) ), @@ -204,14 +206,14 @@ public void testAllowMajorUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, - mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); - }} ), - null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - null ) + mockAetherRepositorySystem( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); + }} ), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -222,6 +224,8 @@ public void testAllowMajorUpdatesFalse() setVariableValueToObject( this, "dependencyExcludes", emptyList() ); this.outputFile = tempFile; setPluginContext( new HashMap<>() ); + + session = mockMavenSession(); }}.execute(); String output = String.join( "", Files.readAllLines( tempPath ) ); @@ -248,15 +252,14 @@ public void testAllowMinorUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, - mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", - new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), - null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - null ) + mockAetherRepositorySystem( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -267,6 +270,8 @@ public void testAllowMinorUpdatesFalse() setVariableValueToObject( this, "dependencyExcludes", emptyList() ); this.outputFile = tempFile; setPluginContext( new HashMap<>() ); + + session = mockMavenSession(); }}.execute(); String output = String.join( "", Files.readAllLines( tempPath ) ); @@ -294,15 +299,14 @@ public void testAllowIncrementalUpdatesFalse() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, - mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", - new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), - null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - null ) + mockAetherRepositorySystem( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); + }} ), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -313,6 +317,8 @@ public void testAllowIncrementalUpdatesFalse() setVariableValueToObject( this, "dependencyExcludes", emptyList() ); this.outputFile = tempFile; setPluginContext( new HashMap<>() ); + + session = mockMavenSession(); }}.execute(); String output = String.join( "", Files.readAllLines( tempPath ) ); @@ -341,16 +347,15 @@ public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() tempPath = Files.createTempFile( "display-dependency-updates", "" ); final File tempFile = tempPath.toFile(); new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - null, - mockArtifactMetadataSource( new HashMap() - {{ - put( "default-dependency", - new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", - "1.9.0-rc1"} ); - }} ), - null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - null ) + mockAetherRepositorySystem( new HashMap() + {{ + put( "default-dependency", new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", + "1.9.0-rc1"} ); + }} ), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + null ) {{ setProject( createProject() ); setVariableValueToObject( this, "allowAnyUpdates", false ); @@ -362,6 +367,8 @@ public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() this.allowSnapshots = true; this.outputFile = tempFile; setPluginContext( new HashMap<>() ); + + session = mockMavenSession(); }}.execute(); assertThat( String.join( "", Files.readAllLines( tempPath ) ), @@ -403,7 +410,7 @@ public void testDetermineUpdatedSegment() throws Exception // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() {{ put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); }} ); @@ -434,7 +441,7 @@ public void testVersionInterpolation() throws Exception // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() {{ put( "dummy-api", new String[] { "2.0.1" } ); }} ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java index c9f896a110..a1e78b1a3f 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java @@ -25,7 +25,6 @@ import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; -import org.codehaus.mojo.versions.utils.MockUtils; import org.codehaus.mojo.versions.utils.TestUtils; import org.junit.After; import org.junit.Before; @@ -33,6 +32,7 @@ import org.junit.Test; import static org.apache.commons.codec.CharEncoding.UTF_8; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.matchesPattern; import static org.hamcrest.Matchers.not; @@ -80,7 +80,7 @@ public void testPropertiesFromParent() throws Exception mojo.outputEncoding = UTF_8; mojo.outputFile = tempFile.toFile(); mojo.setPluginContext( new HashMap<>() ); - mojo.artifactMetadataSource = MockUtils.mockArtifactMetadataSource(); + mojo.aetherRepositorySystem = mockAetherRepositorySystem(); mojo.includeParent = true; mojo.execute(); @@ -101,7 +101,7 @@ public void testDisablePropertiesFromParent() throws Exception mojo.outputEncoding = UTF_8; mojo.outputFile = tempFile.toFile(); mojo.setPluginContext( new HashMap<>() ); - mojo.artifactMetadataSource = MockUtils.mockArtifactMetadataSource(); + mojo.aetherRepositorySystem = mockAetherRepositorySystem(); mojo.includeParent = false; mojo.execute(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 3bdf537f95..0c9d66182c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -11,6 +11,7 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; @@ -22,7 +23,8 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItem; @@ -63,9 +65,10 @@ public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); mojo = new ForceReleasesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource(), - null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - changeRecorder.asTestMap() ); + mockAetherRepositorySystem(), + null, null, new StubArtifactResolver( new ArtifactStubFactory(), + false, false ), + changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() {{ @@ -76,11 +79,13 @@ null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), setVersion( "1.0.0" ); }} ); }}; + mojo.session = mockMavenSession(); } @Test public void testProcessParent() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processParent", true ); mojo.getProject().setParent( new MavenProject( new Model() @@ -107,7 +112,7 @@ public void testProcessParent() @Test public void testReplaceSnapshotWithRelease() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) @@ -131,7 +136,7 @@ public void testReplaceSnapshotWithRelease() @Test public void testUpgrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) @@ -155,7 +160,7 @@ public void testUpgrade() @Test public void testDowngrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) @@ -179,9 +184,9 @@ public void testDowngrade() @Test public void testFailIfNotReplaced() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { - mojo.artifactMetadataSource = mockArtifactMetadataSource( singletonMap( "test-artifact", + mojo.aetherRepositorySystem = mockAetherRepositorySystem( singletonMap( "test-artifact", new String[] {} ) ); mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java index 7854a027f1..43e8c3046c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java @@ -31,14 +31,16 @@ import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Model; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.codehaus.mojo.versions.reporting.ReportRendererFactoryImpl; import org.codehaus.plexus.i18n.I18N; import org.junit.Test; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; @@ -57,11 +59,11 @@ public void testAllowSnapshots() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new ParentUpdatesReportMojo( MOCK_I18N, mockRepositorySystem(), null, - mockArtifactMetadataSource( new HashMap() + new ParentUpdatesReportMojo( MOCK_I18N, mockRepositorySystem(), + mockAetherRepositorySystem( new HashMap() {{ put( "default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"} ); - }} ), null, new ReportRendererFactoryImpl( MOCK_I18N ) ) + }} ), null, null, new ReportRendererFactoryImpl( MOCK_I18N ) ) {{ allowSnapshots = true; project = new MavenProject( new Model() @@ -79,7 +81,10 @@ public void testAllowSnapshots() throws IOException, MavenReportException reactorProjects = new ArrayList<>(); project.setParentArtifact( new DefaultArtifact( project.getParent().getGroupId(), project.getParent().getArtifactId(), project.getParent().getVersion(), - Artifact.SCOPE_COMPILE, "pom", "default", null ) ); + Artifact.SCOPE_COMPILE, "pom", "default", + new DefaultArtifactHandlerStub( "default" ) ) ); + + session = mockMavenSession(); }}.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); String output = os.toString(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java index 46053944ce..e799b17afd 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java @@ -29,12 +29,12 @@ import java.util.Set; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; @@ -45,8 +45,9 @@ import org.junit.Test; import static org.apache.maven.artifact.Artifact.SCOPE_RUNTIME; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.codehaus.mojo.versions.utils.MockUtils.mockI18N; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; @@ -68,15 +69,15 @@ private static class TestPluginUpdatesReportMojo extends PluginUpdatesReportMojo static final I18N MOCK_I18N = mockI18N(); TestPluginUpdatesReportMojo() { - super( MOCK_I18N, mockRepositorySystem(), null, mockArtifactMetadataSource(), - null, new ReportRendererFactoryImpl( MOCK_I18N ) ); + super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), + null, null, new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); project.setBuild( new Build() ); project.getBuild().setPluginManagement( new PluginManagement() ); - artifactMetadataSource = mockArtifactMetadataSource(); + session = mockMavenSession(); } public TestPluginUpdatesReportMojo withPlugins( Plugin... plugins ) @@ -85,10 +86,10 @@ public TestPluginUpdatesReportMojo withPlugins( Plugin... plugins ) return this; } - public TestPluginUpdatesReportMojo withArtifactMetadataSource( - ArtifactMetadataSource artifactMetadataSource ) + public TestPluginUpdatesReportMojo withAetherRepositorySystem( + org.eclipse.aether.RepositorySystem repositorySystem ) { - this.artifactMetadataSource = artifactMetadataSource; + this.aetherRepositorySystem = repositorySystem; return this; } @@ -132,7 +133,8 @@ private static RepositorySystem mockRepositorySystem() { Plugin plugin = invocation.getArgument( 0 ); return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), - SCOPE_RUNTIME, "maven-plugin", "jar", null ); + SCOPE_RUNTIME, "maven-plugin", "jar", + new DefaultArtifactHandlerStub( "default" ) ); } ); return repositorySystem; } @@ -161,7 +163,7 @@ public void testOnlyUpgradablePlugins() throws IOException, MavenReportException OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); put( "artifactB", new String[] { "1.0.0" } ); @@ -185,7 +187,7 @@ public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenRe OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withArtifactMetadataSource( mockArtifactMetadataSource( new HashMap() + .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() {{ put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); put( "artifactB", new String[] { "1.0.0" } ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java index f0adb37f64..c62ac79d10 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java @@ -23,7 +23,6 @@ import java.io.OutputStream; import java.util.Locale; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.doxia.module.xhtml5.Xhtml5SinkFactory; import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.doxia.tools.SiteTool; @@ -33,7 +32,7 @@ import org.junit.Rule; import org.junit.Test; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.codehaus.mojo.versions.utils.MockUtils.mockSiteTool; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; @@ -46,7 +45,7 @@ public class PropertyUpdatesReportMojoTest extends AbstractMojoTestCase { @Rule public MojoRule mojoRule = new MojoRule( this ); - private static final ArtifactMetadataSource ARTIFACT_METADATA_SOURCE = mockArtifactMetadataSource(); + private static final org.eclipse.aether.RepositorySystem AETHER_REPOSITORY_SYSTEM = mockAetherRepositorySystem(); private static final SiteTool SITE_TOOL = mockSiteTool(); private static final StubArtifactRepository LOCAL_REPOSITORY = new StubArtifactRepository( "" ); @@ -62,7 +61,7 @@ public void testIncludeParentTrueShouldContainProperty() throws Exception "property-updates-report" ); setVariableValueToObject( mojo, "localRepository", LOCAL_REPOSITORY ); setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); - setVariableValueToObject( mojo, "artifactMetadataSource", ARTIFACT_METADATA_SOURCE ); + setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); setVariableValueToObject( mojo, "includeParent", true ); mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); @@ -85,7 +84,7 @@ public void testIncludeParentFalseShouldNotContainProperty() throws Exception "property-updates-report" ); setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( "" ) ); setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); - setVariableValueToObject( mojo, "artifactMetadataSource", ARTIFACT_METADATA_SOURCE ); + setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); setVariableValueToObject( mojo, "includeParent", false ); mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index 5605952eb2..a4a30b8f20 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -1,11 +1,7 @@ package org.codehaus.mojo.versions; -import javax.xml.stream.XMLStreamException; - import java.util.List; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.junit.Before; import org.junit.Test; @@ -23,8 +19,8 @@ public void setUp() { mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null, null ) { + @Override protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException { } }; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java index 1005ade873..b4cffc0894 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -19,26 +19,29 @@ * under the License. */ -import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Objects; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResult; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import static org.codehaus.mojo.versions.utils.TestUtils.copyDir; +import static org.codehaus.mojo.versions.utils.TestUtils.createTempDir; +import static org.codehaus.mojo.versions.utils.TestUtils.tearDownTempDir; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.matchesPattern; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Basic tests for {@linkplain SetPropertyMojoTest}. @@ -56,7 +59,7 @@ public class SetPropertyMojoTest extends AbstractMojoTestCase public void setUp() throws Exception { super.setUp(); - pomDir = Files.createTempDirectory( "set-property-" ); + pomDir = createTempDir( "set-property" ); } @After @@ -64,26 +67,25 @@ public void tearDown() throws Exception { try { - if ( pomDir != null && pomDir.toFile().exists() ) - { - Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); - pomDir.toFile().delete(); - } + tearDownTempDir( pomDir ); } finally { super.tearDown(); } } - @Test + @Test public void testNullNewVersion() throws Exception { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version" ), pomDir ); SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set-property" ); - mojo.localRepository = new StubArtifactRepository( pomDir.toString() ); + + mojo.aetherRepositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); + when( mojo.aetherRepositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) + .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) ); + setVariableValueToObject( mojo, "newVersion", null ); mojo.execute(); @@ -98,11 +100,14 @@ public void testNullNewVersion() public void testNewVersionEmpty() throws Exception { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version/pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version" ), pomDir ); SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set-property" ); - mojo.localRepository = new StubArtifactRepository( pomDir.toString() ); + + mojo.aetherRepositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); + when( mojo.aetherRepositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) + .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) ); + setVariableValueToObject( mojo, "newVersion", "" ); mojo.execute(); @@ -117,8 +122,7 @@ public void testNewVersionEmpty() public void testNullProperty() throws Exception { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-property/pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-property" ), pomDir ); SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), "set-property" ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 27b9724589..4707286319 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -7,8 +7,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -17,9 +15,11 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.utils.TestChangeRecorder; @@ -31,7 +31,8 @@ import static java.util.Collections.singleton; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; @@ -53,13 +54,13 @@ public class UpdateParentMojoTest private static RepositorySystem repositorySystem; - private static ArtifactMetadataSource artifactMetadataSource; + private static org.eclipse.aether.RepositorySystem aetherRepositorySystem; @BeforeClass public static void setUpStatic() { repositorySystem = mockRepositorySystem(); - artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() {{ put( "parent-artifact", new String[] { "0.9.0", "1.0.0", "1.0.1-SNAPSHOT" } ); put( "issue-670-artifact", new String[] { "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" } ); @@ -75,15 +76,12 @@ public void setUp() throws IllegalAccessException changeRecorder = new TestChangeRecorder(); artifactResolver = mock( ArtifactResolver.class ); - mojo = new UpdateParentMojo( repositorySystem, - null, - artifactMetadataSource, - null, - artifactResolver, - changeRecorder.asTestMap() ) + mojo = new UpdateParentMojo( repositorySystem, aetherRepositorySystem, null, null, + artifactResolver, changeRecorder.asTestMap() ) {{ setProject( createProject() ); reactorProjects = Collections.emptyList(); + session = mockMavenSession(); }}; } @@ -115,7 +113,8 @@ private static RepositorySystem mockRepositorySystem() Dependency dependency = invocation.getArgument( 0 ); return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType(), dependency.getClassifier() != null - ? dependency.getClassifier() : "default", null ); + ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub( "default" ) ); } ); return repositorySystem; } @@ -123,8 +122,9 @@ private static RepositorySystem mockRepositorySystem() @Test @SuppressWarnings( "deprecation" ) public void testArtifactIdDoesNotExist() - throws ArtifactMetadataRetrievalException, MojoExecutionException, - XMLStreamException, MojoFailureException, InvalidVersionSpecificationException + throws VersionRetrievalException, MojoExecutionException, + XMLStreamException, MojoFailureException, InvalidVersionSpecificationException, + VersionRetrievalException { mojo.getProject().setParent( new MavenProject() {{ @@ -135,7 +135,7 @@ public void testArtifactIdDoesNotExist() Artifact artifact = new DefaultArtifact( "default-group", "unknown-artifact", "1.0.1-SNAPSHOT", SCOPE_COMPILE, "pom", - "default", null ); + "default", new DefaultArtifactHandlerStub( "default" ) ); assertThat( mojo.findLatestVersion( artifact, VersionRange.createFromVersionSpec( "1.0.1-SNAPSHOT" ), null, false ), is( nullValue() ) ); @@ -149,7 +149,8 @@ public void testArtifactIdDoesNotExist() @Test public void testParentDowngradeAllowed() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.allowDowngrade = true; try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) @@ -165,7 +166,8 @@ public void testParentDowngradeAllowed() @Test public void testParentDowngradeForbidden() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.allowDowngrade = false; try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) @@ -179,7 +181,7 @@ public void testParentDowngradeForbidden() @Test public void testParentDowngradeAllowedWithRange() - throws MojoExecutionException, ArtifactMetadataRetrievalException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowDowngrade = true; @@ -196,7 +198,7 @@ public void testParentDowngradeAllowedWithRange() @Test public void testParentDowngradeForbiddenWithRange() - throws MojoExecutionException, ArtifactMetadataRetrievalException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowDowngrade = false; @@ -206,7 +208,7 @@ public void testParentDowngradeForbiddenWithRange() @Test public void testAllowSnapshots() - throws MojoExecutionException, ArtifactMetadataRetrievalException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.allowSnapshots = true; @@ -223,7 +225,8 @@ public void testAllowSnapshots() @Test public void testAllowSnapshotsWithParentVersion() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.allowSnapshots = true; mojo.parentVersion = "0.0.1-1-impl-SNAPSHOT"; @@ -248,7 +251,7 @@ public void testAllowSnapshotsWithParentVersion() @Test public void testIgnoredVersions() throws MojoExecutionException, IllegalAccessException, - ArtifactMetadataRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException + VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.getProject().setParent( new MavenProject() {{ @@ -260,24 +263,24 @@ public void testIgnoredVersions() } @Test - public void testSkipResolutionDowngradeUnknownVersion() + public void testSkipResolutionDowngradeUnknownVersion() throws VersionRetrievalException { testSkipResolution( "0.8.0" ); } @Test - public void testSkipResolutionDowngrade() + public void testSkipResolutionDowngrade() throws VersionRetrievalException { testSkipResolution( "0.9.0" ); } @Test - public void testSkipResolutionUpgradeUnknownVersion() + public void testSkipResolutionUpgradeUnknownVersion() throws VersionRetrievalException { testSkipResolution( "2.0.0" ); } - private void testSkipResolution( String version ) + private void testSkipResolution( String version ) throws VersionRetrievalException { mojo.parentVersion = version; mojo.skipResolution = true; @@ -304,7 +307,8 @@ private void testSkipResolution( String version ) } @Test - public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException + public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.getProject().setParent( new MavenProject() {{ @@ -326,7 +330,7 @@ public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStre @Test public void testAllowMinorUpdates() - throws MojoExecutionException, ArtifactMetadataRetrievalException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.getProject().setParent( new MavenProject() @@ -347,7 +351,7 @@ public void testAllowMinorUpdates() @Test public void testAllowIncrementalUpdates() - throws MojoExecutionException, ArtifactMetadataRetrievalException, + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException { mojo.getProject().setParent( new MavenProject() @@ -366,7 +370,8 @@ public void testAllowIncrementalUpdates() } @Test - public void testParentVersionRange() throws MojoExecutionException, XMLStreamException, MojoFailureException + public void testParentVersionRange() throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.getProject().setParent( new MavenProject() {{ @@ -387,7 +392,8 @@ public void testParentVersionRange() throws MojoExecutionException, XMLStreamExc } @Test - public void testParentVersionRange2() throws MojoExecutionException, XMLStreamException, MojoFailureException + public void testParentVersionRange2() throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.getProject().setParent( new MavenProject() {{ diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java index afcb78fe8c..4d69cabbf4 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; @@ -33,7 +32,7 @@ import org.junit.Before; import org.junit.Rule; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; import static org.codehaus.mojo.versions.utils.TestUtils.createTempDir; import static org.codehaus.mojo.versions.utils.TestUtils.tearDownTempDir; @@ -45,7 +44,7 @@ public abstract class UpdatePropertiesMojoTestBase extends AbstractMojoTestCase @Rule public MojoRule mojoRule = new MojoRule( this ); protected Path pomDir; - protected ArtifactMetadataSource artifactMetadataSource; + protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; protected TestChangeRecorder changeRecorder; @Before @@ -53,7 +52,7 @@ public void setUp() throws Exception { super.setUp(); pomDir = createTempDir( "update-property" ); - artifactMetadataSource = mockArtifactMetadataSource( new HashMap() + aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() {{ put( "default-artifact", new String[] {"1.0.0", "1.0.1-rc1", "1.1.0-alpha", "2.0.0-M1"} ); }} ); @@ -77,7 +76,7 @@ protected T setUpMojo( String goal ) throws Exception { T mojo = (T) mojoRule.lookupConfiguredMojo( pomDir.toFile(), goal ); setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( pomDir.toString() ) ); - setVariableValueToObject( mojo, "artifactMetadataSource", artifactMetadataSource ); + setVariableValueToObject( mojo, "aetherRepositorySystem", aetherRepositorySystem ); setVariableValueToObject( mojo, "generateBackupPoms", false ); setVariableValueToObject( mojo, "changeRecorderFormat", "test" ); changeRecorder = (TestChangeRecorder) diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index 82446fda07..f2c7d708e1 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -5,14 +5,15 @@ import java.util.HashMap; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.hamcrest.Matchers; @@ -24,14 +25,14 @@ import static java.util.Collections.singletonList; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -@SuppressWarnings( "deprecation" ) public class UseLatestReleasesMojoTest { private UseLatestReleasesMojo mojo; @@ -46,10 +47,12 @@ public void setUp() throws Exception Dependency dependency = invocation.getArgument( 0 ); return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier() != null ? dependency.getClassifier() : "default", null ); + dependency.getClassifier() != null ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub( "default" ) ); } ); - ArtifactMetadataSource artifactMetadataSourceMock = mockArtifactMetadataSource( new HashMap() + org.eclipse.aether.RepositorySystem aetherRepositorySystem = mockAetherRepositorySystem( + new HashMap() {{ put( "dependency-artifact", new String[] {"0.9.0", "1.0.0-beta"} ); }} ); @@ -57,11 +60,11 @@ public void setUp() throws Exception changeRecorder = new TestChangeRecorder(); mojo = new UseLatestReleasesMojo( repositorySystemMock, - null, - artifactMetadataSourceMock, - null, - null, - changeRecorder.asTestMap() ) + aetherRepositorySystem, + null, + null, + null, + changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); MavenProject project = new MavenProject() @@ -84,12 +87,15 @@ public void setUp() throws Exception }} ); }}; setProject( project ); + + session = mockMavenSession(); }}; } @Test public void testDontUpgradeToBeta() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index ed0b35723e..4152a9019a 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -7,15 +7,16 @@ import java.util.HashMap; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; @@ -28,7 +29,8 @@ import static java.util.Collections.singleton; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; import static org.apache.maven.plugin.testing.ArtifactStubFactory.setVariableValueToObject; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasItem; @@ -54,10 +56,12 @@ public void setUp() throws Exception Dependency dependency = invocation.getArgument( 0 ); return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier() != null ? dependency.getClassifier() : "default", null ); + dependency.getClassifier() != null ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub( "default" ) ); } ); - ArtifactMetadataSource artifactMetadataSourceMock = mockArtifactMetadataSource( new HashMap() + org.eclipse.aether.RepositorySystem aetherRepositorySystem = mockAetherRepositorySystem( + new HashMap() {{ put( "dependency-artifact", new String[] {"1.1.1-SNAPSHOT", "1.1.0", "1.1.0-SNAPSHOT", "1.0.0", "1.0.0-SNAPSHOT", "0.9.0"} ); @@ -69,11 +73,11 @@ public void setUp() throws Exception changeRecorder = new TestChangeRecorder(); mojo = new UseLatestVersionsMojo( repositorySystemMock, - null, - artifactMetadataSourceMock, - null, - null, - changeRecorder.asTestMap() ) + aetherRepositorySystem, + null, + null, + null, + changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); MavenProject project = new MavenProject() @@ -95,13 +99,16 @@ public void setUp() throws Exception }} ); }}; setProject( project ); + + session = mockMavenSession(); }}; setVariableValueToObject( mojo, "processDependencyManagement", false ); } @Test public void testDependenciesDowngradeIncremental() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); @@ -122,7 +129,8 @@ public void testDependenciesDowngradeIncremental() @Test public void testDependenciesDowngradeMinor() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); @@ -148,7 +156,8 @@ public void testDependenciesDowngradeMinor() @Test public void testDependenciesDowngradeMajor() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); @@ -170,7 +179,8 @@ public void testDependenciesDowngradeMajor() @Test public void testDependencyManagementDowngrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencyManagement", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); @@ -193,7 +203,8 @@ public void testDependencyManagementDowngrade() @Test public void testParentDowngrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processParent", true ); setVariableValueToObject( mojo, "allowSnapshots", false ); @@ -225,7 +236,8 @@ public void testParentDowngrade() @Test public void testPoisonDependencyVersion() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { mojo.getProject().getModel().setDependencies( Arrays.asList( DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", @@ -255,7 +267,8 @@ public void testPoisonDependencyVersion() @Test public void testIgnoredVersions() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processDependencies", true ); setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.1.0" ) ); @@ -271,7 +284,8 @@ public void testIgnoredVersions() @Test public void testIncludeFilter() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { mojo.getProject().getModel().setDependencies( Arrays.asList( DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", @@ -296,7 +310,8 @@ public void testIncludeFilter() @Test public void testExcludeFilter() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { mojo.getProject().getModel().setDependencies( Arrays.asList( DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index fe28fdf43a..463a00e395 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -11,6 +11,7 @@ import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.change.DefaultVersionChange; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; @@ -22,7 +23,8 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE; -import static org.codehaus.mojo.versions.utils.MockUtils.mockArtifactMetadataSource; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasItem; @@ -63,9 +65,11 @@ public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); mojo = new UseReleasesMojo( mockRepositorySystem(), - null, mockArtifactMetadataSource(), - null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), - changeRecorder.asTestMap() ); + mockAetherRepositorySystem(), + null, + null, + new StubArtifactResolver( new ArtifactStubFactory(), false, false ), + changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() {{ @@ -76,11 +80,13 @@ null, new StubArtifactResolver( new ArtifactStubFactory(), false, false ), setVersion( "1.0.0" ); }} ); }}; + mojo.session = mockMavenSession(); } @Test public void testProcessParent() - throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException + throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, + VersionRetrievalException { setVariableValueToObject( mojo, "processParent", true ); mojo.getProject().setParent( new MavenProject( new Model() @@ -107,7 +113,8 @@ public void testProcessParent() @Test public void testReplaceSnapshotWithRelease() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) @@ -131,9 +138,10 @@ public void testReplaceSnapshotWithRelease() @Test public void testFailIfNotReplaced() - throws MojoExecutionException, XMLStreamException, MojoFailureException + throws MojoExecutionException, XMLStreamException, MojoFailureException, + VersionRetrievalException { - mojo.artifactMetadataSource = mockArtifactMetadataSource( singletonMap( "test-artifact", + mojo.aetherRepositorySystem = mockAetherRepositorySystem( singletonMap( "test-artifact", new String[] {} ) ); mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() .withGroupId( "default-group" ) diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java index 991a944098..bf980f3786 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -26,16 +26,21 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.doxia.tools.SiteToolException; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.i18n.I18N; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.aether.resolution.VersionRangeResult; +import org.eclipse.aether.version.Version; +import static java.util.Collections.emptyList; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -54,42 +59,44 @@ public class MockUtils }}; /** - * Creates a mocked {@linkplain ArtifactMetadataSource}, providing the default version set - * @return mocked {@linkplain ArtifactMetadataSource} + * Creates a mocked {@linkplain org.eclipse.aether.RepositorySystem}, providing the default version set + * @return mocked {@linkplain org.eclipse.aether.RepositorySystem} */ - public static ArtifactMetadataSource mockArtifactMetadataSource() + public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem() { - return mockArtifactMetadataSource( DEFAULT_VERSION_MAP ); + return mockAetherRepositorySystem( DEFAULT_VERSION_MAP ); } /** - * Creates a mocked {@linkplain ArtifactMetadataSource}, providing the version map given in the argument + * Creates a mocked {@linkplain org.eclipse.aether.RepositorySystem}, providing the version map given in + * the argument. * @param versionMap requested version map - * @return mocked {@linkplain ArtifactMetadataSource} + * @return mocked {@linkplain org.eclipse.aether.RepositorySystem} */ - public static ArtifactMetadataSource mockArtifactMetadataSource( Map versionMap ) + public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem( Map versionMap ) { - ArtifactMetadataSource artifactMetadataSource = mock( ArtifactMetadataSource.class ); + org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); try { - when( artifactMetadataSource.retrieveAvailableVersions( any( Artifact.class ), any(), any() ) ).then( + when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ).then( invocation -> { - Artifact artifact = invocation.getArgument( 0 ); + VersionRangeRequest request = invocation.getArgument( 1 ); return versionMap.entrySet().stream() - .filter( e -> e.getKey().equals( artifact.getArtifactId() ) ) + .filter( e -> e.getKey().equals( request.getArtifact().getArtifactId() ) ) .findAny() .map( e -> Arrays.stream( e.getValue() ) - .map( DefaultArtifactVersion::new ) - .collect( ArrayList::new, ArrayList::add, ArrayList::add ) ) + .map( VersionStub::new ) + .collect( () -> new ArrayList(), ArrayList::add, ArrayList::addAll ) ) + .map( versions -> new VersionRangeResult( request ).setVersions( versions ) ) .orElse( null ); // should tell us if we haven't populated all cases in the test } ); } - catch ( ArtifactMetadataRetrievalException e ) + catch ( VersionRangeResolutionException e ) { throw new RuntimeException( e ); } - return artifactMetadataSource; + return repositorySystem; } public static I18N mockI18N() @@ -129,4 +136,22 @@ public static RepositorySystem mockRepositorySystem() } ); return repositorySystem; } + + /** + * Creates a very simple mock of {@link MavenSession} + * by providing only a non-{@code null} implementation of its {@link MavenSession#getRepositorySession()} method. + * @return mocked {@link MavenSession} + */ + public static MavenSession mockMavenSession() + { + MavenSession session = mock( MavenSession.class ); + when( session.getRepositorySession() ) + .thenReturn( mock( RepositorySystemSession.class ) ); + when( session.getCurrentProject() ).thenReturn( mock( MavenProject.class ) ); + when( session.getCurrentProject().getRemotePluginRepositories() ).thenReturn( emptyList() ); + when( session.getCurrentProject().getPluginArtifactRepositories() ).thenReturn( emptyList() ); + when( session.getCurrentProject().getRemoteArtifactRepositories() ).thenReturn( emptyList() ); + when( session.getCurrentProject().getRemoteProjectRepositories() ).thenReturn( emptyList() ); + return session; + } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java new file mode 100644 index 0000000000..807e21574f --- /dev/null +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java @@ -0,0 +1,76 @@ +package org.codehaus.mojo.versions.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.eclipse.aether.version.Version; + +/** + * Stubs the {@link Version} + */ +public class VersionStub implements Version +{ + private final String version; + + /** + * Creates a new instance with the given version string + * @param version version to be set + */ + public VersionStub( String version ) + { + assert version != null; + this.version = version; + } + + @Override + public String toString() + { + return version; + } + + @Override + public int compareTo( Version o ) + { + return o != null + ? version.compareTo( o.toString() ) + : 1; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + + if ( !( o instanceof Version ) ) + { + return false; + } + + return version.equals( o.toString() ); + } + + @Override + public int hashCode() + { + return version.hashCode(); + } +} From 97683ab27ff45223640296bf820541f4ad4326a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Nov 2022 16:49:54 +0000 Subject: [PATCH 215/441] Bump commons-text from 1.9 to 1.10.0 Bumps commons-text from 1.9 to 1.10.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-text dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8e37806153..5f36ff7ab2 100644 --- a/pom.xml +++ b/pom.xml @@ -199,7 +199,7 @@ org.apache.commons commons-text - 1.9 + 1.10.0 From badd0c4c7bfd5c22f017471db40af6539c4dcf43 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Mon, 24 Oct 2022 13:54:46 +0200 Subject: [PATCH 216/441] Resolves #387: Provide an enforcer rule to specify a maximum number of allowed dependency updates --- pom.xml | 7 + .../versions/api/AbstractVersionDetails.java | 28 +- .../versions/api/DefaultVersionsHelper.java | 18 - .../mojo/versions/api/VersionDetails.java | 24 ++ .../mojo/versions/api/VersionsHelper.java | 10 - .../versions/filtering/DependencyFilter.java | 49 ++- .../ordering/AbstractVersionComparator.java | 10 +- .../versions/ordering/VersionComparator.java | 33 -- .../versions/utils/MavenProjectUtils.java | 168 ++++++++ .../versions/api/ArtifactVersionsTest.java | 63 +++ .../PropertiesVersionsFileReaderTest.java | 8 +- versions-enforcer/pom.xml | 193 +++++++++ .../src/it-repo/dummy-api-1.0.pom | 74 ++++ .../src/it-repo/dummy-api-2.0.pom | 49 +++ .../src/it-repo/dummy-api-2.1.pom | 49 +++ .../invoker.properties | 2 + .../it/it-max-dependency-updates-001/pom.xml | 44 ++ .../invoker.properties | 2 + .../it/it-max-dependency-updates-002/pom.xml | 44 ++ .../invoker.properties | 2 + .../it/it-max-dependency-updates-003/pom.xml | 47 ++ .../invoker.properties | 2 + .../it/it-max-dependency-updates-004/pom.xml | 45 ++ versions-enforcer/src/it/settings.xml | 51 +++ .../enforcer/MaxDependencyUpdates.java | 401 ++++++++++++++++++ .../markdown/max-dependency-updates.md.vm | 114 +++++ versions-enforcer/src/site/site.xml | 15 + .../enforcer/MaxDependencyUpdatesTest.java | 289 +++++++++++++ versions-maven-plugin/pom.xml | 9 +- .../versions/DependencyUpdatesReportMojo.java | 3 +- .../DisplayDependencyUpdatesMojo.java | 251 ++--------- .../src/site/markdown/index.md | 6 + versions-test/pom.xml | 72 ++++ .../mojo/versions/utils/MockUtils.java | 4 +- .../versions/utils/TestChangeRecorder.java | 0 .../mojo/versions/utils/TestUtils.java | 0 .../mojo/versions/utils/VersionStub.java | 0 37 files changed, 1886 insertions(+), 300 deletions(-) create mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java create mode 100644 versions-enforcer/pom.xml create mode 100644 versions-enforcer/src/it-repo/dummy-api-1.0.pom create mode 100644 versions-enforcer/src/it-repo/dummy-api-2.0.pom create mode 100644 versions-enforcer/src/it-repo/dummy-api-2.1.pom create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-001/invoker.properties create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-001/pom.xml create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-002/invoker.properties create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-002/pom.xml create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-003/invoker.properties create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-003/pom.xml create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-004/invoker.properties create mode 100644 versions-enforcer/src/it/it-max-dependency-updates-004/pom.xml create mode 100644 versions-enforcer/src/it/settings.xml create mode 100644 versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java create mode 100644 versions-enforcer/src/site/markdown/max-dependency-updates.md.vm create mode 100644 versions-enforcer/src/site/site.xml create mode 100644 versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java create mode 100644 versions-test/pom.xml rename {versions-maven-plugin/src/test => versions-test/src/main}/java/org/codehaus/mojo/versions/utils/MockUtils.java (100%) rename {versions-maven-plugin/src/test => versions-test/src/main}/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java (100%) rename {versions-maven-plugin/src/test => versions-test/src/main}/java/org/codehaus/mojo/versions/utils/TestUtils.java (100%) rename {versions-maven-plugin/src/test => versions-test/src/main}/java/org/codehaus/mojo/versions/utils/VersionStub.java (100%) diff --git a/pom.xml b/pom.xml index 5f36ff7ab2..ae0e574a9a 100644 --- a/pom.xml +++ b/pom.xml @@ -100,6 +100,8 @@ model-ruleset versions-api versions-common + versions-enforcer + versions-test versions-maven-plugin @@ -139,6 +141,11 @@ + + org.apache.maven.enforcer + enforcer-api + 3.1.0 + org.junit junit-bom diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 1b1a5a080c..939a3f3997 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -34,6 +34,7 @@ import static java.util.Collections.reverseOrder; import static java.util.Optional.empty; import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; /** @@ -72,6 +73,29 @@ protected AbstractVersionDetails() { } + @Override + public Restriction restrictionFor( Optional scope ) + throws InvalidSegmentException + { + ArtifactVersion nextVersion = scope + .filter( s -> s.isMajorTo( SUBINCREMENTAL ) ) + .map( s -> (ArtifactVersion) + new BoundArtifactVersion( currentVersion, Segment.of( s.value() + 1 ) ) ) + .orElse( currentVersion ); + return new Restriction( nextVersion, false, scope.filter( MAJOR::isMajorTo ) + .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ).orElse( null ), + false ); + } + + @Override + public Restriction restrictionForIgnoreScope( Optional ignored ) + { + ArtifactVersion nextVersion = ignored + .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ) + .orElse( currentVersion ); + return new Restriction( nextVersion, false, null, false ); + } + @Override public final boolean isCurrentVersionDefined() { @@ -307,7 +331,7 @@ public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Op { try { - return getNewestVersion( getVersionComparator().restrictionFor( currentVersion, updateScope ), + return getNewestVersion( restrictionFor( updateScope ), includeSnapshots ); } catch ( InvalidSegmentException e ) @@ -322,7 +346,7 @@ public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Op { try { - return getVersions( getVersionComparator().restrictionFor( currentVersion, updateScope ), + return getVersions( restrictionFor( updateScope ), includeSnapshots ); } catch ( InvalidSegmentException e ) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 1ee58570b6..9ef7215ece 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -858,24 +858,6 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr return propertyVersions; } - @Override - public Dependency interpolateVersion( final Dependency dependency, final MavenProject project ) - { - - // resolve version from model properties if necessary (e.g. "${mycomponent.myversion}" - if ( dependency.getVersion().startsWith( "${" ) ) - { - final String resolvedVersion = project.getOriginalModel() - .getProperties().getProperty( - dependency.getVersion().substring( 2, dependency.getVersion().length() - 1 ) ); - if ( resolvedVersion != null && !resolvedVersion.isEmpty() ) - { - dependency.setVersion( resolvedVersion ); - } - } - return dependency; - } - /** * Builder class for {@linkplain DefaultVersionsHelper} */ diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 542130619e..6acedce8df 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -392,4 +392,28 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS */ ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ); + /** + *

    Returns a {@linkplain Restriction} object for computing version upgrades + * with the given segment allowing updates, with all more major segments locked in place.

    + *

    The resulting restriction could be thought of as one + * retaining the versions on positions up to the held position, + * the position right after the position held in place will be incremented by one, + * and on all positions which are more minor than that, the range would contain -∞ + * for the bottom bound and +∞ for the above bound.

    + *

    This will allow matching the required versions while not matching versions which are considered + * inferior than the zeroth version, i.e. versions with a qualifier.

    + * + * @param scope most major segment where updates are allowed Optional.empty() for no restriction + * @return {@linkplain Restriction} object based on the arguments + */ + Restriction restrictionFor( Optional scope ) throws InvalidSegmentException; + + + /** + * Returns the {@link Restriction} objects for a segemnt scope which is to be ignored. + * + * @param ignored most major segment where updates are to be ignored; Optional.empty() for no ignored segments + * @return {@linkplain Restriction} object based on the arguments + */ + Restriction restrictionForIgnoreScope( Optional ignored ); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 28a11879dd..729aef0889 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -414,14 +414,4 @@ public VersionPropertiesMapRequest build() */ void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) throws ArtifactResolutionException, ArtifactNotFoundException; - - /** - * Attempts to interpolate the version from model properties. - * - * @param dependency the dependency - * @param project the maven project - * @return the dependency with interpolated property (as far as possible) - * @since 2.14.0 - */ - Dependency interpolateVersion( Dependency dependency, MavenProject project ); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java index e31a0481a5..00f58cb00c 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java @@ -19,6 +19,7 @@ * under the License. */ +import java.util.Collection; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -26,6 +27,7 @@ import java.util.stream.Collectors; import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.utils.DependencyComparator; public class DependencyFilter @@ -62,12 +64,12 @@ public String toString() return String.format( "%s{%s}", getClass().getSimpleName(), pattern ); } - public Set retainingIn( Set dependencies ) + public Set retainingIn( Collection dependencies ) { return filterBy( dependencies, this::matchersMatch ); } - public Set removingFrom( Set dependencies ) + public Set removingFrom( Collection dependencies ) { return filterBy( dependencies, not( this::matchersMatch ) ); } @@ -77,10 +79,51 @@ private boolean matchersMatch( Dependency dependency ) return matchers.stream().anyMatch( m -> m.test( dependency ) ); } - private TreeSet filterBy( Set dependencies, Predicate predicate ) + private TreeSet filterBy( Collection dependencies, Predicate predicate ) { return dependencies.stream() .filter( predicate ) .collect( Collectors.toCollection( () -> new TreeSet<>( DependencyComparator.INSTANCE ) ) ); } + + /** + * Returns a set of dependencies filtered by the given include- and exclude filters. + * @param dependencies collection of dependencies to filter + * @param includes a list of dependency includes + * @param excludes a list of dependency excludes + * @param section if log is not null, dependency section name for the debug log + * @param log null or log to which debug information will be logged + * @return filtered set of dependencies + */ + public static Set filterDependencies( + Collection dependencies, + List includes, + List excludes, + String section, + Log log + ) + { + DependencyFilter includeDeps = DependencyFilter.parseFrom( includes ); + DependencyFilter excludeDeps = DependencyFilter.parseFrom( excludes ); + + Set filtered = includeDeps.retainingIn( dependencies ); + filtered = excludeDeps.removingFrom( filtered ); + + if ( log != null && log.isDebugEnabled() ) + { + log.debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); + log.debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); + log.debug( String.format( "Unfiltered %s: ", section ) + output( dependencies ) ); + log.debug( String.format( "Filtered %s: ", section ) + output( filtered ) ); + } + + return filtered; + } + + private static String output( Collection dependencies ) + { + return dependencies.stream() + .map( d -> String.format( "%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion() ) ) + .collect( Collectors.joining( ", " ) ); + } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 30a4835026..75b659e047 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -29,14 +29,10 @@ public abstract class AbstractVersionComparator implements VersionComparator { - /** - * {@inheritDoc} - */ + @Override public abstract int compare( ArtifactVersion o1, ArtifactVersion o2 ); - /** - * {@inheritDoc} - */ + @Override public final int getSegmentCount( ArtifactVersion v ) { if ( v == null ) @@ -58,6 +54,7 @@ public final int getSegmentCount( ArtifactVersion v ) * * @return the hash code. */ + @Override public int hashCode() { return getClass().hashCode(); @@ -71,6 +68,7 @@ public int hashCode() * @see #hashCode() * @see java.util.Hashtable */ + @Override public boolean equals( Object obj ) { return obj == this || ( obj != null && getClass().equals( obj.getClass() ) ); diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 91a40848c8..1ca3e6b075 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -20,14 +20,8 @@ */ import java.util.Comparator; -import java.util.Optional; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.Restriction; -import org.codehaus.mojo.versions.api.Segment; - -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; /** * A rule for comparing and manipulating versions. @@ -43,31 +37,4 @@ public interface VersionComparator * @since 1.0-beta-1 */ int getSegmentCount( ArtifactVersion artifactVersion ); - - /** - *

    Returns a {@linkplain Restriction} object for computing version upgrades - * with the given segment allowing updates, with all more major segments locked in place.

    - *

    The resulting restriction could be thought of as one - * retaining the versions on positions up to the held position, - * the position right after the position held in place will be incremented by one, - * and on all positions which are more minor than that, the range would contain -∞ - * for the bottom bound and +∞ for the above bound.

    - *

    This will allow matching the required versions while not matching versions which are considered - * inferior than the zeroth version, i.e. versions with a qualifier.

    - * - * @param currentVersion The current version. - * @param scope most major segment where updates are allowed Optional.empty() for no restriction - * @return {@linkplain Restriction} object based on the arguments - */ - default Restriction restrictionFor( ArtifactVersion currentVersion, Optional scope ) - throws InvalidSegmentException - { - ArtifactVersion nextVersion = scope.filter( s -> s.isMajorTo( SUBINCREMENTAL ) ) - .map( s -> (ArtifactVersion) - new BoundArtifactVersion( currentVersion, Segment.of( s.value() + 1 ) ) ) - .orElse( currentVersion ); - return new Restriction( nextVersion, false, scope.filter( MAJOR::isMajorTo ) - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ).orElse( null ), - false ); - } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java new file mode 100644 index 0000000000..fd51c9d37e --- /dev/null +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java @@ -0,0 +1,168 @@ +package org.codehaus.mojo.versions.utils; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; +import org.codehaus.mojo.versions.api.VersionRetrievalException; + +import static java.util.Collections.emptyList; +import static java.util.Optional.ofNullable; + +/** + * Utility methods for extracting dependencies from a {@link org.apache.maven.project.MavenProject} + */ +public class MavenProjectUtils +{ + /** + * Retrieves dependencies from the plugins section + * @param project {@link MavenProject} instance + * @return set of {@link Dependency} objects + * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved + */ + public static Set extractPluginDependenciesFromPluginsInPluginManagement( MavenProject project ) + { + return ofNullable( project.getBuild() ) + .map( Build::getPluginManagement ) + .map( PluginManagement::getPlugins ) + .orElse( emptyList() ) + .stream() + .filter( plugin -> plugin.getDependencies() != null ) + .flatMap( plugin -> plugin.getDependencies().stream() ) + .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ); + } + + /** + * Retrieves dependencies from plugin management + * @param project {@link MavenProject} instance + * @return set of {@link Dependency} objects + * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved + */ + public static Set extractDependenciesFromPlugins( MavenProject project ) + { + return project.getBuildPlugins().parallelStream() + .filter( plugin -> plugin.getDependencies() != null ) + .flatMap( plugin -> plugin.getDependencies().stream() ) + .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ); + } + + /** + * Retrieves dependencies from the dependency management of the project + * as well as its immediate parent project. + * + * @param project {@link MavenProject} instance + * @param processDependencyManagementTransitive if {@code true}, the original model will be considered + * instead of the interpolated model, which does not contain + * imported dependencies + * @return set of {@link Dependency} objects + * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved + */ + public static Set extractDependenciesFromDependencyManagement( MavenProject project, + boolean processDependencyManagementTransitive, Log log ) + throws VersionRetrievalException + { + Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); + DependencyManagement projectDependencyManagement = processDependencyManagementTransitive + ? project.getDependencyManagement() + : project.getOriginalModel().getDependencyManagement(); + if ( projectDependencyManagement != null ) + { + + List dependenciesFromPom = projectDependencyManagement.getDependencies(); + for ( Dependency dependency : dependenciesFromPom ) + { + log.debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() + + ":" + dependency.getVersion() + ":" + dependency.getScope() ); + if ( dependency.getVersion() == null ) + { + // get parent and get the information from there. + if ( project.hasParent() ) + { + log.debug( "Reading parent dependencyManagement information" ); + DependencyManagement parentProjectDependencyManagement = + processDependencyManagementTransitive + ? project.getParent().getDependencyManagement() + : project.getParent().getOriginalModel().getDependencyManagement(); + if ( parentProjectDependencyManagement != null ) + { + List parentDeps = parentProjectDependencyManagement.getDependencies(); + for ( Dependency parentDep : parentDeps ) + { + // only groupId && artifactId needed cause version is null + if ( dependency.getGroupId().equals( parentDep.getGroupId() ) + && dependency.getArtifactId().equals( parentDep.getArtifactId() ) + && dependency.getType().equals( parentDep.getType() ) ) + { + dependencyManagement.add( parentDep ); + } + } + } + } + else + { + String message = "We can't get the version for the dependency " + dependency.getGroupId() + ":" + + dependency.getArtifactId() + " because there does not exist a parent."; + log.error( message ); + // Throw error because we will not able to get a version for a dependency. + throw new VersionRetrievalException( message ); + } + } + else + { + dependency = interpolateVersion( dependency, project ); + dependencyManagement.add( dependency ); + } + } + } + return dependencyManagement; + } + + /** + * Attempts to interpolate the version from model properties. + * + * @param dependency the dependency + * @param project the maven project + * @return the dependency with interpolated property (as far as possible) + * @since 2.14.0 + */ + public static Dependency interpolateVersion( final Dependency dependency, final MavenProject project ) + { + + // resolve version from model properties if necessary (e.g. "${mycomponent.myversion}" + if ( dependency.getVersion().startsWith( "${" ) ) + { + final String resolvedVersion = project.getOriginalModel() + .getProperties().getProperty( + dependency.getVersion().substring( 2, dependency.getVersion().length() - 1 ) ); + if ( resolvedVersion != null && !resolvedVersion.isEmpty() ) + { + dependency.setVersion( resolvedVersion ); + } + } + return dependency; + } +} diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index 1f4b3633e1..25913f0af8 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -25,6 +25,7 @@ import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.ordering.MavenVersionComparator; @@ -33,9 +34,12 @@ import static java.util.Optional.of; import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining; +import static org.hamcrest.Matchers.arrayWithSize; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -141,4 +145,63 @@ public void testGetNewerVersionsWithSnapshot() throws InvalidSegmentException assertThat( instance.getNewerVersions( "1.0.0-SNAPSHOT", of( SUBINCREMENTAL ), false, false ), arrayContaining( new DefaultArtifactVersion( "1.0.0" ) ) ); } + + @Test + public void testAllVersionsForIgnoreScopeSubIncremental() + { + ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.0.0", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + Restriction restriction = instance.restrictionForIgnoreScope( of( SUBINCREMENTAL ) ); + ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); + assertThat( filteredVersions, arrayWithSize( 1 ) ); + assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "1.0.1" ) ) ); + } + + @Test + public void testAllVersionsForIgnoreScopeIncremental() + { + ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.0.0", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + Restriction restriction = instance.restrictionForIgnoreScope( of( INCREMENTAL ) ); + ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); + assertThat( filteredVersions, arrayWithSize( 1 ) ); + assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "1.1.0" ) ) ); + } + + @Test + public void testAllVersionsForIgnoreScopeMinor() + { + ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.0.0", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + Restriction restriction = instance.restrictionForIgnoreScope( of( MINOR ) ); + ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); + assertThat( filteredVersions, arrayWithSize( 1 ) ); + assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "2.0.0" ) ) ); + } + + @Test + public void testAllVersionsForIgnoreScopeMajor() + { + ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0" ); + ArtifactVersions instance = + new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", + "1.0.0", "foo", "bar", + "jar", null ), + Arrays.asList( versions ), new MavenVersionComparator() ); + Restriction restriction = instance.restrictionForIgnoreScope( of( MAJOR ) ); + ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); + assertThat( filteredVersions, arrayWithSize( 0 ) ); + } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java index 2041c82e9c..4f68d71089 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java @@ -25,11 +25,9 @@ import java.util.Set; import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class PropertiesVersionsFileReaderTest { @@ -43,9 +41,9 @@ public void testRead() throws IOException reader.read(); int numberOfPropertiesConfig = 3; - assertTrue( equalsCvsUnordered( "booking-api.version,booking-lib.version,be-air-impl.version", + Assert.assertTrue( equalsCvsUnordered( "booking-api.version,booking-lib.version,be-air-impl.version", reader.getProperties() ) ); - assertEquals( numberOfPropertiesConfig, reader.getPropertiesConfig().length ); + Assert.assertEquals( numberOfPropertiesConfig, reader.getPropertiesConfig().length ); } private boolean equalsCvsUnordered( String csvExpected, String csvActual ) diff --git a/versions-enforcer/pom.xml b/versions-enforcer/pom.xml new file mode 100644 index 0000000000..a3cda5ad64 --- /dev/null +++ b/versions-enforcer/pom.xml @@ -0,0 +1,193 @@ + + + + versions + org.codehaus.mojo.versions + 2.14.0-SNAPSHOT + + 4.0.0 + + versions-enforcer + + Versions Enforcer + Enforcer rules using Versions Maven Plugin + + + ${maven-enforcer-plugin.version} + + + + + + org.codehaus.mojo.versions + versions-common + ${project.version} + + + + org.codehaus.mojo.versions + versions-test + ${project.version} + test + + + + org.apache.maven.enforcer + enforcer-api + provided + + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + + org.apache.maven + maven-compat + ${mavenVersion} + provided + + + + org.junit.jupiter + junit-jupiter + test + + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + + + + org.mockito + mockito-inline + test + + + + org.hamcrest + hamcrest + test + + + + org.slf4j + slf4j-simple + test + + + + + + + + org.eclipse.sisu + sisu-maven-plugin + + + org.apache.maven.plugins + maven-invoker-plugin + + src/it + ${project.build.directory}/it + ${project.build.directory}/local-repo + src/it/settings.xml + true + true + + 1 + + */pom.xml + + verify + + ${repository.proxy.url} + + -Xmx256m + + + + + + + + + run-its + + verify + + + + org.codehaus.mojo + mrm-maven-plugin + + + + start + stop + + + + + repository.proxy.url + + + src/it-repo + + + ${project.build.directory}/local-repo + + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + integration-test + + install + integration-test + verify + + + false + true + + + + + + + + + + \ No newline at end of file diff --git a/versions-enforcer/src/it-repo/dummy-api-1.0.pom b/versions-enforcer/src/it-repo/dummy-api-1.0.pom new file mode 100644 index 0000000000..ac1f3b6f87 --- /dev/null +++ b/versions-enforcer/src/it-repo/dummy-api-1.0.pom @@ -0,0 +1,74 @@ + + 4.0.0 + + localhost + dummy-api + 1.0 + jar + + + + + + maven-clean-plugin + 2.2 + + + maven-compiler-plugin + 2.0.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-surefire-plugin + 2.4.2 + + + maven-project-info-reports-plugin + 2.1 + + + + + + + maven-site-plugin + 2.0 + + + maven-project-info-reports-plugin + 2.1 + + + + + + true + + + maven-project-info-reports-plugin + 2.1 + + + + + diff --git a/versions-enforcer/src/it-repo/dummy-api-2.0.pom b/versions-enforcer/src/it-repo/dummy-api-2.0.pom new file mode 100644 index 0000000000..1493f76abf --- /dev/null +++ b/versions-enforcer/src/it-repo/dummy-api-2.0.pom @@ -0,0 +1,49 @@ + + 4.0.0 + + localhost + dummy-api + 2.0 + jar + + + + + + maven-clean-plugin + 2.2 + + + maven-compiler-plugin + 2.0.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-surefire-plugin + 2.4.2 + + + + + + diff --git a/versions-enforcer/src/it-repo/dummy-api-2.1.pom b/versions-enforcer/src/it-repo/dummy-api-2.1.pom new file mode 100644 index 0000000000..913d99c9c1 --- /dev/null +++ b/versions-enforcer/src/it-repo/dummy-api-2.1.pom @@ -0,0 +1,49 @@ + + 4.0.0 + + localhost + dummy-api + 2.1 + jar + + + + + + maven-clean-plugin + 2.2 + + + maven-compiler-plugin + 2.0.2 + + + maven-deploy-plugin + 2.3 + + + maven-install-plugin + 2.2 + + + maven-jar-plugin + 2.2 + + + maven-resources-plugin + 2.2 + + + maven-site-plugin + 2.0 + + + maven-surefire-plugin + 2.4.2 + + + + + + diff --git a/versions-enforcer/src/it/it-max-dependency-updates-001/invoker.properties b/versions-enforcer/src/it/it-max-dependency-updates-001/invoker.properties new file mode 100644 index 0000000000..38b185e579 --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-001/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = enforcer:enforce +invoker.buildResult = failure diff --git a/versions-enforcer/src/it/it-max-dependency-updates-001/pom.xml b/versions-enforcer/src/it/it-max-dependency-updates-001/pom.xml new file mode 100644 index 0000000000..130d6e2fbb --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-001/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + localhost + it-max-dependency-upgrades + 1.0 + pom + + + + localhost + dummy-api + 1.0 + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + @maven-enforcer-plugin.version@ + + enforce + + + + + 0 + + + + + + org.codehaus.mojo.versions + versions-enforcer + @project.version@ + + + + + + + diff --git a/versions-enforcer/src/it/it-max-dependency-updates-002/invoker.properties b/versions-enforcer/src/it/it-max-dependency-updates-002/invoker.properties new file mode 100644 index 0000000000..a30e3767bb --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-002/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = enforcer:enforce +invoker.buildResult = success diff --git a/versions-enforcer/src/it/it-max-dependency-updates-002/pom.xml b/versions-enforcer/src/it/it-max-dependency-updates-002/pom.xml new file mode 100644 index 0000000000..f6cddd4cfd --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-002/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + localhost + it-max-dependency-upgrades + 1.0 + pom + + + + localhost + dummy-api + 1.0 + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + @maven-enforcer-plugin.version@ + + enforce + + + + + 1 + + + + + + org.codehaus.mojo.versions + versions-enforcer + @project.version@ + + + + + + + diff --git a/versions-enforcer/src/it/it-max-dependency-updates-003/invoker.properties b/versions-enforcer/src/it/it-max-dependency-updates-003/invoker.properties new file mode 100644 index 0000000000..a30e3767bb --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-003/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = enforcer:enforce +invoker.buildResult = success diff --git a/versions-enforcer/src/it/it-max-dependency-updates-003/pom.xml b/versions-enforcer/src/it/it-max-dependency-updates-003/pom.xml new file mode 100644 index 0000000000..c755c02769 --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-003/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + localhost + it-max-dependency-upgrades + 1.0 + pom + + + + localhost + dummy-api + 1.0 + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + @maven-enforcer-plugin.version@ + + enforce + + + + + 0 + + localhost:* + + + + + + + org.codehaus.mojo.versions + versions-enforcer + @project.version@ + + + + + + + diff --git a/versions-enforcer/src/it/it-max-dependency-updates-004/invoker.properties b/versions-enforcer/src/it/it-max-dependency-updates-004/invoker.properties new file mode 100644 index 0000000000..a30e3767bb --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-004/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = enforcer:enforce +invoker.buildResult = success diff --git a/versions-enforcer/src/it/it-max-dependency-updates-004/pom.xml b/versions-enforcer/src/it/it-max-dependency-updates-004/pom.xml new file mode 100644 index 0000000000..ce96b801cd --- /dev/null +++ b/versions-enforcer/src/it/it-max-dependency-updates-004/pom.xml @@ -0,0 +1,45 @@ + + 4.0.0 + localhost + it-max-dependency-upgrades + 1.0 + pom + + + + localhost + dummy-api + 2.0 + + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + @maven-enforcer-plugin.version@ + + enforce + + + + + 0 + true + + + + + + org.codehaus.mojo.versions + versions-enforcer + @project.version@ + + + + + + + diff --git a/versions-enforcer/src/it/settings.xml b/versions-enforcer/src/it/settings.xml new file mode 100644 index 0000000000..21c5cbc266 --- /dev/null +++ b/versions-enforcer/src/it/settings.xml @@ -0,0 +1,51 @@ + + + + + mrm-maven-plugin + Mock Repository Manager + @repository.proxy.url@ + * + + + + + it-repo + + true + + + + snapshots + @repository.proxy.url@ + + true + ignore + never + + + true + ignore + always + + + + + + snapshots + @repository.proxy.url@ + + true + ignore + never + + + true + ignore + always + + + + + + diff --git a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java new file mode 100644 index 0000000000..3806386d96 --- /dev/null +++ b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java @@ -0,0 +1,401 @@ +package org.apache.maven.plugins.enforcer; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.enforcer.rule.api.EnforcerLevel; +import org.apache.maven.enforcer.rule.api.EnforcerRule; +import org.apache.maven.enforcer.rule.api.EnforcerRule2; +import org.apache.maven.enforcer.rule.api.EnforcerRuleException; +import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.settings.Settings; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.DefaultVersionsHelper; +import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.model.RuleSet; +import org.codehaus.mojo.versions.utils.DependencyComparator; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; +import static org.codehaus.mojo.versions.api.Segment.MINOR; +import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; +import static org.codehaus.mojo.versions.filtering.DependencyFilter.filterDependencies; +import static org.codehaus.mojo.versions.filtering.WildcardMatcher.WILDCARD; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractDependenciesFromDependencyManagement; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractDependenciesFromPlugins; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractPluginDependenciesFromPluginsInPluginManagement; + +public class MaxDependencyUpdates implements EnforcerRule2 +{ + /** + * Maximum allowed number of updates. + * + * @since 2.14.0 + */ + protected int maxUpdates = 0; + + /** + * Whether to process the dependencies section of the project. + * + * @since 2.14.0 + */ + protected boolean processDependencies = true; + + /** + * Whether to process the dependencyManagement section of the project. + * + * @since 1.2 + */ + protected boolean processDependencyManagement = true; + + /** + * Whether to process the dependencyManagement part transitive or not. + * In case of type {@code pom} and scope {@code import}, this means + * by default to report also the imported dependencies. + * If the parameter is set to {@code false}, the report will only show + * updates of the imported pom itself. + * + * @since 2.14.0 + */ + protected boolean processDependencyManagementTransitive = true; + + /** + * Whether to process the dependencies sections of plugins. + * + * @since 2.14.0 + */ + protected boolean processPluginDependencies = true; + + /** + * Whether to process the dependencies sections of plugins which are defined in pluginManagement. + * + * @since 2.14.0 + */ + protected boolean processPluginDependenciesInPluginManagement = true; + + /** + * Whether minor updates should be ignored. Default {@code false}. + * + *

    Note: when {@code true}, will also assume that {@link #ignoreIncrementalUpdates} + * and {@link #ignoreSubIncrementalUpdates} are {@code true}.

    + * + * @since 2.14.0 + */ + protected boolean ignoreMinorUpdates = false; + + /** + * Whether incremental updates should be ignored. Default {@code false}. + * + *

    Note: when {@code true}, will also assume that + * {@link #ignoreSubIncrementalUpdates} is {@code true}.

    + * + * @since 2.14.0 + */ + protected boolean ignoreIncrementalUpdates = false; + + /** + * Whether sub-incremental updates should be ignored. Default {@code false}. + * + * @since 2.14.0 + */ + protected boolean ignoreSubIncrementalUpdates = false; + + /** + * List of dependency inclusion patterns. + * Only dependencies matching all the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List dependencyIncludes = singletonList( WILDCARD ); + + /** + * List of dependency exclusion patterns. + * Only dependencies matching none of the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List dependencyExcludes = emptyList(); + + /** + * List of dependency management inclusion patterns. + * Only dependencies matching all the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List dependencyManagementIncludes = singletonList( WILDCARD ); + + /** + * List of dependency management exclusion patterns. + * Only dependencies matching none of the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List dependencyManagementExcludes = emptyList(); + + /** + * List of plugin dependency inclusion patterns. + * Only dependencies matching all the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List pluginDependencyIncludes = singletonList( WILDCARD ); + + /** + * List of plugin dependency exclusion patterns. + * Only dependencies matching none of the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List pluginDependencyExcludes = emptyList(); + + /** + * List of plugin management dependency inclusion patterns. + * Only dependencies matching all the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List pluginManagementDependencyIncludes = singletonList( WILDCARD ); + + /** + * List of plugin dependency management exclusion patterns. + * Only dependencies matching none of the patterns will be considered. + * The wildcard "*" can be used as the only, first, last or both characters in each token. + * The version token does support version ranges. + * + * @since 2.14.0 + */ + protected List pluginManagementDependencyExcludes = emptyList(); + + /** + * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. + * + * @since 2.14.0 + */ + private String serverId; + + /** + * URI of a ruleSet file containing the rules that control how to compare + * version numbers. The URI could be either a Wagon URI or a classpath URI + * (e.g. classpath:///package/sub/package/rules.xml). + * + * 2.14.0 + */ + private String rulesUri; + + /** + *

    Allows specifying the {@linkplain RuleSet} object describing rules + * on artifact versions to ignore when considering updates.

    + * + * @see + * Using the ruleSet element in the POM + * + * @since 2.14.0 + */ + protected RuleSet ruleSet; + + /** + * Retrieves the maven project from metadata + * @param ruleHelper EnforcerRuleHelper object + * @return maven project + */ + private static MavenProject getMavenProject( EnforcerRuleHelper ruleHelper ) + { + try + { + return (MavenProject) ruleHelper.evaluate( "${project}" ); + } + catch ( ExpressionEvaluationException e ) + { + throw new RuntimeException( "Cannot evaluate project metadata", e ); + } + } + + /** + * Creates the VersionsHelper object + * @param ruleHelper EnforcerRuleHelper object + * @return VersionsHelper object + */ + @SuppressWarnings( "unchecked" ) + private static VersionsHelper createVersionsHelper( EnforcerRuleHelper ruleHelper, + String serverId, + String rulesUri, + RuleSet ruleSet ) + { + try + { + return new DefaultVersionsHelper.Builder() + .withRepositorySystem( ruleHelper.getComponent( RepositorySystem.class ) ) + .withArtifactResolver( ruleHelper.getComponent( ArtifactResolver.class ) ) + .withAetherRepositorySystem( ruleHelper.getComponent( org.eclipse.aether.RepositorySystem.class ) ) + .withLocalRepository( (ArtifactRepository) ruleHelper.evaluate( "${localRepository}" ) ) + .withWagonManager( ruleHelper.getComponent( WagonManager.class ) ) + .withSettings( (Settings) ruleHelper.evaluate( "${settings}" ) ) + .withServerId( serverId ) + .withRulesUri( rulesUri ) + .withRuleSet( ruleSet ) + .withIgnoredVersions( null ) + .withLog( ruleHelper.getLog() ) + .withMavenSession( (MavenSession) ruleHelper.evaluate( "${session}" ) ) + .withMojoExecution( (MojoExecution) ruleHelper.evaluate( "${mojoExecution}" ) ) + .build(); + } + catch ( ExpressionEvaluationException e ) + { + throw new RuntimeException( "Cannot evaluate project metadata", e ); + } + catch ( ComponentLookupException | MojoExecutionException e ) + { + throw new RuntimeException( "Cannot resolve dependency", e ); + } + } + @Override + public boolean isCacheable() + { + return false; + } + + @Override + public boolean isResultValid( EnforcerRule enforcerRule ) + { + return false; + } + + @Override + public String getCacheId() + { + return "Does not matter as not cacheable"; + } + + @Override + public void execute( EnforcerRuleHelper ruleHelper ) throws EnforcerRuleException + { + VersionsHelper versionsHelper = createVersionsHelper( ruleHelper, serverId != null ? serverId : "serverId", + rulesUri, ruleSet ); + MavenProject project = getMavenProject( ruleHelper ); + Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); + if ( processDependencyManagement ) + { + try + { + dependencies.addAll( filterDependencies( extractDependenciesFromDependencyManagement( project, + processDependencyManagementTransitive, ruleHelper.getLog() ), + dependencyManagementIncludes, dependencyManagementExcludes, "Dependency Management", + ruleHelper.getLog() ) ); + } + catch ( VersionRetrievalException e ) + { + throw new EnforcerRuleException( e.getMessage() ); + } + } + if ( processPluginDependencies ) + { + dependencies.addAll( filterDependencies( extractDependenciesFromPlugins( project ), + pluginDependencyIncludes, pluginDependencyExcludes, + "Plugin Dependencies", ruleHelper.getLog() ) ); + } + if ( processPluginDependenciesInPluginManagement ) + { + dependencies.addAll( filterDependencies( + extractPluginDependenciesFromPluginsInPluginManagement( project ), + pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, + "Plugin Management Dependencies", ruleHelper.getLog() ) ); + } + if ( processDependencies ) + { + dependencies.addAll( filterDependencies( project.getDependencies(), + dependencyIncludes, dependencyExcludes, "Dependencies", ruleHelper.getLog() ) ); + } + try + { + Optional ignoredSegment = ignoreSubIncrementalUpdates + ? of( SUBINCREMENTAL ) + : ignoreIncrementalUpdates + ? of( INCREMENTAL ) + : ignoreMinorUpdates + ? of( MINOR ) + : empty(); + List upgradable = versionsHelper + .lookupDependenciesUpdates( dependencies, false ) + .values() + .parallelStream() + .filter( v -> + v.getVersions( v.restrictionForIgnoreScope( ignoredSegment ), true ).length > 0 + ) + .collect( Collectors.toList() ); + if ( upgradable.size() > maxUpdates ) + { + throw new EnforcerRuleException( "More than " + maxUpdates + " upgradable artifacts detected: " + + upgradable.stream().map( av -> av.getArtifact() + " -> [" + + Arrays.stream( av.getVersions() ) + .map( ArtifactVersion::toString ) + .collect( Collectors.joining( ", " ) ) + + "]" ) + .collect( Collectors.joining( ", " ) ) ); + } + } + catch ( VersionRetrievalException e ) + { + throw new RuntimeException( e.getMessage(), e ); + } + } + + @Override + public EnforcerLevel getLevel() + { + // all reported items should be treated as errors + return EnforcerLevel.ERROR; + } +} diff --git a/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm b/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm new file mode 100644 index 0000000000..26100debeb --- /dev/null +++ b/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm @@ -0,0 +1,114 @@ + +title: Introduction +author: Andrzej Jarmoniuk +date: 2022-10-27 + + + +Max Dependency Updates +====================== + +This Maven Enforcer rule checks if the number of dependency updates does not exceed the given threshold. + +The following parameters are supported by this rule: + +| Parameter | Default | Description | +|-----------------------------------------------|:----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `maxUpdates` | `0` | The total maximum allowed number of dependency updates. | +| `processDependencies` | `true` | Whether to process the dependencies section of the project. | +| `processDependencyManagement` | `true` | Whether to process the dependencyManagement section of the project. | +| `processDependencyManagementTransitive` | `true` | Whether to process the dependencyManagement part transitive or not. In case of *type* `pom` and *scope* `import`, this means by default to report also the imported dependencies. If the parameter is set to false the report will only show updates of the imported pom itself. | +| `processPluginDependencies` | `true` | Whether to process the dependencies sections of plugins. | +| `processPluginDependenciesInPluginManagement` | `true` | Whether to process the dependencies sections of plugins which are defined in pluginManagement. | +| `ignoreMinorUpdates` | `false` | Whether minor updates should be ignored. Default `false`.
    **Note:** when true, will also assume that `ignoreIncrementalUpdates` and `ignoreSubIncrementalUpdates` are also `true`. | +| `ignoreIncrementalUpdates` | `false` | Whether incremental updates should be ignored. Default `false`.
    **Note:** when true, will also assume that `ignoreSubIncrementalUpdates` is also `true`. | +| `ignoreSubIncrementalUpdates` | `false` | Whether sub-incremental updates should be ignored. Default `false`. | +| `dependencyIncludes` | `*` | List of dependency inclusion patterns. Only dependencies matching all the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `dependencyExcludes` | (empty) | List of dependency exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `dependencyManagementIncludes` | `*` | List of dependency management inclusion patterns. Only dependencies matching all the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `dependencyManagementExcludes` | (empty) | List of dependency management exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `pluginDependencyIncludes` | `*` | List of plugin dependency inclusion patterns. Only dependencies matching all the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `pluginDependencyExcludes` | (empty) | List of plugin dependency exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `pluginManagementDependencyIncludes` | `*` | List of plugin management dependency inclusion patterns. Only dependencies matching all the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `pluginManagementDependencyExcludes` | (empty) | List of plugin management dependency exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | +| `serverId` | `serverId` | *settings.xml*'s server id for the URL. This is used when wagon needs extra authentication information. | +| `rulesUri` | | URI of a ruleSet file containing the rules that control how to compare version numbers. The URI could be either a Wagon URI or a classpath URI (e.g. *classpath:\/\/\/package/sub/package/rules.xml*). | +| `ruleSet` | | Allows specifying the `RuleSet` object describing rules on artifact versions to ignore when considering updates.
    See: [Using the ruleSet element in the POM](../version-rules.html#Using_the_ruleSet_element_in_the_POM) | + +**Note:** Inclusion/exclusion parameters like `dependencyIncludes`, `dependencyExcludes`, etc. work the same way as parameters +of the same name of the [versions:display-dependency-updates](../display-dependency-updates-mojo.html) goal +of the plugin. + +The parameters accept a list of *extended GAV* patterns, meaning patterns of: + +`groupId:artifactId:version:type:classifier:scope` + +of which only `groupId` is obligatory. On top of that, all of the components can be replaced with the asterisk (`*`) +character in which case it will match all values. + +So, e.g. both of the below patterns: +- `org.codehaus.mojo` +- `org.codehaus.mojo:*` + +will match all artifacts with groupId `org.codehaus.mojo`. + +### Sample Plugin Configuration + +Below a rundimentary example of using the enforcer rule. + +The below example specifies a rule which will not allow any updates except for updates of `localhost:dummy-api`. +It will also ignore all sub-incremental updates. + +```xml + + ... + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin-version} + + enforce + + + + + 0 + + localhost:dummy-api + + true + + + + + + org.codehaus.mojo.versions + versions-enforcer + ${pluginVersion} + + + + + + + +``` \ No newline at end of file diff --git a/versions-enforcer/src/site/site.xml b/versions-enforcer/src/site/site.xml new file mode 100644 index 0000000000..df2fad123c --- /dev/null +++ b/versions-enforcer/src/site/site.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java new file mode 100644 index 0000000000..7493bcce74 --- /dev/null +++ b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java @@ -0,0 +1,289 @@ +package org.apache.maven.plugins.enforcer; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.HashMap; + +import org.apache.maven.artifact.resolver.ArtifactResolver; +import org.apache.maven.enforcer.rule.api.EnforcerRuleException; +import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.settings.Settings; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.junit.Test; +import org.mockito.ArgumentMatchers; + +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; +import static org.codehaus.mojo.versions.utils.DependencyBuilder.dependencyWith; +import static org.codehaus.mojo.versions.utils.MockUtils.mockAetherRepositorySystem; +import static org.codehaus.mojo.versions.utils.MockUtils.mockMavenSession; +import static org.codehaus.mojo.versions.utils.MockUtils.mockRepositorySystem; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class MaxDependencyUpdatesTest +{ + private static EnforcerRuleHelper mockRuleHelper( MavenProject mavenProject, + org.eclipse.aether.RepositorySystem aetherRepositorySystem ) + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mock( EnforcerRuleHelper.class ); + when( ruleHelper.evaluate( anyString() ) ) + .then( ( a ) -> "${project}".equals( a.getArgument( 0 ) ) + ? mavenProject + : "${localRepository}".equals( a.getArgument( 0 ) ) + ? new StubArtifactRepository( "" ) + : "${settings}".equals( a.getArgument( 0 ) ) + ? new Settings() + : "${session}".equals( a.getArgument( 0 ) ) + ? mockMavenSession() + : "${mojoExecution}".equals( a.getArgument( 0 ) ) + ? mock( MojoExecution.class ) + : null ); + when( ruleHelper.getComponent( ArgumentMatchers.>any() ) ) + .then( ( a ) -> a.getArgument( 0 ) == RepositorySystem.class + ? mockRepositorySystem() + : a.getArgument( 0 ) == ArtifactResolver.class + ? mock( ArtifactResolver.class ) + : a.getArgument( 0 ) == org.eclipse.aether.RepositorySystem.class + ? aetherRepositorySystem + : null ); + return ruleHelper; + } + + @Test + public void testRuleFailsByMaxUpdatesExceeded() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( asList( + dependencyWith( "group", "artifactA", "1.0.0" ), + dependencyWith( "group", "artifactB", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0", "2.0.0" } ); + }} ) ); + + try + { + new MaxDependencyUpdates() + {{ + maxUpdates = 1; + }}.execute( ruleHelper ); + + fail( "EnforcerRuleException should have been thrown" ); + } + catch ( EnforcerRuleException e ) + { + assertThat( e.getMessage(), containsString( "More than 1 upgradable artifacts detected" ) ); + } + } + + @Test + public void testRulePassesByMaxUpdatesNotExceeded() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( singletonList( + dependencyWith( "group", "artifactA", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( singletonMap( "artifactA", new String[] { "1.0.0", "2.0.0" } ) ) ); + + try + { + new MaxDependencyUpdates() + {{ + maxUpdates = 1; + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testRulePassesByMaxUpdatesNotExceededDependencyIncludes() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( asList( + dependencyWith( "group", "artifactA", "1.0.0" ), + dependencyWith( "group", "artifactB", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + }} ) ); + + try + { + new MaxDependencyUpdates() + {{ + dependencyIncludes = singletonList( "group:artifactB" ); + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testRulePassesByMaxUpdatesNotExceededDependencyExcludes() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( asList( + dependencyWith( "group", "artifactA", "1.0.0" ), + dependencyWith( "group", "artifactB", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + }} ) ); + + try + { + new MaxDependencyUpdates() + {{ + dependencyExcludes = singletonList( "group:artifactA" ); + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testRulePassesByMaxUpdatesNotExceededDependencyIncludesExcludes() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( asList( + dependencyWith( "group", "artifactA", "1.0.0" ), + dependencyWith( "group", "artifactB", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( new HashMap() + {{ + put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); + put( "artifactB", new String[] { "1.0.0" } ); + }} ) ); + + try + { + new MaxDependencyUpdates() + {{ + dependencyIncludes = singletonList( "group:*" ); + dependencyExcludes = singletonList( "group:artifactA" ); + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testIgnoreSubIncrementalUpdates() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( singletonList( + dependencyWith( "group", "artifactA", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( singletonMap( "artifactA", + new String[] { "1.0.0", "1.0.0-1" } ) ) ); + + try + { + new MaxDependencyUpdates() + {{ + ignoreSubIncrementalUpdates = true; + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testIgnoreIncrementalUpdates() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( singletonList( + dependencyWith( "group", "artifactA", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( singletonMap( "artifactA", + new String[] { "1.0.0", "1.0.0-1", "1.0.1" } ) ) ); + + try + { + new MaxDependencyUpdates() + {{ + ignoreIncrementalUpdates = true; + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } + + @Test + public void testIgnoreMinorUpdates() + throws ExpressionEvaluationException, ComponentLookupException + { + EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() + {{ + setDependencies( asList( + dependencyWith( "group", "artifactA", "1.0.0" ) ) ); + }}, mockAetherRepositorySystem( singletonMap( "artifactA", + new String[] { "1.0.0", "1.0.0-1", "1.0.1", "1.1.0" } ) ) ); + + try + { + new MaxDependencyUpdates() + {{ + ignoreMinorUpdates = true; + }}.execute( ruleHelper ); + } + catch ( EnforcerRuleException e ) + { + fail( "No EnforcerRuleException should have been thrown" ); + } + } +} diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 71519af212..e586a8ba11 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -27,6 +27,13 @@ ${project.version} + + org.codehaus.mojo.versions + versions-test + ${project.version} + test + + org.codehaus.mojo.versions versions-common @@ -38,7 +45,7 @@ maven-plugin-annotations provided - + org.apache.maven maven-artifact diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 5ed1df38b9..fb6fe624b5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -51,6 +51,7 @@ import org.codehaus.plexus.i18n.I18N; import static java.util.Collections.emptyMap; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.interpolateVersion; import static org.codehaus.mojo.versions.utils.MiscUtils.filter; /** @@ -174,7 +175,7 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() ! // TODO: I'm not 100% sure if this will work correctly in all cases. for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) { - dep = getHelper().interpolateVersion( dep, getProject() ); + dep = interpolateVersion( dep, getProject() ); getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 02c7cc1b72..3d37aa60f4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -28,38 +28,37 @@ import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import java.util.stream.Collectors; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.model.Build; import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.filtering.DependencyFilter; import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyComparator; import org.codehaus.mojo.versions.utils.SegmentUtils; import org.codehaus.plexus.util.StringUtils; +import static java.util.Collections.emptySet; import static java.util.Optional.empty; import static java.util.Optional.of; import static org.apache.commons.lang3.StringUtils.countMatches; import static org.codehaus.mojo.versions.api.Segment.MAJOR; +import static org.codehaus.mojo.versions.filtering.DependencyFilter.filterDependencies; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractDependenciesFromDependencyManagement; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractDependenciesFromPlugins; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractPluginDependenciesFromPluginsInPluginManagement; /** * Displays all dependencies that have newer versions available. @@ -357,68 +356,6 @@ public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, changeRecorders ); } - private static Set extractPluginDependenciesFromPluginsInPluginManagement( Build build ) - { - Set result = new TreeSet<>( DependencyComparator.INSTANCE ); - if ( build.getPluginManagement() != null ) - { - for ( Plugin plugin : build.getPluginManagement().getPlugins() ) - { - if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) - { - result.addAll( plugin.getDependencies() ); - } - } - } - return result; - } - - private static Set extractDependenciesFromPlugins( List plugins ) - { - Set result = new TreeSet<>( DependencyComparator.INSTANCE ); - for ( Plugin plugin : plugins ) - { - if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() ) - { - result.addAll( plugin.getDependencies() ); - } - } - return result; - } - - /** - * Returns a set of dependencies where the dependencies which are defined in the dependency management section have - * been filtered out. - * - * @param dependencies The set of dependencies. - * @param dependencyManagement The set of dependencies from the dependency management section. - * @return A new set of dependencies which are from the set of dependencies but not from the set of dependency - * management dependencies. - * @since 1.0-beta-1 - */ - private static Set removeDependencyManagment( Set dependencies, - Set dependencyManagement ) - { - Set result = new TreeSet<>( DependencyComparator.INSTANCE ); - for ( Dependency dependency : dependencies ) - { - boolean matched = false; - for ( Dependency managedDependency : dependencyManagement ) - { - if ( dependenciesMatch( dependency, managedDependency ) ) - { - matched = true; - break; - } - } - if ( !matched ) - { - result.add( dependency ); - } - } - return result; - } - // open for tests protected static boolean dependenciesMatch( Dependency dependency, Dependency managedDependency ) { @@ -491,106 +428,48 @@ public void execute() logInit(); validateInput(); - Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); - DependencyManagement projectDependencyManagement = getProjectDependencyManagement( getProject() ); - if ( projectDependencyManagement != null ) - { - - List dependenciesFromPom = projectDependencyManagement.getDependencies(); - for ( Dependency dependency : dependenciesFromPom ) - { - getLog().debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() - + ":" + dependency.getVersion() + ":" + dependency.getScope() ); - if ( dependency.getVersion() == null ) - { - // get parent and get the information from there. - if ( getProject().hasParent() ) - { - getLog().debug( "Reading parent dependencyManagement information" ); - DependencyManagement parentProjectDependencyManagement = - getProjectDependencyManagement( getProject().getParent() ); - if ( parentProjectDependencyManagement != null ) - { - List parentDeps = parentProjectDependencyManagement.getDependencies(); - for ( Dependency parentDep : parentDeps ) - { - // only groupId && artifactId needed cause version is null - if ( dependency.getGroupId().equals( parentDep.getGroupId() ) - && dependency.getArtifactId().equals( parentDep.getArtifactId() ) - && dependency.getType().equals( parentDep.getType() ) ) - { - dependencyManagement.add( parentDep ); - } - } - } - } - else - { - String message = "We can't get the version for the dependency " + dependency.getGroupId() + ":" - + dependency.getArtifactId() + " cause there does not exist a parent."; - getLog().error( message ); - // Throw error cause we will not able to get a version for a dependency. - throw new MojoExecutionException( message ); - } - } - else - { - dependency = getHelper().interpolateVersion( dependency, getProject() ); - dependencyManagement.add( dependency ); - } - } - } - - Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); - dependencies.addAll( getProject().getDependencies() ); - - if ( isProcessingDependencyManagement() ) - { - dependencies = removeDependencyManagment( dependencies, dependencyManagement ); - } - - Set pluginDependencies = new TreeSet<>( DependencyComparator.INSTANCE ); - - if ( isProcessingPluginDependencies() ) - { - pluginDependencies = extractDependenciesFromPlugins( getProject().getBuildPlugins() ); - } - - Set pluginDependenciesInPluginManagement = new TreeSet<>( DependencyComparator.INSTANCE ); - if ( isProcessPluginDependenciesInDependencyManagement() ) - { - pluginDependenciesInPluginManagement = - extractPluginDependenciesFromPluginsInPluginManagement( getProject().getBuild() ); - } + Set dependencyManagement = emptySet(); try { if ( isProcessingDependencyManagement() ) { - dependencyManagement = filterDependencyManagementIncludes( dependencyManagement ); + dependencyManagement = filterDependencies( extractDependenciesFromDependencyManagement( getProject(), + processDependencyManagementTransitive, getLog() ), + dependencyManagementIncludes, dependencyManagementExcludes, "Dependecy Management", + getLog() ); - logUpdates( getHelper().lookupDependenciesUpdates( dependencyManagement, false ), - "Dependency Management" ); + logUpdates( getHelper().lookupDependenciesUpdates( dependencyManagement, + false ), "Dependency Management" ); } if ( isProcessingDependencies() ) { - dependencies = filterDependencyIncludes( dependencies ); - - logUpdates( getHelper().lookupDependenciesUpdates( dependencies, false ), "Dependencies" ); + Set finalDependencyManagement = dependencyManagement; + logUpdates( getHelper().lookupDependenciesUpdates( + filterDependencies( getProject().getDependencies() + .parallelStream() + .filter( dep -> finalDependencyManagement.parallelStream() + .noneMatch( depMan -> dependenciesMatch( dep, depMan ) ) ) + .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ), + dependencyIncludes, dependencyExcludes, "Dependencies", getLog() ), + false ), + "Dependencies" ); } if ( isProcessPluginDependenciesInDependencyManagement() ) { - pluginDependenciesInPluginManagement = - filterPluginManagementIncludes( pluginDependenciesInPluginManagement ); - - logUpdates( getHelper().lookupDependenciesUpdates( pluginDependenciesInPluginManagement, false ), - "pluginManagement of plugins" ); + logUpdates( getHelper().lookupDependenciesUpdates( filterDependencies( + extractPluginDependenciesFromPluginsInPluginManagement( getProject() ), + pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, + "Plugin Management Dependencies", getLog() ), false ), + "pluginManagement of plugins" ); } if ( isProcessingPluginDependencies() ) { - pluginDependencies = filterPluginDependencyIncludes( pluginDependencies ); - - logUpdates( getHelper().lookupDependenciesUpdates( pluginDependencies, false ), "Plugin Dependencies" ); + logUpdates( getHelper().lookupDependenciesUpdates( filterDependencies( + extractDependenciesFromPlugins( getProject() ), + pluginDependencyIncludes, pluginDependencyExcludes, "Plugin Dependencies", + getLog() ), false ), + "Plugin Dependencies" ); } } catch ( VersionRetrievalException e ) @@ -628,72 +507,6 @@ static void validateGAVList( List gavList, int numSections, String argum } } - private Set filterDependencyIncludes( Set dependencies ) - { - return filterDependencies( dependencies, dependencyIncludes, dependencyExcludes, "Dependencies" ); - } - - private Set filterDependencyManagementIncludes( Set dependencyManagement ) - { - return filterDependencies( dependencyManagement, - dependencyManagementIncludes, dependencyManagementExcludes, "Dependecy Management" ); - } - - private Set filterPluginDependencyIncludes( Set dependencies ) - { - return filterDependencies( dependencies, pluginDependencyIncludes, pluginDependencyExcludes, - "Plugin Dependencies" ); - } - - private Set filterPluginManagementIncludes( Set dependencyManagement ) - { - return filterDependencies( dependencyManagement, - pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, - "Plugin Management Dependencies" ); - } - - private Set filterDependencies( - Set dependencies, - List includes, - List excludes, - String section - ) - { - DependencyFilter includeDeps = DependencyFilter.parseFrom( includes ); - DependencyFilter excludeDeps = DependencyFilter.parseFrom( excludes ); - - Set filtered = includeDeps.retainingIn( dependencies ); - filtered = excludeDeps.removingFrom( filtered ); - - if ( getLog().isDebugEnabled() ) - { - getLog().debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); - getLog().debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); - getLog().debug( String.format( "Unfiltered %s: ", section ) + output( dependencies ) ); - getLog().debug( String.format( "Filtered %s: ", section ) + output( filtered ) ); - } - - return filtered; - } - - private String output( Set dependencies ) - { - return dependencies.stream() - .map( d -> String.format( "%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion() ) ) - .collect( Collectors.joining( ", " ) ); - } - private DependencyManagement getProjectDependencyManagement( MavenProject project ) - { - if ( processDependencyManagementTransitive ) - { - return project.getDependencyManagement(); - } - else - { - return project.getOriginalModel().getDependencyManagement(); - } - } - private Optional calculateUpdateScope() { return allowAnyUpdates diff --git a/versions-maven-plugin/src/site/markdown/index.md b/versions-maven-plugin/src/site/markdown/index.md index f008eb1a60..69a48c2e8e 100644 --- a/versions-maven-plugin/src/site/markdown/index.md +++ b/versions-maven-plugin/src/site/markdown/index.md @@ -86,6 +86,12 @@ The Versions Plugin has the following reporting goals. * [versions:parent-updates-report](./parent-updates-report-mojo.html) produces a report on possible parent artifact upgrades. +## Enforcer rules overview + +The Versions Plugin currently provides one Maven Enforcer Plugin rule: +* [maxDependencyUpdates](../versions-enforcer/max-dependency-updates.html) allows the user to specify a maximum number of updates which, + if exceeded, will trigger the enforcer plugin to fail. + ## Usage General instructions on how to use the Versions Plugin can be found on the [usage page](./usage.html). Some more diff --git a/versions-test/pom.xml b/versions-test/pom.xml new file mode 100644 index 0000000000..1ddf047d9e --- /dev/null +++ b/versions-test/pom.xml @@ -0,0 +1,72 @@ + + + + + + versions + org.codehaus.mojo.versions + 2.14.0-SNAPSHOT + + 4.0.0 + + versions-test + + Versions Test + Test utilities + + + + org.apache.maven + maven-compat + ${mavenVersion} + provided + + + org.apache.maven.doxia + doxia-integration-tools + ${doxiaVersion} + + + org.apache.maven.doxia + doxia-site-renderer + ${doxia-sitetoolsVersion} + + + org.codehaus.mojo.versions + versions-common + ${project.version} + + + org.apache.commons + commons-text + + + org.mockito + mockito-inline + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + + + + \ No newline at end of file diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java rename to versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java index bf980f3786..733344f143 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -1,3 +1,5 @@ +package org.codehaus.mojo.versions.utils; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,8 +19,6 @@ * under the License. */ -package org.codehaus.mojo.versions.utils; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java rename to versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/TestUtils.java rename to versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java similarity index 100% rename from versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java rename to versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java From d4d0f2644ea736bb1fdca42c51694d57a86b45a7 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Thu, 24 Nov 2022 09:52:54 +0100 Subject: [PATCH 217/441] Refactored Reports classes --- .../versions/api/AbstractVersionDetails.java | 2 +- .../AbstractVersionsReportRenderer.java | 341 +++++++++--------- .../DependencyUpdatesReportRenderer.java | 1 + .../PluginUpdatesReportRenderer.java | 188 +--------- .../PropertyUpdatesReportRenderer.java | 274 ++------------ .../reporting/VersionsReportRendererBase.java | 83 +++++ .../dependency-updates-report.properties | 1 + 7 files changed, 300 insertions(+), 590 deletions(-) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 939a3f3997..c16506c894 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -465,7 +465,7 @@ protected Optional getLowerBound( ArtifactVersion version, Optional extends VersionsReportRe protected ArtifactVersionsCache allUpdatesCache = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); + protected final SinkEventAttributes headerAttributes + = new SinkEventAttributeSet( SinkEventAttributes.WIDTH, "30%" ); + protected AbstractVersionsReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, T model ) { super( sink, i18n, locale, bundleName ); @@ -139,18 +146,17 @@ protected void renderOverviewTableRow( Q stats ) renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor(), false ); } + /** + * Renders one table row for the given statistics. + * @param textKey the key of the text to be rendered. + * @param statCount the number of artifacts with the given stat. + * @param forceSuccessIcon if true, the success icon will be rendered regardless. + */ protected void renderStatRow( String textKey, int statCount, boolean forceSuccessIcon ) { sink.tableRow(); sink.tableCell(); - if ( statCount == 0 || forceSuccessIcon ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } + renderIcon( statCount == 0 || forceSuccessIcon ); sink.tableCell_(); sink.tableCell(); sink.text( getText( textKey ) ); @@ -161,6 +167,22 @@ protected void renderStatRow( String textKey, int statCount, boolean forceSucces sink.tableRow_(); } + /** + * Renders the success or warning icon. + * @param success if true, the success icon will be rendered, otherwise the warning icon will be rendered. + */ + protected void renderIcon( boolean success ) + { + if ( success ) + { + renderSuccessIcon(); + } + else + { + renderWarningIcon(); + } + } + /** * Computes the {@linkplain OverviewStats} object needed to render the summary table row * @param concrete {@linkplain OverviewStats} class @@ -207,101 +229,108 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) "report.latestIncremental", "report.latestMinor", "report.latestMajor" ); } - protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, - boolean includeScope ) + protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, boolean includeScope ) { ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.tableRow(); - sink.tableCell(); - if ( upToDate ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getGroupId() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getArtifactId() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getVersion() ); - sink.tableCell_(); - if ( includeScope ) - { - sink.tableCell(); - sink.text( artifact.getScope() ); - sink.tableCell_(); - } - sink.tableCell(); - sink.text( artifact.getClassifier() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getType() ); - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); sink.tableCell(); - if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); - safeBold_(); - } + renderIcon( upToDate ); sink.tableCell_(); - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) + renderCells( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); + if ( includeScope ) { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); - safeBold_(); + renderCell( artifact.getScope() ); } - sink.tableCell_(); + renderCells( artifact.getClassifier(), artifact.getType() ); + renderNewestVersions( details ); sink.tableRow_(); } + /** + * Renders the newest versions for the given artifact. + * @param details the artifact for which to render the newest versions. + */ + protected void renderNewestVersions( AbstractVersionDetails details ) + { + renderBoldCell( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ); + renderBoldCell( newestUpdateCache.get( details, of( INCREMENTAL ) ) ); + renderBoldCell( newestUpdateCache.get( details, of( MINOR ) ) ); + renderBoldCell( newestUpdateCache.get( details, of( MAJOR ) ) ); + } + @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope ) { ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); boolean upToDate = allUpdates == null || allUpdates.length == 0; - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); + + renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); + renderTwoCellsRow( "report.groupId", artifact.getGroupId() ); + renderTwoCellsRow( "report.artifactId", artifact.getArtifactId() ); + renderTwoCellsRow( "report.currentVersion", artifact.getVersion() ); + if ( includeScope ) + { + renderTwoCellsRow( "report.scope", artifact.getScope() ); + } + renderTwoCellsRow( "report.classifier", artifact.getClassifier() ); + renderTwoCellsRow( "report.type", artifact.getType() ); + if ( !upToDate ) + { + renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); + } + + sink.tableRows_(); + sink.table_(); + } + + /** + * Renders a row of two cells, the first cell being an header and the second cell being a non-header cell. + * @param textKey the key of the text to be rendered. + * @param textValue the value of the text to be rendered. + */ + protected void renderTwoCellsRow( String textKey, String textValue ) + { sink.tableRow(); sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.status" ) ); + sink.text( getText( textKey ) ); + sink.tableHeaderCell_(); + sink.tableCell(); + sink.text( textValue ); + sink.tableCell_(); + sink.tableRow_(); + } + + /** + * Renders a row of two cells, the first cell being an header and the second cell being a non-header cell. + * @param textKey the key of the text to be rendered. + * @param runnable the runnable to be executed to render the second cell content. + */ + protected void renderTwoCellsRow( String textKey, Runnable runnable ) + { + sink.tableRow(); + sink.tableHeaderCell( headerAttributes ); + sink.text( getText( textKey ) ); sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); + sink.tableCell(); + runnable.run(); + sink.tableCell_(); + sink.tableRow_(); + } + + /** + * Renders the status of the given artifact. + * @param details the artifact for which to render the status. + */ + protected void renderStatus( AbstractVersionDetails details ) + { if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); @@ -332,111 +361,82 @@ else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) sink.nonBreakingSpace(); sink.text( getText( "report.noUpdatesAvailable" ) ); } - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.groupId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getGroupId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.artifactId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getArtifactId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getVersion() ); - sink.tableCell_(); - sink.tableRow_(); - if ( includeScope ) + } + + private List getArtifactVersionRange( AbstractVersionDetails details ) + { + try { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.scope" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getScope() ); - sink.tableCell_(); - sink.tableRow_(); + String spec = details.getCurrentVersion().toString(); + VersionRange range = VersionRange.createFromVersionSpec( spec ); + return range.getRestrictions(); } - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.classifier" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getClassifier() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.type" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( artifact.getType() ); - sink.tableCell_(); - sink.tableRow_(); - if ( !upToDate ) + catch ( InvalidVersionSpecificationException ignored ) + { + ignored.printStackTrace( System.err ); + } + return Collections.EMPTY_LIST; + } + + /** + * Renders the list of versions that are available for the given artifact or property. + * @param allUpdates the list of all updates available. + * @param details TODO. + */ + protected void renderVersions( ArtifactVersion[] allUpdates, AbstractVersionDetails details ) + { + List versionRange = getArtifactVersionRange( details ); + boolean someNotAllowed = false; + for ( int i = 0; i < allUpdates.length; i++ ) { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.updateVersions" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - for ( int i = 0; i < allUpdates.length; i++ ) + if ( i > 0 ) { - if ( i > 0 ) - { - sink.lineBreak(); - } - String label = getLabel( allUpdates[i], details ); - if ( label != null ) - { - safeBold(); - } - sink.text( allUpdates[i].toString() ); - if ( label != null ) + sink.lineBreak(); + } + // if candidate version in range, display no star. + ArtifactVersion candidate = allUpdates[i]; + boolean allowed = versionRange.stream().anyMatch( restriction -> + details.isVersionInRestriction( restriction, candidate ) ); + String label = getLabel( allUpdates[i], details ); + if ( !allowed ) + { + sink.text( "* " ); + someNotAllowed = true; + } + if ( allowed && label != null ) + { + safeBold(); + } + sink.text( allUpdates[i].toString() ); + if ( label != null ) + { + if ( allowed ) { safeBold_(); - sink.nonBreakingSpace(); - safeItalic(); - sink.text( label ); - safeItalic_(); } + sink.nonBreakingSpace(); + safeItalic(); + sink.text( label ); + safeItalic_(); } - sink.tableCell_(); - sink.tableRow_(); } - sink.tableRows_(); - sink.table_(); + if ( someNotAllowed ) + { + sink.lineBreak(); + sink.lineBreak(); + sink.text( "* " ); + safeItalic(); + sink.text( getText( "report.excludedVersion" ) ); + safeItalic_(); + } } /** - * Renders a table header containing elements denoted by the given keys - * @param keys variable argument list containing keys of the property file to retrieve the - * headers from + * Returns a text label to describe if the given version is a major, minor, incremental or subincremental update. + * @param version the version to describe. + * @param details the artifact for which to render the versions. + * @return a text label to describe if the given version is a major, minor, incremental or subincremental update. */ - protected void renderTableHeaderCells( String... keys ) - { - Arrays.stream( keys ) - .map( this::getText ) - .forEachOrdered( str -> - { - sink.tableHeaderCell(); - sink.text( str ); - sink.tableHeaderCell_(); - } ); - } - protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) { @@ -462,4 +462,5 @@ protected String getLabel( ArtifactVersion version, AbstractVersionDetails detai return null; } + } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index 2d8948280a..8072e31192 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -98,4 +98,5 @@ protected void renderDependencyDetail( Dependency artifact, ArtifactVersions det renderDependencyDetailTable( artifact, details, true ); sink.section2_(); } + } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index c878110a8c..bf2fd24de8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -26,8 +26,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkEventAttributes; -import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PluginUpdatesDetails; @@ -35,11 +33,6 @@ import org.codehaus.plexus.i18n.I18N; import static java.util.Optional.empty; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; /** * @since 1.0-beta-1 @@ -153,79 +146,12 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails sink.tableRow(); sink.tableCell(); - if ( upToDate ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getGroupId() ); - sink.tableCell_(); - sink.tableCell(); - sink.text( artifact.getArtifactId() ); - sink.tableCell_(); - sink.tableCell(); - if ( !details.isArtifactUpdateAvailable() ) - { - safeBold(); - } - sink.text( artifact.getVersion() ); - if ( !details.isArtifactUpdateAvailable() ) - { - safeBold_(); - } - sink.tableCell_(); - sink.tableCell(); - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( details.isDependencyUpdateAvailable() ) - { - renderWarningIcon(); - } - else - { - renderSuccessIcon(); - } - sink.tableCell_(); + renderIcon( upToDate ); + renderCells( artifact.getGroupId(), artifact.getArtifactId() ); + renderBoldCell( upToDate, artifact.getVersion() ); + renderNewestVersions( details ); + renderIcon( !details.isDependencyUpdateAvailable() ); sink.tableRow_(); } @@ -260,110 +186,24 @@ private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails detai private void renderPluginDetailTable( PluginUpdatesDetails details ) { - // warning: using caches here may break plugin report + // warning: using caches here might break plugin report ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); boolean upToDate = allUpdates == null || allUpdates.length == 0; - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.otherUpdatesAvailable" ) ); - } - else if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.incrementalUpdatesAvailable" ) ); - } - else if ( details.getNewestUpdate( of( MINOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.minorUpdatesAvailable" ) ); - } - else if ( details.getNewestUpdate( of( MAJOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.majorUpdatesAvailable" ) ); - } - else - { - renderSuccessIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.noUpdatesAvailable" ) ); - } - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.groupId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( details.getGroupId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.artifactId" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( details.getArtifactId() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( details.getVersion() ); - sink.tableCell_(); - sink.tableRow_(); + + renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); + renderTwoCellsRow( "report.groupId", details.getGroupId() ); + renderTwoCellsRow( "report.artifactId", details.getArtifactId() ); + renderTwoCellsRow( "report.currentVersion", details.getVersion() ); if ( !upToDate ) { - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.updateVersions" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - for ( int i = 0; i < allUpdates.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - String label = getLabel( allUpdates[i], details ); - if ( label != null ) - { - safeBold(); - } - sink.text( allUpdates[i].toString() ); - if ( label != null ) - { - safeBold_(); - sink.nonBreakingSpace(); - safeItalic(); - sink.text( label ); - safeItalic_(); - } - } - sink.tableCell_(); - sink.tableRow_(); + renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); } + sink.tableRows_(); sink.table_(); } -} +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index c68656e6c6..e925ccb204 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -19,31 +19,19 @@ * under the License. */ -import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.util.Set; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.sink.SinkEventAttributes; -import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; import org.codehaus.plexus.i18n.I18N; -import org.codehaus.plexus.util.StringUtils; import static java.util.Optional.empty; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; /** * @since 1.0-beta-1 @@ -120,58 +108,13 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.tableRow(); - sink.tableCell(); - if ( upToDate ) - { - renderSuccessIcon(); - } - else - { - renderWarningIcon(); - } - sink.tableCell_(); - sink.tableCell(); - sink.text( "${" + property.getName() + "}" ); - sink.tableCell_(); - sink.tableCell(); - sink.text( details.getCurrentVersion().toString() ); - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); sink.tableCell(); - if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); - safeBold_(); - } + renderIcon( upToDate ); sink.tableCell_(); - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); - - sink.tableCell(); - if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - safeBold(); - sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); - safeBold_(); - } - sink.tableCell_(); + renderCells( "${" + property.getName() + "}", details.getCurrentVersion() ); + renderNewestVersions( details ); sink.tableRow_(); } @@ -182,207 +125,48 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions de ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); boolean upToDate = allUpdates == null || allUpdates.length == 0; - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.status" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.otherUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.incrementalUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.minorUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) - { - renderWarningIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.majorUpdatesAvailable" ) ); - } - else - { - renderSuccessIcon(); - sink.nonBreakingSpace(); - sink.text( getText( "report.noUpdatesAvailable" ) ); - } - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.property" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( "${" + property.getName() + "}" ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.associations" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - ArtifactAssociation[] associations = details.getAssociations(); - for ( int i = 0; i < associations.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - sink.text( ArtifactUtils.versionlessKey( associations[i].getArtifact() ) ); - } - sink.tableCell_(); - sink.tableRow_(); - - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.currentVersion" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( details.getCurrentVersion().toString() ); - sink.tableCell_(); - sink.tableRow_(); + renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); + renderTwoCellsRow( "report.property", "${" + property.getName() + "}" ); + renderTwoCellsRow( "report.associations", () -> renderAssociations( details ) ); + renderTwoCellsRow( "report.currentVersion", details.getCurrentVersion().toString() ); if ( !upToDate ) { - Set rangeVersions = getVersionsInRange( property, details, allUpdates ); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.updateVersions" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - boolean someNotAllowed = false; - for ( int i = 0; i < allUpdates.length; i++ ) - { - if ( i > 0 ) - { - sink.lineBreak(); - } - boolean allowed = ( rangeVersions.contains( allUpdates[i].toString() ) ); - String label = getLabel( allUpdates[i], details ); - if ( !allowed ) - { - sink.text( "* " ); - someNotAllowed = true; - } - if ( allowed && label != null ) - { - safeBold(); - } - sink.text( allUpdates[i].toString() ); - if ( label != null ) - { - if ( allowed ) - { - safeBold_(); - } - sink.nonBreakingSpace(); - safeItalic(); - sink.text( label ); - safeItalic_(); - } - } - if ( someNotAllowed ) - { - sink.lineBreak(); - sink.lineBreak(); - sink.text( "* " ); - safeItalic(); - sink.text( getText( "report.excludedVersion" ) ); - safeItalic_(); - } - sink.tableCell_(); - sink.tableRow_(); + renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); } - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.versionRange" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( StringUtils.isEmpty( property.getVersion() ) ? "[,)" : property.getVersion() ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.autoLinkDependencies" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isAutoLinkDependencies() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.banSnapshots" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isBanSnapshots() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.searchReactor" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isSearchReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); - sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( "report.preferReactor" ) ); - sink.tableHeaderCell_(); - sink.tableCell( cellAttributes ); - sink.text( property.isPreferReactor() ? getText( "report.yes" ) : getText( "report.no" ) ); - sink.tableCell_(); - sink.tableRow_(); + renderTwoCellsRow( "report.versionRange", details.getCurrentVersion().toString() ); + renderTwoCellsRow( "report.autoLinkDependencies", property.isAutoLinkDependencies() ); + renderTwoCellsRow( "report.banSnapshots", property.isBanSnapshots() ); + renderTwoCellsRow( "report.searchReactor", property.isSearchReactor() ); + renderTwoCellsRow( "report.preferReactor", property.isPreferReactor() ); sink.tableRows_(); sink.table_(); } - @SuppressWarnings( "checkstyle:MethodLength" ) - protected Set getVersionsInRange( Property property, PropertyVersions versions, - ArtifactVersion[] artifactVersions ) + /** + * Renders a row of two cells, the first cell being an header and the second cell being a non-header cell. + * @param textKey the key of the text to be rendered in the header cell. + * @param b a yes/no value to be rendered in the non-header cell. + */ + private void renderTwoCellsRow( String textKey, boolean b ) + { + renderTwoCellsRow( textKey, getText( b ? "report.yes" : "report.no" ) ); + } + + private void renderAssociations( PropertyVersions details ) { - VersionRange range; - Set rangeVersions = new HashSet<>(); - ArtifactVersion[] tmp; - if ( property.getVersion() != null ) + ArtifactAssociation[] associations = details.getAssociations(); + for ( int i = 0; i < associations.length; i++ ) { - try - { - range = VersionRange.createFromVersionSpec( property.getVersion() ); - tmp = versions.getAllUpdates( range ); - } - catch ( InvalidVersionSpecificationException e ) + if ( i > 0 ) { - tmp = artifactVersions; + sink.lineBreak(); } + sink.text( ArtifactUtils.versionlessKey( associations[i].getArtifact() ) ); } - else - { - tmp = artifactVersions; - } - for ( ArtifactVersion artifactVersion : tmp ) - { - rangeVersions.add( artifactVersion.toString() ); - } - return rangeVersions; } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java index 589cfa8a80..82472b4eec 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -20,6 +20,7 @@ * under the License. */ +import java.util.Arrays; import java.util.Locale; import org.apache.maven.artifact.versioning.ArtifactVersion; @@ -142,4 +143,86 @@ protected void safeItalic_() } } + /** + * Renders a table header containing elements denoted by the given keys + * @param keys variable argument list containing keys of the property file to retrieve the + * headers from + */ + protected void renderTableHeaderCells( String... keys ) + { + Arrays.stream( keys ) + .map( this::getText ) + .forEachOrdered( str -> + { + sink.tableHeaderCell(); + sink.text( str ); + sink.tableHeaderCell_(); + } ); + } + + /** + * Renders a bold table cell containing the given text. + * @param object the text to be rendered, or null for an empty cell. + */ + protected void renderBoldCell( Object object ) + { + renderBoldCell( true, object ); + } + /** + * Renders a table cell containing the given text. + * @param object the text to be rendered, or null for an empty cell. + */ + protected void renderCell( Object object ) + { + renderBoldCell( false, object ); + } + /** + * Renders multiple cells containing the given texts. + * @param objects the texts to be rendered, null for empty cells. + */ + protected void renderCells( Object... objects ) + { + for ( Object object : objects ) + { + renderBoldCell( false, object ); + } + } + + /** + * Renders a bold table cell containing the given text. + * @param bold true to render the cell in bold, false otherwise. + * @param object the text to be rendered, or null for an empty cell. + */ + protected void renderBoldCell( boolean bold, Object object ) + { + sink.tableCell(); + renderBoldText( bold, object ); + sink.tableCell_(); + } + + /** + * Renders a bold text. + * @param bold true to render the text in bold, false otherwise. + * @param object the text to be rendered, or null for an empty cell. + */ + protected void renderBoldText( boolean bold, Object object ) + { + if ( object != null ) + { + String text = object.toString(); + if ( !text.isEmpty() ) + { + if ( bold ) + { + safeBold(); + } + sink.text( text ); + if ( bold ) + { + safeBold_(); + } + } + } + } + } diff --git a/versions-maven-plugin/src/main/resources/dependency-updates-report.properties b/versions-maven-plugin/src/main/resources/dependency-updates-report.properties index 9b8626d4a1..fb4a6e44b0 100644 --- a/versions-maven-plugin/src/main/resources/dependency-updates-report.properties +++ b/versions-maven-plugin/src/main/resources/dependency-updates-report.properties @@ -53,3 +53,4 @@ report.minorUpdatesAvailable=There is at least one newer minor version available Minor updates are sometimes passive. report.majorUpdatesAvailable=There is at least one newer major version available. \ Major updates are rarely passive. +report.excludedVersion=Outside allowed version range From d05e5cf3f5f620fef8beb817882da39c8b8e6592 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Wed, 23 Nov 2022 09:34:27 +0100 Subject: [PATCH 218/441] display versions outside range with star --- .../versions/api/AbstractVersionDetails.java | 115 ++++++++++++++++++ .../invoker.properties | 2 + .../it-823-ranges-update-report-001/pom.xml | 22 ++++ .../verify.groovy | 26 ++++ .../invoker.properties | 2 + .../it-823-ranges-update-report-002/pom.xml | 22 ++++ .../verify.groovy | 26 ++++ .../AbstractVersionsReportRenderer.java | 18 ++- .../PluginUpdatesReportRenderer.java | 8 +- .../PropertyUpdatesReportRenderer.java | 1 - 10 files changed, 233 insertions(+), 9 deletions(-) create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-001/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-001/pom.xml create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-002/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-002/pom.xml create mode 100644 versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index c16506c894..13e8966c88 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -20,11 +20,19 @@ */ import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.Objects; import java.util.Optional; +import java.util.TreeSet; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; import org.codehaus.mojo.versions.ordering.BoundArtifactVersion; @@ -47,6 +55,10 @@ public abstract class AbstractVersionDetails implements VersionDetails { + private static final Pattern PREVIEW_PATTERN = + Pattern.compile( "(?i)(?:.*[-.](alpha|a|beta|b|milestone|m|preview|rc)" + + "[-.]?(\\d{0,2}[a-z]?|\\d{6}\\.\\d{4})|\\d{8}(?:\\.?\\d{6})?)$" ); + /** * The current version. Guarded by {@link #currentVersionLock}. * @@ -61,6 +73,8 @@ public abstract class AbstractVersionDetails */ private boolean includeSnapshots = false; + protected boolean verboseDetail = true; + /** * Not sure if we need to be thread safe, but there's no harm being careful, after all we could be invoked from an * IDE. @@ -77,6 +91,24 @@ protected AbstractVersionDetails() public Restriction restrictionFor( Optional scope ) throws InvalidSegmentException { + // one range spec can have multiple restrictions, and multiple 'lower bound', we want the highest one. + // [1.0,2.0),[3.0,4.0) -> 3.0 + ArtifactVersion highestLowerBound = currentVersion; + if ( currentVersion != null ) + { + try + { + highestLowerBound = VersionRange.createFromVersionSpec( currentVersion.toString() ) + .getRestrictions().stream().map( Restriction::getLowerBound ).filter( Objects::nonNull ) + .max( getVersionComparator() ).orElse( currentVersion ); + } + catch ( InvalidVersionSpecificationException ignored ) + { + ignored.printStackTrace( System.err ); + } + } + + final ArtifactVersion currentVersion = highestLowerBound; ArtifactVersion nextVersion = scope .filter( s -> s.isMajorTo( SUBINCREMENTAL ) ) .map( s -> (ArtifactVersion) @@ -480,4 +512,87 @@ public boolean isVersionInRestriction( Restriction restriction, ArtifactVersion } return ( includeLower || lower != 0 ) && ( includeUpper || upper != 0 ); } + + /** + * Returns the latest version newer than the specified current version, and within the specified update scope, + * or null if no such version exists. + * @param updateScope the scope of updates to include. + * @return the newest version after currentVersion within the specified update scope, + * or null if no version is available. + */ + public final ArtifactVersion getReportNewestUpdate( Optional updateScope ) + { + return getArtifactVersionStream( updateScope ) + .min( Collections.reverseOrder( getVersionComparator() ) ).orElse( null ); + } + + /** + * Returns all versions newer than the specified current version, and within the specified update scope. + * @param updateScope the scope of updates to include. + * @return all versions after currentVersion within the specified update scope. + */ + public final ArtifactVersion[] getReportUpdates( Optional updateScope ) + { + TreeSet versions = getArtifactVersionStream( updateScope ) + .collect( Collectors.toCollection( () -> new TreeSet<>( getVersionComparator() ) ) ); + // filter out intermediate minor versions. + if ( !verboseDetail ) + { + int major = 0; + int minor = 0; + boolean needOneMore = false; + for ( Iterator it = versions.descendingIterator(); it.hasNext(); ) + { + ArtifactVersion version = it.next(); + boolean isPreview = PREVIEW_PATTERN.matcher( version.toString() ).matches(); + + // encountered a version in same Major.Minor version, remove it. + if ( version.getMajorVersion() == major && version.getMinorVersion() == minor ) + { + if ( needOneMore && !isPreview ) + { + needOneMore = false; + continue; + } + it.remove(); + continue; + } + + // encountered a new Major.Minor version, keep it. + major = version.getMajorVersion(); + minor = version.getMinorVersion(); + + // if version is a pre-release, also search for the last release. + needOneMore = isPreview; + + } + } + return versions.toArray( new ArtifactVersion[0] ); + } + + /** + * Returns all versions newer than the specified current version, and within the specified update scope. + * @param updateScope the scope of updates to include. + * @return all versions after currentVersion within the specified update scope. + */ + private Stream getArtifactVersionStream( Optional updateScope ) + { + if ( isCurrentVersionDefined() ) + { + try + { + Restriction restriction = restrictionFor( updateScope ); + + return Arrays.stream( getVersions() ).filter( + candidate -> ( isIncludeSnapshots() || !ArtifactUtils.isSnapshot( candidate.toString() ) ) + && isVersionInRestriction( restriction, candidate ) ); + } + catch ( InvalidSegmentException ignored ) + { + ignored.printStackTrace( System.err ); + } + } + return Stream.empty(); + } + } diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-001/invoker.properties b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/invoker.properties new file mode 100644 index 0000000000..53663b3aa4 --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:property-updates-report +invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-001/pom.xml b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/pom.xml new file mode 100644 index 0000000000..1d60d77461 --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + localhost + it-823-ranges-update-report + 1.0 + pom + ranges-update-report + http://localhost/ + + + [1.1.2,3.0] + + + + localhost + dummy-api + ${verion.dummy-api} + + + + diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy new file mode 100644 index 0000000000..4c558ea25a --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy @@ -0,0 +1,26 @@ + +propertyUpdatesReport = new File( basedir, "target/site/property-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +assert ! ( propertyUpdatesReport =~ /\b1\.1\.0-2\b/ ) +assert ! ( propertyUpdatesReport =~ /\b1\.1\.1-2\b/ ) +// Summary +assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\] 1\.1\.3 1\.3 3/ +// Detail +assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ +assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 3\.0\b/ + +dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +assert ! ( dependencyUpdatesReport =~ /\b1\.1\.0-2\b/ ) +assert ! ( dependencyUpdatesReport =~ /\b1\.1\.1-2\b/ ) +// Summary +assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\] 1\.1\.3 1\.3 3/ +// Detail +assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ +assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 3\.0\b/ diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-002/invoker.properties b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/invoker.properties new file mode 100644 index 0000000000..53663b3aa4 --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals.1=${project.groupId}:${project.artifactId}:${project.version}:property-updates-report +invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:dependency-updates-report diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-002/pom.xml b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/pom.xml new file mode 100644 index 0000000000..7078a1dbcc --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + localhost + it-823-ranges-update-report + 1.0 + pom + ranges-update-report + http://localhost/ + + + [1.1.2,3.0) + + + + localhost + dummy-api + ${verion.dummy-api} + + + + diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy new file mode 100644 index 0000000000..c0bf5442e3 --- /dev/null +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy @@ -0,0 +1,26 @@ + +propertyUpdatesReport = new File( basedir, "target/site/property-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +assert ! ( propertyUpdatesReport =~ /\b1\.1\.0-2\b/ ) +assert ! ( propertyUpdatesReport =~ /\b1\.1\.1-2\b/ ) +// Summary +assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\) 1\.1\.3 1\.3 3/ +// Detail +assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ +assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 \* 3\.0\b/ + +dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +assert ! ( dependencyUpdatesReport =~ /\b1\.1\.0-2\b/ ) +assert ! ( dependencyUpdatesReport =~ /\b1\.1\.1-2\b/ ) +// Summary +assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\) 1\.1\.3 1\.3 3/ +// Detail +assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ +assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 \* 3\.0\b/ diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 95f370835f..0b5117d9f3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -62,11 +62,11 @@ public abstract class AbstractVersionsReportRenderer extends VersionsReportRe */ protected T model; - protected ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); + protected final ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getReportNewestUpdate ); - protected ArtifactVersionsCache allUpdatesCache - = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); + protected final ArtifactVersionsCache allUpdatesCache + = new ArtifactVersionsCache( AbstractVersionDetails::getReportUpdates ); protected final SinkEventAttributes headerAttributes = new SinkEventAttributeSet( SinkEventAttributes.WIDTH, "30%" ); @@ -231,6 +231,7 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, boolean includeScope ) { + details.setCurrentVersion( artifact.getVersion() ); ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); boolean upToDate = allUpdates == null || allUpdates.length == 0; @@ -263,7 +264,6 @@ protected void renderNewestVersions( AbstractVersionDetails details ) renderBoldCell( newestUpdateCache.get( details, of( MAJOR ) ) ); } - @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope ) { ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); @@ -363,6 +363,12 @@ else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) } } + /** + * Builds the list of restrictions for the given artifact or property, based on its version range. + * used to determine if a candidate version is outside the range, and if it should be displayed with a star. + * @param details the artifact or property for which to render the versions. + * @return the list of restrictions for the spec versions range. + */ private List getArtifactVersionRange( AbstractVersionDetails details ) { try @@ -381,7 +387,7 @@ private List getArtifactVersionRange( AbstractVersionDetails detail /** * Renders the list of versions that are available for the given artifact or property. * @param allUpdates the list of all updates available. - * @param details TODO. + * @param details the versions details for the given artifact or property. */ protected void renderVersions( ArtifactVersion[] allUpdates, AbstractVersionDetails details ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index bf2fd24de8..bd0e3c2b24 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -145,18 +145,22 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails boolean upToDate = !details.isUpdateAvailable(); sink.tableRow(); - sink.tableCell(); + sink.tableCell(); renderIcon( upToDate ); + sink.tableCell_(); + renderCells( artifact.getGroupId(), artifact.getArtifactId() ); renderBoldCell( upToDate, artifact.getVersion() ); renderNewestVersions( details ); + + sink.tableCell(); renderIcon( !details.isDependencyUpdateAvailable() ); + sink.tableCell_(); sink.tableRow_(); } - @SuppressWarnings( "checkstyle:MethodLength" ) private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails details ) { sink.section2(); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index e925ccb204..8b79da27b1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -119,7 +119,6 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions sink.tableRow_(); } - @SuppressWarnings( "checkstyle:MethodLength" ) protected void renderPropertyDetailTable( Property property, PropertyVersions details ) { ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); From d420a62a68a50227e902b41d11d662161e3377d8 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 24 Nov 2022 18:34:53 +0100 Subject: [PATCH 219/441] #704: Removing ArtifactResolver --- .../versions/api/DefaultVersionsHelper.java | 76 ++++++------------- .../mojo/versions/api/VersionsHelper.java | 6 +- .../api/DefaultVersionsHelperTest.java | 8 -- .../enforcer/MaxDependencyUpdates.java | 6 -- ...AbstractVersionsDependencyUpdaterMojo.java | 5 +- .../versions/AbstractVersionsDisplayMojo.java | 5 +- .../mojo/versions/AbstractVersionsReport.java | 15 ---- .../versions/AbstractVersionsUpdaterMojo.java | 43 +---------- .../versions/CompareDependenciesMojo.java | 9 +-- .../versions/DependencyUpdatesReportMojo.java | 4 +- .../DisplayDependencyUpdatesMojo.java | 5 +- .../versions/DisplayParentUpdatesMojo.java | 5 +- .../versions/DisplayPluginUpdatesMojo.java | 13 ++-- .../versions/DisplayPropertyUpdatesMojo.java | 5 +- .../mojo/versions/ForceReleasesMojo.java | 9 +-- .../mojo/versions/LockSnapshotsMojo.java | 16 ++-- .../versions/ParentUpdatesReportMojo.java | 4 +- .../versions/PluginUpdatesReportMojo.java | 4 +- .../versions/PropertyUpdatesReportMojo.java | 4 +- .../mojo/versions/ResolveRangesMojo.java | 5 +- .../org/codehaus/mojo/versions/SetMojo.java | 10 +-- .../mojo/versions/SetPropertyMojo.java | 11 +-- .../codehaus/mojo/versions/SetScmTagMojo.java | 5 +- .../mojo/versions/UnlockSnapshotsMojo.java | 5 +- .../mojo/versions/UpdateChildModulesMojo.java | 5 +- .../mojo/versions/UpdateParentMojo.java | 5 +- .../mojo/versions/UpdatePropertiesMojo.java | 5 +- .../mojo/versions/UpdatePropertyMojo.java | 5 +- .../mojo/versions/UseDepVersionMojo.java | 5 +- .../mojo/versions/UseLatestReleasesMojo.java | 5 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 5 +- .../mojo/versions/UseLatestVersionsMojo.java | 7 +- .../versions/UseLatestVersionsMojoBase.java | 5 +- .../mojo/versions/UseNextReleasesMojo.java | 9 +-- .../mojo/versions/UseNextSnapshotsMojo.java | 5 +- .../mojo/versions/UseNextVersionsMojo.java | 9 +-- .../mojo/versions/UseReactorMojo.java | 5 +- .../mojo/versions/UseReleasesMojo.java | 5 +- .../DependencyUpdatesReportMojoTest.java | 2 +- .../DisplayDependencyUpdatesMojoTest.java | 7 -- .../mojo/versions/ForceReleasesMojoTest.java | 7 +- .../versions/ParentUpdatesReportMojoTest.java | 2 +- .../versions/PluginUpdatesReportMojoTest.java | 2 +- ...ratePatternsForIncludesAnExcludesTest.java | 2 +- .../codehaus/mojo/versions/SetMojoTest.java | 13 ++-- .../mojo/versions/UpdateParentMojoTest.java | 3 +- .../UpdatePropertiesMojoTestBase.java | 2 - .../versions/UseLatestReleasesMojoTest.java | 1 - .../versions/UseLatestVersionsMojoTest.java | 1 - .../mojo/versions/UseReleasesMojoTest.java | 3 - .../mojo/versions/utils/MockUtils.java | 33 ++++++-- 51 files changed, 129 insertions(+), 307 deletions(-) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 9ef7215ece..c948b7d635 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -47,14 +47,10 @@ import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.execution.MavenSession; @@ -89,9 +85,13 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.VersionRangeRequest; import org.eclipse.aether.resolution.VersionRangeResolutionException; +import static org.apache.maven.RepositoryUtils.toArtifact; + /** * Helper class that provides common functionality required by both the mojos and the reports. * @@ -116,13 +116,6 @@ public class DefaultVersionsHelper */ private RuleSet ruleSet; - /** - * The local repository to consult. - * - * @since 1.0-alpha-3 - */ - private ArtifactRepository localRepository; - private RepositorySystem repositorySystem; private org.eclipse.aether.RepositorySystem aetherRepositorySystem; @@ -141,13 +134,6 @@ public class DefaultVersionsHelper */ private MavenSession mavenSession; - /** - * The artifact resolver. - * - * @since 1.3 - */ - private ArtifactResolver artifactResolver; - private MojoExecution mojoExecution; /** @@ -383,7 +369,7 @@ public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePl return new ArtifactVersions( artifact, aetherRepositorySystem.resolveVersionRange( mavenSession.getRepositorySession(), new VersionRangeRequest( - RepositoryUtils.toArtifact( artifact ).setVersion( "(,)" ), + toArtifact( artifact ).setVersion( "(,)" ), usePluginRepositories ? mavenSession.getCurrentProject().getRemotePluginRepositories() : mavenSession.getCurrentProject().getRemoteProjectRepositories(), @@ -479,13 +465,24 @@ private List getIgnoredVersions( Artifact artifact ) @Override public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactResolutionException, ArtifactNotFoundException + throws ArtifactResolutionException { - artifactResolver.resolve( artifact, - usePluginRepositories - ? mavenSession.getCurrentProject().getPluginArtifactRepositories() - : mavenSession.getCurrentProject().getRemoteArtifactRepositories(), - localRepository ); + try + { + ArtifactResult artifactResult = aetherRepositorySystem.resolveArtifact( mavenSession.getRepositorySession(), + new ArtifactRequest( toArtifact( artifact ), + usePluginRepositories + ? mavenSession.getCurrentProject().getRemotePluginRepositories() + : mavenSession.getCurrentProject().getRemoteProjectRepositories(), + getClass().getName() ) ); + artifact.setFile( artifactResult.getArtifact().getFile() ); + artifact.setVersion( artifactResult.getArtifact().getVersion() ); + artifact.setResolved( artifactResult.isResolved() ); + } + catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) + { + throw new ArtifactResolutionException( e.getMessage(), artifact ); + } } @Override @@ -864,12 +861,9 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr public static class Builder { private RepositorySystem repositorySystem; - private ArtifactResolver artifactResolver; - private ArtifactRepository localRepository; private Collection ignoredVersions; private RuleSet ruleSet; private WagonManager wagonManager; - private Settings settings; private String serverId; private String rulesUri; private Log log; @@ -887,18 +881,6 @@ public Builder withRepositorySystem( RepositorySystem repositorySystem ) return this; } - public Builder withArtifactResolver( ArtifactResolver artifactResolver ) - { - this.artifactResolver = artifactResolver; - return this; - } - - public Builder withLocalRepository( ArtifactRepository localRepository ) - { - this.localRepository = localRepository; - return this; - } - public Builder withIgnoredVersions( Collection ignoredVersions ) { this.ignoredVersions = ignoredVersions; @@ -917,12 +899,6 @@ public Builder withWagonManager( WagonManager wagonManager ) return this; } - public Builder withSettings( Settings settings ) - { - this.settings = settings; - return this; - } - public Builder withServerId( String serverId ) { this.serverId = serverId; @@ -968,7 +944,6 @@ public DefaultVersionsHelper build() throws MojoExecutionException { DefaultVersionsHelper instance = new DefaultVersionsHelper(); instance.repositorySystem = repositorySystem; - instance.artifactResolver = artifactResolver; instance.mavenSession = mavenSession; instance.mojoExecution = mojoExecution; if ( ruleSet != null ) @@ -984,16 +959,15 @@ public DefaultVersionsHelper build() throws MojoExecutionException instance.ruleSet = isBlank( rulesUri ) ? new RuleSet() : isClasspathUri( rulesUri ) - ? getRulesFromClasspath( rulesUri, log ) - : getRulesViaWagon( rulesUri, log, serverId, serverId, wagonManager, - settings ); + ? getRulesFromClasspath( rulesUri, log ) + : getRulesViaWagon( rulesUri, log, serverId, serverId, wagonManager, + mavenSession.getSettings() ); } if ( ignoredVersions != null && !ignoredVersions.isEmpty() ) { instance.ruleSet = enrichRuleSet( ignoredVersions, instance.ruleSet ); } instance.aetherRepositorySystem = aetherRepositorySystem; - instance.localRepository = localRepository; instance.log = log; return instance; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 729aef0889..4f56849e91 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -25,7 +25,6 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; @@ -408,10 +407,9 @@ public VersionPropertiesMapRequest build() * * @param artifact The artifact to resolve. * @param usePluginRepositories whether to resolve from the plugin repositories or the regular repositories. - * @throws ArtifactResolutionException if something goes wrong. - * @throws ArtifactNotFoundException if something goes wrong. + * @throws ArtifactResolutionException if resolution is unsuccessful * @since 1.3 */ void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactResolutionException, ArtifactNotFoundException; + throws ArtifactResolutionException; } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index b442516370..a4ece27ace 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -28,9 +28,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.DefaultArtifactRepository; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; @@ -41,7 +38,6 @@ import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; @@ -234,12 +230,8 @@ private DefaultVersionsHelper createHelper( org.eclipse.aether.RepositorySystem .thenReturn( emptyList() ); return new DefaultVersionsHelper.Builder() .withRepositorySystem( lookup( RepositorySystem.class ) ) - .withArtifactResolver( new DefaultArtifactResolver() ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withLocalRepository( new DefaultArtifactRepository( - "", "", new DefaultRepositoryLayout() ) ) .withWagonManager( lookup( WagonManager.class ) ) - .withSettings( new Settings() ) .withServerId( "" ) .withRulesUri( rulesUri ) .withLog( mock( Log.class ) ) diff --git a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java index 3806386d96..58ea699d1e 100644 --- a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java +++ b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java @@ -26,8 +26,6 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.enforcer.rule.api.EnforcerLevel; import org.apache.maven.enforcer.rule.api.EnforcerRule; @@ -40,7 +38,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.Segment; @@ -278,11 +275,8 @@ private static VersionsHelper createVersionsHelper( EnforcerRuleHelper ruleHelpe { return new DefaultVersionsHelper.Builder() .withRepositorySystem( ruleHelper.getComponent( RepositorySystem.class ) ) - .withArtifactResolver( ruleHelper.getComponent( ArtifactResolver.class ) ) .withAetherRepositorySystem( ruleHelper.getComponent( org.eclipse.aether.RepositorySystem.class ) ) - .withLocalRepository( (ArtifactRepository) ruleHelper.evaluate( "${localRepository}" ) ) .withWagonManager( ruleHelper.getComponent( WagonManager.class ) ) - .withSettings( (Settings) ruleHelper.evaluate( "${settings}" ) ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 5bee054503..3bf069a9c6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; @@ -162,11 +161,9 @@ protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySyst org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 98a6779361..12497c2409 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -31,7 +31,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; @@ -89,11 +88,9 @@ protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } @SuppressWarnings( "unchecked" ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index 45e0b1654f..ab236f9059 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -27,7 +27,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.doxia.sink.Sink; @@ -40,7 +39,6 @@ import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -98,12 +96,6 @@ public abstract class AbstractVersionsReport */ private final WagonManager wagonManager; - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${settings}", readonly = true ) - private Settings settings; - /** * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. * @@ -156,8 +148,6 @@ public abstract class AbstractVersionsReport @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) private MojoExecution mojoExecution; - protected ArtifactResolver artifactResolver; - /** *

    Allows specifying the {@linkplain RuleSet} object describing rules * on artifact versions to ignore when considering updates.

    @@ -196,14 +186,12 @@ public abstract class AbstractVersionsReport protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - ArtifactResolver artifactResolver, WagonManager wagonManager, ReportRendererFactory rendererFactory ) { this.i18n = i18n; this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; - this.artifactResolver = artifactResolver; this.wagonManager = wagonManager; this.rendererFactory = rendererFactory; } @@ -217,11 +205,8 @@ public VersionsHelper getHelper() { helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) - .withArtifactResolver( artifactResolver ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withLocalRepository( localRepository ) .withWagonManager( wagonManager ) - .withSettings( settings ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 4b69512ba5..f878b562d2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -33,10 +33,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -49,7 +46,6 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.PomHelper; @@ -110,35 +106,11 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) protected List reactorProjects; - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true ) - protected List remoteArtifactRepositories; - - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true ) - protected List remotePluginRepositories; - - /** - * @since 1.0-alpha-1 - */ - @Parameter( defaultValue = "${localRepository}", readonly = true ) - protected ArtifactRepository localRepository; - /** * The (injected) {@link WagonManager} instance. */ private final WagonManager wagonManager; - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${settings}", readonly = true ) - protected Settings settings; - /** * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. * @@ -189,7 +161,6 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) private MojoExecution mojoExecution; - protected ArtifactResolver artifactResolver; /** * The format used to record changes. If "none" is specified, no changes are recorded. * @@ -245,14 +216,12 @@ protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; this.projectBuilder = projectBuilder; this.wagonManager = wagonManager; - this.artifactResolver = artifactResolver; this.changeRecorders = changeRecorders; } @@ -262,11 +231,8 @@ public VersionsHelper getHelper() throws MojoExecutionException { helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) - .withArtifactResolver( artifactResolver ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withLocalRepository( localRepository ) .withWagonManager( wagonManager ) - .withSettings( settings ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) @@ -522,18 +488,13 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A artifact.setVersion( updateVersion.toString() ); try { - artifactResolver.resolveAlways( artifact, remoteArtifactRepositories, localRepository ); + getHelper().resolveArtifact( artifact, false ); } - catch ( ArtifactResolutionException e ) + catch ( ArtifactResolutionException | MojoExecutionException e ) { getLog().warn( "Not updating version: could not resolve " + artifact, e ); return false; } - catch ( ArtifactNotFoundException e ) - { - getLog().warn( "Not updating version: could not find " + artifact, e ); - return false; - } if ( currentVersion.equals( updateVersion.toString() ) ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index a955c8555b..06ffe7f528 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -33,7 +33,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -130,12 +129,10 @@ public CompareDependenciesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, MavenProjectBuilder mavenProjectBuilder, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); this.mavenProjectBuilder = mavenProjectBuilder; } @@ -177,7 +174,9 @@ protected void update( ModifiedPomXMLEventReader pom ) try { remoteMavenProject = - mavenProjectBuilder.buildFromRepository( remoteArtifact, remoteArtifactRepositories, localRepository ); + mavenProjectBuilder.buildFromRepository( remoteArtifact, + session.getCurrentProject().getRemoteArtifactRepositories(), + session.getLocalRepository() ); } catch ( ProjectBuildingException e ) { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index fb6fe624b5..55a9f23dec 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -33,7 +33,6 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; @@ -112,11 +111,10 @@ public class DependencyUpdatesReportMojo extends AbstractVersionsReport changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } // open for tests diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index a932c5aa28..0f76921d53 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -25,7 +25,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -57,11 +56,9 @@ public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 41840c2785..7818b310a8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -174,8 +174,7 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, RuntimeInformation runtimeInformation, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; this.pluginManager = pluginManager; @@ -460,7 +459,8 @@ public void execute() { getHelper().resolveArtifact( probe, true ); MavenProject pluginMavenProject = - projectBuilder.buildFromRepository( probe, remotePluginRepositories, localRepository ); + projectBuilder.buildFromRepository( probe, session.getCurrentProject() + .getRemoteArtifactRepositories(), session.getLocalRepository() ); ArtifactVersion pluginRequires = getPrerequisitesMavenVersion( pluginMavenProject ); if ( artifactVersion == null && compare( specMavenVersion, pluginRequires ) >= 0 ) { @@ -506,7 +506,7 @@ public void execute() minRequires = pluginRequires; } } - catch ( ArtifactResolutionException | ArtifactNotFoundException | ProjectBuildingException e ) + catch ( ArtifactResolutionException | ProjectBuildingException e ) { // ignore bad version } @@ -524,14 +524,15 @@ public void execute() { getHelper().resolveArtifact( probe, true ); MavenProject mavenProject = - projectBuilder.buildFromRepository( probe, remotePluginRepositories, localRepository ); + projectBuilder.buildFromRepository( probe, getProject().getRemoteArtifactRepositories(), + session.getLocalRepository() ); ArtifactVersion requires = getPrerequisitesMavenVersion( mavenProject ); if ( minMavenVersion == null || compare( minMavenVersion, requires ) < 0 ) { minMavenVersion = requires; } } - catch ( ArtifactResolutionException | ArtifactNotFoundException | ProjectBuildingException e ) + catch ( ArtifactResolutionException | ProjectBuildingException e ) { // ignore bad version } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 7bf8d69256..d555b87a31 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -28,7 +28,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -145,11 +144,9 @@ public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } public void execute() diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 256c979469..1b7bae0a93 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -29,7 +29,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -41,10 +40,10 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; -import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -74,11 +73,9 @@ public ForceReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 735c43244e..41c860f034 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -28,9 +28,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -42,6 +42,7 @@ import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; +import org.eclipse.aether.resolution.ArtifactRequest; /** * Attempts to resolve unlocked snapshot dependency versions to the locked timestamp versions used in the build. For @@ -71,11 +72,9 @@ public LockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** @@ -200,7 +199,9 @@ private String resolveSnapshotVersion( Artifact artifact ) try { - artifactResolver.resolve( artifact, getProject().getRemoteArtifactRepositories(), localRepository ); + aetherRepositorySystem.resolveArtifact( session.getRepositorySession(), + new ArtifactRequest( RepositoryUtils.toArtifact( artifact ), + getProject().getRemoteProjectRepositories(), getClass().getName() ) ); lockedVersion = artifact.getVersion(); } @@ -226,7 +227,10 @@ private String resolveSnapshotVersion( Dependency dep ) try { Artifact depArtifact = getHelper().createDependencyArtifact( dep ); - artifactResolver.resolve( depArtifact, getProject().getRemoteArtifactRepositories(), localRepository ); + aetherRepositorySystem.resolveArtifact( session.getRepositorySession(), + new ArtifactRequest( RepositoryUtils.toArtifact( depArtifact ), + getProject().getRemoteProjectRepositories(), + getClass().getName() ) ); lockedVersion = depArtifact.getVersion(); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index 83bb2ab4b5..f6b768fe69 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -25,7 +25,6 @@ import java.util.Locale; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -57,11 +56,10 @@ public class ParentUpdatesReportMojo extends AbstractVersionsReport changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 4924289303..f8b7785423 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -42,7 +42,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; @@ -250,12 +249,10 @@ public SetMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders, Prompter prompter ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); this.prompter = prompter; } @@ -310,7 +307,7 @@ public void execute() throws MojoExecutionException, MojoFailureException getLog().info( "removeSnapshot enabled whilst the version is not a snapshot: nothing to do." ); return; } - if ( settings.isInteractiveMode() ) + if ( session.getSettings().isInteractiveMode() ) { try { @@ -340,7 +337,8 @@ public void execute() throws MojoExecutionException, MojoFailureException try { final MavenProject project = processFromLocalAggregationRoot - ? PomHelper.getLocalRoot( projectBuilder, getProject(), localRepository, null, getLog() ) + ? PomHelper.getLocalRoot( projectBuilder, getProject(), session.getLocalRepository(), + null, getLog() ) : getProject(); getLog().info( "Local aggregation root: " + project.getBasedir() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 6abca80b7c..f72ad64f70 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -27,7 +27,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -92,14 +91,12 @@ public class SetPropertyMojo @Inject public SetPropertyMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, - WagonManager wagonManager, - ArtifactResolver artifactResolver, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + MavenProjectBuilder projectBuilder, + WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 777ec9287e..2e73f3dfab 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -9,7 +9,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -71,11 +70,9 @@ public SetScmTagMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index e3c18336ba..a454db574c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -72,11 +71,9 @@ public UnlockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index 0cd87fa827..254db5431d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; @@ -74,11 +73,9 @@ public UpdateChildModulesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 1dac708177..4325f60b09 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -143,11 +142,9 @@ public UpdateParentMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index a5c5d8a094..c04e82d65f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -26,7 +26,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -144,11 +143,9 @@ public UpdatePropertiesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index abef1cf509..21bb0009d4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -26,7 +26,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -143,11 +142,9 @@ public UpdatePropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index c895e14680..2f36f1247f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -28,7 +28,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -78,11 +77,9 @@ public UseDepVersionMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index f0f8d9a2aa..8ee9f69c9f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -107,11 +106,9 @@ public UseLatestReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 96f183b654..92a9be4f9e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -30,7 +30,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -96,11 +95,9 @@ public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index d7d018d906..6a1601d347 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -28,7 +28,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -39,9 +38,9 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.ordering.InvalidSegmentException; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.SegmentUtils; @@ -104,11 +103,9 @@ public UseLatestVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index da94696cd4..dc0ec16a8e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -30,7 +30,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; @@ -54,11 +53,9 @@ public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 64ab6c8b5e..ab700bb25d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -28,7 +28,6 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -36,10 +35,10 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; -import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -70,11 +69,9 @@ public UseNextReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index ced9081288..bded43e366 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -29,7 +29,6 @@ import java.util.Optional; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -95,11 +94,9 @@ public UseNextSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 925ca661c6..7694c5a1ad 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -27,7 +27,6 @@ import java.util.Map; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -35,10 +34,10 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; -import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import static java.util.Collections.singletonList; @@ -62,11 +61,9 @@ public UseNextVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index f583ce2287..c0233e4cff 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -29,7 +29,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -61,11 +60,9 @@ public UseReactorMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index e1a69d156e..6fb108e97f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -31,7 +31,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -88,11 +87,9 @@ public UseReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, MavenProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, artifactResolver, - changeRecorders ); + super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index 4443242d70..81d7f92e51 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -69,7 +69,7 @@ private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesRe TestDependencyUpdatesReportMojo() { super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), null, - null, new ReportRendererFactoryImpl( MOCK_I18N ) ); + new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index f399589147..c2b70a3932 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -31,9 +31,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.plugin.testing.MojoRule; -import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.filtering.WildcardMatcher; import org.codehaus.mojo.versions.model.TestIgnoreVersions; @@ -165,7 +163,6 @@ public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() }} ), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), null ) {{ setProject( createProject() ); @@ -212,7 +209,6 @@ public void testAllowMajorUpdatesFalse() }} ), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), null ) {{ setProject( createProject() ); @@ -258,7 +254,6 @@ public void testAllowMinorUpdatesFalse() }} ), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), null ) {{ setProject( createProject() ); @@ -305,7 +300,6 @@ public void testAllowIncrementalUpdatesFalse() }} ), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), null ) {{ setProject( createProject() ); @@ -354,7 +348,6 @@ public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() }} ), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), null ) {{ setProject( createProject() ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 0c9d66182c..791ab15895 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -7,8 +7,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -64,10 +62,7 @@ public class ForceReleasesMojoTest extends AbstractMojoTestCase public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new ForceReleasesMojo( mockRepositorySystem(), - mockAetherRepositorySystem(), - null, null, new StubArtifactResolver( new ArtifactStubFactory(), - false, false ), + mojo = new ForceReleasesMojo( mockRepositorySystem(), mockAetherRepositorySystem(), null, null, changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java index 43e8c3046c..449f3d025c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java @@ -63,7 +63,7 @@ public void testAllowSnapshots() throws IOException, MavenReportException mockAetherRepositorySystem( new HashMap() {{ put( "default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"} ); - }} ), null, null, new ReportRendererFactoryImpl( MOCK_I18N ) ) + }} ), null, new ReportRendererFactoryImpl( MOCK_I18N ) ) {{ allowSnapshots = true; project = new MavenProject( new Model() diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java index e799b17afd..2342f299bd 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java @@ -70,7 +70,7 @@ private static class TestPluginUpdatesReportMojo extends PluginUpdatesReportMojo TestPluginUpdatesReportMojo() { super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), - null, null, new ReportRendererFactoryImpl( MOCK_I18N ) ); + null, new ReportRendererFactoryImpl( MOCK_I18N ) ); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index a4a30b8f20..4ebed3b4bf 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -17,7 +17,7 @@ public class SeparatePatternsForIncludesAnExcludesTest public void setUp() throws Exception { - mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null, null ) + mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null ) { @Override protected void update( ModifiedPomXMLEventReader pom ) diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index 3a34edd890..0342773f0e 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -6,7 +6,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.model.Model; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -48,7 +47,7 @@ public void tearDown() throws IOException @Test public void testGetIncrementedVersion() throws MojoExecutionException { - new SetMojo( null, null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null ) { { assertThat( getIncrementedVersion( "1.0.0", null ), is( "1.0.1-SNAPSHOT" ) ); @@ -63,7 +62,7 @@ public void testGetIncrementedVersion() throws MojoExecutionException @Test public void testNextSnapshotIndexLowerBound() { - new SetMojo( null, null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null ) { { try @@ -83,7 +82,7 @@ public void testNextSnapshotIndexLowerBound() @Test public void testNextSnapshotIndexUpperBound() { - new SetMojo( null, null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null ) { { try @@ -105,7 +104,7 @@ public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureExcepti { try { - new SetMojo( null, null, null, null, null, null, null ) + new SetMojo( null, null, null, null, null, null ) { { project = new MavenProject(); @@ -146,9 +145,7 @@ public void testRemoveSnapshotIdempotency() // no exception should be thrown, the file should stay with version "1.0" SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); - MavenExecutionRequest request = - (MavenExecutionRequest) getVariableValueFromObject( secondRun.settings, "request" ); - setVariableValueToObject( request, "interactiveMode", false ); + secondRun.session.getSettings().setInteractiveMode( false ); secondRun.execute(); assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), containsString( "1.0" ) ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 4707286319..b987621633 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -74,10 +74,9 @@ public static void setUpStatic() public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - artifactResolver = mock( ArtifactResolver.class ); mojo = new UpdateParentMojo( repositorySystem, aetherRepositorySystem, null, null, - artifactResolver, changeRecorder.asTestMap() ) + changeRecorder.asTestMap() ) {{ setProject( createProject() ); reactorProjects = Collections.emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java index 4d69cabbf4..ba3b7b8c7a 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java @@ -25,7 +25,6 @@ import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.utils.TestChangeRecorder; import org.junit.After; @@ -75,7 +74,6 @@ public void tearDown() throws Exception protected T setUpMojo( String goal ) throws Exception { T mojo = (T) mojoRule.lookupConfiguredMojo( pomDir.toFile(), goal ); - setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( pomDir.toString() ) ); setVariableValueToObject( mojo, "aetherRepositorySystem", aetherRepositorySystem ); setVariableValueToObject( mojo, "generateBackupPoms", false ); setVariableValueToObject( mojo, "changeRecorderFormat", "test" ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index f2c7d708e1..4dd3cb1cd8 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -63,7 +63,6 @@ public void setUp() throws Exception aetherRepositorySystem, null, null, - null, changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 4152a9019a..f95c8462f4 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -76,7 +76,6 @@ public void setUp() throws Exception aetherRepositorySystem, null, null, - null, changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index 463a00e395..0827bc1c84 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -7,8 +7,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.testing.AbstractMojoTestCase; -import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.apache.maven.plugin.testing.stubs.StubArtifactResolver; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -68,7 +66,6 @@ public void setUp() throws IllegalAccessException mockAetherRepositorySystem(), null, null, - new StubArtifactResolver( new ArtifactStubFactory(), false, false ), changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java index 733344f143..b19b3a2ead 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -1,5 +1,3 @@ -package org.codehaus.mojo.versions.utils; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,6 +17,9 @@ * under the License. */ +package org.codehaus.mojo.versions.utils; + +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -35,6 +36,9 @@ import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.i18n.I18N; import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.VersionRangeRequest; import org.eclipse.aether.resolution.VersionRangeResolutionException; import org.eclipse.aether.resolution.VersionRangeResult; @@ -78,8 +82,8 @@ public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem( Ma org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); try { - when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ).then( - invocation -> + when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) + .then( invocation -> { VersionRangeRequest request = invocation.getArgument( 1 ); return versionMap.entrySet().stream() @@ -91,11 +95,28 @@ public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem( Ma .map( versions -> new VersionRangeResult( request ).setVersions( versions ) ) .orElse( null ); // should tell us if we haven't populated all cases in the test } ); + when( repositorySystem.resolveArtifact( any( RepositorySystemSession.class ), + any( ArtifactRequest.class ) ) ) + .then( invocation -> + { + ArtifactRequest request = invocation.getArgument( 1 ); + org.eclipse.aether.artifact.Artifact copiedArtifact = + new org.eclipse.aether.artifact.DefaultArtifact( + request.getArtifact().getGroupId(), + request.getArtifact().getArtifactId(), + request.getArtifact().getClassifier(), + request.getArtifact().getExtension(), + request.getArtifact().getVersion() ); + copiedArtifact.setFile( mock( File.class ) ); + return new ArtifactResult( request ) + .setArtifact( copiedArtifact ); + } ); } - catch ( VersionRangeResolutionException e ) + catch ( VersionRangeResolutionException | ArtifactResolutionException e ) { throw new RuntimeException( e ); } + return repositorySystem; } @@ -149,8 +170,6 @@ public static MavenSession mockMavenSession() .thenReturn( mock( RepositorySystemSession.class ) ); when( session.getCurrentProject() ).thenReturn( mock( MavenProject.class ) ); when( session.getCurrentProject().getRemotePluginRepositories() ).thenReturn( emptyList() ); - when( session.getCurrentProject().getPluginArtifactRepositories() ).thenReturn( emptyList() ); - when( session.getCurrentProject().getRemoteArtifactRepositories() ).thenReturn( emptyList() ); when( session.getCurrentProject().getRemoteProjectRepositories() ).thenReturn( emptyList() ); return session; } From d67f340d078f3f075ac206689a6987823ff488ba Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 25 Nov 2022 08:31:21 +0100 Subject: [PATCH 220/441] #704: Removing MavenProjectBuilder --- .../codehaus/mojo/versions/api/PomHelper.java | 98 ++++++++++++++++--- ...AbstractVersionsDependencyUpdaterMojo.java | 4 +- .../versions/AbstractVersionsDisplayMojo.java | 4 +- .../versions/AbstractVersionsUpdaterMojo.java | 11 --- .../versions/CompareDependenciesMojo.java | 74 +++++++++----- .../DisplayDependencyUpdatesMojo.java | 4 +- .../versions/DisplayParentUpdatesMojo.java | 4 +- .../versions/DisplayPluginUpdatesMojo.java | 88 ++++++++++------- .../versions/DisplayPropertyUpdatesMojo.java | 4 +- .../mojo/versions/ForceReleasesMojo.java | 4 +- .../mojo/versions/LockSnapshotsMojo.java | 4 +- .../mojo/versions/ResolveRangesMojo.java | 4 +- .../codehaus/mojo/versions/RevertMojo.java | 24 +++-- .../org/codehaus/mojo/versions/SetMojo.java | 17 +++- .../mojo/versions/SetPropertyMojo.java | 4 +- .../codehaus/mojo/versions/SetScmTagMojo.java | 4 +- .../mojo/versions/UnlockSnapshotsMojo.java | 4 +- .../mojo/versions/UpdateChildModulesMojo.java | 4 +- .../mojo/versions/UpdateParentMojo.java | 4 +- .../mojo/versions/UpdatePropertiesMojo.java | 4 +- .../mojo/versions/UpdatePropertyMojo.java | 4 +- .../mojo/versions/UseDepVersionMojo.java | 4 +- .../mojo/versions/UseLatestReleasesMojo.java | 4 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 4 +- .../mojo/versions/UseLatestVersionsMojo.java | 4 +- .../versions/UseLatestVersionsMojoBase.java | 4 +- .../mojo/versions/UseNextReleasesMojo.java | 4 +- .../mojo/versions/UseNextSnapshotsMojo.java | 4 +- .../mojo/versions/UseNextVersionsMojo.java | 4 +- .../mojo/versions/UseReactorMojo.java | 4 +- .../mojo/versions/UseReleasesMojo.java | 4 +- .../DisplayDependencyUpdatesMojoTest.java | 5 - .../mojo/versions/ForceReleasesMojoTest.java | 4 +- ...ratePatternsForIncludesAnExcludesTest.java | 2 +- .../mojo/versions/UpdateParentMojoTest.java | 3 +- .../versions/UseLatestReleasesMojoTest.java | 1 - .../versions/UseLatestVersionsMojoTest.java | 1 - .../mojo/versions/UseReleasesMojoTest.java | 1 - 38 files changed, 245 insertions(+), 184 deletions(-) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index 938ba9ee19..f0fbd59472 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -37,29 +37,35 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; +import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; +import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.UrlModelSource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.profiles.ProfileManager; +import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingRequest; +import org.apache.maven.project.ProjectBuildingResult; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.RegexUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; @@ -1462,37 +1468,43 @@ public static String getGroupId( Model model ) } /** - * Finds the local root of the specified project. + * Finds the local root of the current project of the {@link MavenSession} instance. * - * @param project The project to find the local root for. - * @param builder {@linkplain MavenProjectBuilder} object - * @param localRepository the local repo. - * @param globalProfileManager the global profile manager. + * @param projectBuilder {@link ProjectBuilder} instance + * @param mavenSession {@link MavenSession} instance * @param logger The logger to log tog * @return The local root (note this may be the project passed as an argument). */ - public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project, - ArtifactRepository localRepository, ProfileManager globalProfileManager, + public static MavenProject getLocalRoot( ProjectBuilder projectBuilder, + MavenSession mavenSession, Log logger ) { logger.info( "Searching for local aggregator root..." ); + MavenProject project = mavenSession.getCurrentProject(); while ( true ) { final File parentDir = project.getBasedir().getParentFile(); if ( parentDir != null && parentDir.isDirectory() ) { logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" ); - File parent = new File( parentDir, "pom.xml" ); - if ( parent.isFile() ) + File parentFile = new File( parentDir, "pom.xml" ); + if ( parentFile.isFile() ) { try { - final MavenProject parentProject = - builder.build( parent, localRepository, globalProfileManager ); - if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) ) + ProjectBuildingResult result = projectBuilder.build( parentFile, + createProjectBuilderRequest( mavenSession ) ); + if ( !result.getProblems().isEmpty() ) + { + logger.warn( "Problems encountered during the computation of the local aggregation root." ); + result.getProblems().forEach( p -> + logger.warn( "\t" + p.getMessage() ) ); + } + if ( getAllChildModules( result.getProject(), logger ) + .contains( project.getBasedir().getName() ) ) { logger.debug( parentDir + " is an aggregator parent" ); - project = parentProject; + project = result.getProject(); continue; } else @@ -1511,6 +1523,60 @@ public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProje } } + /** + * Retrieves the standalone superproject + * + * @param projectBuilder {@link ProjectBuilder} instance + * @param mavenSession {@link MavenSession} instance + * @param logger The logger to log tog + * + * @return superproject retrieved + * @throws ProjectBuildingException if the retrieval fails + */ + public static MavenProject getStandaloneSuperProject( ProjectBuilder projectBuilder, + MavenSession mavenSession, + Log logger ) throws ProjectBuildingException + { + ProjectBuildingResult result = projectBuilder.build( new UrlModelSource( + Objects.requireNonNull( PomHelper.class.getResource( "standalone.xml" ) ) ), + createProjectBuilderRequest( mavenSession, r -> r.setProcessPlugins( false ) ) ); + if ( !result.getProblems().isEmpty() ) + { + logger.warn( "Problems encountered during building of the superproject." ); + result.getProblems().forEach( p -> + logger.warn( "\t" + p.getMessage() ) ); + } + return result.getProject(); + } + + /** + *

    Convenience method for creating a {@link ProjectBuildingRequest} instance based on maven session.

    + *

    Note: The method initializes the remote repositories with the remote artifact repositories. + * Please use the initializers if you need to override this.

    + * @param mavenSession {@link MavenSession} instance + * @param initializers optional additional initializers, which will be executed after the object is initialized + * @return constructed builder request + */ + @SafeVarargs + public static ProjectBuildingRequest createProjectBuilderRequest( MavenSession mavenSession, + Consumer... initializers ) + { + return new DefaultProjectBuildingRequest() + {{ + setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); + setResolveDependencies( false ); + setLocalRepository( mavenSession.getLocalRepository() ); + setRemoteRepositories( mavenSession.getCurrentProject().getRemoteArtifactRepositories() ); + setBuildStartTime( mavenSession.getStartTime() ); + setUserProperties( mavenSession.getUserProperties() ); + setSystemProperties( mavenSession.getSystemProperties() ); + setActiveProfileIds( mavenSession.getRequest().getActiveProfiles() ); + setInactiveProfileIds( mavenSession.getRequest().getInactiveProfiles() ); + setRepositorySession( mavenSession.getRepositorySession() ); + Arrays.stream( initializers ).forEach( i -> i.accept( this ) ); + }}; + } + /** * Builds a map of raw models keyed by module path. * diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 3bf069a9c6..8992c28daf 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -38,7 +38,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; @@ -159,11 +158,10 @@ public abstract class AbstractVersionsDependencyUpdaterMojo @Inject protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 12497c2409..0009b74339 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -86,11 +85,10 @@ public abstract class AbstractVersionsDisplayMojo @Inject protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } @SuppressWarnings( "unchecked" ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index f878b562d2..5ce3f508ae 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -44,7 +44,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; @@ -92,14 +91,6 @@ public abstract class AbstractVersionsUpdaterMojo */ protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; - /** - * The (injected) {@link MavenProjectBuilder} instance. - */ - /** - * @since 1.0-alpha-1 - */ - protected final MavenProjectBuilder projectBuilder; - /** * @since 1.0-alpha-1 */ @@ -214,13 +205,11 @@ public abstract class AbstractVersionsUpdaterMojo @Inject protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; - this.projectBuilder = projectBuilder; this.wagonManager = wagonManager; this.changeRecorders = changeRecorders; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 06ffe7f528..537fa9ab91 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -33,14 +33,16 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PomHelper; @@ -118,22 +120,23 @@ public class CompareDependenciesMojo protected File reportOutputFile; /** - * The project builder used to initialize the remote project. + * The (injected) instance of {@link ProjectBuilder} + * + * @since 2.14.0 */ - protected MavenProjectBuilder mavenProjectBuilder; + protected final ProjectBuilder projectBuilder; // ------------------------------ METHODS -------------------------- @Inject public CompareDependenciesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, - MavenProjectBuilder mavenProjectBuilder, + ProjectBuilder projectBuilder, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); - this.mavenProjectBuilder = mavenProjectBuilder; + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + this.projectBuilder = projectBuilder; } /** @@ -157,30 +160,21 @@ protected void update( ModifiedPomXMLEventReader pom ) reportMode = false; } - String[] remotePomParts = this.remotePom.split( ":" ); - if ( remotePomParts.length != 3 ) + String[] remoteGAV = this.remotePom.split( ":" ); + if ( remoteGAV.length != 3 ) { throw new MojoFailureException( " Invalid format for remotePom: " + remotePom ); } - String rGroupId = remotePomParts[0]; - String rArtifactId = remotePomParts[1]; - String rVersion = remotePomParts[2]; - - Artifact remoteArtifact = this.toArtifact( DependencyBuilder.newBuilder() - .withGroupId( rGroupId ) - .withArtifactId( rArtifactId ) - .withVersion( rVersion ).build() ); + MavenProject remoteMavenProject = null; try { - remoteMavenProject = - mavenProjectBuilder.buildFromRepository( remoteArtifact, - session.getCurrentProject().getRemoteArtifactRepositories(), - session.getLocalRepository() ); + remoteMavenProject = getRemoteMavenProject( remoteGAV[0], remoteGAV[1], + remoteGAV[2] ); } - catch ( ProjectBuildingException e ) + catch ( ArtifactResolutionException | ProjectBuildingException e ) { - throw new MojoExecutionException( "Unable to build remote project " + remoteArtifact, e ); + throw new MojoFailureException( e.getMessage() ); } Map remoteDepsMap = new HashMap<>(); @@ -276,6 +270,40 @@ && isProcessingParent() ) } + /** + * Builds a {@link MavenProject} instance for the dependency with a given {@code groupId}, + * {@code artifactId}, and {@code version}. + * @param groupId {@code groupId} of the dependency + * @param artifactId {@code artifactId} of the dependency + * @param version {@code version} of the dependency + * @return retrieved {@link MavenProject} instance for the given dependency + * @throws MojoExecutionException thrown if the artifact for the dependency could not be constructed + * @throws ProjectBuildingException thrown if the {@link MavenProject} instance could not be constructed + */ + private MavenProject getRemoteMavenProject( String groupId, String artifactId, String version ) + throws MojoExecutionException, ArtifactResolutionException, ProjectBuildingException + { + Artifact remoteArtifact = toArtifact( DependencyBuilder.newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ) + .build() ); + ProjectBuildingResult result = + projectBuilder.build( remoteArtifact, true, + PomHelper.createProjectBuilderRequest( session, + r -> r.setProcessPlugins( false ), + r -> r.setRemoteRepositories( session.getCurrentProject() + .getPluginArtifactRepositories() ) ) ); + if ( !result.getProblems().isEmpty() ) + { + getLog().warn( "Problems encountered during construction of the POM for " + + remoteArtifact.toString() ); + result.getProblems().forEach( p -> + getLog().warn( "\t" + p.getMessage() ) ); + } + return result.getProject(); + } + /** * Compare the dependency versions of the current project with the dependency versions of a remote project * diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 06ea66476b..7773890a75 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -37,7 +37,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.Segment; @@ -346,11 +345,10 @@ public class DisplayDependencyUpdatesMojo @Inject public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } // open for tests diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 0f76921d53..882d3c6765 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -31,7 +31,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -54,11 +53,10 @@ public class DisplayParentUpdatesMojo @Inject public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 7818b310a8..a0d25aa1d5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -53,7 +53,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -84,10 +83,10 @@ import org.apache.maven.plugin.version.PluginVersionNotFoundException; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; import org.codehaus.mojo.versions.api.ArtifactVersions; @@ -159,22 +158,29 @@ public class DisplayPluginUpdatesMojo */ private RuntimeInformation runtimeInformation; + /** + * The (injected) instance of {@link ProjectBuilder} + * + * @since 2.14.0 + */ + protected final ProjectBuilder projectBuilder; + // --------------------- GETTER / SETTER METHODS --------------------- @Inject @SuppressWarnings( "checkstyle:ParameterNumber" ) public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, + ProjectBuilder projectBuilder, WagonManager wagonManager, - ArtifactResolver artifactResolver, LifecycleExecutor lifecycleExecutor, ModelInterpolator modelInterpolator, PluginManager pluginManager, RuntimeInformation runtimeInformation, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + this.projectBuilder = projectBuilder; this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; this.pluginManager = pluginManager; @@ -297,9 +303,8 @@ else if ( event.isEndElement() ) Map superPomPluginManagement; try { - MavenProject superProject = - projectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() ); - superPomPluginManagement = new HashMap<>( getPluginManagement( superProject.getOriginalModel() ) ); + superPomPluginManagement = new HashMap<>( getPluginManagement( + PomHelper.getStandaloneSuperProject( projectBuilder, session, getLog() ).getOriginalModel() ) ); } catch ( ProjectBuildingException e ) { @@ -448,20 +453,10 @@ public void execute() ArtifactVersion minRequires = null; for ( int j = newerVersions.length - 1; j >= 0; j-- ) { - Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( newerVersions[j].toString() ) - .withType( "pom" ) - .withScope( Artifact.SCOPE_RUNTIME ) - .build() ); try { - getHelper().resolveArtifact( probe, true ); - MavenProject pluginMavenProject = - projectBuilder.buildFromRepository( probe, session.getCurrentProject() - .getRemoteArtifactRepositories(), session.getLocalRepository() ); - ArtifactVersion pluginRequires = getPrerequisitesMavenVersion( pluginMavenProject ); + ArtifactVersion pluginRequires = getPrerequisitesMavenVersion( + getPluginProject( groupId, artifactId, newerVersions[j].toString() ) ); if ( artifactVersion == null && compare( specMavenVersion, pluginRequires ) >= 0 ) { // ok, newer version compatible with current specMavenVersion @@ -513,20 +508,10 @@ public void execute() } if ( effectiveVersion != null ) { - Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( effectiveVersion ) - .withType( "pom" ) - .withScope( Artifact.SCOPE_RUNTIME ) - .build() ); try { - getHelper().resolveArtifact( probe, true ); - MavenProject mavenProject = - projectBuilder.buildFromRepository( probe, getProject().getRemoteArtifactRepositories(), - session.getLocalRepository() ); - ArtifactVersion requires = getPrerequisitesMavenVersion( mavenProject ); + ArtifactVersion requires = getPrerequisitesMavenVersion( + getPluginProject( groupId, artifactId, effectiveVersion ) ); if ( minMavenVersion == null || compare( minMavenVersion, requires ) < 0 ) { minMavenVersion = requires; @@ -716,6 +701,43 @@ else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion logLine( false, "" ); } + /** + * Builds a {@link MavenProject} instance for the plugin with a given {@code groupId}, + * {@code artifactId}, and {@code version}. + * @param groupId {@code groupId} of the plugin + * @param artifactId {@code artifactId} of the plugin + * @param version {@code version} of the plugin + * @return retrieved {@link MavenProject} instance for the given plugin + * @throws MojoExecutionException thrown if the artifact for the plugin could not be constructed + * @throws ProjectBuildingException thrown if the {@link MavenProject} instance could not be constructed + */ + private MavenProject getPluginProject( String groupId, String artifactId, String version ) + throws MojoExecutionException, ProjectBuildingException, ArtifactResolutionException + { + Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() + .withGroupId( groupId ) + .withArtifactId( artifactId ) + .withVersion( version ) + .withType( "pom" ) + .withScope( Artifact.SCOPE_RUNTIME ) + .build() ); + getHelper().resolveArtifact( probe, true ); + ProjectBuildingResult result = + projectBuilder.build( probe, true, + PomHelper.createProjectBuilderRequest( session, + r -> r.setProcessPlugins( false ), + r -> r.setRemoteRepositories( session.getCurrentProject() + .getPluginArtifactRepositories() ) ) ); + if ( !result.getProblems().isEmpty() ) + { + getLog().warn( "Problems encountered during construction of the plugin POM for " + + probe.toString() ); + result.getProblems().forEach( p -> + getLog().warn( "\t" + p.getMessage() ) ); + } + return result.getProject(); + } + private static String pad( String start, int len, String... ends ) { StringBuilder buf = new StringBuilder( len ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index d555b87a31..3596347b93 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -34,7 +34,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -142,11 +141,10 @@ public class DisplayPropertyUpdatesMojo @Inject public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } public void execute() diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 1b7bae0a93..7f2cb52a08 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -37,7 +37,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -71,11 +70,10 @@ public class ForceReleasesMojo @Inject public ForceReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 41c860f034..6074838387 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -37,7 +37,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -70,11 +69,10 @@ public class LockSnapshotsMojo @Inject public LockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index ccffc1e561..29e115e305 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -38,7 +38,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Property; @@ -128,11 +127,10 @@ public class ResolveRangesMojo @Inject public ResolveRangesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java index c2c294fcf2..dd49650b40 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java @@ -28,13 +28,14 @@ import java.util.Set; import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuilder; import org.codehaus.mojo.versions.api.PomHelper; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; @@ -49,12 +50,12 @@ public class RevertMojo extends AbstractMojo { /** - * The Maven Project. + * The {@link MavenSession} instance * - * @since 1.0-alpha-1 + * @since 2.14.0 */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) - private MavenProject project; + @Parameter( defaultValue = "${session}", required = true, readonly = true ) + private MavenSession session; /** * Whether to start processing at the local aggregation root (which might be a parent module @@ -66,13 +67,18 @@ public class RevertMojo extends AbstractMojo @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) private boolean processFromLocalAggregationRoot; - protected MavenProjectBuilder projectBuilder; + /** + * The (injected) {@link ProjectBuilder} instance + * + * @since 2.14.0 + */ + protected final ProjectBuilder projectBuilder; @Parameter( defaultValue = "${localRepository}", readonly = true ) protected ArtifactRepository localRepository; @Inject - protected RevertMojo( MavenProjectBuilder projectBuilder ) + protected RevertMojo( ProjectBuilder projectBuilder ) { this.projectBuilder = projectBuilder; } @@ -80,8 +86,8 @@ protected RevertMojo( MavenProjectBuilder projectBuilder ) public void execute() throws MojoExecutionException, MojoFailureException { final MavenProject projectToProcess = !processFromLocalAggregationRoot - ? PomHelper.getLocalRoot( projectBuilder, this.project, localRepository, null, getLog() ) - : this.project; + ? PomHelper.getLocalRoot( projectBuilder, session, getLog() ) + : session.getCurrentProject(); getLog().info( "Local aggregation root: " + projectToProcess.getBasedir() ); Set reactor = PomHelper.getAllChildModules( projectToProcess, getLog() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index f8b7785423..4c1700bff4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -49,7 +49,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -244,15 +244,23 @@ public class SetMojo extends AbstractVersionsUpdaterMojo */ private final transient List sourceChanges = new ArrayList<>(); + /** + * The (injected) instance of {@link ProjectBuilder} + * + * @since 2.14.0 + */ + protected final ProjectBuilder projectBuilder; + @Inject public SetMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, + ProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders, Prompter prompter ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + this.projectBuilder = projectBuilder; this.prompter = prompter; } @@ -337,8 +345,7 @@ public void execute() throws MojoExecutionException, MojoFailureException try { final MavenProject project = processFromLocalAggregationRoot - ? PomHelper.getLocalRoot( projectBuilder, getProject(), session.getLocalRepository(), - null, getLog() ) + ? PomHelper.getLocalRoot( projectBuilder, session, getLog() ) : getProject(); getLog().info( "Local aggregation root: " + project.getBasedir() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index f72ad64f70..8ea42bfb9c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -31,7 +31,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Property; @@ -92,11 +91,10 @@ public class SetPropertyMojo @Inject public SetPropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 2e73f3dfab..8da3525379 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -14,7 +14,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -68,11 +67,10 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo @Inject public SetScmTagMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index a454db574c..14e88af3a3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -36,7 +36,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecord; @@ -69,11 +68,10 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UnlockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index 254db5431d..a00659d4ce 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -35,7 +35,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -71,11 +70,10 @@ public class UpdateChildModulesMojo @Inject public UpdateChildModulesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 4325f60b09..f9ff516419 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -38,7 +38,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -140,11 +139,10 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Inject public UpdateParentMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index c04e82d65f..8292a6926d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; @@ -141,11 +140,10 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UpdatePropertiesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 21bb0009d4..e8371fd369 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; @@ -140,11 +139,10 @@ public class UpdatePropertyMojo @Inject public UpdatePropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 2f36f1247f..f61b2e4dce 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -34,7 +34,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -75,11 +74,10 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UseDepVersionMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 8ee9f69c9f..cf76a901ac 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -40,7 +40,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; @@ -104,11 +103,10 @@ public class UseLatestReleasesMojo @Inject public UseLatestReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 92a9be4f9e..6ed13e961f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -36,7 +36,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; @@ -93,11 +92,10 @@ public class UseLatestSnapshotsMojo @Inject public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 6a1601d347..099d48c594 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -34,7 +34,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; @@ -101,11 +100,10 @@ public class UseLatestVersionsMojo @Inject public UseLatestVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index dc0ec16a8e..462ebb145b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -34,7 +34,6 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -51,11 +50,10 @@ public abstract class UseLatestVersionsMojoBase { public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index ab700bb25d..04c79dc7cc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -33,7 +33,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -67,11 +66,10 @@ public class UseNextReleasesMojo @Inject public UseNextReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index bded43e366..e688443700 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -35,7 +35,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; @@ -92,11 +91,10 @@ public class UseNextSnapshotsMojo @Inject public UseNextSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 7694c5a1ad..64f4b4b318 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -32,7 +32,6 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -59,11 +58,10 @@ public class UseNextVersionsMojo @Inject public UseNextVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index c0233e4cff..361fcc9b00 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -35,7 +35,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -58,11 +57,10 @@ public class UseReactorMojo @Inject public UseReactorMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 6fb108e97f..4bee79200b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -38,7 +38,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.repository.RepositorySystem; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -85,11 +84,10 @@ public class UseReleasesMojo @Inject public UseReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - MavenProjectBuilder projectBuilder, WagonManager wagonManager, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, projectBuilder, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index c2b70a3932..1119b5636b 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -162,7 +162,6 @@ public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() "2.0.0-rc1"} ); }} ), null, - null, null ) {{ setProject( createProject() ); @@ -208,7 +207,6 @@ public void testAllowMajorUpdatesFalse() put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); }} ), null, - null, null ) {{ setProject( createProject() ); @@ -253,7 +251,6 @@ public void testAllowMinorUpdatesFalse() put( "default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); }} ), null, - null, null ) {{ setProject( createProject() ); @@ -299,7 +296,6 @@ public void testAllowIncrementalUpdatesFalse() put( "default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); }} ), null, - null, null ) {{ setProject( createProject() ); @@ -347,7 +343,6 @@ public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() "1.9.0-rc1"} ); }} ), null, - null, null ) {{ setProject( createProject() ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 791ab15895..5f1aee06b8 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -62,7 +62,9 @@ public class ForceReleasesMojoTest extends AbstractMojoTestCase public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new ForceReleasesMojo( mockRepositorySystem(), mockAetherRepositorySystem(), null, null, + mojo = new ForceReleasesMojo( mockRepositorySystem(), + mockAetherRepositorySystem(), + null, changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index 4ebed3b4bf..d5a4f51e34 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -17,7 +17,7 @@ public class SeparatePatternsForIncludesAnExcludesTest public void setUp() throws Exception { - mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null, null ) + mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null ) { @Override protected void update( ModifiedPomXMLEventReader pom ) diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index b987621633..2673a73bb2 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -75,8 +75,7 @@ public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new UpdateParentMojo( repositorySystem, aetherRepositorySystem, null, null, - changeRecorder.asTestMap() ) + mojo = new UpdateParentMojo( repositorySystem, aetherRepositorySystem, null, changeRecorder.asTestMap() ) {{ setProject( createProject() ); reactorProjects = Collections.emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index 4dd3cb1cd8..a02eef31f3 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -62,7 +62,6 @@ public void setUp() throws Exception mojo = new UseLatestReleasesMojo( repositorySystemMock, aetherRepositorySystem, null, - null, changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index f95c8462f4..9a3db80a40 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -75,7 +75,6 @@ public void setUp() throws Exception mojo = new UseLatestVersionsMojo( repositorySystemMock, aetherRepositorySystem, null, - null, changeRecorder.asTestMap() ) {{ reactorProjects = emptyList(); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index 0827bc1c84..8f108b7447 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -65,7 +65,6 @@ public void setUp() throws IllegalAccessException mojo = new UseReleasesMojo( mockRepositorySystem(), mockAetherRepositorySystem(), null, - null, changeRecorder.asTestMap() ); setVariableValueToObject( mojo, "reactorProjects", emptyList() ); mojo.project = new MavenProject() From 9576c2eb18f78db837e5b4f8fa46f32e4713f3cf Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 26 Nov 2022 20:43:31 +0100 Subject: [PATCH 221/441] Clarification in README - maintained versions, issues and PR creation According to clarification we can only test with the latest Maven on GitHub it will save time for executing --- .github/workflows/maven.yml | 2 -- README.md | 52 +++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 39d6743a49..27386c7bb3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -25,9 +25,7 @@ jobs: uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3 with: ff-goal: '-P run-its install' # site use project version for reporting - ff-maven: "3.8.6" # Maven version for fail-fast-build verify-goal: '-P run-its install' # should be the same as for first build - maven-matrix: '[ "3.2.5", "3.8.6" ]' # Maven versions matrix for verify builds deploy: name: Deploy diff --git a/README.md b/README.md index b2512e9a37..273d759562 100644 --- a/README.md +++ b/README.md @@ -6,44 +6,68 @@ This is the [versions-maven-plugin](http://www.mojohaus.org/versions-maven-plugi [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.mojo/versions-maven-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.codehaus.mojo/versions-maven-plugin) [![Build Status](https://github.com/mojohaus/versions-maven-plugin/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/mojohaus/versions-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) +## Maintained versions + +Versions Maven Plugin requires Maven 3.2.5+ and JDK 1.8+ + +However, we maintain the latest Plugin version with the latest Maven. + +We execute tests against different operating systems and JDKs +by [GitHub Actions](https://github.com/mojohaus/versions-maven-plugin/actions/workflows/maven.yml?query=branch%3Amaster) ## Contributing ### Creating Issues -If you find a problem please create an -[issue in the ticket](https://github.com/mojohaus/versions-maven-plugin/issues) +If you find a problem please first search current opened and closed issues and pull requests. +It can be that someone already has reported similar. + +You can also check current [milestone](https://github.com/mojohaus/versions-maven-plugin/milestones) +in order to see what will be in next release. + +Only when you can not find similar issue please create a new one in the +[ticket system](https://github.com/mojohaus/versions-maven-plugin/issues) and describe what is going wrong or what you expect to happen. + If you have a full working example or a log file this is also helpful. + You should of course describe only a single issue in a single ticket and not -mixing up several different things into a single issue. +mixing up several things into a single issue. + +Please always check your issue with the latest Plugin and tha latest Maven version. ### Creating a Pull Request -Before you create a pull request it is necessary to create an issue in +Before you start working on more complicated change, new feature +it is good practice to create an issue in the [ticket system](https://github.com/mojohaus/versions-maven-plugin/issues) -and describe what the problem is or what kind of feature you would like -to add. Afterwards you can create an appropriate pull request. +or send an emil to [development list](https://www.mojohaus.org/versions-maven-plugin/mailing-lists.html) +and describe what the problem is or what kind of feature you would like to add. +Wait a few days for feedback from other contributors. +Afterwards you can create an appropriate pull request. -It is required if you want to get a Pull request to be integrated into please -squash your commits into a single commit which references the issue in the -commit message which looks like this: +It is required if you want to get a pull request to be integrated into please +squash your commits into a single commit which references the optional issue +in the commit message which looks like this: ``` -Fixed #Issue - o Description. +Fixed #Issue - change subject + +a description ``` +Please take consider that change subject will be used in release notes +and will be present in git history so should be enough descriptive. + This makes it simpler to merge it and this will also close the -appropriate issue automatically in one go. This make the life as -maintainer a little bit easier. +appropriate issue automatically in one go. +This make the life as maintainer a little bit easier. A pull request has to fulfill only a single ticket and should never create/add/fix several issues in one, cause otherwise the history is hard to read and to understand and makes the maintenance of the issues and pull request hard or to be honest impossible. - ## Releasing * Make sure `gpg-agent` is running. From f61270bacaccf019dcd7e1886aa0e12d0af47922 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Fri, 25 Nov 2022 15:36:37 +0100 Subject: [PATCH 222/441] #704: Remove WagonManager --- pom.xml | 1 - versions-common/pom.xml | 13 - .../versions/api/DefaultVersionsHelper.java | 455 ++++++++++-------- .../mojo/versions/utils/WagonUtils.java | 112 ----- .../api/DefaultVersionsHelperTest.java | 40 +- .../enforcer/MaxDependencyUpdates.java | 11 +- .../markdown/max-dependency-updates.md.vm | 2 +- ...AbstractVersionsDependencyUpdaterMojo.java | 6 +- .../versions/AbstractVersionsDisplayMojo.java | 6 +- .../mojo/versions/AbstractVersionsReport.java | 35 +- .../versions/AbstractVersionsUpdaterMojo.java | 20 +- .../versions/CompareDependenciesMojo.java | 7 +- .../versions/DependencyUpdatesReportMojo.java | 6 +- .../DisplayDependencyUpdatesMojo.java | 6 +- .../versions/DisplayParentUpdatesMojo.java | 6 +- .../versions/DisplayPluginUpdatesMojo.java | 6 +- .../versions/DisplayPropertyUpdatesMojo.java | 6 +- .../mojo/versions/ForceReleasesMojo.java | 6 +- .../mojo/versions/LockSnapshotsMojo.java | 6 +- .../versions/ParentUpdatesReportMojo.java | 7 +- .../versions/PluginUpdatesReportMojo.java | 6 +- .../versions/PropertyUpdatesReportMojo.java | 6 +- .../mojo/versions/ResolveRangesMojo.java | 6 +- .../org/codehaus/mojo/versions/SetMojo.java | 6 +- .../mojo/versions/SetPropertyMojo.java | 6 +- .../codehaus/mojo/versions/SetScmTagMojo.java | 6 +- .../mojo/versions/UnlockSnapshotsMojo.java | 6 +- .../mojo/versions/UpdateChildModulesMojo.java | 6 +- .../mojo/versions/UpdateParentMojo.java | 6 +- .../mojo/versions/UpdatePropertiesMojo.java | 6 +- .../mojo/versions/UpdatePropertyMojo.java | 6 +- .../mojo/versions/UseDepVersionMojo.java | 6 +- .../mojo/versions/UseLatestReleasesMojo.java | 6 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 6 +- .../mojo/versions/UseLatestVersionsMojo.java | 6 +- .../versions/UseLatestVersionsMojoBase.java | 6 +- .../mojo/versions/UseNextReleasesMojo.java | 6 +- .../mojo/versions/UseNextSnapshotsMojo.java | 6 +- .../mojo/versions/UseNextVersionsMojo.java | 6 +- .../mojo/versions/UseReactorMojo.java | 6 +- .../mojo/versions/UseReleasesMojo.java | 6 +- 41 files changed, 421 insertions(+), 462 deletions(-) delete mode 100644 versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java diff --git a/pom.xml b/pom.xml index ae0e574a9a..9ea4a7ea1c 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,6 @@ ${mojo.java.target} 5.9.1 3.2.5 - 3.5.2 1.11.1 1.11.1 ${project.version} diff --git a/versions-common/pom.xml b/versions-common/pom.xml index 365dba0074..5b791a896b 100644 --- a/versions-common/pom.xml +++ b/versions-common/pom.xml @@ -63,25 +63,12 @@ ${mavenVersion} provided
    - - org.apache.maven.wagon - wagon-provider-api - ${wagonVersion} - provided - com.fasterxml.woodstox woodstox-core test - - - org.apache.maven.wagon - wagon-file - ${wagonVersion} - test - org.apache.commons commons-lang3 diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index c948b7d635..85ce4a8aef 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -20,11 +20,11 @@ */ import java.io.BufferedInputStream; -import java.io.File; import java.io.IOException; -import java.io.InputStream; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -35,6 +35,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -49,7 +50,6 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; @@ -61,14 +61,10 @@ import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.ResourceDoesNotExistException; -import org.apache.maven.wagon.TransferFailedException; -import org.apache.maven.wagon.UnsupportedProtocolException; import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.authorization.AuthorizationException; +import org.apache.maven.wagon.authentication.AuthenticationInfo; +import org.apache.maven.wagon.observers.Debug; +import org.apache.maven.wagon.proxy.ProxyInfo; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; @@ -80,16 +76,21 @@ import org.codehaus.mojo.versions.utils.PluginComparator; import org.codehaus.mojo.versions.utils.RegexUtils; import org.codehaus.mojo.versions.utils.VersionsExpressionEvaluator; -import org.codehaus.mojo.versions.utils.WagonUtils; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.eclipse.aether.repository.AuthenticationContext; +import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.VersionRangeRequest; import org.eclipse.aether.resolution.VersionRangeResolutionException; +import static java.util.Collections.singletonList; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; import static org.apache.maven.RepositoryUtils.toArtifact; /** @@ -143,7 +144,6 @@ public class DefaultVersionsHelper * @since 2.12 */ private final Map artifactBestFitRule = new HashMap<>(); - /** * Private constructor used by the builder */ @@ -151,43 +151,6 @@ private DefaultVersionsHelper() { } - @Deprecated - private static RuleSet getRuleSet( Wagon wagon, String remoteURI ) - throws IOException, AuthorizationException, TransferFailedException, ResourceDoesNotExistException - { - File tempFile = File.createTempFile( "ruleset", ".xml" ); - try - { - wagon.get( remoteURI, tempFile ); - try ( InputStream is = Files.newInputStream( tempFile.toPath() ) ) - { - return readRulesFromStream( is ); - } - } - finally - { - if ( !tempFile.delete() ) - { - // maybe we can delete this later - tempFile.deleteOnExit(); - } - } - } - - private static RuleSet readRulesFromStream( InputStream stream ) - throws IOException - { - RuleXpp3Reader reader = new RuleXpp3Reader(); - try ( BufferedInputStream bis = new BufferedInputStream( stream ) ) - { - return reader.read( bis ); - } - catch ( XmlPullParserException e ) - { - throw new IOException( e ); - } - } - static boolean exactMatch( String wildcardRule, String value ) { Pattern p = Pattern.compile( RegexUtils.convertWildcardsToRegex( wildcardRule, true ) ); @@ -200,149 +163,6 @@ static boolean match( String wildcardRule, String value ) return p.matcher( value ).matches(); } - /** - *

    Creates the enriched version of the ruleSet given as parameter; the ruleSet will contain the - * set of ignored versions passed on top of its own (if defined).

    - * - *

    If the {@code originalRuleSet} is {@code null}, a new {@linkplain RuleSet} will be created as - * a result.

    - * - *

    The method does not change the {@code originalRuleSet} object.

    - * - * @param ignoredVersions collection of ignored version to enrich the clone of the original rule set - * @param originalRuleSet original rule set - * @return new RuleSet object containing the (if passed) cloned version of the rule set, enriched with - * the given set of ignored versions - */ - @SuppressWarnings( "checkstyle:AvoidNestedBlocks" ) - private static RuleSet enrichRuleSet( Collection ignoredVersions, RuleSet originalRuleSet ) - { - RuleSet ruleSet = new RuleSet(); - if ( originalRuleSet != null ) - { - ruleSet.setComparisonMethod( originalRuleSet.getComparisonMethod() ); - if ( originalRuleSet.getRules() != null ) - { - ruleSet.setRules( new ArrayList<>( originalRuleSet.getRules() ) ); - } - if ( originalRuleSet.getIgnoreVersions() != null ) - { - ruleSet.setIgnoreVersions( new ArrayList<>( originalRuleSet.getIgnoreVersions() ) ); - } - } - - if ( ruleSet.getIgnoreVersions() == null ) - { - ruleSet.setIgnoreVersions( new ArrayList<>() ); - } - ruleSet.getIgnoreVersions().addAll( ignoredVersions.stream().map( v -> - { - IgnoreVersion ignoreVersion = new IgnoreVersion(); - ignoreVersion.setType( TYPE_REGEX ); - ignoreVersion.setVersion( v ); - return ignoreVersion; - } ).collect( Collectors.toList() ) ); - - return ruleSet; - } - - private static RuleSet getRulesFromClasspath( String uri, Log logger ) - throws MojoExecutionException - { - logger.debug( "Going to load rules from \"" + uri + "\"" ); - - String choppedUrl = uri.substring( CLASSPATH_PROTOCOL.length() + 3 ); - - URL url = DefaultVersionsHelper.class.getResource( choppedUrl ); - - if ( null == url ) - { - String message = "Resource \"" + uri + "\" not found in classpath."; - - throw new MojoExecutionException( message ); - } - - try - { - RuleSet rules = readRulesFromStream( url.openStream() ); - logger.debug( "Loaded rules from \"" + uri + "\" successfully" ); - return rules; - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Could not load specified rules from " + uri, e ); - } - } - - private static RuleSet getRulesViaWagon( String rulesUri, Log logger, String serverId, String id, - WagonManager wagonManager, Settings settings ) - throws MojoExecutionException - { - RuleSet loadedRules; - - int split = rulesUri.lastIndexOf( '/' ); - String baseUri = rulesUri; - String fileUri = ""; - - if ( split != -1 ) - { - baseUri = rulesUri.substring( 0, split ) + '/'; - fileUri = split + 1 < rulesUri.length() ? rulesUri.substring( split + 1 ) : ""; - } - - try - { - Wagon wagon = WagonUtils.createWagon( serverId, baseUri, wagonManager, settings, logger ); - try - { - logger.debug( "Trying to load ruleset from file \"" + fileUri + "\" in " + baseUri ); - loadedRules = getRuleSet( wagon, fileUri ); - } - finally - { - logger.debug( "Rule set loaded" ); - - if ( wagon != null ) - { - try - { - wagon.disconnect(); - } - catch ( ConnectionException e ) - { - logger.warn( "Could not disconnect wagon!", e ); - } - } - } - } - catch ( TransferFailedException e ) - { - throw new MojoExecutionException( "Could not transfer rules from " + rulesUri, e ); - } - catch ( AuthorizationException e ) - { - throw new MojoExecutionException( "Authorization failure trying to load rules from " + rulesUri, e ); - } - catch ( ResourceDoesNotExistException | IOException e ) - { - throw new MojoExecutionException( "Could not load specified rules from " + rulesUri, e ); - } - catch ( AuthenticationException e ) - { - throw new MojoExecutionException( "Authentication failure trying to load rules from " + rulesUri, e ); - } - catch ( UnsupportedProtocolException e ) - { - throw new MojoExecutionException( "Unsupported protocol for " + rulesUri, e ); - } - catch ( ConnectionException e ) - { - throw new MojoExecutionException( "Could not establish connection to " + rulesUri, e ); - } - - return loadedRules; - } - static boolean isClasspathUri( String uri ) { return ( uri != null && uri.startsWith( CLASSPATH_PROTOCOL + ":" ) ); @@ -863,18 +683,250 @@ public static class Builder private RepositorySystem repositorySystem; private Collection ignoredVersions; private RuleSet ruleSet; - private WagonManager wagonManager; private String serverId; private String rulesUri; private Log log; private MavenSession mavenSession; private MojoExecution mojoExecution; private org.eclipse.aether.RepositorySystem aetherRepositorySystem; + private Map wagonMap; public Builder() { } + private static RuleSet getRulesFromClasspath( String uri, Log logger ) + throws MojoExecutionException + { + logger.debug( "Going to load rules from \"" + uri + "\"" ); + String choppedUrl = uri.substring( CLASSPATH_PROTOCOL.length() + 3 ); + URL url = DefaultVersionsHelper.class.getResource( choppedUrl ); + if ( url == null ) + { + throw new MojoExecutionException( "Resource \"" + uri + "\" not found in classpath." ); + } + + try ( BufferedInputStream bis = new BufferedInputStream( url.openStream() ) ) + { + RuleSet result = new RuleXpp3Reader().read( bis ); + logger.debug( "Loaded rules from \"" + uri + "\" successfully" ); + return result; + } + catch ( IOException | XmlPullParserException e ) + { + throw new MojoExecutionException( "Could not load specified rules from " + uri, e ); + } + } + + /** + *

    Creates the enriched version of the ruleSet given as parameter; the ruleSet will contain the + * set of ignored versions passed on top of its own (if defined).

    + * + *

    If the {@code originalRuleSet} is {@code null}, a new {@linkplain RuleSet} will be created as + * a result.

    + * + *

    The method does not change the {@code originalRuleSet} object.

    + * + * @param ignoredVersions collection of ignored version to enrich the clone of the original rule set + * @param originalRuleSet original rule set + * @return new RuleSet object containing the (if passed) cloned version of the rule set, enriched with + * the given set of ignored versions + */ + @SuppressWarnings( "checkstyle:AvoidNestedBlocks" ) + private static RuleSet enrichRuleSet( Collection ignoredVersions, RuleSet originalRuleSet ) + { + RuleSet ruleSet = new RuleSet(); + if ( originalRuleSet != null ) + { + ruleSet.setComparisonMethod( originalRuleSet.getComparisonMethod() ); + if ( originalRuleSet.getRules() != null ) + { + ruleSet.setRules( new ArrayList<>( originalRuleSet.getRules() ) ); + } + if ( originalRuleSet.getIgnoreVersions() != null ) + { + ruleSet.setIgnoreVersions( new ArrayList<>( originalRuleSet.getIgnoreVersions() ) ); + } + } + + if ( ruleSet.getIgnoreVersions() == null ) + { + ruleSet.setIgnoreVersions( new ArrayList<>() ); + } + ruleSet.getIgnoreVersions().addAll( ignoredVersions.stream().map( v -> + { + IgnoreVersion ignoreVersion = new IgnoreVersion(); + ignoreVersion.setType( TYPE_REGEX ); + ignoreVersion.setVersion( v ); + return ignoreVersion; + } ).collect( Collectors.toList() ) ); + + return ruleSet; + } + + private static class RulesUri + { + String basePath; + String resource; + + private RulesUri( String basePath, String resource ) + { + this.basePath = basePath; + this.resource = resource; + } + + static RulesUri build( String rulesUri ) throws URISyntaxException + { + int split = rulesUri.lastIndexOf( '/' ); + return split == -1 + ? new RulesUri( rulesUri, "" ) + : new RulesUri( rulesUri.substring( 0, split ) + '/', + split + 1 < rulesUri.length() + ? rulesUri.substring( split + 1 ) + : "" ) ; + } + } + + private RemoteRepository remoteRepository( RulesUri uri ) + { + RemoteRepository prototype = new RemoteRepository.Builder( serverId, null, uri.basePath ).build(); + RemoteRepository.Builder builder = new RemoteRepository.Builder( prototype ); + ofNullable( mavenSession.getRepositorySession().getProxySelector().getProxy( prototype ) ) + .ifPresent( builder::setProxy ); + ofNullable( mavenSession.getRepositorySession().getAuthenticationSelector().getAuthentication( prototype ) ) + .ifPresent( builder::setAuthentication ); + ofNullable( mavenSession.getRepositorySession().getMirrorSelector().getMirror( prototype ) ) + .ifPresent( mirror -> builder.setMirroredRepositories( singletonList( mirror ) ) ); + return builder.build(); + } + + private Optional getProxyInfo( RemoteRepository repository ) + { + return ofNullable( repository.getProxy() ) + .map( proxy -> new ProxyInfo() + {{ + setHost( proxy.getHost() ); + setPort( proxy.getPort() ); + setType( proxy.getType() ); + ofNullable( proxy.getAuthentication() ) + .ifPresent( auth -> + { + try ( AuthenticationContext authCtx = AuthenticationContext + .forProxy( mavenSession.getRepositorySession(), repository ) ) + { + ofNullable( authCtx.get( AuthenticationContext.USERNAME ) ) + .ifPresent( this::setUserName ); + ofNullable( authCtx.get( AuthenticationContext.PASSWORD ) ) + .ifPresent( this::setPassword ); + ofNullable( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ) + .ifPresent( this::setNtlmDomain ); + ofNullable( authCtx.get( AuthenticationContext + .NTLM_WORKSTATION ) ).ifPresent( this::setNtlmHost ); + } + } ); + }} ); + } + + private Optional getAuthenticationInfo( RemoteRepository repository ) + { + return ofNullable( repository.getAuthentication() ) + .map( authentication -> new AuthenticationInfo() + {{ + try ( AuthenticationContext authCtx = AuthenticationContext + .forProxy( mavenSession.getRepositorySession(), repository ) ) + { + ofNullable( authCtx.get( AuthenticationContext.USERNAME ) ) + .ifPresent( this::setUserName ); + ofNullable( authCtx.get( AuthenticationContext.PASSWORD ) ) + .ifPresent( this::setPassword ); + ofNullable( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ) + .ifPresent( this::setPassphrase ); + ofNullable( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ) + .ifPresent( this::setPrivateKey ); + } + }} ); + } + + private org.apache.maven.wagon.repository.Repository wagonRepository( RemoteRepository repository ) + { + return new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); + } + + private RuleSet getRulesUsingWagon() throws MojoExecutionException + { + RulesUri uri; + try + { + uri = RulesUri.build( rulesUri ); + } + catch ( URISyntaxException e ) + { + log.warn( "Invalid rulesUri protocol: " + e.getMessage() ); + return null; + } + + RemoteRepository repository = remoteRepository( uri ); + return ofNullable( wagonMap.get( repository.getProtocol() ) ) + .map( wagon -> + { + if ( log.isDebugEnabled() ) + { + Debug debug = new Debug(); + wagon.addSessionListener( debug ); + wagon.addTransferListener( debug ); + } + + try + { + Optional proxyInfo = getProxyInfo( repository ); + Optional authenticationInfo = getAuthenticationInfo( repository ); + if ( log.isDebugEnabled() ) + { + log.debug( "Connecting to remote repository \"" + repository.getId() + "\"" + + proxyInfo.map( pi -> " using proxy " + pi.getHost() + ":" + + pi.getPort() ).orElse( "" ) + + authenticationInfo.map( ai -> " as " + ai.getUserName() ).orElse( "" ) ); + } + wagon.connect( wagonRepository( repository ), getAuthenticationInfo( repository ) + .orElse( null ), getProxyInfo( repository ).orElse( null ) ); + try + { + Path tempFile = Files.createTempFile( "rules-", ".xml" ); + wagon.get( uri.resource, tempFile.toFile() ); + try ( BufferedInputStream is = new BufferedInputStream( + Files.newInputStream( tempFile ) ) ) + { + return new RuleXpp3Reader().read( is ); + } + finally + { + Files.deleteIfExists( tempFile ); + } + + } + finally + { + wagon.disconnect(); + } + } + catch ( Exception e ) + { + log.warn( e.getMessage() ); + return null; + } + } ) + .orElseThrow( () -> new MojoExecutionException( "Could not load specified rules from " + + rulesUri ) ); + } + + public static Optional protocol( final String url ) + { + int pos = url.indexOf( ":" ); + return pos == -1 + ? empty() + : of( url.substring( 0, pos ).trim() ); + } + public Builder withRepositorySystem( RepositorySystem repositorySystem ) { this.repositorySystem = repositorySystem; @@ -893,12 +945,6 @@ public Builder withRuleSet( RuleSet ruleSet ) return this; } - public Builder withWagonManager( WagonManager wagonManager ) - { - this.wagonManager = wagonManager; - return this; - } - public Builder withServerId( String serverId ) { this.serverId = serverId; @@ -935,10 +981,16 @@ public Builder withAetherRepositorySystem( org.eclipse.aether.RepositorySystem a return this; } + public Builder withWagonMap( Map wagonMap ) + { + this.wagonMap = wagonMap; + return this; + } + /** * Builds the constructed {@linkplain DefaultVersionsHelper} object * @return constructed {@linkplain DefaultVersionsHelper} - * @throws MojoExecutionException should the constructor with the Wagon go wrong + * @throws MojoExecutionException should the constructor with the RuleSet retrieval doesn't succeed */ public DefaultVersionsHelper build() throws MojoExecutionException { @@ -960,8 +1012,7 @@ public DefaultVersionsHelper build() throws MojoExecutionException ? new RuleSet() : isClasspathUri( rulesUri ) ? getRulesFromClasspath( rulesUri, log ) - : getRulesViaWagon( rulesUri, log, serverId, serverId, wagonManager, - mavenSession.getSettings() ); + : getRulesUsingWagon(); } if ( ignoredVersions != null && !ignoredVersions.isEmpty() ) { diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java deleted file mode 100644 index 5e02e041b2..0000000000 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/WagonUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.codehaus.mojo.versions.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.repository.legacy.WagonConfigurationException; -import org.apache.maven.settings.Proxy; -import org.apache.maven.settings.Settings; -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.UnsupportedProtocolException; -import org.apache.maven.wagon.Wagon; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.observers.Debug; -import org.apache.maven.wagon.proxy.ProxyInfo; -import org.apache.maven.wagon.repository.Repository; - -/** - * Utility methods to help with using {@link Wagon}s. - * - * @author Stephen Connolly - * @since 1.0-alpha-3 - */ -public final class WagonUtils -{ - private WagonUtils() - { - throw new IllegalAccessError( "Utility classes should never be instantiated" ); - } - - /** - * Convenience method to convert the {@link org.apache.maven.settings.Proxy} object from a - * {@link org.apache.maven.settings.Settings} into a {@link org.apache.maven.wagon.proxy.ProxyInfo}. - * - * @param settings The settings to use. - * @return The proxy details from the settings or null if the settings do not define a proxy. - */ - public static ProxyInfo getProxyInfo( Settings settings ) - { - ProxyInfo proxyInfo = null; - if ( settings != null && settings.getActiveProxy() != null ) - { - proxyInfo = new ProxyInfo(); - final Proxy proxy = settings.getActiveProxy(); - proxyInfo.setHost( proxy.getHost() ); - proxyInfo.setType( proxy.getProtocol() ); - proxyInfo.setPort( proxy.getPort() ); - proxyInfo.setNonProxyHosts( proxy.getNonProxyHosts() ); - proxyInfo.setUserName( proxy.getUsername() ); - proxyInfo.setPassword( proxy.getPassword() ); - } - return proxyInfo; - } - - /** - * Convenience method to create a wagon. - * - * @param serverId The serverId to use if the wagonManager needs help. - * @param url The url to create a wagon for. - * @param wagonManager The wgaon manager to use. - * @param settings The settings to use. - * @param logger The logger to use. - * @return The wagon to connect to the url. - * @throws org.apache.maven.wagon.UnsupportedProtocolException if the protocol is not supported. - * @throws org.apache.maven.repository.legacy.WagonConfigurationException if the wagon cannot be configured. - * @throws org.apache.maven.wagon.ConnectionException If the connection cannot be established. - * @throws org.apache.maven.wagon.authentication.AuthenticationException If the connection cannot be authenticated. - */ - public static Wagon createWagon( String serverId, String url, WagonManager wagonManager, Settings settings, - Log logger ) - throws UnsupportedProtocolException, WagonConfigurationException, - ConnectionException, AuthenticationException - { - Repository repository = new Repository( serverId, url ); - Wagon wagon = wagonManager.getWagon( repository ); - - if ( logger.isDebugEnabled() ) - { - Debug debug = new Debug(); - wagon.addSessionListener( debug ); - wagon.addTransferListener( debug ); - } - - ProxyInfo proxyInfo = getProxyInfo( settings ); - if ( proxyInfo != null ) - { - wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ), proxyInfo ); - } - else - { - wagon.connect( repository, wagonManager.getAuthenticationInfo( repository.getId() ) ); - } - return wagon; - } -} diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index a4ece27ace..47ee52d3ac 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -19,6 +19,10 @@ * under the License. */ +import java.io.File; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -27,7 +31,6 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecution; @@ -38,25 +41,39 @@ import org.apache.maven.plugin.testing.stubs.DefaultArtifactHandlerStub; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.ConnectionException; +import org.apache.maven.wagon.ResourceDoesNotExistException; +import org.apache.maven.wagon.TransferFailedException; +import org.apache.maven.wagon.Wagon; +import org.apache.maven.wagon.authentication.AuthenticationException; +import org.apache.maven.wagon.authentication.AuthenticationInfo; +import org.apache.maven.wagon.authorization.AuthorizationException; +import org.apache.maven.wagon.proxy.ProxyInfo; import org.codehaus.mojo.versions.model.IgnoreVersion; import org.codehaus.mojo.versions.model.Rule; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.ordering.VersionComparators; import org.codehaus.mojo.versions.utils.VersionStub; +import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.resolution.VersionRangeRequest; import org.eclipse.aether.resolution.VersionRangeResult; import org.eclipse.aether.version.Version; import org.hamcrest.CoreMatchers; import org.junit.Test; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; +import static java.util.Collections.singletonMap; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsIterableContaining.hasItems; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -65,7 +82,6 @@ */ public class DefaultVersionsHelperTest extends AbstractMojoTestCase { - @Test public void testPerRuleVersionsIgnored() throws Exception { @@ -217,6 +233,22 @@ private DefaultVersionsHelper createHelper() return createHelper( null ); } + private static Wagon mockFileWagon( URI rulesUri ) + throws AuthenticationException, ConnectionException, AuthorizationException, TransferFailedException, + ResourceDoesNotExistException + { + Wagon fileWagon = mock( Wagon.class ); + doNothing().when( fileWagon ).connect( any( org.apache.maven.wagon.repository.Repository.class ), + any( AuthenticationInfo.class ), any( ProxyInfo.class ) ); + doAnswer( i -> + { + File tempFile = i.getArgument( 1 ); + Files.copy( Paths.get( rulesUri ), tempFile.toPath(), REPLACE_EXISTING ); + return null; + } ).when( fileWagon ).get( anyString(), any( File.class ) ); + return fileWagon; + } + private DefaultVersionsHelper createHelper( org.eclipse.aether.RepositorySystem aetherRepositorySystem ) throws Exception { @@ -228,10 +260,12 @@ private DefaultVersionsHelper createHelper( org.eclipse.aether.RepositorySystem .thenReturn( emptyList() ); when( mavenSession.getCurrentProject().getRemotePluginRepositories() ) .thenReturn( emptyList() ); + when( mavenSession.getRepositorySession() ).thenReturn( new DefaultRepositorySystemSession() ); + return new DefaultVersionsHelper.Builder() .withRepositorySystem( lookup( RepositorySystem.class ) ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonManager( lookup( WagonManager.class ) ) + .withWagonMap( singletonMap( "file", mockFileWagon( new URI( rulesUri ) ) ) ) .withServerId( "" ) .withRulesUri( rulesUri ) .withLog( mock( Log.class ) ) diff --git a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java index 58ea699d1e..2895596b70 100644 --- a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java +++ b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java @@ -19,13 +19,13 @@ */ import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.enforcer.rule.api.EnforcerLevel; import org.apache.maven.enforcer.rule.api.EnforcerRule; @@ -38,6 +38,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.Segment; @@ -276,7 +277,13 @@ private static VersionsHelper createVersionsHelper( EnforcerRuleHelper ruleHelpe return new DefaultVersionsHelper.Builder() .withRepositorySystem( ruleHelper.getComponent( RepositorySystem.class ) ) .withAetherRepositorySystem( ruleHelper.getComponent( org.eclipse.aether.RepositorySystem.class ) ) - .withWagonManager( ruleHelper.getComponent( WagonManager.class ) ) + .withWagonMap( ruleHelper.getComponentMap( Wagon.class.getName() ) + .entrySet() + .parallelStream() + .filter( e -> e.getValue() instanceof Wagon ) + .collect( HashMap::new, + ( m, e ) -> m.put( e.getKey(), (Wagon) e.getValue() ), + HashMap::putAll ) ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) diff --git a/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm b/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm index 26100debeb..d5912718f2 100644 --- a/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm +++ b/versions-enforcer/src/site/markdown/max-dependency-updates.md.vm @@ -46,7 +46,7 @@ The following parameters are supported by this rule: | `pluginDependencyExcludes` | (empty) | List of plugin dependency exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | | `pluginManagementDependencyIncludes` | `*` | List of plugin management dependency inclusion patterns. Only dependencies matching all the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | | `pluginManagementDependencyExcludes` | (empty) | List of plugin management dependency exclusion patterns. Only dependencies matching none of the patterns will be considered.
    The wildcard (`*`) can be used as the only, first, last or both characters in each token. The version token does support version ranges. | -| `serverId` | `serverId` | *settings.xml*'s server id for the URL. This is used when wagon needs extra authentication information. | +| `serverId` | `serverId` | *settings.xml*'s server id for the URL. This is used when Wagon needs extra authentication information. | | `rulesUri` | | URI of a ruleSet file containing the rules that control how to compare version numbers. The URI could be either a Wagon URI or a classpath URI (e.g. *classpath:\/\/\/package/sub/package/rules.xml*). | | `ruleSet` | | Allows specifying the `RuleSet` object describing rules on artifact versions to ignore when considering updates.
    See: [Using the ruleSet element in the POM](../version-rules.html#Using_the_ruleSet_element_in_the_POM) | diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 8992c28daf..04b5dc541f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -31,7 +31,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.model.Dependency; import org.apache.maven.model.Parent; @@ -41,6 +40,7 @@ import org.apache.maven.repository.RepositorySystem; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -158,10 +158,10 @@ public abstract class AbstractVersionsDependencyUpdaterMojo @Inject protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 0009b74339..635732cb83 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -30,9 +30,9 @@ import java.util.Set; import org.apache.commons.lang3.StringUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; /** @@ -85,10 +85,10 @@ public abstract class AbstractVersionsDisplayMojo @Inject protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } @SuppressWarnings( "unchecked" ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index ab236f9059..b33e642016 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -20,13 +20,11 @@ */ import java.io.File; -import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.doxia.sink.Sink; @@ -39,6 +37,7 @@ import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -79,23 +78,6 @@ public abstract class AbstractVersionsReport */ protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true ) - protected List remoteArtifactRepositories; - - /** - * @since 1.0-alpha-3 - */ - @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true ) - protected List remotePluginRepositories; - - /** - * @since 1.0-alpha-3 - */ - private final WagonManager wagonManager; - /** * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. * @@ -182,17 +164,24 @@ public abstract class AbstractVersionsReport */ protected ReportRendererFactory rendererFactory; + /** + * (injected) map of {@link Wagon} instances + * + * @since 2.14.0 + */ + protected Map wagonMap; + // --------------------- GETTER / SETTER METHODS --------------------- protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, ReportRendererFactory rendererFactory ) { this.i18n = i18n; this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; - this.wagonManager = wagonManager; + this.wagonMap = wagonMap; this.rendererFactory = rendererFactory; } @@ -206,7 +195,7 @@ public VersionsHelper getHelper() helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonManager( wagonManager ) + .withWagonMap( wagonMap ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 5ce3f508ae..c2f28e7902 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -32,7 +32,6 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -45,6 +44,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; import org.codehaus.mojo.versions.api.PomHelper; @@ -97,11 +97,6 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) protected List reactorProjects; - /** - * The (injected) {@link WagonManager} instance. - */ - private final WagonManager wagonManager; - /** * settings.xml's server id for the URL. This is used when wagon needs extra authentication information. * @@ -200,17 +195,24 @@ public abstract class AbstractVersionsUpdaterMojo @Parameter( property = "maven.version.ignore" ) protected Set ignoredVersions; + /** + * (injected) map of {@link Wagon} instances + * + * @since 2.14.0 + */ + protected final Map wagonMap; + // --------------------- GETTER / SETTER METHODS --------------------- @Inject protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; - this.wagonManager = wagonManager; + this.wagonMap = wagonMap; this.changeRecorders = changeRecorders; } @@ -221,7 +223,7 @@ public VersionsHelper getHelper() throws MojoExecutionException helper = new DefaultVersionsHelper.Builder() .withRepositorySystem( repositorySystem ) .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonManager( wagonManager ) + .withWagonMap( wagonMap ) .withServerId( serverId ) .withRulesUri( rulesUri ) .withRuleSet( ruleSet ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index 537fa9ab91..a531a5c131 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -32,7 +32,6 @@ import java.util.Map; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -44,6 +43,7 @@ import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Property; @@ -131,11 +131,11 @@ public class CompareDependenciesMojo @Inject public CompareDependenciesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, ProjectBuilder projectBuilder, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); this.projectBuilder = projectBuilder; } @@ -308,6 +308,7 @@ private MavenProject getRemoteMavenProject( String groupId, String artifactId, S * Compare the dependency versions of the current project with the dependency versions of a remote project * * @throws XMLStreamException + * @throws MojoExecutionException */ private List compareVersions( ModifiedPomXMLEventReader pom, List dependencies, Map remoteDependencies, diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 55a9f23dec..8eb146ea6a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -32,7 +32,6 @@ import java.util.TreeSet; import java.util.stream.Collectors; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; @@ -41,6 +40,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; @@ -111,10 +111,10 @@ public class DependencyUpdatesReportMojo extends AbstractVersionsReport wagonMap, ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, aetherRepositorySystem, wagonManager, rendererFactory ); + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 7773890a75..9f978b18aa 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -30,7 +30,6 @@ import java.util.TreeSet; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -38,6 +37,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -345,10 +345,10 @@ public class DisplayDependencyUpdatesMojo @Inject public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } // open for tests diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index 882d3c6765..a65d58faa2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -24,7 +24,6 @@ import java.util.Map; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -32,6 +31,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -53,10 +53,10 @@ public class DisplayParentUpdatesMojo @Inject public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index a0d25aa1d5..c38aaebbe3 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -49,7 +49,6 @@ import org.apache.maven.BuildFailureException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; @@ -89,6 +88,7 @@ import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.settings.Settings; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -172,14 +172,14 @@ public class DisplayPluginUpdatesMojo public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, ProjectBuilder projectBuilder, - WagonManager wagonManager, + Map wagonMap, LifecycleExecutor lifecycleExecutor, ModelInterpolator modelInterpolator, PluginManager pluginManager, RuntimeInformation runtimeInformation, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); this.projectBuilder = projectBuilder; this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index 3596347b93..dcf7be6ff9 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -27,7 +27,6 @@ import java.util.Optional; import java.util.TreeSet; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -35,6 +34,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.Segment; @@ -141,10 +141,10 @@ public class DisplayPropertyUpdatesMojo @Inject public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } public void execute() diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 7f2cb52a08..28de4ba3f5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -28,7 +28,6 @@ import java.util.regex.Matcher; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -38,6 +37,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -70,10 +70,10 @@ public class ForceReleasesMojo @Inject public ForceReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 6074838387..9b57fc8914 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -30,7 +30,6 @@ import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -38,6 +37,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -69,10 +69,10 @@ public class LockSnapshotsMojo @Inject public LockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index f6b768fe69..61097221ee 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Locale; +import java.util.Map; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -32,6 +32,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; @@ -56,10 +57,10 @@ public class ParentUpdatesReportMojo extends AbstractVersionsReport wagonMap, ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, aetherRepositorySystem, wagonManager, rendererFactory ); + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 975b796e53..7c64b14c89 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -30,7 +30,6 @@ import java.util.Set; import java.util.TreeSet; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; @@ -38,6 +37,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PluginUpdatesDetails; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; @@ -86,10 +86,10 @@ public class PluginUpdatesReportMojo extends AbstractVersionsReport wagonMap, ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, aetherRepositorySystem, wagonManager, rendererFactory ); + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index db0d102b62..8dd941dff4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.TreeMap; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; @@ -37,6 +36,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.VersionsHelper; @@ -109,10 +109,10 @@ public class PropertyUpdatesReportMojo extends AbstractVersionsReport wagonMap, ReportRendererFactory rendererFactory ) { - super( i18n, repositorySystem, aetherRepositorySystem, wagonManager, rendererFactory ); + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index 29e115e305..f6278cdc66 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -30,7 +30,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.model.Dependency; @@ -39,6 +38,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -127,10 +127,10 @@ public class ResolveRangesMojo @Inject public ResolveRangesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 4c1700bff4..1bdceacb0b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -41,7 +41,6 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; @@ -51,6 +50,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.change.DefaultVersionChange; @@ -255,11 +255,11 @@ public class SetMojo extends AbstractVersionsUpdaterMojo public SetMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, ProjectBuilder projectBuilder, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders, Prompter prompter ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); this.projectBuilder = projectBuilder; this.prompter = prompter; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 8ea42bfb9c..427cca501d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -26,12 +26,12 @@ import java.util.Arrays; import java.util.Map; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -91,10 +91,10 @@ public class SetPropertyMojo @Inject public SetPropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 8da3525379..5940640bec 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -8,13 +8,13 @@ import java.util.List; import java.util.Map; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Scm; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -67,10 +67,10 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo @Inject public SetScmTagMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index 14e88af3a3..b490d1400c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -29,7 +29,6 @@ import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -37,6 +36,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -68,10 +68,10 @@ public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UnlockSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index a00659d4ce..6a0bc41362 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -29,13 +29,13 @@ import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; @@ -70,10 +70,10 @@ public class UpdateChildModulesMojo @Inject public UpdateChildModulesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index f9ff516419..0841f9e865 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -29,7 +29,6 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; @@ -39,6 +38,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; @@ -139,10 +139,10 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo @Inject public UpdateParentMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 8292a6926d..9ef536db4d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Optional; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -33,6 +32,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -140,10 +140,10 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UpdatePropertiesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index e8371fd369..32c569623f 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Optional; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -33,6 +32,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; @@ -139,10 +139,10 @@ public class UpdatePropertyMojo @Inject public UpdatePropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index f61b2e4dce..1972443640 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -27,7 +27,6 @@ import java.util.Map; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -35,6 +34,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -74,10 +74,10 @@ public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo @Inject public UseDepVersionMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index cf76a901ac..5202196bc5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -31,7 +31,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; @@ -41,6 +40,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -103,10 +103,10 @@ public class UseLatestReleasesMojo @Inject public UseLatestReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index 6ed13e961f..f1f86dfa82 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Optional; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -37,6 +36,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -92,10 +92,10 @@ public class UseLatestSnapshotsMojo @Inject public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 099d48c594..8021f2fb38 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Optional; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -35,6 +34,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -100,10 +100,10 @@ public class UseLatestVersionsMojo @Inject public UseLatestVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } @Override diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 462ebb145b..2b95c0f1e1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -29,12 +29,12 @@ import java.util.function.Predicate; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; @@ -50,10 +50,10 @@ public abstract class UseLatestVersionsMojoBase { public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 04c79dc7cc..70e86055e1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -27,13 +27,13 @@ import java.util.Map; import java.util.regex.Pattern; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; @@ -66,10 +66,10 @@ public class UseNextReleasesMojo @Inject public UseNextReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index e688443700..7d5483afa1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.Optional; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -36,6 +35,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -91,10 +91,10 @@ public class UseNextSnapshotsMojo @Inject public UseNextSnapshotsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 64f4b4b318..67abe9b090 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -26,13 +26,13 @@ import java.util.Collection; import java.util.Map; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecord; @@ -58,10 +58,10 @@ public class UseNextVersionsMojo @Inject public UseNextVersionsMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index 361fcc9b00..552dda2e82 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -28,7 +28,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -36,6 +35,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; @@ -57,10 +57,10 @@ public class UseReactorMojo @Inject public UseReactorMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 4bee79200b..89ffbf8938 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -30,7 +30,6 @@ import java.util.regex.Matcher; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; @@ -39,6 +38,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; import org.codehaus.mojo.versions.api.VersionRetrievalException; @@ -84,10 +84,10 @@ public class UseReleasesMojo @Inject public UseReleasesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, - WagonManager wagonManager, + Map wagonMap, Map changeRecorders ) { - super( repositorySystem, aetherRepositorySystem, wagonManager, changeRecorders ); + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); } /** From bc10d1a9f23c35d49e0e3cc42c1c16441f38a9b8 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Thu, 1 Dec 2022 17:43:38 +0100 Subject: [PATCH 223/441] Resolves #837: Add includeParent (default true) to UpdatePropertiesMojo --- .../invoker.properties | 2 + .../parent-pom.xml | 14 ++ .../it/it-update-properties-issue-837/pom.xml | 23 +++ .../verify.groovy | 1 + .../invoker.properties | 2 + .../parent-pom.xml | 14 ++ .../it/it-update-property-issue-837/pom.xml | 23 +++ .../verify.groovy | 2 + .../versions/AbstractVersionsUpdaterMojo.java | 17 +- .../mojo/versions/UpdatePropertiesMojo.java | 143 +------------- .../versions/UpdatePropertiesMojoBase.java | 179 ++++++++++++++++++ .../mojo/versions/UpdatePropertyMojo.java | 135 ++----------- .../versions/UpdatePropertiesMojoTest.java | 28 ++- .../issue-837/parent-pom.xml | 14 ++ .../mojo/update-properties/issue-837/pom.xml | 23 +++ 15 files changed, 360 insertions(+), 260 deletions(-) create mode 100644 versions-maven-plugin/src/it/it-update-properties-issue-837/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-update-properties-issue-837/parent-pom.xml create mode 100644 versions-maven-plugin/src/it/it-update-properties-issue-837/pom.xml create mode 100644 versions-maven-plugin/src/it/it-update-properties-issue-837/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-update-property-issue-837/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-update-property-issue-837/parent-pom.xml create mode 100644 versions-maven-plugin/src/it/it-update-property-issue-837/pom.xml create mode 100644 versions-maven-plugin/src/it/it-update-property-issue-837/verify.groovy create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/parent-pom.xml create mode 100644 versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/pom.xml diff --git a/versions-maven-plugin/src/it/it-update-properties-issue-837/invoker.properties b/versions-maven-plugin/src/it/it-update-properties-issue-837/invoker.properties new file mode 100644 index 0000000000..b992cb3c77 --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-properties-issue-837/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-properties +invoker.mavenOpts = -DincludeParent=false diff --git a/versions-maven-plugin/src/it/it-update-properties-issue-837/parent-pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-837/parent-pom.xml new file mode 100644 index 0000000000..d01abb3eec --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-properties-issue-837/parent-pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + default-group + parent-artifact + 1.0.0 + pom + + + 1.0 + + + diff --git a/versions-maven-plugin/src/it/it-update-properties-issue-837/pom.xml b/versions-maven-plugin/src/it/it-update-properties-issue-837/pom.xml new file mode 100644 index 0000000000..e80ba17a43 --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-properties-issue-837/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + + default-group + parent-artifact + 1.0.0 + parent-pom.xml + + + child-artifact + 1.0.0 + + + + localhost + dummy-api + ${artifact-version} + + + + diff --git a/versions-maven-plugin/src/it/it-update-properties-issue-837/verify.groovy b/versions-maven-plugin/src/it/it-update-properties-issue-837/verify.groovy new file mode 100644 index 0000000000..5b4f858adb --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-properties-issue-837/verify.groovy @@ -0,0 +1 @@ +assert ! ( new File( basedir, "build.log" ).text.contains( 'Property ${artifact-version}' ) ) diff --git a/versions-maven-plugin/src/it/it-update-property-issue-837/invoker.properties b/versions-maven-plugin/src/it/it-update-property-issue-837/invoker.properties new file mode 100644 index 0000000000..3d5b27837c --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-property-issue-837/invoker.properties @@ -0,0 +1,2 @@ +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:update-property +invoker.mavenOpts = -DincludeParent=false -Dproperty=artifact-version diff --git a/versions-maven-plugin/src/it/it-update-property-issue-837/parent-pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-837/parent-pom.xml new file mode 100644 index 0000000000..d01abb3eec --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-property-issue-837/parent-pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + default-group + parent-artifact + 1.0.0 + pom + + + 1.0 + + + diff --git a/versions-maven-plugin/src/it/it-update-property-issue-837/pom.xml b/versions-maven-plugin/src/it/it-update-property-issue-837/pom.xml new file mode 100644 index 0000000000..e80ba17a43 --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-property-issue-837/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + + default-group + parent-artifact + 1.0.0 + parent-pom.xml + + + child-artifact + 1.0.0 + + + + localhost + dummy-api + ${artifact-version} + + + + diff --git a/versions-maven-plugin/src/it/it-update-property-issue-837/verify.groovy b/versions-maven-plugin/src/it/it-update-property-issue-837/verify.groovy new file mode 100644 index 0000000000..f60420cb94 --- /dev/null +++ b/versions-maven-plugin/src/it/it-update-property-issue-837/verify.groovy @@ -0,0 +1,2 @@ +assert ! ( new File( basedir, "build.log" ).text + .contains( 'Property ${artifact-version}: Set of valid available versions is [1.0, 1.0.1,' ) ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index c2f28e7902..92021ba27d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -495,6 +495,20 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A return true; } + /** + * Attempts to update the property to a newer version, if that exists + * @param pom pom to update + * @param property property to update + * @param version {@link PropertyVersions} object + * @param currentVersion current version + * @param allowDowngrade if downgrades should be allowed if snapshots are not allowed + * @param unchangedSegment most major segment not to be changed + * @return new version of the artifact, if the property was updated; {@code null} if there was no update + * @throws XMLStreamException thrown from {@link ModifiedPomXMLEventReader} if the update doesn't succeed + * @throws InvalidVersionSpecificationException thrown if {@code unchangedSegment} doesn't match the version + * @throws InvalidSegmentException thrown if {@code unchangedSegment} is invalid + * @throws MojoExecutionException thrown if any other error occurs + */ protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, PropertyVersions version, String currentVersion, boolean allowDowngrade, @@ -513,9 +527,10 @@ protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventRead else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.getName(), winner.toString() ) ) { getLog().info( "Updated ${" + property.getName() + "} from " + currentVersion + " to " + winner ); + return winner; } - return winner; + return null; } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index 9ef536db4d..a91837629b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -19,32 +19,20 @@ * under the License. */ -import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; - -import java.util.Map; -import java.util.Optional; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; -import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; -import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; +import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; +import java.util.Map; /** * Sets properties to the latest versions of specific artifacts. @@ -53,11 +41,8 @@ * @since 1.0-alpha-1 */ @Mojo( name = "update-properties", threadSafe = true ) -public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo +public class UpdatePropertiesMojo extends UpdatePropertiesMojoBase { - - // ------------------------------ FIELDS ------------------------------ - /** * Any restrictions that apply to specific properties. * @@ -82,61 +67,6 @@ public class UpdatePropertiesMojo extends AbstractVersionsDependencyUpdaterMojo @Parameter( property = "excludeProperties" ) private String excludeProperties = null; - /** - * Whether properties linking versions should be auto-detected or not. - * - * @since 1.0-alpha-2 - */ - @Parameter( property = "autoLinkItems", - defaultValue = "true" ) - private boolean autoLinkItems; - - /** - * If a property points to a version like 1.2.3-SNAPSHOT and your repo contains a version like - * 1.1.0 without settings this to true the property will not being changed. - * - * @since 2.4 - */ - @Parameter( property = "allowDowngrade", - defaultValue = "false" ) - private boolean allowDowngrade; - - /** - * Whether to allow the major version number to be changed. - * - * @since 2.4 - */ - @Parameter( property = "allowMajorUpdates", - defaultValue = "true" ) - protected boolean allowMajorUpdates = true; - - /** - *

    Whether to allow the minor version number to be changed.

    - * - *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    - * - * @since 2.4 - */ - @Parameter( property = "allowMinorUpdates", - defaultValue = "true" ) - protected boolean allowMinorUpdates = true; - - /** - *

    Whether to allow the incremental version number to be changed.

    - * - *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} - * and {@linkplain #allowMinorUpdates} {@code false}

    - * - * @since 2.4 - */ - @Parameter( property = "allowIncrementalUpdates", - defaultValue = "true" ) - protected boolean allowIncrementalUpdates = true; - - // -------------------------- STATIC METHODS -------------------------- - - // -------------------------- OTHER METHODS -------------------------- - @Inject public UpdatePropertiesMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, @@ -157,74 +87,15 @@ public UpdatePropertiesMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - Map propertyVersions = getHelper().getVersionPropertiesMap( + update( pom, getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() .withMavenProject( getProject() ) .withPropertyDefinitions( properties ) .withIncludeProperties( includeProperties ) .withExcludeProperties( excludeProperties ) .withAutoLinkItems( autoLinkItems ) - .build() ); - for ( Map.Entry entry : propertyVersions.entrySet() ) - { - Property property = entry.getKey(); - PropertyVersions version = entry.getValue(); - - final String currentVersion = getProject().getProperties().getProperty( property.getName() ); - if ( currentVersion == null ) - { - continue; - } - boolean canUpdateProperty = true; - for ( ArtifactAssociation association : version.getAssociations() ) - { - if ( !( isIncluded( association.getArtifact() ) ) ) - { - getLog().info( - "Not updating the property ${" + property.getName() + "} because it is used by artifact " - + association.getArtifact().toString() - + " and that artifact is not included in the list of " - + " allowed artifacts to be updated." ); - canUpdateProperty = false; - break; - } - } - - if ( canUpdateProperty ) - { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ); - try - { - ArtifactVersion targetVersion = - updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, unchangedSegment ); - - if ( targetVersion != null ) - { - for ( final ArtifactAssociation association : version.getAssociations() ) - { - if ( ( isIncluded( association.getArtifact() ) ) ) - { - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( - ChangeRecord.ChangeKind.PROPERTY ) - .withArtifact( association.getArtifact() ) - .withOldVersion( currentVersion ) - .withNewVersion( targetVersion.toString() ) - .build() ); - } - } - } - } - catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), - property.getVersion(), e.getMessage() ) ); - } - } - - } + .withIncludeParent( includeParent ) + .build() ) ); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java new file mode 100644 index 0000000000..8baa1eda0b --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java @@ -0,0 +1,179 @@ +package org.codehaus.mojo.versions; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.api.ArtifactAssociation; +import org.codehaus.mojo.versions.api.Property; +import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.Segment; +import org.codehaus.mojo.versions.api.recording.ChangeRecord; +import org.codehaus.mojo.versions.api.recording.ChangeRecorder; +import org.codehaus.mojo.versions.ordering.InvalidSegmentException; +import org.codehaus.mojo.versions.recording.DefaultChangeRecord; +import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; + +import javax.xml.stream.XMLStreamException; +import java.util.Map; +import java.util.Optional; + +import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; + +/** + * Common base class for {@link UpdatePropertiesMojo} + * and {@link UpdatePropertyMojo} + */ +public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependencyUpdaterMojo +{ + /** + * Whether properties linking versions should be auto-detected or not. + * + * @since 1.0-alpha-2 + */ + @Parameter( property = "autoLinkItems", defaultValue = "true" ) + protected boolean autoLinkItems; + + /** + * If a property points to a version like 1.2.3 and your repository contains versions like + * 1.2.3 and 1.1.0 without settings this to true the property will never + * being changed back to 1.1.0 by using -DnewVersion=[1.1.0]. + * + * @since 3.0.0 + */ + @Parameter( property = "allowDowngrade", defaultValue = "false" ) + protected boolean allowDowngrade; + + /** + * Whether to allow the major version number to be changed. + * + * @since 2.4 + */ + @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + protected boolean allowMajorUpdates; + + /** + *

    Whether to allow the minor version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    + * + * @since 2.4 + */ + @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + protected boolean allowMinorUpdates; + + /** + *

    Whether to allow the incremental version number to be changed.

    + * + *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} + * and {@linkplain #allowMinorUpdates} {@code false}

    + * + * @since 2.4 + */ + @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + protected boolean allowIncrementalUpdates; + + /** + *

    Whether to include parent POMs in the search. Default: {@code true}

    + *

    Setting this to {@code false} can speed up execution, but will not resolve + * property-bound dependencies, defined in parent POMs. + * + * @since 2.14.0 + */ + + @Parameter( property = "includeParent", defaultValue = "true" ) + protected boolean includeParent = true; + + public UpdatePropertiesMojoBase( RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders ) + { + super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + } + + protected void update( ModifiedPomXMLEventReader pom, Map propertyVersions ) + throws XMLStreamException + { + for ( Map.Entry entry : propertyVersions.entrySet() ) + { + Property property = entry.getKey(); + PropertyVersions version = entry.getValue(); + + final String currentVersion = getProject().getProperties().getProperty( property.getName() ); + if ( currentVersion == null ) + { + continue; + } + boolean canUpdateProperty = true; + for ( ArtifactAssociation association : version.getAssociations() ) + { + if ( !( isIncluded( association.getArtifact() ) ) ) + { + getLog().info( + "Not updating the property ${" + property.getName() + "} because it is used by artifact " + + association.getArtifact().toString() + + " and that artifact is not included in the list of " + + " allowed artifacts to be updated." ); + canUpdateProperty = false; + break; + } + } + + if ( canUpdateProperty ) + { + Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, + allowIncrementalUpdates, getLog() ); + try + { + ArtifactVersion targetVersion = + updatePropertyToNewestVersion( pom, property, version, currentVersion, + allowDowngrade, unchangedSegment ); + + if ( targetVersion != null ) + { + for ( final ArtifactAssociation association : version.getAssociations() ) + { + if ( ( isIncluded( association.getArtifact() ) ) ) + { + getChangeRecorder().recordChange( DefaultChangeRecord.builder() + .withKind( + ChangeRecord.ChangeKind.PROPERTY ) + .withArtifact( association.getArtifact() ) + .withOldVersion( currentVersion ) + .withNewVersion( targetVersion.toString() ) + .build() ); + } + } + } + } + catch ( InvalidSegmentException | InvalidVersionSpecificationException | MojoExecutionException e ) + { + getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), + property.getVersion(), e.getMessage() ) ); + } + } + + } + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 32c569623f..2fc55cf48e 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -19,31 +19,20 @@ * under the License. */ -import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; - -import java.util.Map; -import java.util.Optional; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; -import org.codehaus.mojo.versions.api.ArtifactAssociation; import org.codehaus.mojo.versions.api.Property; -import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.api.Segment; import org.codehaus.mojo.versions.api.VersionsHelper; -import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -import org.codehaus.mojo.versions.ordering.InvalidSegmentException; -import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import org.codehaus.mojo.versions.utils.SegmentUtils; + +import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; +import java.util.Map; /** * Sets a property to the latest version in a given range of associated artifacts. @@ -52,12 +41,8 @@ * @since 1.3 */ @Mojo( name = "update-property", threadSafe = true ) -public class UpdatePropertyMojo - extends AbstractVersionsUpdaterMojo +public class UpdatePropertyMojo extends UpdatePropertiesMojoBase { - - // ------------------------------ FIELDS ------------------------------ - /** * A property to update. * @@ -85,57 +70,6 @@ public class UpdatePropertyMojo @Parameter( property = "newVersion" ) private String newVersion = null; - /** - * Whether properties linking versions should be auto-detected or not. - * - * @since 1.0-alpha-2 - */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) - private boolean autoLinkItems; - - /** - * If a property points to a version like 1.2.3 and your repository contains versions like - * 1.2.3 and 1.1.0 without settings this to true the property will never - * being changed back to 1.1.0 by using -DnewVersion=[1.1.0]. - * - * @since 3.0.0 - */ - @Parameter( property = "allowDowngrade", defaultValue = "false" ) - private boolean allowDowngrade; - - /** - * Whether to allow the major version number to be changed. - * - * @since 2.4 - */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) - protected boolean allowMajorUpdates; - - /** - *

    Whether to allow the minor version number to be changed.

    - * - *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    - * - * @since 2.4 - */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) - protected boolean allowMinorUpdates; - - /** - *

    Whether to allow the incremental version number to be changed.

    - * - *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} - * and {@linkplain #allowMinorUpdates} {@code false}

    - * - * @since 2.4 - */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) - protected boolean allowIncrementalUpdates; - - // -------------------------- STATIC METHODS -------------------------- - - // -------------------------- OTHER METHODS -------------------------- - @Inject public UpdatePropertyMojo( RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, @@ -156,54 +90,17 @@ public UpdatePropertyMojo( RepositorySystem repositorySystem, protected void update( ModifiedPomXMLEventReader pom ) throws MojoExecutionException, MojoFailureException, XMLStreamException { - Property propertyConfig = new Property( property ); - propertyConfig.setVersion( newVersion ); - Map propertyVersions = - this.getHelper().getVersionPropertiesMap( - VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( new Property[] {propertyConfig} ) - .withIncludeProperties( property ) - .withAutoLinkItems( autoLinkItems ) - .build() ); - for ( Map.Entry entry : propertyVersions.entrySet() ) - { - Property property = entry.getKey(); - PropertyVersions version = entry.getValue(); - - final String currentVersion = getProject().getProperties().getProperty( property.getName() ); - if ( currentVersion == null ) - { - continue; - } - - Optional unchangedSegment = - SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ); - try - { - ArtifactVersion targetVersion = updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, unchangedSegment ); - - if ( targetVersion != null ) - { - for ( final ArtifactAssociation association : version.getAssociations() ) - { - this.getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( ChangeRecord.ChangeKind.PROPERTY ) - .withArtifact( association.getArtifact() ) - .withOldVersion( currentVersion ) - .withNewVersion( targetVersion.toString() ) - .build() ); - } - } - } - catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), - property.getVersion(), e.getMessage() ) ); - } - } + update( pom, getHelper().getVersionPropertiesMap( + VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject( getProject() ) + .withPropertyDefinitions( new Property[] { new Property( property ) + {{ + setVersion( newVersion ); + }} } ) + .withIncludeProperties( property ) + .withAutoLinkItems( autoLinkItems ) + .withIncludeParent( includeParent ) + .build() ) ); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java index 62c034b105..2da6749d03 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java @@ -22,11 +22,15 @@ import java.nio.file.Paths; import org.codehaus.mojo.versions.change.DefaultVersionChange; -import org.hamcrest.Matchers; +import org.codehaus.mojo.versions.utils.TestChangeRecorder; +import org.codehaus.mojo.versions.utils.TestUtils; import org.junit.Test; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; /** * Unit tests for {@link UpdatePropertiesMojo} @@ -39,7 +43,7 @@ public void testAllowMajorUpdates() throws Exception Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); setUpMojo( "update-properties" ).execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( + assertThat( changeRecorder.getChanges(), hasItem( new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); } @@ -51,7 +55,7 @@ public void testAllowMinorUpdates() throws Exception UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); mojo.allowMajorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( + assertThat( changeRecorder.getChanges(), hasItem( new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); } @@ -64,7 +68,23 @@ public void testAllowIncrementalUpdates() throws Exception mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( + assertThat( changeRecorder.getChanges(), hasItem( new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); } + + @Test + public void testChangesNotRegisteredIfNoUpdatesInPom() + throws Exception + { + TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-837" ), + pomDir ); + UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); + TestChangeRecorder changeRecorder = new TestChangeRecorder(); + setVariableValueToObject( mojo, "changeRecorders", changeRecorder.asTestMap() ); + setVariableValueToObject( mojo, "changeRecorderFormat", "none" ); +// pomHelperClass.when( () -> PomHelper.setPropertyVersion( any(), anyString(), anyString(), anyString() ) ) +// .thenReturn( false ); + mojo.execute( ); + assertThat( changeRecorder.getChanges(), is( empty() ) ); + } } diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/parent-pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/parent-pom.xml new file mode 100644 index 0000000000..d01abb3eec --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/parent-pom.xml @@ -0,0 +1,14 @@ + + 4.0.0 + + default-group + parent-artifact + 1.0.0 + pom + + + 1.0 + + + diff --git a/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/pom.xml b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/pom.xml new file mode 100644 index 0000000000..31c6622ece --- /dev/null +++ b/versions-maven-plugin/src/test/resources/org/codehaus/mojo/update-properties/issue-837/pom.xml @@ -0,0 +1,23 @@ + + 4.0.0 + + + default-group + parent-artifact + 1.0.0 + parent-pom.xml + + + child-artifact + 1.0.0 + + + + default-group + default-artifact + ${artifact-version} + + + + From 112e9ee8f19cbbf48f17e7695907648d4d4a3c5e Mon Sep 17 00:00:00 2001 From: mstemberger Date: Mon, 21 Nov 2022 12:16:19 +0100 Subject: [PATCH 224/441] Fixed #333 aggregated reports --- .../versions/api/DefaultVersionsHelper.java | 6 +- .../codehaus/mojo/versions/api/Property.java | 18 + .../versions/utils/PropertyComparator.java | 13 +- .../src/it-repo/dummy-aggregate-child-333.pom | 38 ++ .../it-repo/dummy-aggregate-parent-333.pom | 33 ++ .../child-one/pom.xml | 25 ++ .../child-two/pom.xml | 17 + .../invoker.properties | 1 + .../pom.xml | 68 ++++ .../src/site/site.xml | 7 + .../verify.groovy | 15 + .../child-one/pom.xml | 28 ++ .../child-two/pom.xml | 25 ++ .../invoker.properties | 1 + .../pom.xml | 56 +++ .../src/site/site.xml | 7 + .../verify.groovy | 13 + .../child-one/pom.xml | 22 ++ .../child-two/pom.xml | 18 + .../invoker.properties | 1 + .../pom.xml | 61 +++ .../src/site/site.xml | 7 + .../verify.groovy | 7 + .../AbstractDependencyUpdatesReportMojo.java | 365 ++++++++++++++++++ .../AbstractPluginUpdatesReportMojo.java | 249 ++++++++++++ .../AbstractPropertyUpdatesReportMojo.java | 218 +++++++++++ .../versions/AbstractVersionsUpdaterMojo.java | 2 + .../DependencyUpdatesAggregateReportMojo.java | 92 +++++ .../versions/DependencyUpdatesReportMojo.java | 226 +---------- .../PluginUpdatesAggregateReportMojo.java | 88 +++++ .../versions/PluginUpdatesReportMojo.java | 154 +------- .../PropertyUpdatesAggregateReportMojo.java | 95 +++++ .../versions/PropertyUpdatesReportMojo.java | 132 +------ .../versions/UseLatestVersionsMojoBase.java | 1 + .../reporting/ReportRendererFactoryImpl.java | 10 +- .../reporting/model/PropertyUpdatesModel.java | 6 +- .../reporting/util/AggregateReportUtils.java | 53 +++ ...ndency-updates-aggregate-report.properties | 55 +++ ...plugin-updates-aggregate-report.properties | 63 +++ ...operty-updates-aggregate-report.properties | 61 +++ 40 files changed, 1868 insertions(+), 489 deletions(-) create mode 100644 versions-maven-plugin/src/it-repo/dummy-aggregate-child-333.pom create mode 100644 versions-maven-plugin/src/it-repo/dummy-aggregate-parent-333.pom create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-one/pom.xml create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-two/pom.xml create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/pom.xml create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/src/site/site.xml create mode 100644 versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-one/pom.xml create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-two/pom.xml create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/pom.xml create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/src/site/site.xml create mode 100644 versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/verify.groovy create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-one/pom.xml create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-two/pom.xml create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/invoker.properties create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/pom.xml create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/src/site/site.xml create mode 100644 versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/verify.groovy create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java create mode 100644 versions-maven-plugin/src/main/resources/dependency-updates-aggregate-report.properties create mode 100644 versions-maven-plugin/src/main/resources/plugin-updates-aggregate-report.properties create mode 100644 versions-maven-plugin/src/main/resources/property-updates-aggregate-report.properties diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 85ce4a8aef..0ee3df21f9 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -663,8 +663,10 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr + builder.getVersionRange() ); property.setVersion( builder.getVersionRange() ); } - versions.setCurrentVersion( request.getMavenProject().getProperties() - .getProperty( property.getName() ) ); + final String currentVersion = request.getMavenProject().getProperties() + .getProperty( property.getName() ); + versions.setCurrentVersion( currentVersion ); + property.setValue( currentVersion ); propertyVersions.put( property, versions ); } catch ( VersionRetrievalException e ) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java index 09b5f56125..395121df9f 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java @@ -46,6 +46,13 @@ public class Property */ private String version; + /** + * Used by {@link org.codehaus.mojo.versions.utils.PropertyComparator} when comparing two same named properties + * + * @since 2.14.0 + */ + private String value; + /** * Whether to automatically link dependencies to the property. * @@ -105,6 +112,7 @@ public Property( String name ) this.searchReactor = true; this.preferReactor = true; this.version = null; + this.value = null; } public String getName() @@ -176,4 +184,14 @@ public void setBanSnapshots( boolean banSnapshots ) { this.banSnapshots = banSnapshots; } + + public String getValue() + { + return value; + } + + public void setValue( String value ) + { + this.value = value; + } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java index 8459950159..88112eec75 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java @@ -20,7 +20,6 @@ */ import java.util.Comparator; - import org.apache.commons.lang3.StringUtils; import org.codehaus.mojo.versions.api.Property; @@ -42,14 +41,18 @@ public enum PropertyComparator implements Comparator * @see java.util.Comparator#compare(Object, Object) * @since 1.0-beta-1 */ + @SuppressWarnings( "checkstyle:InnerAssignment" ) public int compare( Property p1, Property p2 ) { + int r; return p1 == p2 ? 0 : p1 == null - ? 1 - : p2 == null - ? -1 - : StringUtils.compare( p1.getName(), p2.getName() ); + ? 1 + : p2 == null + ? -1 + : ( r = StringUtils.compare( p1.getName(), p2.getName() ) ) == 0 + ? StringUtils.compare( p1.getValue(), p2.getValue() ) + : r ; } } diff --git a/versions-maven-plugin/src/it-repo/dummy-aggregate-child-333.pom b/versions-maven-plugin/src/it-repo/dummy-aggregate-child-333.pom new file mode 100644 index 0000000000..d2358bef97 --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-aggregate-child-333.pom @@ -0,0 +1,38 @@ + + 4.0.0 + + + localhost + dummy-aggregate-parent + 1.0.1-SNAPSHOT + + + localhost + dummy-aggregate-child + 1.0.1-SNAPSHOT + pom + + + 2.0.0.0 + + + + + + test.bigversion + dummy-lib + ${version.dummy-lib} + + + + + + + test.package + module + 0.0.2.19 + + + + diff --git a/versions-maven-plugin/src/it-repo/dummy-aggregate-parent-333.pom b/versions-maven-plugin/src/it-repo/dummy-aggregate-parent-333.pom new file mode 100644 index 0000000000..43659cde3d --- /dev/null +++ b/versions-maven-plugin/src/it-repo/dummy-aggregate-parent-333.pom @@ -0,0 +1,33 @@ + + 4.0.0 + + localhost + dummy-aggregate-parent + 1.0.1-SNAPSHOT + pom + + + 3.0.0 + + + + + + + maven-clean-plugin + ${version.maven-clean-plugin} + + + maven-deploy-plugin + 3.0.0-M1 + + + + + + + true + + + diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-one/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-one/pom.xml new file mode 100644 index 0000000000..8df7644fb5 --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-one/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + + localhost + it-dependency-updates-aggregate-report-333 + 1.0 + + + localhost + it-dependency-updates-aggregate-report-333-child-one + 1.0 + jar + http://localhost/ + + + + test.bigversion + dummy-lib + 3.0.0.0-SNAPSHOT + + + + diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-two/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-two/pom.xml new file mode 100644 index 0000000000..e1f678e742 --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/child-two/pom.xml @@ -0,0 +1,17 @@ + + 4.0.0 + + + localhost + it-dependency-updates-aggregate-report-333 + 1.0 + + + localhost + it-dependency-updates-aggregate-report-333-child-two + 1.0 + jar + http://localhost/ + + diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/invoker.properties b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/invoker.properties new file mode 100644 index 0000000000..c01f7db0e4 --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/invoker.properties @@ -0,0 +1 @@ +invoker.goals=site diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/pom.xml b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/pom.xml new file mode 100644 index 0000000000..fe946378ff --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/pom.xml @@ -0,0 +1,68 @@ + + 4.0.0 + + + localhost + dummy-aggregate-child + 1.0.1-SNAPSHOT + + + localhost + it-dependency-updates-aggregate-report-333 + 1.0 + pom + http://localhost/ + + + + + + localhost + dummy-api + 1.1 + + + localhost + dummy-impl + 1.1 + + + + + + + + + maven-site-plugin + @sitePluginVersion@ + + + + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + false + + + + dependency-updates-aggregate-report + + + + + + + + + child-one + child-two + + + diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/src/site/site.xml b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/src/site/site.xml new file mode 100644 index 0000000000..e955148484 --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/src/site/site.xml @@ -0,0 +1,7 @@ + + + org.apache.maven.skins + maven-default-skin + 1.0 + + diff --git a/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/verify.groovy b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/verify.groovy new file mode 100644 index 0000000000..4fc618e338 --- /dev/null +++ b/versions-maven-plugin/src/it/it-dependency-updates-aggregate-report-issue-333/verify.groovy @@ -0,0 +1,15 @@ +output = new File( basedir, 'target/site/dependency-updates-aggregate-report.html' ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +// Dependency management +assert !( output =~ 'This project does not declare any dependencies in a dependencyManagement section.' ) +assert ( output =~ 'localhost dummy-api 1.1 jar' ) +assert ( output =~ 'localhost dummy-impl 1.1 jar' ) +assert ( output =~ 'test.bigversion dummy-lib 2.0.0.0 jar' ) + +// Dependencies +assert !( output =~ 'This project does not declare any dependencies.' ) +assert ( output =~ 'test.bigversion dummy-lib 3.0.0.0-SNAPSHOT compile jar' ) +assert ( output =~ 'test.package module 0.0.2.19 compile jar' ) diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-one/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-one/pom.xml new file mode 100644 index 0000000000..88cacf2bcc --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-one/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + + localhost + it-plugin-updates-aggregate-report-333 + 1.0 + + + localhost + it-plugin-updates-aggregate-report-333-child-one + 1.0 + jar + dependency-updates-report + http://localhost/ + + + + + maven-clean-plugin + 3.2.0 + + + + + + diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-two/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-two/pom.xml new file mode 100644 index 0000000000..c88648b24e --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/child-two/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + + localhost + it-plugin-updates-aggregate-report-333 + 1.0 + + + localhost + it-plugin-updates-aggregate-report-333-child-two + 1.0 + jar + http://localhost/ + + + + + maven-deploy-plugin + + + + + diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/invoker.properties b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/invoker.properties new file mode 100644 index 0000000000..c01f7db0e4 --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/invoker.properties @@ -0,0 +1 @@ +invoker.goals=site diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/pom.xml b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/pom.xml new file mode 100644 index 0000000000..ee5e25f6df --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + + + localhost + dummy-aggregate-child + 1.0.1-SNAPSHOT + + + localhost + it-plugin-updates-aggregate-report-333 + 1.0 + pom + http://localhost/ + + + + + + maven-site-plugin + @sitePluginVersion@ + + + + + + maven-clean-plugin + 3.1.0 + + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + false + + + + plugin-updates-aggregate-report + + + + + + + + + child-one + child-two + + diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/src/site/site.xml b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/src/site/site.xml new file mode 100644 index 0000000000..e955148484 --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/src/site/site.xml @@ -0,0 +1,7 @@ + + + org.apache.maven.skins + maven-default-skin + 1.0 + + diff --git a/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/verify.groovy b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/verify.groovy new file mode 100644 index 0000000000..4c672cfe9c --- /dev/null +++ b/versions-maven-plugin/src/it/it-plugin-updates-aggregate-report-issue-333/verify.groovy @@ -0,0 +1,13 @@ +output = new File( basedir, 'target/site/plugin-updates-aggregate-report.html' ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +// Plugin management +assert !( output =~ 'This project does not declare any plugins in a build/pluginManagement section.' ) +assert ( output =~ 'org.apache.maven.plugins maven-clean-plugin 3.0.0' ) + +// Plugins +assert !( output =~ 'This project does not declare any plugins in a build/plugins section.' ) +assert ( output =~ 'org.apache.maven.plugins maven-clean-plugin 3.1.0' ) +assert ( output =~ 'org.apache.maven.plugins maven-clean-plugin 3.2.0' ) diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-one/pom.xml b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-one/pom.xml new file mode 100644 index 0000000000..5f5fee9fc0 --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-one/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + + localhost + it-property-updates-aggregate-report-333 + 1.0 + + + localhost + it-property-updates-aggregate-report-333-child-one + 1.0 + jar + dependency-updates-report + http://localhost/ + + + 1.1.1.1 + + + diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-two/pom.xml b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-two/pom.xml new file mode 100644 index 0000000000..843a9253aa --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/child-two/pom.xml @@ -0,0 +1,18 @@ + + 4.0.0 + + + localhost + it-property-updates-aggregate-report-333 + 1.0 + + + localhost + it-property-updates-aggregate-report-333-child-two + 1.0 + jar + dependency-updates-report + http://localhost/ + + diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/invoker.properties b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/invoker.properties new file mode 100644 index 0000000000..c01f7db0e4 --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/invoker.properties @@ -0,0 +1 @@ +invoker.goals=site diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/pom.xml b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/pom.xml new file mode 100644 index 0000000000..8d4b029b53 --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + + + localhost + dummy-aggregate-child + 1.0.1-SNAPSHOT + + + localhost + it-property-updates-aggregate-report-333 + 1.0 + pom + http://localhost/ + + + 2.12.0.0 + + + + + + + maven-site-plugin + @sitePluginVersion@ + + + + + + + + test.bigversion + dummy-lib + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + false + + + + property-updates-aggregate-report + + + + + + + + + child-one + child-two + + diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/src/site/site.xml b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/src/site/site.xml new file mode 100644 index 0000000000..e955148484 --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/src/site/site.xml @@ -0,0 +1,7 @@ + + + org.apache.maven.skins + maven-default-skin + 1.0 + + diff --git a/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/verify.groovy b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/verify.groovy new file mode 100644 index 0000000000..bd1522b849 --- /dev/null +++ b/versions-maven-plugin/src/it/it-property-updates-aggregate-report-issue-333/verify.groovy @@ -0,0 +1,7 @@ +output = new File( basedir, 'target/site/property-updates-aggregate-report.html' ).text + .replaceAll( '<[^>]+>', ' ' ) + .replaceAll( '&[^;]+;', ' ' ) + .replaceAll( '\\s+', ' ' ) + +assert ( output =~ '\\$\\{version.dummy-lib} 1.1.1.1' ) +assert ( output =~ '\\$\\{version.dummy-lib} 2.12.0.0' ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java new file mode 100644 index 0000000000..d183fbdb2d --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java @@ -0,0 +1,365 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +import static java.util.Collections.emptyMap; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.interpolateVersion; +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collections; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; +import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.api.ArtifactVersions; +import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; +import org.codehaus.mojo.versions.utils.DependencyComparator; +import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates a report of available updates for the dependencies of a project. + */ +public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersionsReport +{ + + private static final DependencyComparator DEPENDENCY_COMPARATOR = DependencyComparator.INSTANCE; + + /** + * Whether to process the dependencyManagement in pom or not. + * + * @since 2.5 + */ + @Parameter( property = "processDependencyManagement", defaultValue = "true" ) + protected boolean processDependencyManagement; + + /** + * Whether to process the dependencyManagement part transitive or not. + * In case of <type>pom</type>and + * <scope>import</scope> this means + * by default to report also the imported dependencies. + * If processTransitive is set to false the report will only show + * updates of the imported pom itself. + * + * @since 2.5 Note: Currently in experimental state. + */ + @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) + protected boolean processDependencyManagementTransitive; + + /** + * Report formats (html and/or xml). HTML by default. + */ + @Parameter( property = "dependencyUpdatesReportFormats", defaultValue = "html" ) + protected String[] formats = new String[] {"html"}; + + /** + * If true, only shows the subsection of the dependencyManagement artifacts that + * are actually used in the project's dependency graph. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyProjectDependencies", defaultValue = "false" ) + protected boolean onlyProjectDependencies; + + /** + * If true, only shows upgradable dependencies in the report. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + protected boolean onlyUpgradable; + + public AbstractDependencyUpdatesReportMojo( I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + /** + * {@inheritDoc} + */ + public boolean isExternalReport() + { + return false; + } + + /** + * {@inheritDoc} + */ + public boolean canGenerateReport() + { + return true; + } + + /** + * generates an empty report in case there are no sources to generate a report with + * + * @param locale the locale to generate the report for. + * @param sink the report formatting tool + */ + @SuppressWarnings( "deprecation" ) + protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException + { + + Set dependencies = getDependencies(); + + Set dependencyManagement; + + if ( processDependencyManagement ) + { + dependencyManagement = getDependencyManagement( dependencies ); + handleOnlyProjectDependencies( dependencyManagement, dependencies ); + } + else + { + dependencyManagement = Collections.emptySet(); + } + + try + { + + Map dependencyUpdates = + getHelper().lookupDependenciesUpdates( dependencies, false ); + + Map dependencyManagementUpdates = + processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) + : emptyMap(); + + if ( onlyUpgradable ) + { + dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 0 ); + dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 0 ); + } + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "Dependency versions:" ); + dependencyUpdates.forEach( ( key, value ) -> getLog().debug( + key.toString() + ": " + Arrays.stream( value.getVersions() ) + .map( ArtifactVersion::toString ) + .collect( Collectors.joining( ", " ) ) ) ); + + getLog().debug( "Dependency management versions:" ); + dependencyManagementUpdates.forEach( ( key, value ) -> getLog().debug( + key.toString() + ": " + Arrays.stream( value.getVersions() ) + .map( ArtifactVersion::toString ) + .collect( Collectors.joining( ", " ) ) ) ); + } + + DependencyUpdatesModel model = new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); + + renderReport( locale, sink, model ); + } + catch ( VersionRetrievalException e ) + { + throw new RuntimeException( e ); + } + } + + protected void handleDependencyManagementTransitive( MavenProject project, + Set dependencyManagementCollector ) + throws MavenReportException + { + if ( processDependencyManagementTransitive ) + { + if ( hasDependencyManagement( project ) ) + { + for ( Dependency dep : project.getDependencyManagement().getDependencies() ) + { + getLog().debug( + "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" + + dep.getType() + ":" + dep.getScope() ); + } + dependencyManagementCollector.addAll( project.getDependencyManagement().getDependencies() ); + } + } + else + { + if ( project.getOriginalModel().getDependencyManagement() != null + && project.getOriginalModel().getDependencyManagement().getDependencies() != null ) + { + // Using the original model to get the original dependencyManagement entries and + // not the interpolated model. + // TODO: I'm not 100% sure if this will work correctly in all cases. + for ( Dependency dep : project.getOriginalModel().getDependencyManagement().getDependencies() ) + { + dep = interpolateVersion( dep, project ); + + getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + } + dependencyManagementCollector.addAll( + project.getOriginalModel().getDependencyManagement().getDependencies() ); + } + } + } + + private void handleOnlyProjectDependencies( Set dependencyManagement, + Set dependencies ) + { + if ( !onlyProjectDependencies ) + { + // Retains only dependencies not present in dependencyManagement + dependencies.removeIf( dep -> dependencyManagement.stream().anyMatch( dmDep -> match( dep, dmDep ) ) ); + } + else + { + // Retain only dependencies in dependencyManagement that are also present in dependencies + dependencyManagement.removeIf( dep -> dependencies.stream().noneMatch( dmDep -> match( dep, dmDep ) ) ); + } + } + + /** + * Constructs a final instance of a {@link Set} with a {@link DependencyComparator} comparator. + * This set can be further populated by implementations, and should contain dependencies, that are present + * in projects direct dependencies section. + * + * @return a {@link Set} that can be additionally populated by {@link #populateDependencies(Set)}. + * If not, an empty set is returned + * */ + private Set getDependencies() + { + final Set dependenciesCollector = new TreeSet<>( DEPENDENCY_COMPARATOR ); + populateDependencies( dependenciesCollector ); + return dependenciesCollector; + } + + /** + * Implementations of {@link AbstractDependencyUpdatesReportMojo} may use this to supply the main processing logic + * (see {@link #getDependencyManagement(Set)}) with desired dependency data, which will be used + * in the creation of the report. + * + * @param dependenciesCollector, a Set, initialized with a DependencyComparator + * comparator. + * */ + protected abstract void populateDependencies( Set dependenciesCollector ); + + /** + * Constructs a final instance of a {@link Set} with a {@link DependencyComparator} comparator. + * This set can be further populated by implementations, and should contain dependencies, that are present + * in projects dependencyManagement section. + * + * @return a {@link Set} that can be additionally populated by + * {@link #populateDependencyManagement(Set, Set)}. If not, an empty set is returned + * */ + private Set getDependencyManagement( Set dependencies ) throws MavenReportException + { + final Set dependencyManagementCollector = new TreeSet<>( DEPENDENCY_COMPARATOR ); + populateDependencyManagement ( dependencyManagementCollector, dependencies ); + return dependencyManagementCollector; + } + + /** + * Implementations of {@link AbstractDependencyUpdatesReportMojo} may use this to supply the main processing logic + * (see {@link #getDependencyManagement(Set)}) with desired managed dependencies data, which will be used + * in the creation of the report. + * + * @param dependencyManagementCollector, a Set initialized with a DependencyComparator + * @param dependencies an already populated set of dependencies(non-managed) + * comparator. + * + * @throws MavenReportException when things go wrong. + * */ + protected abstract void populateDependencyManagement( Set dependencyManagementCollector, + Set dependencies ) + throws MavenReportException; + + private void renderReport( Locale locale, + Sink sink, + DependencyUpdatesModel model ) + throws MavenReportException + { + for ( String format : formats ) + { + if ( "html".equals( format ) ) + { + rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); + } + else if ( "xml".equals( format ) ) + { + Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); + if ( !Files.exists( outputDir ) ) + { + try + { + Files.createDirectories( outputDir ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Could not create the output directory" ); + } + } + Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); + new DependencyUpdatesXmlReportRenderer( model, outputFile ).render(); + } + } + } + + /** + * Compares two dependencies with each other + * + * @return true if the two dependencies match + */ + private boolean match( Dependency dep, Dependency dmDep ) + { + return dmDep.getGroupId().equals( dep.getGroupId() ) + && dmDep.getArtifactId().equals( dep.getArtifactId() ) + && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) + && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) + && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() + .equals( dep.getVersion() ) ); + } + + protected boolean hasDependencyManagement( MavenProject project ) + { + if ( project == null ) + { + return false; + } + return project.getDependencyManagement() != null + && project.getDependencyManagement().getDependencies() != null; + } + + /** + * {@inheritDoc} + */ + public String getOutputName() + { + return "dependency-updates-report"; + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java new file mode 100644 index 0000000000..36ed84d9f0 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java @@ -0,0 +1,249 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.api.PluginUpdatesDetails; +import org.codehaus.mojo.versions.api.VersionRetrievalException; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; +import org.codehaus.mojo.versions.utils.PluginComparator; +import org.codehaus.mojo.versions.xml.PluginUpdatesXmlReportRenderer; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates a report of available updates for the plugins of a project. + */ + +public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsReport +{ + + private static final PluginComparator PLUGIN_COMPARATOR = PluginComparator.INSTANCE; + + /** + * Report formats (html and/or xml). HTML by default. + */ + @Parameter( property = "pluginUpdatesReportFormats", defaultValue = "html" ) + private String[] formats = new String[] { "html" }; + + /** + * If true, only shows the subsection of the pluginManagement artifacts that + * are actually used in the project's plugin graph. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyProjectPlugins", defaultValue = "false" ) + protected boolean onlyProjectPlugins; + + /** + * If true, only shows upgradable plugins in the report. false by default. + * + * @since 2.12 + */ + @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + protected boolean onlyUpgradable; + + public AbstractPluginUpdatesReportMojo( I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + /** + * {@inheritDoc} + */ + public boolean isExternalReport() + { + return false; + } + + /** + * {@inheritDoc} + */ + public boolean canGenerateReport() + { + return haveBuildPlugins( getProject() ) || haveBuildPluginManagementPlugins( getProject() ); + } + + protected boolean haveBuildPluginManagementPlugins( MavenProject project ) + { + return project.getBuild() != null && project.getBuild().getPluginManagement() != null + && project.getBuild().getPluginManagement().getPlugins() != null && !project.getBuild() + .getPluginManagement().getPlugins().isEmpty(); + } + + protected boolean haveBuildPlugins( MavenProject project ) + { + return project.getBuild() != null && project.getBuild().getPlugins() != null + && !project.getBuild().getPlugins().isEmpty(); + } + + /** + * generates an empty report in case there are no sources to generate a report with + * + * @param locale the locale to generate the report for. + * @param sink the report formatting tool + */ + protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException + { + + Set pluginManagement = getPluginManagement(); + + Set plugins = getPlugins(); + + handleOnlyProjectPlugins( pluginManagement, plugins ); + + try + { + + Map pluginUpdates = + getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); + Map pluginManagementUpdates = + getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); + + if ( onlyUpgradable ) + { + pluginUpdates = filter( pluginUpdates, p -> p.getVersions().length > 0 ); + pluginManagementUpdates = filter( pluginManagementUpdates, p -> p.getVersions().length > 0 ); + } + + renderReport( locale, sink, new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ) ); + } + catch ( VersionRetrievalException e ) + { + throw new MavenReportException( e.getMessage(), e ); + } + } + + /** + * Constructs a instance of a {@link Set} with a {@link PluginComparator} comparator. This set can be + * further populated by implementations and should contain plugins, that are present in projects pluginManagement + * section. + * + * @return a {@link Set} that can be additionally populated by {@link #populatePluginManagement(Set)}}. + * If not, an empty set is returned + * */ + private Set getPluginManagement() + { + final Set pluginManagementCollector = new TreeSet<>( PLUGIN_COMPARATOR ); + populatePluginManagement( pluginManagementCollector ); + return pluginManagementCollector; + } + + /** + * Implementations of {@link AbstractPluginUpdatesReportMojo} may use this to supply the main processing logic + * with desired pluginManagement data, which will be used in the creation of the report. + * + * @param pluginManagementCollector, a set initialized with a {@link PluginComparator} comparator. + * */ + protected abstract void populatePluginManagement( Set pluginManagementCollector ); + + + /** + * Constructs a final instance of a {@link Set} with a {@link PluginComparator} comparator. This set can be + * further populated by implementations, and should contain plugins, that are present in projects build section. + * + * @return a {@link Set} that can be additionally populated by {@link #populatePlugins(Set)}. + * If not, an empty set is returned + * */ + private Set getPlugins() + { + final Set pluginsCollector = new TreeSet<>( PLUGIN_COMPARATOR ); + populatePlugins( pluginsCollector ); + return pluginsCollector; + } + + /** + * Implementations of {@link AbstractPluginUpdatesReportMojo} may use this to supply the main processing logic + * with desired build plugin information, which will be used to create the report. + * + *@param pluginsCollector, a set initialized with a {@link PluginComparator} comparator. + * */ + protected abstract void populatePlugins( Set pluginsCollector ); + + private void renderReport( Locale locale, Sink sink, PluginUpdatesModel model ) + throws MavenReportException + { + for ( String format : formats ) + { + if ( "html".equals( format ) ) + { + rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); + } + else if ( "xml".equals( format ) ) + { + Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); + if ( !Files.exists( outputDir ) ) + { + try + { + Files.createDirectories( outputDir ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Could not create the output directory" ); + } + } + Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); + new PluginUpdatesXmlReportRenderer( model, outputFile ).render(); + } + } + } + + private void handleOnlyProjectPlugins( Set pluginManagement, Set plugins ) + { + + if ( !onlyProjectPlugins ) + { + // Retains only plugins not present in pluginManagement + plugins.removeIf( plugin -> pluginManagement.stream() + .anyMatch( pmPlugin -> PLUGIN_COMPARATOR.compare( plugin, pmPlugin ) == 0 ) ); + } + else + { + // Retain only plugins in pluginManagement that are also present in plugins + pluginManagement.removeIf( + pmPlugin -> plugins.stream() + .noneMatch( plugin -> PLUGIN_COMPARATOR.compare( plugin, pmPlugin ) == 0 ) ); + } + } + + /** + * {@inheritDoc} + */ + public abstract String getOutputName(); +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java new file mode 100644 index 0000000000..0380369d03 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java @@ -0,0 +1,218 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; +import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.api.Property; +import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.VersionsHelper.VersionPropertiesMapRequest; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; +import org.codehaus.mojo.versions.utils.PropertyComparator; +import org.codehaus.mojo.versions.xml.PropertyUpdatesXmlReportRenderer; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates a report of available updates for properties of a project which are linked to the dependencies and/or + * plugins of a project. + */ +public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersionsReport +{ + + + private static final PropertyComparator PROPERTIES_COMPARATOR = PropertyComparator.INSTANCE; + + /** + * Any restrictions that apply to specific properties. + * + * @since 1.0-beta-1 + */ + @Parameter + private Property[] properties; + + /** + * A comma separated list of properties to include in the report. + * + * @since 1.0-beta-1 + */ + @Parameter( property = "includeProperties" ) + private String includeProperties = null; + + /** + * A comma separated list of properties to not include in the report. + * + * @since 1.0-beta-1 + */ + @Parameter( property = "excludeProperties" ) + private String excludeProperties = null; + + /** + * Whether properties linking versions should be auto-detected or not. + * + * @since 1.0-beta-1 + */ + @Parameter( property = "autoLinkItems", defaultValue = "true" ) + private boolean autoLinkItems; + + /** + *

    Whether to include property updates from parent.

    + * + * @since 2.14.0 + */ + @Parameter( property = "includeParent", defaultValue = "true" ) + private boolean includeParent = true; + + /** + * Report formats (html and/or xml). HTML by default. + * + * @since 2.14.0 + */ + @Parameter( property = "propertyUpdatesReportFormats", defaultValue = "html" ) + protected String[] formats = new String[] {"html"}; + + public AbstractPropertyUpdatesReportMojo( I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + /** + * {@inheritDoc} + */ + public boolean isExternalReport() + { + return false; + } + + /** + * {@inheritDoc} + */ + public boolean canGenerateReport() + { + return haveBuildProperties(); + } + + protected boolean haveBuildProperties() + { + return getProject().getProperties() != null && !getProject().getProperties().isEmpty(); + } + + protected void doGenerateReport( Locale locale, Sink sink ) + throws MavenReportException + { + try + { + final Map updateSet = new TreeMap<>( PROPERTIES_COMPARATOR ); + populateUpdateSet( updateSet ); + + renderReport( locale, + sink, + getPropertyUpdatesModel( updateSet ) ); + } + catch ( MojoExecutionException e ) + { + throw new MavenReportException( e.getMessage(), e ); + } + + } + + /** + * Method used to supply {@link PropertyUpdatesModel} with data about updated properties. + * + * @param propertyCollector map for collecting properties in implementations + * + * @throws MavenReportException when things go wrong. + * @throws MojoExecutionException if something goes wrong. + * */ + protected abstract void populateUpdateSet( + Map propertyCollector ) + throws MojoExecutionException, MavenReportException; + + + private void renderReport( Locale locale, Sink sink, PropertyUpdatesModel propertyUpdatesModel ) + throws MavenReportException + { + + for ( String format : this.formats ) + { + if ( "html".equals( format ) ) + { + this.rendererFactory.createReportRenderer( getOutputName(), sink, locale, propertyUpdatesModel ) + .render(); + } + else if ( "xml".equals( format ) ) + { + Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); + if ( !Files.exists( outputDir ) ) + { + try + { + Files.createDirectories( outputDir ); + } + catch ( IOException e ) + { + throw new MavenReportException( "Could not create the output directory" ); + } + } + Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); + new PropertyUpdatesXmlReportRenderer( propertyUpdatesModel, outputFile ).render(); + } + } + } + + private PropertyUpdatesModel getPropertyUpdatesModel( Map updateSet ) + { + return new PropertyUpdatesModel( PROPERTIES_COMPARATOR, updateSet ); + } + + protected VersionPropertiesMapRequest getRequest( MavenProject project ) + { + return VersionPropertiesMapRequest.builder() + .withMavenProject( project ) + .withPropertyDefinitions( this.properties ) + .withIncludeProperties( this.includeProperties ) + .withExcludeProperties( this.excludeProperties ) + .withIncludeParent( this.includeParent ) + .withAutoLinkItems( this.autoLinkItems ) + .build(); + } + + /** + * {@inheritDoc} + */ + public String getOutputName() + { + return "property-updates-report"; + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index 92021ba27d..c97b653ce4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -537,6 +537,7 @@ else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.ge * Configure and return the change recorder. * * @return The change recorder + * @throws MojoExecutionException if something goes wrong. */ protected ChangeRecorder getChangeRecorder() throws MojoExecutionException { @@ -553,6 +554,7 @@ protected ChangeRecorder getChangeRecorder() throws MojoExecutionException * Save all of the changes recorded by the change recorder. * * @throws IOException On I/O errors + * @throws MojoExecutionException if something goes wrong. */ protected void saveChangeRecorderResults() throws IOException, MojoExecutionException diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java new file mode 100644 index 0000000000..63b07f8513 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java @@ -0,0 +1,92 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +import java.util.Map; +import java.util.Set; +import javax.inject.Inject; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.util.AggregateReportUtils; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates an aggregate report of available updates for the dependencies of a project. + * + * @since 2.14.0 + */ +@Mojo( name = "dependency-updates-aggregate-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true, aggregator = true ) +public class DependencyUpdatesAggregateReportMojo extends AbstractDependencyUpdatesReportMojo +{ + + @Inject + protected DependencyUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + /** + * {@inheritDoc} + * */ + @Override + protected void populateDependencies( Set dependenciesCollector ) + { + getLog().debug( String.format( "Collecting dependencies for project %s", + project.getName() ) ); + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + dependenciesCollector.addAll( project.getDependencies() ); + } + } + + /** + * {@inheritDoc} + * */ + @Override + protected void populateDependencyManagement( Set dependencyManagementCollector, + Set dependencies ) throws MavenReportException + { + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + getLog().debug( String.format( "Collecting managed dependencies for project %s", + project.getName() ) ); + handleDependencyManagementTransitive( project, dependencyManagementCollector ); + } + } + + /** + * {@inheritDoc} + */ + @Override + public String getOutputName() + { + return "dependency-updates-aggregate-report"; + } + +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 8eb146ea6a..711086ccb8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -19,40 +19,18 @@ * under the License. */ -import javax.inject.Inject; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.doxia.sink.Sink; +import javax.inject.Inject; import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; -import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; -import org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel; -import org.codehaus.mojo.versions.utils.DependencyComparator; -import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; -import static java.util.Collections.emptyMap; -import static org.codehaus.mojo.versions.utils.MavenProjectUtils.interpolateVersion; -import static org.codehaus.mojo.versions.utils.MiscUtils.filter; - /** * Generates a report of available updates for the dependencies of a project. * @@ -61,53 +39,9 @@ */ @Mojo( name = "dependency-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class DependencyUpdatesReportMojo extends AbstractVersionsReport +public class DependencyUpdatesReportMojo extends AbstractDependencyUpdatesReportMojo { - /** - * Whether to process the dependencyManagement in pom or not. - * - * @since 2.5 - */ - @Parameter( property = "processDependencyManagement", defaultValue = "true" ) - protected boolean processDependencyManagement; - - /** - * Whether to process the dependencyManagement part transitive or not. - * In case of <type>pom</type>and - * <scope>import</scope> this means - * by default to report also the imported dependencies. - * If processTransitive is set to false the report will only show - * updates of the imported pom itself. - * - * @since 2.5 Note: Currently in experimental state. - */ - @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) - protected boolean processDependencyManagementTransitive; - - /** - * Report formats (html and/or xml). HTML by default. - */ - @Parameter( property = "dependencyUpdatesReportFormats", defaultValue = "html" ) - protected String[] formats = new String[] {"html"}; - - /** - * If true, only shows the subsection of the dependencyManagement artifacts that - * are actually used in the project's dependency graph. false by default. - * - * @since 2.12 - */ - @Parameter( property = "onlyProjectDependencies", defaultValue = "false" ) - protected boolean onlyProjectDependencies; - - /** - * If true, only shows upgradable dependencies in the report. false by default. - * - * @since 2.12 - */ - @Parameter( property = "onlyUpgradable", defaultValue = "false" ) - protected boolean onlyUpgradable; - @Inject protected DependencyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystem aetherRepositorySystem, @@ -119,157 +53,30 @@ protected DependencyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySys /** * {@inheritDoc} - */ - public boolean isExternalReport() + * */ + @Override + protected void populateDependencies( Set dependenciesCollector ) { - return false; + getLog().debug( String.format( "Collecting dependencies for project %s", + getProject().getName() ) ); + dependenciesCollector.addAll( getProject().getDependencies() ); } /** * {@inheritDoc} - */ - public boolean canGenerateReport() + * */ + @Override + protected void populateDependencyManagement( Set dependencyManagementCollector, + Set dependencies ) throws MavenReportException { - return true; - } - - /** - * generates an empty report in case there are no sources to generate a report with - * - * @param locale the locale to generate the report for. - * @param sink the report formatting tool - */ - @SuppressWarnings( "deprecation" ) - protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException - { - Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); - dependencies.addAll( getProject().getDependencies() ); - - Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); - - if ( processDependencyManagement ) + if ( hasDependencyManagement( getProject() ) ) { - if ( processDependencyManagementTransitive ) - { - if ( getProject().getDependencyManagement() != null - && getProject().getDependencyManagement().getDependencies() != null ) - { - for ( Dependency dep : getProject().getDependencyManagement().getDependencies() ) - { - getLog().debug( - "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" - + dep.getType() + ":" + dep.getScope() ); - } - dependencyManagement.addAll( getProject().getDependencyManagement().getDependencies() ); - } - } - else - { - if ( getProject().getOriginalModel().getDependencyManagement() != null - && getProject().getOriginalModel().getDependencyManagement().getDependencies() != null ) - { - // Using the original model to get the original dependencyManagement entries and - // not the interpolated model. - // TODO: I'm not 100% sure if this will work correctly in all cases. - for ( Dependency dep : getProject().getOriginalModel().getDependencyManagement().getDependencies() ) - { - dep = interpolateVersion( dep, getProject() ); - - getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" - + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); - } - dependencyManagement.addAll( - getProject().getOriginalModel().getDependencyManagement().getDependencies() ); - } - } - - if ( !onlyProjectDependencies ) - { - // Retains only dependencies not present in dependencyManagement - dependencies.removeIf( dep -> dependencyManagement.stream().anyMatch( dmDep -> match( dep, dmDep ) ) ); - } - else - { - // Retain only dependencies in dependencyManagement that are also present in dependencies - dependencyManagement.removeIf( dep -> dependencies.stream().noneMatch( dmDep -> match( dep, dmDep ) ) ); - } - } - - try - { - Map dependencyUpdates = - getHelper().lookupDependenciesUpdates( dependencies, false ); - - Map dependencyManagementUpdates = - processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) - : emptyMap(); - - if ( onlyUpgradable ) - { - dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 0 ); - dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 0 ); - } - - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Dependency versions:" ); - dependencyUpdates.forEach( ( key, value ) -> getLog().debug( key.toString() + ": " - + Arrays.stream( value.getVersions() ).map( ArtifactVersion::toString ) - .collect( Collectors.joining( ", " ) ) ) ); - - getLog().debug( "Dependency management versions:" ); - dependencyManagementUpdates.forEach( ( key, value ) -> getLog().debug( key.toString() + ": " - + Arrays.stream( value.getVersions() ).map( ArtifactVersion::toString ) - .collect( Collectors.joining( ", " ) ) ) ); - } - - DependencyUpdatesModel model = new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); - for ( String format : formats ) - { - if ( "html".equals( format ) ) - { - rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); - } - } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new DependencyUpdatesXmlReportRenderer( model, outputFile ).render(); - } - } - } - catch ( VersionRetrievalException e ) - { - throw new MavenReportException( e.getMessage(), e ); + getLog().debug( String.format( "Collecting managed dependencies for project %s", + getProject().getName() ) ); + handleDependencyManagementTransitive( getProject(), dependencyManagementCollector ); } } - /** - * Compares two dependencies with each other - * - * @return true if the two dependencies match - */ - private boolean match( Dependency dep, Dependency dmDep ) - { - return dmDep.getGroupId().equals( dep.getGroupId() ) - && dmDep.getArtifactId().equals( dep.getArtifactId() ) - && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) - && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) - && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() - .equals( dep.getVersion() ) ); - } - /** * {@inheritDoc} */ @@ -278,4 +85,3 @@ public String getOutputName() return "dependency-updates-report"; } } - diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java new file mode 100644 index 0000000000..f9305383b5 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java @@ -0,0 +1,88 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +import java.util.Map; +import java.util.Set; +import javax.inject.Inject; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.util.AggregateReportUtils; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates an aggregated report of available updates for the plugins of a project. + * + * @since 2.14.0 + */ +@Mojo( name = "plugin-updates-aggregate-report", requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true, aggregator = true ) +public class PluginUpdatesAggregateReportMojo extends AbstractPluginUpdatesReportMojo +{ + + @Inject + protected PluginUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + @Override + protected void populatePluginManagement( Set pluginManagementCollector ) + { + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + if ( haveBuildPluginManagementPlugins( project ) ) + { + pluginManagementCollector.addAll( project.getBuild().getPluginManagement().getPlugins() ); + } + } + } + + /** + * {@inheritDoc} + * */ + @Override + protected void populatePlugins( Set pluginsCollector ) + { + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + if ( haveBuildPluginManagementPlugins( project ) ) + { + pluginsCollector.addAll( project.getBuild().getPlugins() ); + } + } + } + + /** + * {@inheritDoc} + */ + public String getOutputName() + { + return "plugin-updates-aggregate-report"; + } + +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 7c64b14c89..8eec073c5b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -19,35 +19,17 @@ * under the License. */ -import javax.inject.Inject; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.TreeSet; - -import org.apache.maven.doxia.sink.Sink; +import javax.inject.Inject; import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; -import org.codehaus.mojo.versions.api.PluginUpdatesDetails; -import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; -import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; -import org.codehaus.mojo.versions.utils.PluginComparator; -import org.codehaus.mojo.versions.xml.PluginUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; -import static org.codehaus.mojo.versions.utils.MiscUtils.filter; - /** * Generates a report of available updates for the plugins of a project. * @@ -56,32 +38,9 @@ */ @Mojo( name = "plugin-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class PluginUpdatesReportMojo extends AbstractVersionsReport +public class PluginUpdatesReportMojo extends AbstractPluginUpdatesReportMojo { - /** - * Report formats (html and/or xml). HTML by default. - */ - @Parameter( property = "pluginUpdatesReportFormats", defaultValue = "html" ) - private String[] formats = new String[] { "html" }; - - /** - * If true, only shows the subsection of the pluginManagement artifacts that - * are actually used in the project's plugin graph. false by default. - * - * @since 2.12 - */ - @Parameter( property = "onlyProjectPlugins", defaultValue = "false" ) - protected boolean onlyProjectPlugins; - - /** - * If true, only shows upgradable plugins in the report. false by default. - * - * @since 2.12 - */ - @Parameter( property = "onlyUpgradable", defaultValue = "false" ) - protected boolean onlyUpgradable; - @Inject protected PluginUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, @@ -94,109 +53,25 @@ protected PluginUpdatesReportMojo( I18N i18n, /** * {@inheritDoc} - */ - public boolean isExternalReport() + * */ + @Override + protected void populatePluginManagement( Set pluginManagementCollector ) { - return false; + if ( haveBuildPluginManagementPlugins( getProject() ) ) + { + pluginManagementCollector.addAll( getProject().getBuild().getPluginManagement().getPlugins() ); + } } /** * {@inheritDoc} - */ - public boolean canGenerateReport() + * */ + @Override + protected void populatePlugins( Set pluginsCollector ) { - return haveBuildPlugins() || haveBuildPluginManagementPlugins(); - } - - private boolean haveBuildPluginManagementPlugins() - { - return getProject().getBuild() != null && getProject().getBuild().getPluginManagement() != null - && getProject().getBuild().getPluginManagement().getPlugins() != null && !getProject().getBuild() - .getPluginManagement().getPlugins().isEmpty(); - } - - private boolean haveBuildPlugins() - { - return getProject().getBuild() != null && getProject().getBuild().getPlugins() != null - && !getProject().getBuild().getPlugins().isEmpty(); - } - - /** - * generates an empty report in case there are no sources to generate a report with - * - * @param locale the locale to generate the report for. - * @param sink the report formatting tool - */ - protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException - { - Set pluginManagement = new TreeSet<>( PluginComparator.INSTANCE ); - if ( haveBuildPluginManagementPlugins() ) - { - pluginManagement.addAll( getProject().getBuild().getPluginManagement().getPlugins() ); - } - - Set plugins = new TreeSet<>( PluginComparator.INSTANCE ); - if ( haveBuildPlugins() ) - { - plugins.addAll( getProject().getBuild().getPlugins() ); - } - - PluginComparator comparator = PluginComparator.INSTANCE; - if ( !onlyProjectPlugins ) - { - // Retains only plugins not present in pluginManagement - plugins.removeIf( plugin -> pluginManagement.stream() - .anyMatch( pmPlugin -> comparator.compare( plugin, pmPlugin ) == 0 ) ); - } - else + if ( haveBuildPlugins( getProject() ) ) { - // Retain only plugins in pluginManagement that are also present in plugins - pluginManagement.removeIf( - pmPlugin -> plugins.stream().noneMatch( plugin -> comparator.compare( plugin, pmPlugin ) == 0 ) ); - } - - try - { - Map pluginUpdates = - getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); - Map pluginManagementUpdates = - getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); - - if ( onlyUpgradable ) - { - pluginUpdates = filter( pluginUpdates, p -> p.getVersions().length > 0 ); - pluginManagementUpdates = filter( pluginManagementUpdates, p -> p.getVersions().length > 0 ); - } - - PluginUpdatesModel model = new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ); - for ( String format : formats ) - { - if ( "html".equals( format ) ) - { - rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model ).render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); - } - } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new PluginUpdatesXmlReportRenderer( model, outputFile ).render(); - } - } - } - catch ( VersionRetrievalException e ) - { - throw new MavenReportException( e.getMessage(), e ); + pluginsCollector.addAll( getProject().getBuild().getPlugins() ); } } @@ -208,4 +83,3 @@ public String getOutputName() return "plugin-updates-report"; } } - diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java new file mode 100644 index 0000000000..fdb022f74e --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java @@ -0,0 +1,95 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +import java.util.Map; +import javax.inject.Inject; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.MavenReportException; +import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.wagon.Wagon; +import org.codehaus.mojo.versions.api.Property; +import org.codehaus.mojo.versions.api.PropertyVersions; +import org.codehaus.mojo.versions.api.VersionsHelper; +import org.codehaus.mojo.versions.reporting.ReportRendererFactory; +import org.codehaus.mojo.versions.reporting.util.AggregateReportUtils; +import org.codehaus.plexus.i18n.I18N; + +/** + * Generates an aggregate report of available updates for properties of a project which are linked to the dependencies + * and/or plugins of a project. + * + * @since 2.14.0 + */ +@Mojo( name = "property-updates-aggregate-report", requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true, aggregator = true ) +public class PropertyUpdatesAggregateReportMojo extends AbstractPropertyUpdatesReportMojo +{ + + @Inject + protected PropertyUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory ) + { + super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + } + + /** + * {@inheritDoc} + * */ + @Override + protected void populateUpdateSet( Map propertyCollector ) + throws MojoExecutionException, MavenReportException + { + VersionsHelper helper = getHelper(); + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + propertyCollector.putAll( helper.getVersionPropertiesMap( getRequest( project ) ) ); + } + } + + /** + * {@inheritDoc} + * */ + @Override + protected boolean haveBuildProperties() + { + for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) + { + if ( project.getProperties() != null && !project.getProperties().isEmpty() ) + { + return true; + } + } + + return false; + } + + /** + * {@inheritDoc} + */ + public String getOutputName() + { + return "property-updates-aggregate-report"; + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 8dd941dff4..8b6abe85be 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -19,31 +19,17 @@ * under the License. */ -import javax.inject.Inject; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Locale; import java.util.Map; -import java.util.TreeMap; - -import org.apache.maven.doxia.sink.Sink; +import javax.inject.Inject; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; -import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; -import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; -import org.codehaus.mojo.versions.utils.PropertyComparator; -import org.codehaus.mojo.versions.xml.PropertyUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; /** @@ -55,56 +41,8 @@ */ @Mojo( name = "property-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class PropertyUpdatesReportMojo extends AbstractVersionsReport +public class PropertyUpdatesReportMojo extends AbstractPropertyUpdatesReportMojo { - /** - * Any restrictions that apply to specific properties. - * - * @since 1.0-beta-1 - */ - @Parameter - private Property[] properties; - - /** - * A comma separated list of properties to include in the report. - * - * @since 1.0-beta-1 - */ - @Parameter( property = "includeProperties" ) - private String includeProperties = null; - - /** - * A comma separated list of properties to not include in the report. - * - * @since 1.0-beta-1 - */ - @Parameter( property = "excludeProperties" ) - private String excludeProperties = null; - - /** - * Whether properties linking versions should be auto-detected or not. - * - * @since 1.0-beta-1 - */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) - private boolean autoLinkItems; - - /** - *

    Whether to include property updates from parent. Default: {@code false}

    - * - * @since 2.14.0 - */ - @Parameter( property = "includeParent", defaultValue = "false" ) - private boolean includeParent = true; - - /** - * Report formats (html and/or xml). HTML by default. - * - * @since 2.14.0 - */ - @Parameter( property = "propertyUpdatesReportFormats", defaultValue = "html" ) - protected String[] formats = new String[] {"html"}; - @Inject protected PropertyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, @@ -118,68 +56,11 @@ protected PropertyUpdatesReportMojo( I18N i18n, /** * {@inheritDoc} */ - public boolean isExternalReport() + @Override + protected void populateUpdateSet( Map propertyCollector ) + throws MojoExecutionException, MavenReportException { - return false; - } - - /** - * {@inheritDoc} - */ - public boolean canGenerateReport() - { - return haveBuildProperties(); - } - - private boolean haveBuildProperties() - { - return getProject().getProperties() != null && !getProject().getProperties().isEmpty(); - } - - protected void doGenerateReport( Locale locale, Sink sink ) - throws MavenReportException - { - final Map updateSet = new TreeMap<>( PropertyComparator.INSTANCE ); - try - { - updateSet.putAll( getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( properties ) - .withIncludeProperties( includeProperties ) - .withExcludeProperties( excludeProperties ) - .withIncludeParent( includeParent ) - .withAutoLinkItems( autoLinkItems ) - .build() ) ); - } - catch ( MojoExecutionException e ) - { - throw new MavenReportException( e.getMessage(), e ); - } - PropertyUpdatesModel model = new PropertyUpdatesModel( updateSet ); - for ( String format : formats ) - { - if ( "html".equals( format ) ) - { - rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model ).render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); - } - } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new PropertyUpdatesXmlReportRenderer( model, outputFile ).render(); - } - } + propertyCollector.putAll( getHelper().getVersionPropertiesMap( getRequest( getProject() ) ) ); } /** @@ -190,4 +71,3 @@ public String getOutputName() return "property-updates-report"; } } - diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 2b95c0f1e1..1b76bd9e0c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -67,6 +67,7 @@ public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, * @param changeKind title for the change recorder records * @param filters optional array of filters * @throws XMLStreamException thrown if the POM update doesn't succeed + * @throws MojoExecutionException if something goes wrong. * @throws VersionRetrievalException thrown if an artifact versions cannot be retrieved */ @SafeVarargs diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java index d1344a811c..e66a1ad422 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java @@ -41,8 +41,11 @@ public class ReportRendererFactoryImpl implements ReportRendererFactory { public static final String DEPENDENCY_UPDATES_REPORT = "dependency-updates-report"; + public static final String DEPENDENCY_UPDATES_AGGREGATE_REPORT = "dependency-updates-aggregate-report"; public static final String PLUGIN_UPDATES_REPORT = "plugin-updates-report"; + public static final String PLUGIN_UPDATES_AGGREGATE_REPORT = "plugin-updates-aggregate-report"; public static final String PROPERTY_UPDATES_REPORT = "property-updates-report"; + public static final String PROPERTY_UPDATES_AGGREGATE_REPORT = "property-updates-aggregate-report"; public static final String PARENT_UPDATES_REPORT = "parent-updates-report"; private final I18N i18N; @@ -60,17 +63,18 @@ public ReportRendererFactoryImpl( I18N i18N ) public T createReportRenderer( String reportName, Sink sink, Locale locale, U model ) throws IllegalArgumentException { - if ( DEPENDENCY_UPDATES_REPORT.equals( reportName ) ) + if ( DEPENDENCY_UPDATES_REPORT.equals( reportName ) + || DEPENDENCY_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) { return (T) new DependencyUpdatesReportRenderer<>( i18N, sink, locale, reportName, (DependencyUpdatesModel) model ); } - if ( PLUGIN_UPDATES_REPORT.equals( reportName ) ) + if ( PLUGIN_UPDATES_REPORT.equals( reportName ) || PLUGIN_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) { return (T) new PluginUpdatesReportRenderer( i18N, sink, locale, reportName, (PluginUpdatesModel) model ); } - if ( PROPERTY_UPDATES_REPORT.equals( reportName ) ) + if ( PROPERTY_UPDATES_REPORT.equals( reportName ) || PROPERTY_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) { return (T) new PropertyUpdatesReportRenderer( i18N, sink, locale, reportName, (PropertyUpdatesModel) model ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java index c2a6aa4606..44058e6982 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java @@ -21,7 +21,6 @@ import java.util.Map; import java.util.TreeMap; - import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.utils.PropertyComparator; @@ -33,9 +32,9 @@ public class PropertyUpdatesModel { private final Map allUpdates; - public PropertyUpdatesModel( Map propertyUpdates ) + public PropertyUpdatesModel( PropertyComparator comparator, Map propertyUpdates ) { - this.allUpdates = new TreeMap<>( PropertyComparator.INSTANCE ); + this.allUpdates = new TreeMap<>( comparator ); this.allUpdates.putAll( propertyUpdates ); } @@ -43,4 +42,5 @@ public Map getAllUpdates() { return allUpdates; } + } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java new file mode 100644 index 0000000000..12ff25b558 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java @@ -0,0 +1,53 @@ +package org.codehaus.mojo.versions.reporting.util; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.apache.maven.project.MavenProject; + +/** + * Class that contains common aggregate operations + * + * @since 2.14.0 + * */ +public class AggregateReportUtils +{ + + /** + * Returns an aggregated list of {@link MavenProject} for the given project. + * + * @param project to aggregate + * + * @return aggregated list of MavenProject objects for the given project(also containing the project itself) + * */ + public static List getProjectsToProcess( final MavenProject project ) + { + if ( project == null ) + { + return Collections.emptyList(); + } + + List result = new ArrayList<>(); + result.add( project ); + result.addAll( project.getCollectedProjects() ); + return result; + } + +} diff --git a/versions-maven-plugin/src/main/resources/dependency-updates-aggregate-report.properties b/versions-maven-plugin/src/main/resources/dependency-updates-aggregate-report.properties new file mode 100644 index 0000000000..5043fdd823 --- /dev/null +++ b/versions-maven-plugin/src/main/resources/dependency-updates-aggregate-report.properties @@ -0,0 +1,55 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.title=Dependency Updates Aggregate Report +report.description=Provides aggregated details of the dependencies which have updated versions available. +report.overview.title=Overview +report.overview.text=This report summarizes newer versions that may be available for your project's various \ + dependencies. +report.overview.dependencyManagement=Dependency Management +report.overview.noDependencyManagement=This project does not declare any dependencies in a dependencyManagement section. +report.overview.dependency=Dependencies +report.overview.noDependency=This project does not declare any dependencies. +report.overview.numUpToDate=# of dependencies using the latest version available +report.overview.numNewerMajorAvailable=# of dependencies where the next version available is a major version update +report.overview.numNewerMinorAvailable=# of dependencies where the next version available is a minor version update +report.overview.numNewerIncrementalAvailable=# of dependencies where the next version available is an incremental \ + version update +report.overview.numNewerVersionAvailable=# of dependencies where the next version available is smaller than an \ + incremental version update +report.detail.title=Dependency Updates +report.detail.text= +report.status=Status +report.groupId=Group Id +report.artifactId=Artifact Id +report.currentVersion=Current Version +report.scope=Scope +report.classifier=Classifier +report.type=Type +report.latestSubIncremental=Latest Subincremental +report.latestIncremental=Latest Incremental +report.latestMinor=Latest Minor +report.latestMajor=Latest Major +report.updateVersions=Newer versions +report.noUpdatesAvailable=No newer versions available. +report.otherUpdatesAvailable=There is at least one newer version available. +report.incrementalUpdatesAvailable=There is at least one newer incremental version available. \ + Incremental updates are typically passive. +report.minorUpdatesAvailable=There is at least one newer minor version available. \ + Minor updates are sometimes passive. +report.majorUpdatesAvailable=There is at least one newer major version available. \ + Major updates are rarely passive. diff --git a/versions-maven-plugin/src/main/resources/plugin-updates-aggregate-report.properties b/versions-maven-plugin/src/main/resources/plugin-updates-aggregate-report.properties new file mode 100644 index 0000000000..9d47f004b7 --- /dev/null +++ b/versions-maven-plugin/src/main/resources/plugin-updates-aggregate-report.properties @@ -0,0 +1,63 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.title=Plugin Updates Aggregate Report +report.description=Provides aggregated details of the plugins used by this project which have newer versions available. +report.overview.title=Overview +report.overview.text=This report summarizes newer versions that may be available for your project's various \ + plugins. +report.overview.pluginManagement=Plugin Management +report.overview.noPluginManagement=This project does not declare any plugins in a build/pluginManagement section. +report.overview.plugin=Plugins +report.overview.noPlugin=This project does not declare any plugins in a build/plugins section. +report.overview.numUpToDate=# of plugins using the latest version available +report.overview.numNewerMajorAvailable=# of plugins where the next version available is a major version update +report.overview.numNewerMinorAvailable=# of plugins where the next version available is a minor version update +report.overview.numNewerIncrementalAvailable=# of plugins where the next version available is an incremental \ + version update +report.overview.numNewerVersionAvailable=# of plugins where the next version available is smaller than an \ + incremental version update +report.overview.numNewerDependenciesAvailable=# of plugins where a dependencies section containes a dependency \ + with an updated version +report.detail.title=Plugin Updates +report.detail.text= +report.status=Status +report.groupId=Group Id +report.artifactId=Artifact Id +report.currentVersion=Current Version +report.scope=Scope +report.classifier=Classifier +report.type=Type +report.latestSubIncremental=Latest Subincremental +report.latestIncremental=Latest Incremental +report.latestMinor=Latest Minor +report.latestMajor=Latest Major +report.dependencyStatus=Dependency status +report.updateVersions=Newer versions +report.noUpdatesAvailable=No newer versions available. +report.otherUpdatesAvailable=There is at least one newer version available. +report.incrementalUpdatesAvailable=There is at least one newer incremental version available. \ + Incremental updates are typically passive. +report.minorUpdatesAvailable=There is at least one newer minor version available. \ + Minor updates are sometimes passive. +report.majorUpdatesAvailable=There is at least one newer major version available. \ + Major updates are rarely passive. +report.yes=Y +report.no=N +report.pluginDependencies=Dependencies of {0} +report.pluginDependency=Dependency {0} +report.plugin=Plugin {0} diff --git a/versions-maven-plugin/src/main/resources/property-updates-aggregate-report.properties b/versions-maven-plugin/src/main/resources/property-updates-aggregate-report.properties new file mode 100644 index 0000000000..2a81c60c51 --- /dev/null +++ b/versions-maven-plugin/src/main/resources/property-updates-aggregate-report.properties @@ -0,0 +1,61 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +report.title=Property Updates Aggregate Report +report.description=Provides aggregated details of properties which control versions of dependencies and/or plugins, \ + and indicates any newer versions which are available. +report.overview.title=Overview +report.overview.text=This report summarizes newer versions that may be available for your project's various \ + properties associated with artifacts. +report.overview.dependency=Properties +report.overview.noDependency=This project does not declare any properties associated with artifact versions. +report.overview.numUpToDate=# of properties using the latest version available +report.overview.numNewerMajorAvailable=# of properties where the next version available is a major version update +report.overview.numNewerMinorAvailable=# of properties where the next version available is a minor version update +report.overview.numNewerIncrementalAvailable=# of properties where the next version available is an incremental \ + version update +report.overview.numNewerVersionAvailable=# of properties where the next version available is smaller than an \ + incremental version update +report.overview.property=Summary of properties associated with artifact versions +report.overview.noProperty=No properties associated with artifacts have been defined. +report.detail.title=Properties associated with artifact versions +report.detail.text= +report.status=Status +report.property=Property +report.currentVersion=Current Version +report.latestSubIncremental=Latest Subincremental +report.latestIncremental=Latest Incremental +report.latestMinor=Latest Minor +report.latestMajor=Latest Major +report.updateVersions=Newer versions +report.noUpdatesAvailable=No newer versions available. +report.otherUpdatesAvailable=There is at least one newer version available. +report.incrementalUpdatesAvailable=There is at least one newer incremental version available. \ + Incremental updates are typically passive. +report.minorUpdatesAvailable=There is at least one newer minor version available. \ + Minor updates are sometimes passive. +report.majorUpdatesAvailable=There is at least one newer major version available. \ + Major updates are rarely passive. +report.yes=Yes +report.no=No +report.versionRange=Allowed version range +report.autoLinkDependencies=Infer associations from project +report.banSnapshots=Only use release versions +report.searchReactor=Include projects from reactor +report.preferReactor=Always use reactor projects (even if older or -SNAPSHOT) +report.associations=Associated artifacts +report.excludedVersion=Outside allowed version range From cf0453dd35046b3f2524ef0b44df340805e6b062 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 3 Dec 2022 16:39:06 +0100 Subject: [PATCH 225/441] Rename models module to meet project conventions All module's name start from versions, so rename to be the same --- pom.xml | 6 +++--- versions-common/pom.xml | 2 +- versions-maven-plugin/pom.xml | 4 ++-- versions-maven-plugin/src/site/markdown/version-rules.md.vm | 6 +++--- versions-maven-plugin/src/site/site.xml | 4 ++-- {model-report => versions-model-report}/pom.xml | 6 +++--- .../src/main/mdo/dependency-updates-report.mdo | 0 .../src/main/mdo/plugin-updates-report.mdo | 0 .../src/main/mdo/property-updates-report.mdo | 2 +- {model-ruleset => versions-model}/pom.xml | 6 +++--- {model-ruleset => versions-model}/src/main/mdo/rule.mdo | 2 +- .../src/site/markdown/xsd/index.md | 0 {model-ruleset => versions-model}/src/site/site.xml | 0 versions-test/pom.xml | 4 ++-- 14 files changed, 21 insertions(+), 21 deletions(-) rename {model-report => versions-model-report}/pom.xml (95%) rename {model-report => versions-model-report}/src/main/mdo/dependency-updates-report.mdo (100%) rename {model-report => versions-model-report}/src/main/mdo/plugin-updates-report.mdo (100%) rename {model-report => versions-model-report}/src/main/mdo/property-updates-report.mdo (97%) rename {model-ruleset => versions-model}/pom.xml (95%) rename {model-ruleset => versions-model}/src/main/mdo/rule.mdo (98%) rename {model-ruleset => versions-model}/src/site/markdown/xsd/index.md (100%) rename {model-ruleset => versions-model}/src/site/site.xml (100%) diff --git a/pom.xml b/pom.xml index 9ea4a7ea1c..a2bf061caa 100644 --- a/pom.xml +++ b/pom.xml @@ -96,13 +96,13 @@ - model-report - model-ruleset versions-api versions-common versions-enforcer - versions-test versions-maven-plugin + versions-model-report + versions-model + versions-test diff --git a/versions-common/pom.xml b/versions-common/pom.xml index 5b791a896b..f200c4decf 100644 --- a/versions-common/pom.xml +++ b/versions-common/pom.xml @@ -22,7 +22,7 @@
    org.codehaus.mojo.versions - model-ruleset + versions-model ${project.version} diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index e586a8ba11..aab141b4c6 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -17,13 +17,13 @@ org.codehaus.mojo.versions - model-ruleset + versions-model ${project.version} org.codehaus.mojo.versions - model-report + versions-model-report ${project.version} diff --git a/versions-maven-plugin/src/site/markdown/version-rules.md.vm b/versions-maven-plugin/src/site/markdown/version-rules.md.vm index f564ef959f..6411fd94f0 100644 --- a/versions-maven-plugin/src/site/markdown/version-rules.md.vm +++ b/versions-maven-plugin/src/site/markdown/version-rules.md.vm @@ -58,7 +58,7 @@ it otherwise. Rules.xml --------- -To specify the version schemes to use, you may define a [rule-set xml file](../model-ruleset/rule.html), use the `ruleSet` +To specify the version schemes to use, you may define a [rule-set xml file](../versions-model/rule.html), use the `ruleSet` element in the `versions-maven-plugin` plugin configuration, or specify ignored versions via the `maven.version.ignore` property. @@ -69,7 +69,7 @@ The `rules.xml` file should conform to the xsd specified in the example below. ```xml + xsi:schemaLocation="https://www.mojohaus.org/VERSIONS/RULE/2.1.0 https://www.mojohaus.org/versions/versiosn-model/xsd/rule-2.1.0.xsd"> @@ -79,7 +79,7 @@ The `rules.xml` file should conform to the xsd specified in the example below. ``` -The rule-set files must match the [XSD schema](./xsd/index.html). +The rule-set files must match the [XSD schema](../versions-model/xsd/index.html). You can then use the `rulesUri` parameter to specify the rule-set to be used by the `versions-maven-plugin`. diff --git a/versions-maven-plugin/src/site/site.xml b/versions-maven-plugin/src/site/site.xml index 30922de522..ddbdef6e04 100644 --- a/versions-maven-plugin/src/site/site.xml +++ b/versions-maven-plugin/src/site/site.xml @@ -29,8 +29,8 @@
    - - + + diff --git a/model-report/pom.xml b/versions-model-report/pom.xml similarity index 95% rename from model-report/pom.xml rename to versions-model-report/pom.xml index ef30e642ac..6ba1fbb1bf 100644 --- a/model-report/pom.xml +++ b/versions-model-report/pom.xml @@ -9,10 +9,10 @@ 4.0.0 - model-report + versions-model-report - Versions reports model - Modello model for reports + Versions Model Report + Modello models used in reports diff --git a/model-report/src/main/mdo/dependency-updates-report.mdo b/versions-model-report/src/main/mdo/dependency-updates-report.mdo similarity index 100% rename from model-report/src/main/mdo/dependency-updates-report.mdo rename to versions-model-report/src/main/mdo/dependency-updates-report.mdo diff --git a/model-report/src/main/mdo/plugin-updates-report.mdo b/versions-model-report/src/main/mdo/plugin-updates-report.mdo similarity index 100% rename from model-report/src/main/mdo/plugin-updates-report.mdo rename to versions-model-report/src/main/mdo/plugin-updates-report.mdo diff --git a/model-report/src/main/mdo/property-updates-report.mdo b/versions-model-report/src/main/mdo/property-updates-report.mdo similarity index 97% rename from model-report/src/main/mdo/property-updates-report.mdo rename to versions-model-report/src/main/mdo/property-updates-report.mdo index 0f9a2df326..4a67cebc27 100644 --- a/model-report/src/main/mdo/property-updates-report.mdo +++ b/versions-model-report/src/main/mdo/property-updates-report.mdo @@ -22,7 +22,7 @@ under the License. + xml.schemaLocation="https://www.mojohaus.org/versions/versions-model-report/xsd/property-updates-report-${version}.xsd"> property-updates-report PropertyUpdatesReport diff --git a/model-ruleset/pom.xml b/versions-model/pom.xml similarity index 95% rename from model-ruleset/pom.xml rename to versions-model/pom.xml index c4ef287788..b813ea9eb8 100644 --- a/model-ruleset/pom.xml +++ b/versions-model/pom.xml @@ -9,10 +9,10 @@ 4.0.0 - model-ruleset + versions-model - Versions ruleSet model - Modello model for ruleSet + Versions Model + Modello models used in plugin diff --git a/model-ruleset/src/main/mdo/rule.mdo b/versions-model/src/main/mdo/rule.mdo similarity index 98% rename from model-ruleset/src/main/mdo/rule.mdo rename to versions-model/src/main/mdo/rule.mdo index c4c9c27095..0134a4b086 100644 --- a/model-ruleset/src/main/mdo/rule.mdo +++ b/versions-model/src/main/mdo/rule.mdo @@ -22,7 +22,7 @@ under the License. + xml.schemaLocation="https://www.mojohaus.org/versions/versions-model/xsd/rule-${version}.xsd"> rule Rule diff --git a/model-ruleset/src/site/markdown/xsd/index.md b/versions-model/src/site/markdown/xsd/index.md similarity index 100% rename from model-ruleset/src/site/markdown/xsd/index.md rename to versions-model/src/site/markdown/xsd/index.md diff --git a/model-ruleset/src/site/site.xml b/versions-model/src/site/site.xml similarity index 100% rename from model-ruleset/src/site/site.xml rename to versions-model/src/site/site.xml diff --git a/versions-test/pom.xml b/versions-test/pom.xml index 1ddf047d9e..316baef3c2 100644 --- a/versions-test/pom.xml +++ b/versions-test/pom.xml @@ -21,17 +21,17 @@ + 4.0.0 versions org.codehaus.mojo.versions 2.14.0-SNAPSHOT - 4.0.0 versions-test Versions Test - Test utilities + Internal test utilities used in project From 635b310c1104b3677b7861c756fddbbdf3c7d073 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Sun, 27 Nov 2022 10:44:36 +0100 Subject: [PATCH 226/441] #704: Removing ArtifactRepository leftovers; using ranges for version resolution --- versions-common/pom.xml | 14 +- .../versions/api/DefaultVersionsHelper.java | 24 +- .../codehaus/mojo/versions/api/PomHelper.java | 28 - .../mojo/versions/api/VersionsHelper.java | 17 + versions-enforcer/pom.xml | 7 - .../enforcer/MaxDependencyUpdatesTest.java | 25 +- versions-maven-plugin/pom.xml | 13 +- .../src/it-repo/dummy-maven-plugin-3.1.pom | 8 +- .../it/it-display-plugin-updates-001/pom.xml | 2 +- .../it-display-plugin-updates-008/verify.bsh | 28 - .../verify.groovy | 6 + .../invoker.properties | 3 +- .../verify.bsh | 27 - .../verify.groovy | 1 + .../mojo/versions/AbstractVersionsReport.java | 34 - .../versions/AbstractVersionsUpdaterMojo.java | 3 +- .../versions/DisplayPluginUpdatesMojo.java | 819 ++++-------------- .../codehaus/mojo/versions/RevertMojo.java | 4 - .../PropertyUpdatesReportMojoTest.java | 4 - .../mojo/versions/UpdateParentMojoTest.java | 3 - versions-test/pom.xml | 7 +- 21 files changed, 266 insertions(+), 811 deletions(-) delete mode 100644 versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.groovy delete mode 100644 versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh create mode 100644 versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.groovy diff --git a/versions-common/pom.xml b/versions-common/pom.xml index f200c4decf..5f40995b25 100644 --- a/versions-common/pom.xml +++ b/versions-common/pom.xml @@ -40,10 +40,9 @@ provided - org.apache.maven - maven-compat - ${mavenVersion} - provided + org.apache.maven.wagon + wagon-provider-api + 3.5.2 org.apache.maven @@ -110,6 +109,13 @@ slf4j-simple test + + + org.apache.maven + maven-compat + ${mavenVersion} + test + diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index 0ee3df21f9..b0a6d1483c 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -53,6 +53,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; @@ -175,7 +176,8 @@ public Log getLog() } @Override - public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) + public ArtifactVersions lookupArtifactVersions( Artifact artifact, VersionRange versionRange, + boolean usePluginRepositories ) throws VersionRetrievalException { try @@ -189,11 +191,14 @@ public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePl return new ArtifactVersions( artifact, aetherRepositorySystem.resolveVersionRange( mavenSession.getRepositorySession(), new VersionRangeRequest( - toArtifact( artifact ).setVersion( "(,)" ), - usePluginRepositories - ? mavenSession.getCurrentProject().getRemotePluginRepositories() - : mavenSession.getCurrentProject().getRemoteProjectRepositories(), - "lookupArtifactVersions" ) ) + toArtifact( artifact ).setVersion( + versionRange != null + ? versionRange.toString() + : "(,)" ), + usePluginRepositories + ? mavenSession.getCurrentProject().getRemotePluginRepositories() + : mavenSession.getCurrentProject().getRemoteProjectRepositories(), + "lookupArtifactVersions" ) ) .getVersions() .parallelStream() .filter( v -> ignoredVersions.stream() @@ -237,6 +242,13 @@ public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePl } } + @Override + public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) + throws VersionRetrievalException + { + return lookupArtifactVersions( artifact, null, usePluginRepositories ); + } + /** * Returns a list of versions which should not be considered when looking for updates. * diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index f0fbd59472..cc1d1126c1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -37,7 +37,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Properties; import java.util.Set; import java.util.Stack; @@ -57,7 +56,6 @@ import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.UrlModelSource; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.DefaultProjectBuildingRequest; @@ -1523,32 +1521,6 @@ public static MavenProject getLocalRoot( ProjectBuilder projectBuilder, } } - /** - * Retrieves the standalone superproject - * - * @param projectBuilder {@link ProjectBuilder} instance - * @param mavenSession {@link MavenSession} instance - * @param logger The logger to log tog - * - * @return superproject retrieved - * @throws ProjectBuildingException if the retrieval fails - */ - public static MavenProject getStandaloneSuperProject( ProjectBuilder projectBuilder, - MavenSession mavenSession, - Log logger ) throws ProjectBuildingException - { - ProjectBuildingResult result = projectBuilder.build( new UrlModelSource( - Objects.requireNonNull( PomHelper.class.getResource( "standalone.xml" ) ) ), - createProjectBuilderRequest( mavenSession, r -> r.setProcessPlugins( false ) ) ); - if ( !result.getProblems().isEmpty() ) - { - logger.warn( "Problems encountered during building of the superproject." ); - result.getProblems().forEach( p -> - logger.warn( "\t" + p.getMessage() ) ); - } - return result.getProject(); - } - /** *

    Convenience method for creating a {@link ProjectBuildingRequest} instance based on maven session.

    *

    Note: The method initializes the remote repositories with the remote artifact repositories. diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 4f56849e91..8e66f93223 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -27,6 +27,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.model.Dependency; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; @@ -154,6 +155,22 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) throws VersionRetrievalException; + /** + * Looks up the versions of the specified artifact that are available in either the local repository, or the + * appropriate remote repositories. + * + * @param artifact The artifact to look for versions of. + * @param versionRange versionRange to restrict the search + * @param usePluginRepositories true will consult the pluginRepositories, while false will + * consult the repositories for normal dependencies. + * @return The details of the available artifact versions. + * @throws VersionRetrievalException thrown if version resolution fails + * @since 1.0-alpha-3 + */ + ArtifactVersions lookupArtifactVersions( Artifact artifact, VersionRange versionRange, + boolean usePluginRepositories ) + throws VersionRetrievalException; + /** * Looks up the updates for a set of dependencies. * diff --git a/versions-enforcer/pom.xml b/versions-enforcer/pom.xml index a3cda5ad64..376f23b5f9 100644 --- a/versions-enforcer/pom.xml +++ b/versions-enforcer/pom.xml @@ -46,13 +46,6 @@ provided - - org.apache.maven - maven-compat - ${mavenVersion} - provided - - org.junit.jupiter junit-jupiter diff --git a/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java index 7493bcce74..62e029e813 100644 --- a/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java +++ b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java @@ -20,14 +20,11 @@ import java.util.HashMap; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.enforcer.rule.api.EnforcerRuleException; import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.junit.Test; @@ -57,23 +54,17 @@ private static EnforcerRuleHelper mockRuleHelper( MavenProject mavenProject, when( ruleHelper.evaluate( anyString() ) ) .then( ( a ) -> "${project}".equals( a.getArgument( 0 ) ) ? mavenProject - : "${localRepository}".equals( a.getArgument( 0 ) ) - ? new StubArtifactRepository( "" ) - : "${settings}".equals( a.getArgument( 0 ) ) - ? new Settings() - : "${session}".equals( a.getArgument( 0 ) ) - ? mockMavenSession() - : "${mojoExecution}".equals( a.getArgument( 0 ) ) - ? mock( MojoExecution.class ) - : null ); + : "${session}".equals( a.getArgument( 0 ) ) + ? mockMavenSession() + : "${mojoExecution}".equals( a.getArgument( 0 ) ) + ? mock( MojoExecution.class ) + : null ); when( ruleHelper.getComponent( ArgumentMatchers.>any() ) ) .then( ( a ) -> a.getArgument( 0 ) == RepositorySystem.class ? mockRepositorySystem() - : a.getArgument( 0 ) == ArtifactResolver.class - ? mock( ArtifactResolver.class ) - : a.getArgument( 0 ) == org.eclipse.aether.RepositorySystem.class - ? aetherRepositorySystem - : null ); + : a.getArgument( 0 ) == org.eclipse.aether.RepositorySystem.class + ? aetherRepositorySystem + : null ); return ruleHelper; } diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index aab141b4c6..19f022fd5c 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -58,12 +58,6 @@ ${mavenVersion} provided - - org.apache.maven - maven-compat - ${mavenVersion} - provided - org.apache.maven maven-model @@ -162,6 +156,13 @@ slf4j-simple test + + + org.apache.maven + maven-compat + ${mavenVersion} + test + diff --git a/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom index ba9772205d..b31981f615 100644 --- a/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom +++ b/versions-maven-plugin/src/it-repo/dummy-maven-plugin-3.1.pom @@ -21,14 +21,14 @@ - 2.0.9 + 3.8.4 org.apache.maven maven-model - 2.0.6 + 3.8.4 org.codehaus.plexus @@ -39,12 +39,12 @@ org.apache.maven maven-plugin-api - 2.0.6 + 3.8.4 org.apache.maven maven-project - 2.0.6 + 3.8.4 org.apache.maven diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml b/versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml index f66295573f..6c874e49c1 100644 --- a/versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml +++ b/versions-maven-plugin/src/it/it-display-plugin-updates-001/pom.xml @@ -9,7 +9,7 @@ display-plugin-updates - 2.0.6 + 3.2.5 diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh deleted file mode 100644 index d0f1c821b1..0000000000 --- a/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.bsh +++ /dev/null @@ -1,28 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; -import java.util.regex.*; - -try -{ - File file = new File( basedir, "build.log" ); - String buf = FileUtils.fileRead( file ); - - Pattern p1 = Pattern.compile( "\\QRequire Maven 2.0.9 to use the following plugin updates:\\E" ); - Matcher m1 = p1.matcher( buf.toString() ); - Pattern p2 = Pattern.compile( "\\Qlocalhost:dummy-maven-plugin\\E\\s*\\.*\\s*\\Q1.0 -> 3.1\\E" ); - Matcher m2 = p2.matcher( buf.toString() ); - if ( !m1.find() || !m2.find() || m2.start() < m1.start() ) - { - System.out.println( "Did not suggest updating to Maven 2.0.9 for upgrading dummy-maven-plugin to version 3.1" ); - return false; - } - System.out.println( m1.group( 0 ) ); - System.out.println( m2.group( 0 ) ); -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.groovy b/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.groovy new file mode 100644 index 0000000000..fb763e5583 --- /dev/null +++ b/versions-maven-plugin/src/it/it-display-plugin-updates-008/verify.groovy @@ -0,0 +1,6 @@ +def buildLog = new File( basedir, "build.log" ).text + +m1 = buildLog =~ /Require Maven 3\.8\.4 to use the following plugin updates:/ +m2 = buildLog =~ /localhost:dummy-maven-plugin *\.*\s*\b1\.0 -> 3\.1\b/ + +assert m1 && m2 && m1.start() < m2.start() \ No newline at end of file diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties index af55d25b87..cd8e358b93 100644 --- a/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties +++ b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/invoker.properties @@ -1 +1,2 @@ -invoker.goals=${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates -Dversions.outputFile=./dependencyUpdate.txt -Dversions.outputLineWidth=120 +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:display-plugin-updates +invoker.mavenOpts = -Dversions.outputFile=./dependencyUpdate.txt -Dversions.outputLineWidth=60 diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh deleted file mode 100644 index 17f842afab..0000000000 --- a/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.bsh +++ /dev/null @@ -1,27 +0,0 @@ -import java.io.*; -import org.codehaus.plexus.util.FileUtils; - -try -{ - - // validate outputFile - File outputFile = new File( basedir, "dependencyUpdate.txt" ); - if (!outputFile.exists()) { - System.out.println( "outputFile not found: " + outputFile.getPath() ); - return false; - } - buf = FileUtils.fileRead( outputFile ); - if ( !buf.contains("maven-deploy-plugin ............................................................................ 2.3 ->") ) - { - System.out.println( "displayTerminalWidth parameter not respected" ); - return false; - } - -} -catch( Throwable t ) -{ - t.printStackTrace(); - return false; -} - -return true; diff --git a/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.groovy b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.groovy new file mode 100644 index 0000000000..64d3851adb --- /dev/null +++ b/versions-maven-plugin/src/it/it-display-plugin-updates-012-outputLineWidth/verify.groovy @@ -0,0 +1 @@ +assert new File( basedir, "dependencyUpdate.txt" ).text =~ /\.{14}/ diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index b33e642016..bf7d697965 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -24,9 +24,6 @@ import java.util.Map; import java.util.Set; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.execution.MavenSession; @@ -38,9 +35,7 @@ import org.apache.maven.reporting.MavenReportException; import org.apache.maven.repository.RepositorySystem; import org.apache.maven.wagon.Wagon; -import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.DefaultVersionsHelper; -import org.codehaus.mojo.versions.api.VersionRetrievalException; import org.codehaus.mojo.versions.api.VersionsHelper; import org.codehaus.mojo.versions.model.RuleSet; import org.codehaus.mojo.versions.reporting.ReportRendererFactory; @@ -243,35 +238,6 @@ protected void executeReport( Locale locale ) protected abstract void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException, MojoExecutionException; - /** - * Finds the latest version of the specified artifact that matches the version range. - * - * @param artifact The artifact. - * @param versionRange The version range. - * @param allowingSnapshots null for no override, otherwise the local override to apply. - * @param usePluginRepositories Use plugin repositories - * @return The latest version of the specified artifact that matches the specified version range or - * null if no matching version could be found. - * @throws MavenReportException If the artifact metadata could not be found. - * @since 1.0-alpha-1 - */ - protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, - Boolean allowingSnapshots, boolean usePluginRepositories ) - throws MavenReportException - { - boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; - try - { - final ArtifactVersions artifactVersions = - getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); - return artifactVersions.getNewestVersion( versionRange, includeSnapshots ); - } - catch ( VersionRetrievalException e ) - { - throw new MavenReportException( e.getMessage(), e ); - } - } - @Override protected MavenProject getProject() { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index c97b653ce4..b9b15b5cf6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -308,7 +308,8 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver throws MojoExecutionException, VersionRetrievalException { boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; - final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories ); + final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, versionRange, + usePluginRepositories ); return artifactVersions.getNewestVersion( versionRange, null, includeSnapshots, false ); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index c38aaebbe3..0b9c84508b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -27,40 +27,29 @@ import java.io.IOException; import java.io.Reader; import java.io.StringWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Pattern; -import org.apache.maven.BuildFailureException; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.RuntimeInformation; -import org.apache.maven.lifecycle.Lifecycle; -import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.lifecycle.LifecycleExecutor; -import org.apache.maven.lifecycle.mapping.LifecycleMapping; +import org.apache.maven.model.BuildBase; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.Prerequisites; @@ -72,22 +61,15 @@ import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.model.interpolation.ModelInterpolator; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; -import org.apache.maven.plugin.InvalidPluginException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.PluginManager; -import org.apache.maven.plugin.PluginManagerException; -import org.apache.maven.plugin.PluginNotFoundException; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.version.PluginVersionNotFoundException; -import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.repository.RepositorySystem; -import org.apache.maven.settings.Settings; +import org.apache.maven.rtinfo.RuntimeInformation; import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; import org.codehaus.mojo.versions.api.PomHelper; @@ -97,10 +79,13 @@ import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; import org.codehaus.mojo.versions.utils.DependencyBuilder; import org.codehaus.mojo.versions.utils.PluginComparator; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.StringUtils; + +import static java.util.Collections.emptyMap; +import static java.util.Optional.ofNullable; +import static java.util.stream.Collectors.toMap; +import static java.util.stream.Collectors.toSet; /** * Displays all plugins that have newer versions available, taking care of Maven version prerequisites. @@ -110,7 +95,7 @@ */ @Mojo( name = "display-plugin-updates", threadSafe = true ) public class DisplayPluginUpdatesMojo - extends AbstractVersionsDisplayMojo + extends AbstractVersionsDisplayMojo { // ------------------------------ FIELDS ------------------------------ @@ -135,6 +120,7 @@ public class DisplayPluginUpdatesMojo * @since 1.0-alpha-1 */ private static final String FROM_SUPER_POM = "(from super-pom) "; + public static final String DEFAULT_MVN_VERSION = "3.2.5"; /** * @since 1.0-alpha-1 @@ -147,16 +133,11 @@ public class DisplayPluginUpdatesMojo private ModelInterpolator modelInterpolator; /** - * The plugin manager. + * (Injected) instance of {@link RuntimeInformation} * - * @since 1.0-alpha-1 - */ - private PluginManager pluginManager; - - /** - * @since 1.3 + * @since 2.14.0 */ - private RuntimeInformation runtimeInformation; + private final RuntimeInformation runtimeInformation; /** * The (injected) instance of {@link ProjectBuilder} @@ -175,7 +156,6 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, Map wagonMap, LifecycleExecutor lifecycleExecutor, ModelInterpolator modelInterpolator, - PluginManager pluginManager, RuntimeInformation runtimeInformation, Map changeRecorders ) { @@ -183,7 +163,6 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, this.projectBuilder = projectBuilder; this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; - this.pluginManager = pluginManager; this.runtimeInformation = runtimeInformation; } @@ -194,123 +173,96 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, * @throws MojoExecutionException when things go wrong. */ private Map getSuperPomPluginManagement() - throws MojoExecutionException + throws MojoExecutionException { - if ( new DefaultArtifactVersion( "3.0" ).compareTo( runtimeInformation.getApplicationVersion() ) <= 0 ) + // we need to provide a copy with the version blanked out so that inferring from super-pom + // works as for 2.x as 3.x fills in the version on us! + Map result = lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( getProject() + .getPackaging() ) + .stream() + .collect( LinkedHashMap::new, + ( m, p ) -> m.put( p.getKey(), p.getVersion() ), + Map::putAll ); + + URL superPom = getClass().getClassLoader().getResource( "org/apache/maven/model/pom-4.0.0.xml" ); + if ( superPom != null ) { - getLog().debug( "Using Maven 3.x strategy to determine superpom defined plugins" ); try { - Method getPluginsBoundByDefaultToAllLifecycles = - LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - String.class ); - Set plugins = - (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { - getProject().getPackaging()} ); - // we need to provide a copy with the version blanked out so that inferring from super-pom - // works as for 2.x as 3.x fills in the version on us! - Map result = new LinkedHashMap<>( plugins.size() ); - for ( Plugin plugin : plugins ) - { - result.put( plugin.getKey(), plugin.getVersion() ); - } - URL superPom = getClass().getClassLoader().getResource( "org/apache/maven/model/pom-4.0.0.xml" ); - if ( superPom != null ) + try ( Reader reader = ReaderFactory.newXmlReader( superPom ) ) { - try + StringBuilder buf = new StringBuilder( IOUtil.toString( reader ) ); + ModifiedPomXMLEventReader pom = newModifiedPomXER( buf, superPom.toString() ); + + Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" + + "((/build(/pluginManagement)?)|(/reporting))" + + "/plugins/plugin" ); + Stack pathStack = new Stack<>(); + StackState curState = null; + while ( pom.hasNext() ) { - try ( Reader reader = ReaderFactory.newXmlReader( superPom ) ) + XMLEvent event = pom.nextEvent(); + if ( event.isStartDocument() ) { - StringBuilder buf = new StringBuilder( IOUtil.toString( reader ) ); - ModifiedPomXMLEventReader pom = newModifiedPomXER( buf, superPom.toString() ); - - Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))" - + "/plugins/plugin" ); - Stack pathStack = new Stack<>(); - StackState curState = null; - while ( pom.hasNext() ) + curState = new StackState( "" ); + pathStack.clear(); + } + else if ( event.isStartElement() ) + { + String elementName = event.asStartElement().getName().getLocalPart(); + if ( curState != null && pathRegex.matcher( curState.path ).matches() ) { - XMLEvent event = pom.nextEvent(); - if ( event.isStartDocument() ) + if ( "groupId".equals( elementName ) ) { - curState = new StackState( "" ); - pathStack.clear(); + curState.groupId = pom.getElementText().trim(); + continue; } - else if ( event.isStartElement() ) + else if ( "artifactId".equals( elementName ) ) { - String elementName = event.asStartElement().getName().getLocalPart(); - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { - curState.groupId = pom.getElementText().trim(); - continue; - } - else if ( "artifactId".equals( elementName ) ) - { - curState.artifactId = pom.getElementText().trim(); - continue; - - } - else if ( "version".equals( elementName ) ) - { - curState.version = pom.getElementText().trim(); - continue; - } - } + curState.artifactId = pom.getElementText().trim(); + continue; - pathStack.push( curState ); - curState = new StackState( curState.path + "/" + elementName ); } - else if ( event.isEndElement() ) + else if ( "version".equals( elementName ) ) + { + curState.version = pom.getElementText().trim(); + continue; + } + } + + pathStack.push( curState ); + curState = new StackState( curState.path + "/" + elementName ); + } + else if ( event.isEndElement() ) + { + if ( curState != null && pathRegex.matcher( curState.path ).matches() ) + { + if ( curState.artifactId != null ) { - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) + Plugin plugin = new Plugin(); + plugin.setArtifactId( curState.artifactId ); + plugin.setGroupId( curState.groupId == null + ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID + : curState.groupId ); + plugin.setVersion( curState.version ); + if ( !result.containsKey( plugin.getKey() ) ) { - if ( curState.artifactId != null ) - { - Plugin plugin = new Plugin(); - plugin.setArtifactId( curState.artifactId ); - plugin.setGroupId( curState.groupId == null - ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID - : curState.groupId ); - plugin.setVersion( curState.version ); - if ( !result.containsKey( plugin.getKey() ) ) - { - result.put( plugin.getKey(), plugin.getVersion() ); - } - } + result.put( plugin.getKey(), plugin.getVersion() ); } - curState = pathStack.pop(); } } + curState = pathStack.pop(); } } - catch ( IOException | XMLStreamException e ) - { - // ignore - } } - - return result; } - catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e1 ) + catch ( IOException | XMLStreamException e ) { - // no much we can do here + // ignore } } - getLog().debug( "Using Maven 2.x strategy to determine superpom defined plugins" ); - Map superPomPluginManagement; - try - { - superPomPluginManagement = new HashMap<>( getPluginManagement( - PomHelper.getStandaloneSuperProject( projectBuilder, session, getLog() ).getOriginalModel() ) ); - } - catch ( ProjectBuildingException e ) - { - throw new MojoExecutionException( "Could not determine the super pom.xml", e ); - } - return superPomPluginManagement; + + return result; } /** @@ -382,13 +334,16 @@ private Map getPluginManagement( Model model ) */ @SuppressWarnings( "checkstyle:MethodLength" ) public void execute() - throws MojoExecutionException, MojoFailureException + throws MojoExecutionException, MojoFailureException { logInit(); Set pluginsWithVersionsSpecified; try { - pluginsWithVersionsSpecified = findPluginsWithVersionsSpecified( getProject() ); + MavenProject project1 = getProject(); + pluginsWithVersionsSpecified = + findPluginsWithVersionsSpecified( PomHelper.readXmlFile( project1.getFile() ), + getSafeProjectPathInfo( project1 ) ); } catch ( XMLStreamException | IOException e ) { @@ -408,12 +363,13 @@ public void execute() Map parentReportPlugins = new HashMap<>(); Set plugins = getProjectPlugins( superPomPluginManagement, parentPlugins, parentBuildPlugins, - parentReportPlugins, pluginsWithVersionsSpecified ); + parentReportPlugins, pluginsWithVersionsSpecified ); List pluginUpdates = new ArrayList<>(); List pluginLockdowns = new ArrayList<>(); - ArtifactVersion curMavenVersion = runtimeInformation.getApplicationVersion(); - ArtifactVersion specMavenVersion = MinimalMavenBuildVersionFinder.find( getProject(), "2.0", getLog() ); + ArtifactVersion curMavenVersion = new DefaultArtifactVersion( runtimeInformation.getMavenVersion() ); + ArtifactVersion specMavenVersion = MinimalMavenBuildVersionFinder.find( getProject(), DEFAULT_MVN_VERSION, + getLog() ); ArtifactVersion minMavenVersion = null; boolean superPomDrivingMinVersion = false; // if Maven prerequisite upgraded to a version, Map @@ -442,7 +398,7 @@ public void execute() String effectiveVersion = version; Artifact artifactRange = getHelper().createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), - version ); + version ); ArtifactVersion artifactVersion = null; try @@ -477,7 +433,7 @@ public void execute() if ( minRequires == null || compare( minRequires, pluginRequires ) > 0 ) { Map upgradePlugins = - mavenUpgrades.computeIfAbsent( pluginRequires, k -> new LinkedHashMap<>() ); + mavenUpgrades.computeIfAbsent( pluginRequires, k -> new LinkedHashMap<>() ); String upgradePluginKey = compactKey( groupId, artifactId ); if ( !upgradePlugins.containsKey( upgradePluginKey ) ) @@ -487,15 +443,15 @@ public void execute() { // plugin version configured that require a Maven version higher than spec upgradePlugins.put( upgradePluginKey, - pad( upgradePluginKey, - INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); + pad( upgradePluginKey, + INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); } else { // plugin that can be upgraded upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE - + getOutputLineWidthOffset(), - effectiveVersion, " -> ", newer ) ); + + getOutputLineWidthOffset(), + effectiveVersion, " -> ", newer ) ); } } minRequires = pluginRequires; @@ -552,15 +508,15 @@ public void execute() getLog().debug( "[" + coords + "].superPom.version=" + version ); newVersion = artifactVersion != null ? artifactVersion.toString() - : ( version != null ? version - : ( effectiveVersion != null ? effectiveVersion : "(unknown)" ) ); + : ( version != null ? version + : ( effectiveVersion != null ? effectiveVersion : "(unknown)" ) ); if ( version != null ) { superPomDrivingMinVersion = true; } pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getOutputLineWidthOffset(), - superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); + superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); } else if ( artifactVersion != null ) { @@ -571,11 +527,12 @@ else if ( artifactVersion != null ) newVersion = null; } if ( version != null && artifactVersion != null && newVersion != null && effectiveVersion != null - && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) - < 0 ) + && + new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) + < 0 ) { pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getOutputLineWidthOffset(), - effectiveVersion, " -> ", newVersion ) ); + effectiveVersion, " -> ", newVersion ) ); } } @@ -617,7 +574,8 @@ && new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifact boolean noMavenMinVersion = MinimalMavenBuildVersionFinder.find( getProject(), null, getLog() ) == null; if ( noMavenMinVersion ) { - getLog().warn( "Project does not define minimum Maven version required for build, default is: 2.0" ); + getLog().warn( "Project does not define minimum Maven version required for build, default is: " + + DEFAULT_MVN_VERSION ); } else { @@ -704,11 +662,12 @@ else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion /** * Builds a {@link MavenProject} instance for the plugin with a given {@code groupId}, * {@code artifactId}, and {@code version}. - * @param groupId {@code groupId} of the plugin + * + * @param groupId {@code groupId} of the plugin * @param artifactId {@code artifactId} of the plugin - * @param version {@code version} of the plugin + * @param version {@code version} of the plugin * @return retrieved {@link MavenProject} instance for the given plugin - * @throws MojoExecutionException thrown if the artifact for the plugin could not be constructed + * @throws MojoExecutionException thrown if the artifact for the plugin could not be constructed * @throws ProjectBuildingException thrown if the {@link MavenProject} instance could not be constructed */ private MavenProject getPluginProject( String groupId, String artifactId, String version ) @@ -731,7 +690,7 @@ private MavenProject getPluginProject( String groupId, String artifactId, String if ( !result.getProblems().isEmpty() ) { getLog().warn( "Problems encountered during construction of the plugin POM for " - + probe.toString() ); + + probe.toString() ); result.getProblems().forEach( p -> getLog().warn( "\t" + p.getMessage() ) ); } @@ -762,13 +721,13 @@ private static String pad( String start, int len, String... ends ) } private Map getParentsPlugins( List parents ) - throws MojoExecutionException + throws MojoExecutionException { Map parentPlugins = new HashMap<>(); for ( MavenProject parentProject : parents ) { getLog().debug( "Processing parent: " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() - + ":" + parentProject.getVersion() + " -> " + parentProject.getFile() ); + + ":" + parentProject.getVersion() + " -> " + parentProject.getFile() ); StringWriter writer = new StringWriter(); boolean havePom = false; @@ -778,8 +737,8 @@ private Map getParentsPlugins( List parents ) if ( originalModel == null ) { getLog().warn( "project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" - + parentProject.getArtifactId() + ":" + parentProject.getVersion() - + " is null, substituting project.getModel()" ); + + parentProject.getArtifactId() + ":" + parentProject.getVersion() + + " is null, substituting project.getModel()" ); originalModel = parentProject.getModel(); } try @@ -795,15 +754,15 @@ private Map getParentsPlugins( List parents ) ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); modelBuildingRequest.setUserProperties( getProject().getProperties() ); interpolatedModel = modelInterpolator.interpolateModel( originalModel, null, - modelBuildingRequest, - new IgnoringModelProblemCollector() ); + modelBuildingRequest, + new IgnoringModelProblemCollector() ); if ( havePom ) { try { Set withVersionSpecified = - findPluginsWithVersionsSpecified( new StringBuilder( writer.toString() ), - getSafeProjectPathInfo( parentProject ) ); + findPluginsWithVersionsSpecified( new StringBuilder( writer.toString() ), + getSafeProjectPathInfo( parentProject ) ); Map map = getPluginManagement( interpolatedModel ); map.keySet().retainAll( withVersionSpecified ); @@ -834,16 +793,11 @@ private Map getParentsPlugins( List parents ) private String getSafeProjectPathInfo( MavenProject project ) { - File file = project.getFile(); - if ( file != null ) - { - return file.getAbsolutePath(); - } - else - { - // path is used only as information in error message, we can fallback to project artifact info here - return project.toString(); - } + return ofNullable( project.getFile() ) + .map( File::getAbsolutePath ) + // path is used only as information in error message, + // we can fallback to project artifact info here + .orElse( project.toString() ); } private boolean isMavenPluginProject() @@ -853,12 +807,10 @@ private boolean isMavenPluginProject() private String compactKey( String groupId, String artifactId ) { - if ( PomHelper.APACHE_MAVEN_PLUGINS_GROUPID.equals( groupId ) ) - { - // a core plugin... group id is not needed - return artifactId; - } - return groupId + ":" + artifactId; + return PomHelper.APACHE_MAVEN_PLUGINS_GROUPID.equals( groupId ) + // a core plugin... group id is not needed + ? artifactId + : groupId + ":" + artifactId; } private static final class StackState @@ -882,19 +834,6 @@ public String toString() } } - /** - * Returns a set of Strings which correspond to the plugin coordinates where there is a version specified. - * - * @param project The project to get the plugins with versions specified. - * @return a set of Strings which correspond to the plugin coordinates where there is a version specified. - */ - private Set findPluginsWithVersionsSpecified( MavenProject project ) - throws IOException, XMLStreamException - { - return findPluginsWithVersionsSpecified( PomHelper.readXmlFile( project.getFile() ), - getSafeProjectPathInfo( project ) ); - } - /** * Returns a set of Strings which correspond to the plugin coordinates where there is a version specified. * @@ -903,13 +842,13 @@ private Set findPluginsWithVersionsSpecified( MavenProject project ) * @return a set of Strings which correspond to the plugin coordinates where there is a version specified. */ private Set findPluginsWithVersionsSpecified( StringBuilder pomContents, String path ) - throws XMLStreamException + throws XMLStreamException { Set result = new HashSet<>(); ModifiedPomXMLEventReader pom = newModifiedPomXER( pomContents, path ); Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); + + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); Stack pathStack = new Stack<>(); StackState curState = null; while ( pom.hasNext() ) @@ -979,75 +918,48 @@ else if ( event.isEndElement() ) */ private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject ) { - Prerequisites prerequisites = pluginProject.getPrerequisites(); - if ( null == prerequisites ) - { - return new DefaultArtifactVersion( "2.0" ); - } - - String prerequisitesMavenValue = prerequisites.getMaven(); - if ( null == prerequisitesMavenValue ) - { - return new DefaultArtifactVersion( "2.0" ); - } + return ofNullable( pluginProject.getPrerequisites() ) + .map( Prerequisites::getMaven ) + .map( DefaultArtifactVersion::new ) + .orElse( new DefaultArtifactVersion( DEFAULT_MVN_VERSION ) ); + } - return new DefaultArtifactVersion( prerequisitesMavenValue ); + /** + * Retrieves plugins from the given model + * + * @param build build + * @param onlyIncludeInherited {@code true} to only return the plugins definitions that will be inherited by + * child projects. + * @return map of plugin name x version + */ + private Map getPluginsFromBuild( BuildBase build, boolean onlyIncludeInherited ) + { + return ofNullable( build ) + .flatMap( b -> ofNullable( b.getPlugins() ) + .map( plugins -> plugins.stream() + .filter( plugin -> plugin.getVersion() != null ) + .filter( plugin -> !onlyIncludeInherited || getPluginInherited( plugin ) ) + .collect( toMap( Plugin::getKey, Plugin::getVersion ) ) ) ) + .orElse( emptyMap() ); } /** * Gets the build plugins of a specific project. * * @param model the model to get the build plugins from. - * @param onlyIncludeInherited true to only return the plugins definitions that will be inherited by + * @param onlyIncludeInherited {@code true} to only return the plugins definitions that will be inherited by * child projects. * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ private Map getBuildPlugins( Model model, boolean onlyIncludeInherited ) { - Map buildPlugins = new HashMap<>(); - try - { - for ( Plugin plugin : model.getBuild().getPlugins() ) - { - String coord = plugin.getKey(); - String version = plugin.getVersion(); - if ( version != null && ( !onlyIncludeInherited || getPluginInherited( plugin ) ) ) - { - buildPlugins.put( coord, version ); - } - } - } - catch ( NullPointerException e ) - { - // guess there are no plugins here - } - try - { - for ( Profile profile : model.getProfiles() ) - { - try - { - for ( Plugin plugin : profile.getBuild().getPlugins() ) - { - String coord = plugin.getKey(); - String version = plugin.getVersion(); - if ( version != null && ( !onlyIncludeInherited || getPluginInherited( plugin ) ) ) - { - buildPlugins.put( coord, version ); - } - } - } - catch ( NullPointerException e ) - { - // guess there are no plugins here - } - } - } - catch ( NullPointerException e ) - { - // guess there are no profiles here - } + Map buildPlugins = + new HashMap<>( getPluginsFromBuild( model.getBuild(), onlyIncludeInherited ) ); + ofNullable( model.getProfiles() ) + .ifPresent( profiles -> profiles.stream() + .map( profile -> getPluginsFromBuild( profile.getBuild(), onlyIncludeInherited ) ) + .forEach( buildPlugins::putAll ) ); return buildPlugins; } @@ -1061,7 +973,7 @@ private Map getBuildPlugins( Model model, boolean onlyIncludeInh private static boolean getPluginInherited( Object plugin ) { return "true".equalsIgnoreCase( plugin instanceof ReportPlugin ? ( (ReportPlugin) plugin ).getInherited() - : ( (Plugin) plugin ).getInherited() ); + : ( (Plugin) plugin ).getInherited() ); } /** @@ -1073,35 +985,15 @@ private static boolean getPluginInherited( Object plugin ) * @since 1.0-alpha-1 */ private Map getLifecyclePlugins( MavenProject project ) - throws MojoExecutionException + throws MojoExecutionException { - Map lifecyclePlugins = new HashMap<>(); - try - { - Set plugins = getBoundPlugins( project, "clean,deploy,site" ); - for ( Plugin plugin : plugins ) - { - lifecyclePlugins.put( plugin.getKey(), plugin ); - } - } - catch ( PluginNotFoundException e ) - { - throw new MojoExecutionException( "Could not find plugin", e ); - } - catch ( LifecycleExecutionException e ) - { - throw new MojoExecutionException( "Could not determine lifecycle", e ); - } - catch ( IllegalAccessException e ) - { - throw new MojoExecutionException( "Could not determine lifecycles", e ); - } - catch ( NullPointerException e ) - { - // Maven 3.x - - } - return lifecyclePlugins; + return getBoundPlugins( project ) + .parallelStream() + .filter( Objects::nonNull ) + .filter( p -> p.getKey() != null ) + .collect( HashMap::new, + ( m, p ) -> m.put( p.getKey(), p ), + Map::putAll ); } /** @@ -1109,327 +1001,22 @@ private Map getLifecyclePlugins( MavenProject project ) * later than the plugin is executing. * * @param project the project - * @param thePhases the the phases * @return the bound plugins - * @throws org.apache.maven.plugin.PluginNotFoundException the plugin not found exception - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws IllegalAccessException the illegal access exception */ // pilfered this from enforcer-rules // TODO coordinate with Brian Fox to remove the duplicate code - private Set getBoundPlugins( MavenProject project, String thePhases ) - throws PluginNotFoundException, LifecycleExecutionException, IllegalAccessException + private Set getBoundPlugins( MavenProject project ) { - if ( new DefaultArtifactVersion( "3.0" ).compareTo( runtimeInformation.getApplicationVersion() ) <= 0 ) - { - getLog().debug( "Using Maven 3.0+ strategy to determine lifecycle defined plugins" ); - try - { - Method getPluginsBoundByDefaultToAllLifecycles = - LifecycleExecutor.class.getMethod( "getPluginsBoundByDefaultToAllLifecycles", - String.class ); - Set plugins = - (Set) getPluginsBoundByDefaultToAllLifecycles.invoke( lifecycleExecutor, new Object[] { - project.getPackaging() == null ? "jar" : project.getPackaging()} ); - // we need to provide a copy with the version blanked out so that inferring from super-pom - // works as for 2.x as 3.x fills in the version on us! - Set result = new LinkedHashSet<>( plugins.size() ); - for ( Plugin plugin : plugins ) - { - Plugin dup = new Plugin(); - dup.setGroupId( plugin.getGroupId() ); - dup.setArtifactId( plugin.getArtifactId() ); - result.add( dup ); - } - return result; - } - catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e1 ) - { - // no much we can do here - } - } - List lifecycles = null; - getLog().debug( "Using Maven 2.0.10+ strategy to determine lifecycle defined plugins" ); - try - { - Method getLifecycles = LifecycleExecutor.class.getMethod( "getLifecycles" ); - lifecycles = (List) getLifecycles.invoke( lifecycleExecutor, new Object[0] ); - } - catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e1 ) - { - // no much we can do here - } - - Set allPlugins = new HashSet<>(); - - // lookup the bindings for all the passed in phases - for ( String lifecyclePhase : thePhases.split( "," ) ) - { - if ( StringUtils.isNotEmpty( lifecyclePhase ) ) - { - try - { - Lifecycle lifecycle = getLifecycleForPhase( lifecycles, lifecyclePhase ); - allPlugins.addAll( getAllPlugins( project, lifecycle ) ); - } - catch ( BuildFailureException e ) - { - // i'm going to swallow this because the - // user may have declared a phase that - // doesn't exist for every module. - } - } - } - return allPlugins; - } - - /** - * Gets the lifecycle for phase. - * - * @param lifecycles The list of lifecycles. - * @param phase the phase - * @return the lifecycle for phase - * @throws BuildFailureException the build failure exception - * @throws LifecycleExecutionException the lifecycle execution exception - */ - private Lifecycle getLifecycleForPhase( List lifecycles, String phase ) - throws BuildFailureException, LifecycleExecutionException - { - Lifecycle lifecycle = getPhaseToLifecycleMap( lifecycles ).get( phase ); - - if ( lifecycle == null ) - { - throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" ); - } - return lifecycle; - } - - /* - * Uses borrowed lifecycle code to get a list of all plugins bound to the lifecycle. - */ - - /** - * Gets the all plugins. - * - * @param project the project - * @param lifecycle the lifecycle - * @return the all plugins - * @throws PluginNotFoundException the plugin not found exception - * @throws LifecycleExecutionException the lifecycle execution exception - */ - private Set getAllPlugins( MavenProject project, Lifecycle lifecycle ) - throws PluginNotFoundException, LifecycleExecutionException - - { - Set plugins = new HashSet<>(); - // first, bind those associated with the packaging - Map mappings = findMappingsForLifecycle( project, lifecycle ); - - for ( Map.Entry entry : mappings.entrySet() ) - { - String value = (String) entry.getValue(); - String[] tokens = value.split( ":" ); - - Plugin plugin = new Plugin(); - plugin.setGroupId( tokens[0] ); - plugin.setArtifactId( tokens[1] ); - plugins.add( plugin ); - } - - for ( String value : findOptionalMojosForLifecycle( project, lifecycle ) ) - { - String[] tokens = value.split( ":" ); - - Plugin plugin = new Plugin(); - plugin.setGroupId( tokens[0] ); - plugin.setArtifactId( tokens[1] ); - plugins.add( plugin ); - } - - plugins.addAll( project.getBuildPlugins() ); - - return plugins; - } - - /** - * Find mappings for lifecycle. - * - * @param project the project - * @param lifecycle the lifecycle - * @return the map - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception - */ - private Map findMappingsForLifecycle( MavenProject project, Lifecycle lifecycle ) - throws LifecycleExecutionException, PluginNotFoundException - { - String packaging = project.getPackaging(); - Map mappings = null; - - LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, - session.getSettings(), session.getLocalRepository() ); - if ( m != null ) - { - mappings = m.getPhases( lifecycle.getId() ); - } - - Map defaultMappings = lifecycle.getDefaultPhases(); - - if ( mappings == null ) - { - try - { - m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); - mappings = m.getPhases( lifecycle.getId() ); - } - catch ( ComponentLookupException e ) - { - if ( defaultMappings == null ) - { - throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: '" + packaging - + "'.", e ); - } - } - } - - if ( mappings == null ) - { - if ( defaultMappings == null ) - { - throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: '" + packaging - + "', and there is no default" ); - } - else - { - mappings = defaultMappings; - } - } - - return mappings; - } - - /** - * Find optional mojos for lifecycle. - * - * @param project the project - * @param lifecycle the lifecycle - * @return the list - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception - */ - private List findOptionalMojosForLifecycle( MavenProject project, Lifecycle lifecycle ) - throws LifecycleExecutionException, PluginNotFoundException - { - String packaging = project.getPackaging(); - List optionalMojos = null; - - LifecycleMapping m = (LifecycleMapping) findExtension( project, LifecycleMapping.ROLE, packaging, - session.getSettings(), session.getLocalRepository() ); - - if ( m != null ) - { - optionalMojos = m.getOptionalMojos( lifecycle.getId() ); - } - - if ( optionalMojos == null ) - { - try - { - m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging ); - optionalMojos = m.getOptionalMojos( lifecycle.getId() ); - } - catch ( ComponentLookupException e ) - { - getLog().debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " - + lifecycle.getId() + ". Error: " + e.getMessage(), e ); - } - } - - if ( optionalMojos == null ) - { - optionalMojos = Collections.emptyList(); - } - - return optionalMojos; - } - - /** - * Find extension. - * - * @param project the project - * @param role the role - * @param roleHint the role hint - * @param settings the settings - * @param localRepository the local repository - * @return the object - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception - */ - private Object findExtension( MavenProject project, String role, String roleHint, Settings settings, - ArtifactRepository localRepository ) - throws LifecycleExecutionException, PluginNotFoundException - { - Object pluginComponent = null; - - for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null; ) - { - Plugin plugin = (Plugin) i.next(); - - if ( plugin.isExtensions() ) - { - loadPluginDescriptor( plugin, project, session ); - - // TODO: if moved to the plugin manager we - // already have the descriptor from above - // and so do can lookup the container - // directly - try - { - pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint ); - } - catch ( ComponentLookupException e ) - { - getLog().debug( "Unable to find the lifecycle component in the extension", e ); - } - catch ( PluginManagerException e ) - { - throw new LifecycleExecutionException( "Error getting extensions from the plugin '" - + plugin.getKey() + "': " + e.getMessage(), e ); - } - } - } - return pluginComponent; - } - - /** - * Verify plugin. - * - * @param plugin the plugin - * @param project the project - * @param session the session - * @return the plugin descriptor - * @throws LifecycleExecutionException the lifecycle execution exception - * @throws PluginNotFoundException the plugin not found exception - */ - private PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) - throws LifecycleExecutionException, PluginNotFoundException - { - PluginDescriptor pluginDescriptor; - try - { - pluginDescriptor = pluginManager.loadPluginDescriptor( plugin, project, session ); - } - catch ( PluginManagerException e ) - { - throw new LifecycleExecutionException( "Internal error in the plugin manager getting plugin '" - + plugin.getKey() + "': " + e.getMessage(), e ); - } - catch ( PluginVersionResolutionException | InvalidVersionSpecificationException | InvalidPluginException // - | ArtifactNotFoundException | ArtifactResolutionException | PluginVersionNotFoundException e ) - { - throw new LifecycleExecutionException( e.getMessage(), e ); - } - return pluginDescriptor; + // we need to provide a copy with the version blanked out so that inferring from super-pom + // works as for 2.x as 3.x fills in the version on us! + return lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( project.getPackaging() ) + .parallelStream() + .map( p -> new Plugin() + {{ + setGroupId( p.getGroupId() ); + setArtifactId( p.getArtifactId() ); + }} ) + .collect( toSet() ); } /** @@ -1441,7 +1028,7 @@ private PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject proje * @since 1.0-alpha-1 */ private List getParentProjects( MavenProject project ) - throws MojoExecutionException + throws MojoExecutionException { List parents = new ArrayList<>(); while ( project.getParent() != null ) @@ -1452,45 +1039,7 @@ private List getParentProjects( MavenProject project ) return parents; } - /* - * NOTE: All the code following this point was scooped from the DefaultLifecycleExecutor. There must be a better way - * but for now it should work. - */ - - /** - * Gets the phase to lifecycle map. - * - * @param lifecycles The list of lifecycles. - * @return the phase to lifecycle map. - * @throws LifecycleExecutionException the lifecycle execution exception. - */ - public Map getPhaseToLifecycleMap( List lifecycles ) - throws LifecycleExecutionException - { - Map phaseToLifecycleMap = new HashMap<>(); - - for ( Lifecycle lifecycle : lifecycles ) - { - for ( String phase : lifecycle.getPhases() ) - { - if ( phaseToLifecycleMap.containsKey( phase ) ) - { - Lifecycle prevLifecycle = phaseToLifecycleMap.get( phase ); - throw new LifecycleExecutionException( "Phase '" + phase - + "' is defined in more than one lifecycle: '" - + lifecycle.getId() + "' and '" - + prevLifecycle.getId() + "'" ); - } - else - { - phaseToLifecycleMap.put( phase, lifecycle ); - } - } - } - return phaseToLifecycleMap; - } - - /** + /** * Returns the set of all plugins used by the project. * * @param superPomPluginManagement the super pom's pluginManagement plugins. @@ -1507,7 +1056,7 @@ private Set getProjectPlugins( Map superPomPluginManagem Map parentBuildPlugins, Map parentReportPlugins, Set pluginsWithVersionsSpecified ) - throws MojoExecutionException + throws MojoExecutionException { Map plugins = new HashMap<>(); @@ -1544,13 +1093,13 @@ private Set getProjectPlugins( Map superPomPluginManagem ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); modelBuildingRequest.setUserProperties( getProject().getProperties() ); Model originalModel = - modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), - modelBuildingRequest, new IgnoringModelProblemCollector() ); + modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), + modelBuildingRequest, new IgnoringModelProblemCollector() ); try { addProjectPlugins( plugins, originalModel.getBuild().getPluginManagement().getPlugins(), - excludePluginManagement ); + excludePluginManagement ); } catch ( NullPointerException e ) { @@ -1642,7 +1191,7 @@ private Set getProjectPlugins( Map superPomPluginManagem try { addProjectPlugins( plugins, profile.getBuild().getPluginManagement().getPlugins(), - excludePluginManagement ); + excludePluginManagement ); } catch ( NullPointerException e ) { @@ -1692,8 +1241,8 @@ private void addProjectPlugins( Map plugins, Collection String version = plugin.getVersion(); String parentVersion = parentDefinitions.get( coord ); if ( version == null - && ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null ) - && parentVersion != null ) + && ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null ) + && parentVersion != null ) { Plugin parentPlugin = new Plugin(); parentPlugin.setGroupId( plugin.getGroupId() ); diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java index dd49650b40..1f232613b7 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java @@ -27,7 +27,6 @@ import java.nio.file.Paths; import java.util.Set; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -74,9 +73,6 @@ public class RevertMojo extends AbstractMojo */ protected final ProjectBuilder projectBuilder; - @Parameter( defaultValue = "${localRepository}", readonly = true ) - protected ArtifactRepository localRepository; - @Inject protected RevertMojo( ProjectBuilder projectBuilder ) { diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java index c62ac79d10..89f0a75cc7 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java @@ -28,7 +28,6 @@ import org.apache.maven.doxia.tools.SiteTool; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugin.testing.MojoRule; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; import org.junit.Rule; import org.junit.Test; @@ -47,7 +46,6 @@ public class PropertyUpdatesReportMojoTest extends AbstractMojoTestCase public MojoRule mojoRule = new MojoRule( this ); private static final org.eclipse.aether.RepositorySystem AETHER_REPOSITORY_SYSTEM = mockAetherRepositorySystem(); private static final SiteTool SITE_TOOL = mockSiteTool(); - private static final StubArtifactRepository LOCAL_REPOSITORY = new StubArtifactRepository( "" ); @Test public void testIncludeParentTrueShouldContainProperty() throws Exception @@ -59,7 +57,6 @@ public void testIncludeParentTrueShouldContainProperty() throws Exception (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), "property-updates-report" ); - setVariableValueToObject( mojo, "localRepository", LOCAL_REPOSITORY ); setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); setVariableValueToObject( mojo, "includeParent", true ); @@ -82,7 +79,6 @@ public void testIncludeParentFalseShouldNotContainProperty() throws Exception (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), "property-updates-report" ); - setVariableValueToObject( mojo, "localRepository", new StubArtifactRepository( "" ) ); setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); setVariableValueToObject( mojo, "includeParent", false ); diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index 2673a73bb2..f7a25407ee 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -7,7 +7,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; @@ -50,8 +49,6 @@ public class UpdateParentMojoTest private UpdateParentMojo mojo; - private ArtifactResolver artifactResolver; - private static RepositorySystem repositorySystem; private static org.eclipse.aether.RepositorySystem aetherRepositorySystem; diff --git a/versions-test/pom.xml b/versions-test/pom.xml index 316baef3c2..3c81525f99 100644 --- a/versions-test/pom.xml +++ b/versions-test/pom.xml @@ -36,10 +36,15 @@ org.apache.maven - maven-compat + maven-core ${mavenVersion} provided + + org.eclipse.aether + aether-api + 1.1.0 + org.apache.maven.doxia doxia-integration-tools From 3003f8bde8b2e6e778be1d0e39e479d8aeed9c7a Mon Sep 17 00:00:00 2001 From: mstemberger Date: Mon, 5 Dec 2022 19:55:51 +0100 Subject: [PATCH 227/441] Fixed #333 adding aggregate plugins information to site --- versions-maven-plugin/src/site/markdown/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/versions-maven-plugin/src/site/markdown/index.md b/versions-maven-plugin/src/site/markdown/index.md index 69a48c2e8e..3aa1cc9dea 100644 --- a/versions-maven-plugin/src/site/markdown/index.md +++ b/versions-maven-plugin/src/site/markdown/index.md @@ -79,10 +79,17 @@ The Versions Plugin has the following goals. The Versions Plugin has the following reporting goals. * [versions:dependency-updates-report](./dependency-updates-report-mojo.html) produces a report of those project dependencies which have newer versions available. +* [versions:dependency-updates-aggregate-report](./dependency-updates-aggregate-report-mojo.html) produces an aggregated + report(project + its submodules) of those dependencies which have newer versions available. * [versions:plugin-updates-report](./plugin-updates-report-mojo.html) produces a report of those plugins which have newer versions available. +* [versions:plugin-updates-aggregate-report](./plugin-updates-aggregate-report-mojo.html) produces an aggregated report + (project + its submodules) of those plugins which have newer versions available. * [versions:property-updates-report](./property-updates-report-mojo.html) produces a report of those properties which are used to control artifact versions and which properties have newer versions available. +* [versions:property-updates-aggregate-report](./property-updates-aggregate-report-mojo.html) produces an aggregated + report(project + its submodules) of those properties which are used to control artifact versions and + which properties have newer versions available. * [versions:parent-updates-report](./parent-updates-report-mojo.html) produces a report on possible parent artifact upgrades. From 3e4aee00be9aa503d5c19b94dc4d42982eb74652 Mon Sep 17 00:00:00 2001 From: Andrzej Jarmoniuk Date: Tue, 6 Dec 2022 17:40:43 +0100 Subject: [PATCH 228/441] Wagon should use remote repository instead of proxy repository for repo authentication --- .../org/codehaus/mojo/versions/api/DefaultVersionsHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index b0a6d1483c..cc55e3f379 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -847,7 +847,7 @@ private Optional getAuthenticationInfo( RemoteRepository rep .map( authentication -> new AuthenticationInfo() {{ try ( AuthenticationContext authCtx = AuthenticationContext - .forProxy( mavenSession.getRepositorySession(), repository ) ) + .forRepository( mavenSession.getRepositorySession(), repository ) ) { ofNullable( authCtx.get( AuthenticationContext.USERNAME ) ) .ifPresent( this::setUserName ); From 1f7058d25f4b388b1eaa9f19741f285f76569445 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 11 Dec 2022 18:35:17 +0100 Subject: [PATCH 229/441] Bump parent version from 71 to 72 --- pom.xml | 78 +------------------ versions-maven-plugin/pom.xml | 2 +- ...AbstractVersionsDependencyUpdaterMojo.java | 4 +- 3 files changed, 6 insertions(+), 78 deletions(-) diff --git a/pom.xml b/pom.xml index a2bf061caa..fcebe8d5e1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.codehaus.mojo mojo-parent - 71 + 72 org.codehaus.mojo.versions @@ -212,25 +212,6 @@ - - - - org.eclipse.sisu - sisu-maven-plugin - ${sisu-maven-plugin-version} - - - generate-index - - main-index - test-index - - - - - - - org.apache.maven.plugins @@ -275,64 +256,11 @@ - - + org.apache.maven.plugins - maven-checkstyle-plugin - - - - true - - - - - - org.apache.maven.plugins - maven-jxr-plugin - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - - - - - - - - org.apache.maven.plugins - maven-pmd-plugin - - - - true - - - - - - org.apache.maven.plugins - maven-surefire-report-plugin - - - - true - - - - - - org.codehaus.mojo - taglist-maven-plugin - ${taglist-maven-plugin.version} + maven-plugin-report-plugin diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 19f022fd5c..629e0eaa5a 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -214,7 +214,7 @@ org.apache.maven.plugins - maven-plugin-plugin + maven-plugin-report-plugin diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 04b5dc541f..2f442832aa 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -73,7 +73,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * A comma separated list of artifact patterns to include. Follows the pattern * "groupId:artifactId:type:classifier:version". Designed to allow specifying the set of includes from the command * line. When specifying includes from the pom, use the {@link #includes} configuration instead. If this property is - * specified then the {@link # include} configuration is ignored. + * specified then the {@link #includes} configuration is ignored. * * @since 1.0-beta-1 */ @@ -84,7 +84,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * A comma separated list of artifact patterns to exclude. Follows the pattern * "groupId:artifactId:type:classifier:version". Designed to allow specifying the set of excludes from the command * line. When specifying excludes from the pom, use the {@link #excludes} configuration instead. If this property is - * specified then the {@link # exclude} configuration is ignored. + * specified then the {@link #excludes} configuration is ignored. * * @since 1.0-beta-1 */ From 42341fb778c83994def92ee7975930359b73047c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 11 Dec 2022 22:03:53 +0100 Subject: [PATCH 230/441] Enable Spotless plugin - automatic code formatting --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index fcebe8d5e1..122f136dbf 100644 --- a/pom.xml +++ b/pom.xml @@ -213,9 +213,16 @@ + + com.diffplug.spotless + spotless-maven-plugin + org.apache.maven.plugins maven-checkstyle-plugin + + ${checkstyle.spotless.config} + org.codehaus.mojo From 1fb9f3be46943a2c67e32ff23ed2246d1b4e4fd9 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 11 Dec 2022 22:11:51 +0100 Subject: [PATCH 231/441] Enable Spotless plugin - code reformat --- pom.xml | 16 +- versions-api/pom.xml | 4 +- .../versions/api/change/VersionChange.java | 4 +- .../versions/api/recording/ChangeRecord.java | 24 +- .../api/recording/ChangeRecorder.java | 7 +- versions-common/pom.xml | 238 ++- .../versions/api/AbstractVersionDetails.java | 480 +++--- .../versions/api/ArtifactAssociation.java | 3 +- .../mojo/versions/api/ArtifactVersions.java | 121 +- .../versions/api/ArtifactVersionsCache.java | 18 +- .../api/DefaultArtifactAssociation.java | 71 +- .../versions/api/DefaultVersionsHelper.java | 976 +++++------ .../versions/api/PluginUpdatesDetails.java | 37 +- .../codehaus/mojo/versions/api/PomHelper.java | 1444 +++++++---------- .../codehaus/mojo/versions/api/Property.java | 57 +- .../mojo/versions/api/PropertyVersions.java | 398 ++--- .../versions/api/PropertyVersionsBuilder.java | 196 +-- .../mojo/versions/api/ReportRenderer.java | 3 +- .../codehaus/mojo/versions/api/Segment.java | 25 +- .../mojo/versions/api/VersionDetails.java | 79 +- .../api/VersionRetrievalException.java | 21 +- .../mojo/versions/api/VersionsHelper.java | 106 +- .../change/AbstractVersionChanger.java | 18 +- .../change/CompositeVersionChanger.java | 23 +- .../versions/change/DefaultVersionChange.java | 50 +- .../change/DependencyVersionChanger.java | 28 +- .../versions/change/ParentVersionChanger.java | 27 +- .../versions/change/PluginVersionChanger.java | 26 +- .../change/ProjectVersionChanger.java | 26 +- .../mojo/versions/change/VersionChanger.java | 6 +- .../change/VersionChangerFactory.java | 99 +- .../versions/filtering/DependencyFilter.java | 84 +- .../filtering/NullAwareWildcardMatcher.java | 16 +- .../versions/filtering/TokenizedMatcher.java | 110 +- .../versions/filtering/WildcardMatcher.java | 71 +- .../ordering/AbstractVersionComparator.java | 31 +- .../ordering/BoundArtifactVersion.java | 98 +- .../versions/ordering/ComparableVersion.java | 290 ++-- .../ordering/InvalidSegmentException.java | 20 +- .../ordering/MavenVersionComparator.java | 142 +- .../ordering/MercuryVersionComparator.java | 106 +- .../ordering/NumericVersionComparator.java | 302 ++-- .../ordering/ReactorDepthComparator.java | 27 +- .../versions/ordering/VersionComparator.java | 6 +- .../versions/ordering/VersionComparators.java | 130 +- .../recording/ChangeRecorderNull.java | 17 +- .../versions/recording/ChangeRecorderXML.java | 70 +- .../recording/DefaultChangeRecord.java | 53 +- .../rewriting/ModifiedPomXMLEventReader.java | 273 ++-- .../mojo/versions/utils/ContextualLog.java | 6 +- .../utils/DelegatingContextualLog.java | 150 +- .../versions/utils/DependencyBuilder.java | 95 +- .../versions/utils/DependencyComparator.java | 25 +- .../versions/utils/MavenProjectUtils.java | 113 +- .../mojo/versions/utils/MiscUtils.java | 12 +- .../mojo/versions/utils/PluginComparator.java | 47 +- .../utils/PropertiesVersionsFileReader.java | 42 +- .../versions/utils/PropertyComparator.java | 17 +- .../mojo/versions/utils/RegexUtils.java | 103 +- .../mojo/versions/utils/SegmentUtils.java | 34 +- .../utils/VersionsExpressionEvaluator.java | 10 +- .../versions/api/ArtifactVersionsTest.java | 260 +-- .../api/DefaultVersionsHelperTest.java | 363 +++-- .../mojo/versions/api/PomHelperTest.java | 197 +-- .../filtering/DependencyFilterTest.java | 191 +-- .../versions/filtering/HasGAVMatcher.java | 30 +- .../filtering/TokenizedMatcherTest.java | 151 +- .../filtering/WildcardMatcherTest.java | 319 ++-- .../ordering/BoundArtifactVersionTest.java | 83 +- .../ordering/MavenVersionComparatorTest.java | 63 +- .../MercuryVersionComparatorTest.java | 25 +- .../NumericVersionComparatorTest.java | 104 +- .../ordering/VersionComparatorTestBase.java | 72 +- .../recording/ChangeRecorderXMLTest.java | 125 +- .../ModifiedPomXMLEventReaderTest.java | 85 +- .../utils/ModifiedPomXMLEventReaderUtils.java | 29 +- .../PropertiesVersionsFileReaderTest.java | 28 +- .../mojo/versions/utils/SegmentUtilsTest.java | 36 +- .../mojo/versions/utils/VersionStub.java | 30 +- versions-enforcer/pom.xml | 354 ++-- .../enforcer/MaxDependencyUpdates.java | 207 +-- .../enforcer/MaxDependencyUpdatesTest.java | 359 ++-- versions-maven-plugin/pom.xml | 18 +- .../AbstractDependencyUpdatesReportMojo.java | 259 ++- .../AbstractPluginUpdatesReportMojo.java | 158 +- .../AbstractPropertyUpdatesReportMojo.java | 130 +- ...AbstractVersionsDependencyUpdaterMojo.java | 364 ++--- .../versions/AbstractVersionsDisplayMojo.java | 136 +- .../mojo/versions/AbstractVersionsReport.java | 128 +- .../versions/AbstractVersionsUpdaterMojo.java | 295 ++-- .../codehaus/mojo/versions/CommitMojo.java | 30 +- .../versions/CompareDependenciesMojo.java | 413 ++--- .../DependencyUpdatesAggregateReportMojo.java | 54 +- .../versions/DependencyUpdatesReportMojo.java | 50 +- .../DisplayDependencyUpdatesMojo.java | 336 ++-- .../versions/DisplayParentUpdatesMojo.java | 138 +- .../versions/DisplayPluginUpdatesMojo.java | 1245 ++++++-------- .../versions/DisplayPropertyUpdatesMojo.java | 181 +-- .../mojo/versions/ForceReleasesMojo.java | 124 +- .../mojo/versions/LockSnapshotsMojo.java | 176 +- .../MinimalMavenBuildVersionFinder.java | 194 +-- .../versions/ParentUpdatesReportMojo.java | 92 +- .../PluginUpdatesAggregateReportMojo.java | 53 +- .../versions/PluginUpdatesReportMojo.java | 44 +- .../PropertyUpdatesAggregateReportMojo.java | 48 +- .../versions/PropertyUpdatesReportMojo.java | 34 +- .../mojo/versions/ResolveRangesMojo.java | 252 ++- .../codehaus/mojo/versions/RevertMojo.java | 66 +- .../org/codehaus/mojo/versions/SetMojo.java | 478 +++--- .../mojo/versions/SetPropertyMojo.java | 127 +- .../codehaus/mojo/versions/SetScmTagMojo.java | 117 +- .../mojo/versions/UnlockSnapshotsMojo.java | 158 +- .../mojo/versions/UpdateChildModulesMojo.java | 178 +- .../mojo/versions/UpdateParentMojo.java | 170 +- .../mojo/versions/UpdatePropertiesMojo.java | 56 +- .../versions/UpdatePropertiesMojoBase.java | 116 +- .../mojo/versions/UpdatePropertyMojo.java | 63 +- .../mojo/versions/UseDepVersionMojo.java | 115 +- .../mojo/versions/UseLatestReleasesMojo.java | 128 +- .../mojo/versions/UseLatestSnapshotsMojo.java | 99 +- .../mojo/versions/UseLatestVersionsMojo.java | 109 +- .../versions/UseLatestVersionsMojoBase.java | 73 +- .../mojo/versions/UseNextReleasesMojo.java | 73 +- .../mojo/versions/UseNextSnapshotsMojo.java | 96 +- .../mojo/versions/UseNextVersionsMojo.java | 70 +- .../mojo/versions/UseReactorMojo.java | 109 +- .../mojo/versions/UseReleasesMojo.java | 145 +- .../AbstractVersionsReportRenderer.java | 287 ++-- .../DependencyUpdatesReportRenderer.java | 58 +- .../versions/reporting/OverviewStats.java | 71 +- .../ParentUpdatesReportRenderer.java | 18 +- .../reporting/PluginOverviewStats.java | 41 +- .../PluginUpdatesReportRenderer.java | 145 +- .../PropertyUpdatesReportRenderer.java | 138 +- .../reporting/ReportRendererFactory.java | 5 +- .../reporting/ReportRendererFactoryImpl.java | 41 +- .../reporting/VersionsReportRendererBase.java | 138 +- .../reporting/model/AbstractUpdatesModel.java | 42 +- .../model/DependencyUpdatesModel.java | 11 +- .../reporting/model/ParentUpdatesModel.java | 8 +- .../reporting/model/PluginUpdatesModel.java | 19 +- .../reporting/model/PropertyUpdatesModel.java | 15 +- .../reporting/util/AggregateReportUtils.java | 15 +- .../xml/CommonXmlReportRendererUtils.java | 23 +- .../DependencyUpdatesXmlReportRenderer.java | 93 +- .../xml/PluginUpdatesXmlReportRenderer.java | 95 +- .../xml/PropertyUpdatesXmlReportRenderer.java | 106 +- .../AbstractVersionsUpdaterMojoTest.java | 27 +- .../DependencyUpdatesReportMojoTest.java | 343 ++-- .../DependencyUpdatesXmlRendererTest.java | 87 +- .../DisplayDependencyUpdatesMojoTest.java | 561 ++++--- .../DisplayPropertyUpdatesMojoTest.java | 64 +- .../mojo/versions/ForceReleasesMojoTest.java | 247 +-- .../MinimalMavenBuildVersionFinderTest.java | 52 +- .../versions/ParentUpdatesReportMojoTest.java | 82 +- .../versions/PluginUpdatesReportMojoTest.java | 194 +-- .../PluginUpdatesXmlRendererTest.java | 99 +- .../PropertyUpdatesReportMojoTest.java | 58 +- .../mojo/versions/RevertMojoTest.java | 53 +- .../mojo/versions/RewriteWithStAXTest.java | 366 ++--- ...ratePatternsForIncludesAnExcludesTest.java | 87 +- .../codehaus/mojo/versions/SetMojoTest.java | 159 +- .../mojo/versions/SetPropertyMojoTest.java | 98 +- .../mojo/versions/SetScmTagMojoTest.java | 31 +- .../mojo/versions/UpdateParentMojoTest.java | 494 +++--- .../versions/UpdatePropertiesMojoTest.java | 73 +- .../UpdatePropertiesMojoTestBase.java | 48 +- .../mojo/versions/UpdatePropertyMojoTest.java | 52 +- .../mojo/versions/UseDepVersionMojoTest.java | 23 +- .../versions/UseLatestReleasesMojoTest.java | 124 +- .../versions/UseLatestVersionsMojoTest.java | 484 +++--- .../mojo/versions/UseReleasesMojoTest.java | 163 +- .../versions/model/TestIgnoreVersions.java | 37 +- versions-model-report/pom.xml | 144 +- versions-model/pom.xml | 136 +- versions-test/pom.xml | 105 +- .../mojo/versions/utils/MockUtils.java | 140 +- .../versions/utils/TestChangeRecorder.java | 22 +- .../mojo/versions/utils/TestUtils.java | 49 +- .../mojo/versions/utils/VersionStub.java | 30 +- 180 files changed, 10393 insertions(+), 13448 deletions(-) diff --git a/pom.xml b/pom.xml index 122f136dbf..67eb0fe9d4 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - + + 4.0.0 @@ -108,8 +107,8 @@ scm:git:https://github.com/mojohaus/versions.git scm:git:ssh://git@github.com/mojohaus/versions.git - https://github.com/mojohaus/versions/tree/master HEAD + https://github.com/mojohaus/versions/tree/master @@ -133,7 +132,8 @@ 3.7 2.1.0 2.0.0 - ${project.build.directory}/staging + ${project.build.directory}/staging + 2022-10-23T15:41:47Z 0.9.0.M1 @@ -230,10 +230,10 @@ check-java18 - test check + test org.codehaus.mojo.signature @@ -251,11 +251,11 @@ default-site - site site stage + site @@ -270,7 +270,7 @@ maven-plugin-report-plugin - + diff --git a/versions-api/pom.xml b/versions-api/pom.xml index 72458be0d6..748c3a4296 100644 --- a/versions-api/pom.xml +++ b/versions-api/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java index 656d42aa0b..c8b6f63216 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/change/VersionChange.java @@ -23,8 +23,7 @@ * @author Slawomir Jaranowski * @since 2.14.0 */ -public interface VersionChange -{ +public interface VersionChange { /** * @return a groupId of changed item * @since 2.14.0 @@ -48,5 +47,4 @@ public interface VersionChange * @since 2.14.0 */ String getNewVersion(); - } diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java index 18ab668071..9328aac507 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecord.java @@ -25,29 +25,25 @@ * @author Slawomir Jaranowski * @since 2.14.0 */ -public interface ChangeRecord -{ +public interface ChangeRecord { /** * Describe where version item is updated. */ - enum ChangeKind - { - DEPENDENCY( "dependency-update" ), - DEPENDENCY_MANAGEMENT( "dependency-management-update" ), - PARENT( "parent-update" ), - PLUGIN( "plugin-update" ), - PLUGIN_MANAGEMENT( "plugin-management-update" ), - PROPERTY( "property-update" ); + enum ChangeKind { + DEPENDENCY("dependency-update"), + DEPENDENCY_MANAGEMENT("dependency-management-update"), + PARENT("parent-update"), + PLUGIN("plugin-update"), + PLUGIN_MANAGEMENT("plugin-management-update"), + PROPERTY("property-update"); private final String label; - ChangeKind( String label ) - { + ChangeKind(String label) { this.label = label; } - public String getLabel() - { + public String getLabel() { return label; } } diff --git a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java index 42d961357c..4618818250 100644 --- a/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java +++ b/versions-api/src/main/java/org/codehaus/mojo/versions/api/recording/ChangeRecorder.java @@ -26,15 +26,14 @@ * @author Slawomir Jaranowski * @since 2.14.0 */ -public interface ChangeRecorder -{ +public interface ChangeRecorder { /** * Record that a dependency was updated. * * @param changeRecord a record described change * @since 2.14.0 */ - void recordChange( ChangeRecord changeRecord ); + void recordChange(ChangeRecord changeRecord); /** * Write the current set of changes to the given output path. @@ -48,5 +47,5 @@ public interface ChangeRecorder * @throws IOException On write and/or I/O errors * @since 2.14.0 */ - void writeReport( Path outputPath ) throws IOException; + void writeReport(Path outputPath) throws IOException; } diff --git a/versions-common/pom.xml b/versions-common/pom.xml index 5f40995b25..a566ae9d93 100644 --- a/versions-common/pom.xml +++ b/versions-common/pom.xml @@ -1,129 +1,127 @@ - - - versions - org.codehaus.mojo.versions - 2.14.0-SNAPSHOT - - 4.0.0 + + 4.0.0 + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + - versions-common + versions-common - Versions Common - Common components for the Versions Maven Plugin + Versions Common + Common components for the Versions Maven Plugin - - - org.codehaus.mojo.versions - versions-api - 2.14.0-SNAPSHOT - - - org.codehaus.mojo.versions - versions-model - ${project.version} - + + + org.codehaus.mojo.versions + versions-api + 2.14.0-SNAPSHOT + + + org.codehaus.mojo.versions + versions-model + ${project.version} + - - org.apache.maven - maven-artifact - ${mavenVersion} - provided - + + org.apache.maven + maven-artifact + ${mavenVersion} + provided + - - org.apache.maven - maven-core - ${mavenVersion} - provided - - - org.apache.maven.wagon - wagon-provider-api - 3.5.2 - - - org.apache.maven - maven-model - ${mavenVersion} - provided - - - org.apache.maven - maven-plugin-api - ${mavenVersion} - provided - - - org.apache.maven - maven-settings - ${mavenVersion} - provided - - - - com.fasterxml.woodstox - woodstox-core - test - - - org.apache.commons - commons-lang3 - + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.apache.maven.wagon + wagon-provider-api + 3.5.2 + + + org.apache.maven + maven-model + ${mavenVersion} + provided + + + org.apache.maven + maven-plugin-api + ${mavenVersion} + provided + + + org.apache.maven + maven-settings + ${mavenVersion} + provided + + + + com.fasterxml.woodstox + woodstox-core + test + + + org.apache.commons + commons-lang3 + - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - test - - - org.junit.jupiter - junit-jupiter - test - - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - - - org.mockito - mockito-inline - test - - - org.hamcrest - hamcrest - test - - - org.slf4j - slf4j-simple - test - - - - org.apache.maven - maven-compat - ${mavenVersion} - test - - + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + test + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + + + org.mockito + mockito-inline + test + + + org.hamcrest + hamcrest + test + + + org.slf4j + slf4j-simple + test + + + + org.apache.maven + maven-compat + ${mavenVersion} + test + + - - - - org.eclipse.sisu - sisu-maven-plugin - - - + + + + org.eclipse.sisu + sisu-maven-plugin + + + diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java index 13e8966c88..3ba86c0a7d 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/AbstractVersionDetails.java @@ -51,13 +51,11 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -public abstract class AbstractVersionDetails - implements VersionDetails -{ +public abstract class AbstractVersionDetails implements VersionDetails { private static final Pattern PREVIEW_PATTERN = - Pattern.compile( "(?i)(?:.*[-.](alpha|a|beta|b|milestone|m|preview|rc)" - + "[-.]?(\\d{0,2}[a-z]?|\\d{6}\\.\\d{4})|\\d{8}(?:\\.?\\d{6})?)$" ); + Pattern.compile("(?i)(?:.*[-.](alpha|a|beta|b|milestone|m|preview|rc)" + + "[-.]?(\\d{0,2}[a-z]?|\\d{6}\\.\\d{4})|\\d{8}(?:\\.?\\d{6})?)$"); /** * The current version. Guarded by {@link #currentVersionLock}. @@ -83,359 +81,299 @@ public abstract class AbstractVersionDetails */ private final Object currentVersionLock = new Object(); - protected AbstractVersionDetails() - { - } + protected AbstractVersionDetails() {} @Override - public Restriction restrictionFor( Optional scope ) - throws InvalidSegmentException - { + public Restriction restrictionFor(Optional scope) throws InvalidSegmentException { // one range spec can have multiple restrictions, and multiple 'lower bound', we want the highest one. // [1.0,2.0),[3.0,4.0) -> 3.0 ArtifactVersion highestLowerBound = currentVersion; - if ( currentVersion != null ) - { - try - { - highestLowerBound = VersionRange.createFromVersionSpec( currentVersion.toString() ) - .getRestrictions().stream().map( Restriction::getLowerBound ).filter( Objects::nonNull ) - .max( getVersionComparator() ).orElse( currentVersion ); - } - catch ( InvalidVersionSpecificationException ignored ) - { - ignored.printStackTrace( System.err ); + if (currentVersion != null) { + try { + highestLowerBound = + VersionRange.createFromVersionSpec(currentVersion.toString()).getRestrictions().stream() + .map(Restriction::getLowerBound) + .filter(Objects::nonNull) + .max(getVersionComparator()) + .orElse(currentVersion); + } catch (InvalidVersionSpecificationException ignored) { + ignored.printStackTrace(System.err); } } final ArtifactVersion currentVersion = highestLowerBound; - ArtifactVersion nextVersion = scope - .filter( s -> s.isMajorTo( SUBINCREMENTAL ) ) - .map( s -> (ArtifactVersion) - new BoundArtifactVersion( currentVersion, Segment.of( s.value() + 1 ) ) ) - .orElse( currentVersion ); - return new Restriction( nextVersion, false, scope.filter( MAJOR::isMajorTo ) - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ).orElse( null ), - false ); + ArtifactVersion nextVersion = scope.filter(s -> s.isMajorTo(SUBINCREMENTAL)) + .map(s -> (ArtifactVersion) new BoundArtifactVersion(currentVersion, Segment.of(s.value() + 1))) + .orElse(currentVersion); + return new Restriction( + nextVersion, + false, + scope.filter(MAJOR::isMajorTo) + .map(s -> (ArtifactVersion) new BoundArtifactVersion(currentVersion, s)) + .orElse(null), + false); } @Override - public Restriction restrictionForIgnoreScope( Optional ignored ) - { - ArtifactVersion nextVersion = ignored - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, s ) ) - .orElse( currentVersion ); - return new Restriction( nextVersion, false, null, false ); + public Restriction restrictionForIgnoreScope(Optional ignored) { + ArtifactVersion nextVersion = ignored.map(s -> (ArtifactVersion) new BoundArtifactVersion(currentVersion, s)) + .orElse(currentVersion); + return new Restriction(nextVersion, false, null, false); } @Override - public final boolean isCurrentVersionDefined() - { + public final boolean isCurrentVersionDefined() { return getCurrentVersion() != null; } @Override - public final ArtifactVersion getCurrentVersion() - { - synchronized ( currentVersionLock ) - { + public final ArtifactVersion getCurrentVersion() { + synchronized (currentVersionLock) { return currentVersion; } } @Override - public final void setCurrentVersion( ArtifactVersion currentVersion ) - { - synchronized ( currentVersionLock ) - { + public final void setCurrentVersion(ArtifactVersion currentVersion) { + synchronized (currentVersionLock) { this.currentVersion = currentVersion; } } @Override - public final void setCurrentVersion( String currentVersion ) - { - setCurrentVersion( currentVersion == null ? null : new DefaultArtifactVersion( currentVersion ) ); + public final void setCurrentVersion(String currentVersion) { + setCurrentVersion(currentVersion == null ? null : new DefaultArtifactVersion(currentVersion)); } @Override - public final boolean isIncludeSnapshots() - { - synchronized ( currentVersionLock ) - { + public final boolean isIncludeSnapshots() { + synchronized (currentVersionLock) { return includeSnapshots; } } @Override - public final void setIncludeSnapshots( boolean includeSnapshots ) - { - synchronized ( currentVersionLock ) - { + public final void setIncludeSnapshots(boolean includeSnapshots) { + synchronized (currentVersionLock) { this.includeSnapshots = includeSnapshots; } } @Override - public final ArtifactVersion[] getVersions() - { - return getVersions( isIncludeSnapshots() ); + public final ArtifactVersion[] getVersions() { + return getVersions(isIncludeSnapshots()); } @Override - public abstract ArtifactVersion[] getVersions( boolean includeSnapshots ); + public abstract ArtifactVersion[] getVersions(boolean includeSnapshots); @Override - public final ArtifactVersion[] getVersions( VersionRange versionRange, boolean includeSnapshots ) - { - return getVersions( versionRange, null, includeSnapshots ); + public final ArtifactVersion[] getVersions(VersionRange versionRange, boolean includeSnapshots) { + return getVersions(versionRange, null, includeSnapshots); } @Override - public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound ) - { - return getVersions( lowerBound, upperBound, isIncludeSnapshots() ); + public final ArtifactVersion[] getVersions(ArtifactVersion lowerBound, ArtifactVersion upperBound) { + return getVersions(lowerBound, upperBound, isIncludeSnapshots()); } @Override - public final ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - return getVersions( restriction, includeSnapshots ); + public final ArtifactVersion[] getVersions( + ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots) { + Restriction restriction = new Restriction(lowerBound, false, upperBound, false); + return getVersions(restriction, includeSnapshots); } @Override - public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ) - { - return getNewestVersion( lowerBound, upperBound, isIncludeSnapshots() ); + public final ArtifactVersion getNewestVersion(ArtifactVersion lowerBound, ArtifactVersion upperBound) { + return getNewestVersion(lowerBound, upperBound, isIncludeSnapshots()); } @Override - public final ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots ) - { - Restriction restriction = new Restriction( lowerBound, false, upperBound, false ); - return getNewestVersion( restriction, includeSnapshots ); + public final ArtifactVersion getNewestVersion( + ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots) { + Restriction restriction = new Restriction(lowerBound, false, upperBound, false); + return getNewestVersion(restriction, includeSnapshots); } @Override - public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, - boolean includeSnapshots ) - { - return getNewestVersion( versionRange, restriction, includeSnapshots, false ); + public final ArtifactVersion getNewestVersion( + VersionRange versionRange, Restriction restriction, boolean includeSnapshots) { + return getNewestVersion(versionRange, restriction, includeSnapshots, false); } @Override - public final ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, - boolean includeSnapshots, boolean allowDowngrade ) - { + public final ArtifactVersion getNewestVersion( + VersionRange versionRange, Restriction restriction, boolean includeSnapshots, boolean allowDowngrade) { // reverseOrder( getVersions( ... ) ) will contain versions sorted from latest to oldest, // so we only need to find the first candidate fulfilling the criteria - return Arrays.stream( getVersions( includeSnapshots ) ) - .sorted( reverseOrder() ) - .filter( candidate -> allowDowngrade || versionRange == null - || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) - .filter( candidate -> restriction == null || isVersionInRestriction( restriction, candidate ) ) - .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) + return Arrays.stream(getVersions(includeSnapshots)) + .sorted(reverseOrder()) + .filter(candidate -> allowDowngrade + || versionRange == null + || ArtifactVersions.isVersionInRange(candidate, versionRange)) + .filter(candidate -> restriction == null || isVersionInRestriction(restriction, candidate)) + .filter(candidate -> includeSnapshots || !ArtifactUtils.isSnapshot(candidate.toString())) .findAny() - .orElse( null ); + .orElse(null); } @Override - public final ArtifactVersion getNewestVersion( Restriction restriction, boolean includeSnapshots ) - { - return getNewestVersion( null, restriction, includeSnapshots ); + public final ArtifactVersion getNewestVersion(Restriction restriction, boolean includeSnapshots) { + return getNewestVersion(null, restriction, includeSnapshots); } @Override - public final ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ) - { - return getNewestVersion( versionRange, null, includeSnapshots ); + public final ArtifactVersion getNewestVersion(VersionRange versionRange, boolean includeSnapshots) { + return getNewestVersion(versionRange, null, includeSnapshots); } @Override - public final boolean containsVersion( String version ) - { - for ( ArtifactVersion candidate : getVersions( true ) ) - { - if ( version.equals( candidate.toString() ) ) - { + public final boolean containsVersion(String version) { + for (ArtifactVersion candidate : getVersions(true)) { + if (version.equals(candidate.toString())) { return true; } } return false; } - private ArtifactVersion[] getNewerVersions( ArtifactVersion version, boolean includeSnapshots ) - { - Restriction restriction = new Restriction( version, false, null, false ); - return getVersions( restriction, includeSnapshots ); + private ArtifactVersion[] getNewerVersions(ArtifactVersion version, boolean includeSnapshots) { + Restriction restriction = new Restriction(version, false, null, false); + return getVersions(restriction, includeSnapshots); } @Override - public final ArtifactVersion[] getNewerVersions( String version, boolean includeSnapshots ) - { - return getNewerVersions( new DefaultArtifactVersion( version ), includeSnapshots ); + public final ArtifactVersion[] getNewerVersions(String version, boolean includeSnapshots) { + return getNewerVersions(new DefaultArtifactVersion(version), includeSnapshots); } @Deprecated @Override - public final ArtifactVersion[] getNewerVersions( String version, Optional upperBoundSegment, - boolean includeSnapshots ) - throws InvalidSegmentException - { - return getNewerVersions( version, upperBoundSegment, includeSnapshots, false ); + public final ArtifactVersion[] getNewerVersions( + String version, Optional upperBoundSegment, boolean includeSnapshots) + throws InvalidSegmentException { + return getNewerVersions(version, upperBoundSegment, includeSnapshots, false); } @Override - public final ArtifactVersion[] getNewerVersions( String versionString, Optional unchangedSegment, - boolean includeSnapshots, boolean allowDowngrade ) - throws InvalidSegmentException - { - ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); + public final ArtifactVersion[] getNewerVersions( + String versionString, Optional unchangedSegment, boolean includeSnapshots, boolean allowDowngrade) + throws InvalidSegmentException { + ArtifactVersion currentVersion = new DefaultArtifactVersion(versionString); ArtifactVersion lowerBound = allowDowngrade - ? getLowerBound( currentVersion, unchangedSegment ) - .map( DefaultArtifactVersion::new ) - .orElse( null ) + ? getLowerBound(currentVersion, unchangedSegment) + .map(DefaultArtifactVersion::new) + .orElse(null) : currentVersion; - ArtifactVersion upperBound = - unchangedSegment - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, - s.isMajorTo( SUBINCREMENTAL ) - ? Segment.of( s.value() + 1 ) - : s ) ) - .orElse( null ); + ArtifactVersion upperBound = unchangedSegment + .map(s -> (ArtifactVersion) new BoundArtifactVersion( + currentVersion, s.isMajorTo(SUBINCREMENTAL) ? Segment.of(s.value() + 1) : s)) + .orElse(null); - Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); - return getVersions( restriction, includeSnapshots ); + Restriction restriction = new Restriction(lowerBound, allowDowngrade, upperBound, allowDowngrade); + return getVersions(restriction, includeSnapshots); } @Override - public Optional getNewestVersion( String versionString, Optional upperBoundSegment, - boolean includeSnapshots, boolean allowDowngrade ) - throws InvalidSegmentException - { - ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); + public Optional getNewestVersion( + String versionString, Optional upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade) + throws InvalidSegmentException { + ArtifactVersion currentVersion = new DefaultArtifactVersion(versionString); ArtifactVersion lowerBound = allowDowngrade - ? getLowerBound( currentVersion, upperBoundSegment ) - .map( DefaultArtifactVersion::new ) - .orElse( null ) + ? getLowerBound(currentVersion, upperBoundSegment) + .map(DefaultArtifactVersion::new) + .orElse(null) : currentVersion; - ArtifactVersion upperBound = - upperBoundSegment - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, - s.isMajorTo( SUBINCREMENTAL ) - ? Segment.of( s.value() + 1 ) - : s ) ) - .orElse( null ); + ArtifactVersion upperBound = upperBoundSegment + .map(s -> (ArtifactVersion) new BoundArtifactVersion( + currentVersion, s.isMajorTo(SUBINCREMENTAL) ? Segment.of(s.value() + 1) : s)) + .orElse(null); - Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); - return Arrays.stream( getVersions( includeSnapshots ) ) - .filter( candidate -> isVersionInRestriction( restriction, candidate ) ) - .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) - .max( getVersionComparator() ); + Restriction restriction = new Restriction(lowerBound, allowDowngrade, upperBound, allowDowngrade); + return Arrays.stream(getVersions(includeSnapshots)) + .filter(candidate -> isVersionInRestriction(restriction, candidate)) + .filter(candidate -> includeSnapshots || !ArtifactUtils.isSnapshot(candidate.toString())) + .max(getVersionComparator()); } @Override - public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ) - { - return getVersions( null, restriction, includeSnapshots ); + public final ArtifactVersion[] getVersions(Restriction restriction, boolean includeSnapshots) { + return getVersions(null, restriction, includeSnapshots); } @Override - public final ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, - boolean includeSnapshots ) - { - return Arrays.stream( getVersions( includeSnapshots ) ) - .filter( candidate -> - versionRange == null || ArtifactVersions.isVersionInRange( candidate, versionRange ) ) - .filter( candidate -> restriction == null || isVersionInRestriction( restriction, candidate ) ) - .filter( candidate -> includeSnapshots || !ArtifactUtils.isSnapshot( candidate.toString() ) ) - .sorted( getVersionComparator() ) + public final ArtifactVersion[] getVersions( + VersionRange versionRange, Restriction restriction, boolean includeSnapshots) { + return Arrays.stream(getVersions(includeSnapshots)) + .filter(candidate -> versionRange == null || ArtifactVersions.isVersionInRange(candidate, versionRange)) + .filter(candidate -> restriction == null || isVersionInRestriction(restriction, candidate)) + .filter(candidate -> includeSnapshots || !ArtifactUtils.isSnapshot(candidate.toString())) + .sorted(getVersionComparator()) .distinct() - .toArray( ArtifactVersion[]::new ); + .toArray(ArtifactVersion[]::new); } @Override - public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) - { - try - { - return getNewestVersion( restrictionFor( updateScope ), - includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { + public final ArtifactVersion getNewestUpdate( + ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots) { + try { + return getNewestVersion(restrictionFor(updateScope), includeSnapshots); + } catch (InvalidSegmentException e) { return null; } } @Override - public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) - { - try - { - return getVersions( restrictionFor( updateScope ), - includeSnapshots ); - } - catch ( InvalidSegmentException e ) - { + public final ArtifactVersion[] getAllUpdates( + ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots) { + try { + return getVersions(restrictionFor(updateScope), includeSnapshots); + } catch (InvalidSegmentException e) { return null; } } @Override - public final ArtifactVersion getNewestUpdate( Optional updateScope ) - { - return getNewestUpdate( updateScope, isIncludeSnapshots() ); + public final ArtifactVersion getNewestUpdate(Optional updateScope) { + return getNewestUpdate(updateScope, isIncludeSnapshots()); } @Override - public final ArtifactVersion[] getAllUpdates( Optional updateScope ) - { - return getAllUpdates( updateScope, isIncludeSnapshots() ); + public final ArtifactVersion[] getAllUpdates(Optional updateScope) { + return getAllUpdates(updateScope, isIncludeSnapshots()); } @Override - public final ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeSnapshots ) - { - if ( isCurrentVersionDefined() ) - { - return getNewestUpdate( getCurrentVersion(), updateScope, includeSnapshots ); + public final ArtifactVersion getNewestUpdate(Optional updateScope, boolean includeSnapshots) { + if (isCurrentVersionDefined()) { + return getNewestUpdate(getCurrentVersion(), updateScope, includeSnapshots); } return null; } @Override - public final ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) - { - if ( isCurrentVersionDefined() ) - { - return getAllUpdates( getCurrentVersion(), updateScope, includeSnapshots ); + public final ArtifactVersion[] getAllUpdates(Optional updateScope, boolean includeSnapshots) { + if (isCurrentVersionDefined()) { + return getAllUpdates(getCurrentVersion(), updateScope, includeSnapshots); } return null; } @Override - public final ArtifactVersion[] getAllUpdates() - { - return getAllUpdates( (VersionRange) null, isIncludeSnapshots() ); + public final ArtifactVersion[] getAllUpdates() { + return getAllUpdates((VersionRange) null, isIncludeSnapshots()); } @Override - public final ArtifactVersion[] getAllUpdates( VersionRange versionRange ) - { - return getAllUpdates( versionRange, isIncludeSnapshots() ); + public final ArtifactVersion[] getAllUpdates(VersionRange versionRange) { + return getAllUpdates(versionRange, isIncludeSnapshots()); } @Override - public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ) - { - Restriction restriction = new Restriction( getCurrentVersion(), false, null, false ); - return getVersions( versionRange, restriction, includeSnapshots ); + public ArtifactVersion[] getAllUpdates(VersionRange versionRange, boolean includeSnapshots) { + Restriction restriction = new Restriction(getCurrentVersion(), false, null, false); + return getVersions(versionRange, restriction, includeSnapshots); } /** @@ -449,44 +387,34 @@ public ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean inclu * @throws InvalidSegmentException if the requested segment is outside of the bounds (less than 1 or greater than * the segment count) */ - protected Optional getLowerBound( ArtifactVersion version, Optional unchangedSegment ) - throws InvalidSegmentException - { - if ( !unchangedSegment.isPresent() ) - { + protected Optional getLowerBound(ArtifactVersion version, Optional unchangedSegment) + throws InvalidSegmentException { + if (!unchangedSegment.isPresent()) { return empty(); } - int segmentCount = getVersionComparator().getSegmentCount( version ); - if ( unchangedSegment.get().value() > segmentCount ) - { - throw new InvalidSegmentException( unchangedSegment.get(), segmentCount, version ); + int segmentCount = getVersionComparator().getSegmentCount(version); + if (unchangedSegment.get().value() > segmentCount) { + throw new InvalidSegmentException(unchangedSegment.get(), segmentCount, version); } StringBuilder newVersion = new StringBuilder(); - newVersion.append( version.getMajorVersion() ); + newVersion.append(version.getMajorVersion()); - if ( segmentCount > 0 ) - { - newVersion.append( "." ).append( unchangedSegment.get().value() >= 1 ? version.getMinorVersion() : 0 ); + if (segmentCount > 0) { + newVersion.append(".").append(unchangedSegment.get().value() >= 1 ? version.getMinorVersion() : 0); } - if ( segmentCount > 1 ) - { - newVersion.append( "." ) - .append( unchangedSegment.get().value() >= 2 ? version.getIncrementalVersion() : 0 ); + if (segmentCount > 1) { + newVersion.append(".").append(unchangedSegment.get().value() >= 2 ? version.getIncrementalVersion() : 0); } - if ( segmentCount > 2 ) - { - if ( version.getQualifier() != null ) - { - newVersion.append( "-" ).append( unchangedSegment.get().value() >= 3 ? version.getQualifier() : "0" ); - } - else - { - newVersion.append( "-" ).append( unchangedSegment.get().value() >= 3 ? version.getBuildNumber() : "0" ); + if (segmentCount > 2) { + if (version.getQualifier() != null) { + newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getQualifier() : "0"); + } else { + newVersion.append("-").append(unchangedSegment.get().value() >= 3 ? version.getBuildNumber() : "0"); } } - return of( newVersion.toString() ); + return of(newVersion.toString()); } /** @@ -497,20 +425,18 @@ protected Optional getLowerBound( ArtifactVersion version, Optional 0 || upper < 0 ) - { + int lower = lowerBound == null ? -1 : versionComparator.compare(lowerBound, candidate); + int upper = upperBound == null ? +1 : versionComparator.compare(upperBound, candidate); + if (lower > 0 || upper < 0) { return false; } - return ( includeLower || lower != 0 ) && ( includeUpper || upper != 0 ); + return (includeLower || lower != 0) && (includeUpper || upper != 0); } /** @@ -520,10 +446,10 @@ public boolean isVersionInRestriction( Restriction restriction, ArtifactVersion * @return the newest version after currentVersion within the specified update scope, * or null if no version is available. */ - public final ArtifactVersion getReportNewestUpdate( Optional updateScope ) - { - return getArtifactVersionStream( updateScope ) - .min( Collections.reverseOrder( getVersionComparator() ) ).orElse( null ); + public final ArtifactVersion getReportNewestUpdate(Optional updateScope) { + return getArtifactVersionStream(updateScope) + .min(Collections.reverseOrder(getVersionComparator())) + .orElse(null); } /** @@ -531,26 +457,21 @@ public final ArtifactVersion getReportNewestUpdate( Optional updateScop * @param updateScope the scope of updates to include. * @return all versions after currentVersion within the specified update scope. */ - public final ArtifactVersion[] getReportUpdates( Optional updateScope ) - { - TreeSet versions = getArtifactVersionStream( updateScope ) - .collect( Collectors.toCollection( () -> new TreeSet<>( getVersionComparator() ) ) ); + public final ArtifactVersion[] getReportUpdates(Optional updateScope) { + TreeSet versions = getArtifactVersionStream(updateScope) + .collect(Collectors.toCollection(() -> new TreeSet<>(getVersionComparator()))); // filter out intermediate minor versions. - if ( !verboseDetail ) - { + if (!verboseDetail) { int major = 0; int minor = 0; boolean needOneMore = false; - for ( Iterator it = versions.descendingIterator(); it.hasNext(); ) - { + for (Iterator it = versions.descendingIterator(); it.hasNext(); ) { ArtifactVersion version = it.next(); - boolean isPreview = PREVIEW_PATTERN.matcher( version.toString() ).matches(); + boolean isPreview = PREVIEW_PATTERN.matcher(version.toString()).matches(); // encountered a version in same Major.Minor version, remove it. - if ( version.getMajorVersion() == major && version.getMinorVersion() == minor ) - { - if ( needOneMore && !isPreview ) - { + if (version.getMajorVersion() == major && version.getMinorVersion() == minor) { + if (needOneMore && !isPreview) { needOneMore = false; continue; } @@ -564,10 +485,9 @@ public final ArtifactVersion[] getReportUpdates( Optional updateScope ) // if version is a pre-release, also search for the last release. needOneMore = isPreview; - } } - return versions.toArray( new ArtifactVersion[0] ); + return versions.toArray(new ArtifactVersion[0]); } /** @@ -575,24 +495,18 @@ public final ArtifactVersion[] getReportUpdates( Optional updateScope ) * @param updateScope the scope of updates to include. * @return all versions after currentVersion within the specified update scope. */ - private Stream getArtifactVersionStream( Optional updateScope ) - { - if ( isCurrentVersionDefined() ) - { - try - { - Restriction restriction = restrictionFor( updateScope ); - - return Arrays.stream( getVersions() ).filter( - candidate -> ( isIncludeSnapshots() || !ArtifactUtils.isSnapshot( candidate.toString() ) ) - && isVersionInRestriction( restriction, candidate ) ); - } - catch ( InvalidSegmentException ignored ) - { - ignored.printStackTrace( System.err ); + private Stream getArtifactVersionStream(Optional updateScope) { + if (isCurrentVersionDefined()) { + try { + Restriction restriction = restrictionFor(updateScope); + + return Arrays.stream(getVersions()) + .filter(candidate -> (isIncludeSnapshots() || !ArtifactUtils.isSnapshot(candidate.toString())) + && isVersionInRestriction(restriction, candidate)); + } catch (InvalidSegmentException ignored) { + ignored.printStackTrace(System.err); } } return Stream.empty(); } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java index 71043e9694..794db9d4a8 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactAssociation.java @@ -27,8 +27,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public interface ArtifactAssociation extends Comparable -{ +public interface ArtifactAssociation extends Comparable { String getGroupId(); String getArtifactId(); diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java index 6a398891b1..a31ce9171e 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersions.java @@ -40,9 +40,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class ArtifactVersions - extends AbstractVersionDetails implements Comparable -{ +public class ArtifactVersions extends AbstractVersionDetails implements Comparable { /** * The artifact that who's versions we hold details of. * @@ -72,15 +70,13 @@ public class ArtifactVersions * @param versionComparator The version comparison rule. * @since 1.0-alpha-3 */ - public ArtifactVersions( Artifact artifact, List versions, VersionComparator versionComparator ) - { + public ArtifactVersions(Artifact artifact, List versions, VersionComparator versionComparator) { this.artifact = artifact; this.versionComparator = versionComparator; - this.versions = new TreeSet<>( versionComparator ); - this.versions.addAll( versions ); - if ( artifact.getVersion() != null ) - { - setCurrentVersion( artifact.getVersion() ); + this.versions = new TreeSet<>(versionComparator); + this.versions.addAll(versions); + if (artifact.getVersion() != null) { + setCurrentVersion(artifact.getVersion()); } } @@ -90,59 +86,53 @@ public ArtifactVersions( Artifact artifact, List versions, Vers * @param other other object to be linked to * @since 2.13.0 */ - public ArtifactVersions( ArtifactVersions other ) - { + public ArtifactVersions(ArtifactVersions other) { artifact = other.artifact; versionComparator = other.versionComparator; versions = other.versions; - setCurrentVersion( other.getCurrentVersion() ); - setIncludeSnapshots( other.isIncludeSnapshots() ); + setCurrentVersion(other.getCurrentVersion()); + setIncludeSnapshots(other.isIncludeSnapshots()); } - @SuppressWarnings( "checkstyle:InnerAssignment" ) - public int compareTo( ArtifactVersions that ) - { + @SuppressWarnings("checkstyle:InnerAssignment") + public int compareTo(ArtifactVersions that) { int rv; return this == that ? 0 : that == null || getClass() != that.getClass() - ? 1 - : ( rv = compare( getGroupId(), that.getGroupId() ) ) != 0 - ? rv - : ( rv = compare( getArtifactId(), that.getArtifactId() ) ) != 0 - ? rv - : compare( getVersion(), that.getVersion() ); + ? 1 + : (rv = compare(getGroupId(), that.getGroupId())) != 0 + ? rv + : (rv = compare(getArtifactId(), that.getArtifactId())) != 0 + ? rv + : compare(getVersion(), that.getVersion()); } @Override - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( !( o instanceof ArtifactVersions ) ) - { + if (!(o instanceof ArtifactVersions)) { return false; } ArtifactVersions that = (ArtifactVersions) o; return new EqualsBuilder() - .append( getArtifact(), that.getArtifact() ) - .append( getVersions(), that.getVersions() ) - .append( getVersionComparator(), that.getVersionComparator() ) + .append(getArtifact(), that.getArtifact()) + .append(getVersions(), that.getVersions()) + .append(getVersionComparator(), that.getVersionComparator()) .isEquals(); } @Override - public int hashCode() - { - return new HashCodeBuilder( 17, 37 ) - .append( getArtifact() ) - .append( getVersions() ) - .append( getVersionComparator() ) + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(getArtifact()) + .append(getVersions()) + .append(getVersionComparator()) .toHashCode(); } @@ -155,31 +145,23 @@ public int hashCode() * @return true if and only if the version is in the range. * @since 1.3 */ - public static boolean isVersionInRange( ArtifactVersion version, VersionRange range ) - { - if ( !range.containsVersion( version ) ) - { + public static boolean isVersionInRange(ArtifactVersion version, VersionRange range) { + if (!range.containsVersion(version)) { return false; } - for ( Restriction r : range.getRestrictions() ) - { - if ( r.containsVersion( version ) ) - { + for (Restriction r : range.getRestrictions()) { + if (r.containsVersion(version)) { // check for the -! syntax - if ( !r.isLowerBoundInclusive() && r.getLowerBound() != null ) - { + if (!r.isLowerBoundInclusive() && r.getLowerBound() != null) { String s = r.getLowerBound().toString(); - if ( s.endsWith( "-!" ) && version.toString().startsWith( s.substring( 0, s.length() - 2 ) ) ) - { + if (s.endsWith("-!") && version.toString().startsWith(s.substring(0, s.length() - 2))) { return false; } } - if ( !r.isUpperBoundInclusive() && r.getUpperBound() != null ) - { + if (!r.isUpperBoundInclusive() && r.getUpperBound() != null) { String s = r.getUpperBound().toString(); - if ( s.endsWith( "-!" ) && version.toString().startsWith( s.substring( 0, s.length() - 2 ) ) ) - { + if (s.endsWith("-!") && version.toString().startsWith(s.substring(0, s.length() - 2))) { return false; } } @@ -194,8 +176,7 @@ public static boolean isVersionInRange( ArtifactVersion version, VersionRange ra * @return the artifact who's version information we are holding. * @since 1.0-alpha-3 */ - public Artifact getArtifact() - { + public Artifact getArtifact() { return artifact; } @@ -205,8 +186,7 @@ public Artifact getArtifact() * @return the groupId. * @since 1.0-alpha-3 */ - public String getGroupId() - { + public String getGroupId() { return getArtifact().getGroupId(); } @@ -216,8 +196,7 @@ public String getGroupId() * @return the artifactId. * @since 1.0-alpha-3 */ - public String getArtifactId() - { + public String getArtifactId() { return getArtifact().getArtifactId(); } @@ -227,31 +206,27 @@ public String getArtifactId() * @return current version * @since 2.13.0 */ - public String getVersion() - { + public String getVersion() { return getArtifact().getVersion(); } - public ArtifactVersion[] getVersions( boolean includeSnapshots ) - { + public ArtifactVersion[] getVersions(boolean includeSnapshots) { return includeSnapshots - ? versions.toArray( new ArtifactVersion[0] ) - : versions.stream().filter( v -> !ArtifactUtils.isSnapshot( v.toString() ) ) - .toArray( ArtifactVersion[]::new ); + ? versions.toArray(new ArtifactVersion[0]) + : versions.stream() + .filter(v -> !ArtifactUtils.isSnapshot(v.toString())) + .toArray(ArtifactVersion[]::new); } - public VersionComparator getVersionComparator() - { + public VersionComparator getVersionComparator() { return versionComparator; } /** * {@inheritDoc} */ - public String toString() - { + public String toString() { return "ArtifactVersions" + "{artifact=" + artifact + ", versions=" + versions + ", versionComparator=" - + versionComparator + '}'; + + versionComparator + '}'; } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java index 9966d9a1c2..e51e91938b 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java @@ -1,6 +1,5 @@ package org.codehaus.mojo.versions.api; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -30,8 +29,7 @@ /** * Utility providing a cached {@link ArtifactVersions#getNewestUpdate(Optional)} API */ -public class ArtifactVersionsCache -{ +public class ArtifactVersionsCache { private BiFunction, ?> cachedFunction; private Map>, Object> updateCache = new HashMap<>(); @@ -41,9 +39,7 @@ public class ArtifactVersionsCache * * @param cachedFunction reference to the function computing the required information */ - public ArtifactVersionsCache( BiFunction, ?> - cachedFunction ) - { + public ArtifactVersionsCache(BiFunction, ?> cachedFunction) { this.cachedFunction = cachedFunction; } @@ -58,11 +54,9 @@ public ArtifactVersionsCache( BiFunction R get( V artifactVersions, - Optional updateScope ) - { - return (R) updateCache.computeIfAbsent( Pair.of( artifactVersions, updateScope ), - pair -> cachedFunction.apply( pair.getLeft(), pair.getRight() ) ); + @SuppressWarnings("unchecked") + public R get(V artifactVersions, Optional updateScope) { + return (R) updateCache.computeIfAbsent( + Pair.of(artifactVersions, updateScope), pair -> cachedFunction.apply(pair.getLeft(), pair.getRight())); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java index e75ee3525b..69e281ef00 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultArtifactAssociation.java @@ -30,104 +30,83 @@ * @author connollys * @since Aug 6, 2009 9:23:13 AM */ -final class DefaultArtifactAssociation - implements ArtifactAssociation -{ +final class DefaultArtifactAssociation implements ArtifactAssociation { private final Artifact artifact; private final boolean usePluginRepositories; - DefaultArtifactAssociation( Artifact artifact, boolean usePluginRepositories ) - { - Objects.requireNonNull( artifact ); + DefaultArtifactAssociation(Artifact artifact, boolean usePluginRepositories) { + Objects.requireNonNull(artifact); this.artifact = artifact; this.usePluginRepositories = usePluginRepositories; } - public String getGroupId() - { + public String getGroupId() { return artifact.getGroupId(); } - public String getArtifactId() - { + public String getArtifactId() { return artifact.getArtifactId(); } - - public Artifact getArtifact() - { + public Artifact getArtifact() { return artifact; } - public boolean isUsePluginRepositories() - { + public boolean isUsePluginRepositories() { return usePluginRepositories; } - public int compareTo( ArtifactAssociation o ) - { - if ( this == o ) - { + public int compareTo(ArtifactAssociation o) { + if (this == o) { return 0; } - if ( o == null || getClass() != o.getClass() ) - { + if (o == null || getClass() != o.getClass()) { return 1; } DefaultArtifactAssociation that = (DefaultArtifactAssociation) o; - int rv = getGroupId().compareTo( that.getGroupId() ); - if ( rv != 0 ) - { + int rv = getGroupId().compareTo(that.getGroupId()); + if (rv != 0) { return rv; } - rv = getArtifactId().compareTo( that.getArtifactId() ); - if ( rv != 0 ) - { + rv = getArtifactId().compareTo(that.getArtifactId()); + if (rv != 0) { return rv; } - if ( usePluginRepositories != that.usePluginRepositories ) - { + if (usePluginRepositories != that.usePluginRepositories) { return usePluginRepositories ? 1 : -1; } return 0; } - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( o == null || getClass() != o.getClass() ) - { + if (o == null || getClass() != o.getClass()) { return false; } DefaultArtifactAssociation that = (DefaultArtifactAssociation) o; - if ( usePluginRepositories != that.usePluginRepositories ) - { + if (usePluginRepositories != that.usePluginRepositories) { return false; } - if ( !getArtifactId().equals( that.getArtifactId() ) ) - { + if (!getArtifactId().equals(that.getArtifactId())) { return false; } - return getGroupId().equals( that.getGroupId() ); + return getGroupId().equals(that.getGroupId()); } - public int hashCode() - { + public int hashCode() { int result = getGroupId().hashCode(); result = 31 * result + getArtifactId().hashCode(); - result = 31 * result + ( usePluginRepositories ? 1 : 0 ); + result = 31 * result + (usePluginRepositories ? 1 : 0); return result; } - public String toString() - { - return ( usePluginRepositories ? "plugin:" : "artifact:" ) + ArtifactUtils.versionlessKey( artifact ); + public String toString() { + return (usePluginRepositories ? "plugin:" : "artifact:") + ArtifactUtils.versionlessKey(artifact); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java index cc55e3f379..f2b0687859 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/DefaultVersionsHelper.java @@ -100,9 +100,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class DefaultVersionsHelper - implements VersionsHelper -{ +public class DefaultVersionsHelper implements VersionsHelper { private static final String CLASSPATH_PROTOCOL = "classpath"; private static final String TYPE_EXACT = "exact"; @@ -148,105 +146,94 @@ public class DefaultVersionsHelper /** * Private constructor used by the builder */ - private DefaultVersionsHelper() - { - } + private DefaultVersionsHelper() {} - static boolean exactMatch( String wildcardRule, String value ) - { - Pattern p = Pattern.compile( RegexUtils.convertWildcardsToRegex( wildcardRule, true ) ); - return p.matcher( value ).matches(); + static boolean exactMatch(String wildcardRule, String value) { + Pattern p = Pattern.compile(RegexUtils.convertWildcardsToRegex(wildcardRule, true)); + return p.matcher(value).matches(); } - static boolean match( String wildcardRule, String value ) - { - Pattern p = Pattern.compile( RegexUtils.convertWildcardsToRegex( wildcardRule, false ) ); - return p.matcher( value ).matches(); + static boolean match(String wildcardRule, String value) { + Pattern p = Pattern.compile(RegexUtils.convertWildcardsToRegex(wildcardRule, false)); + return p.matcher(value).matches(); } - static boolean isClasspathUri( String uri ) - { - return ( uri != null && uri.startsWith( CLASSPATH_PROTOCOL + ":" ) ); + static boolean isClasspathUri(String uri) { + return (uri != null && uri.startsWith(CLASSPATH_PROTOCOL + ":")); } @Override - public Log getLog() - { + public Log getLog() { return log; } @Override - public ArtifactVersions lookupArtifactVersions( Artifact artifact, VersionRange versionRange, - boolean usePluginRepositories ) - throws VersionRetrievalException - { - try - { - Collection ignoredVersions = getIgnoredVersions( artifact ); - if ( !ignoredVersions.isEmpty() && getLog().isDebugEnabled() ) - { - getLog().debug( "Found ignored versions: " + ignoredVersions.stream() - .map( IgnoreVersion::toString ).collect( Collectors.joining( ", " ) ) ); - } - return new ArtifactVersions( artifact, - aetherRepositorySystem.resolveVersionRange( mavenSession.getRepositorySession(), + public ArtifactVersions lookupArtifactVersions( + Artifact artifact, VersionRange versionRange, boolean usePluginRepositories) + throws VersionRetrievalException { + try { + Collection ignoredVersions = getIgnoredVersions(artifact); + if (!ignoredVersions.isEmpty() && getLog().isDebugEnabled()) { + getLog().debug("Found ignored versions: " + + ignoredVersions.stream().map(IgnoreVersion::toString).collect(Collectors.joining(", "))); + } + return new ArtifactVersions( + artifact, + aetherRepositorySystem + .resolveVersionRange( + mavenSession.getRepositorySession(), new VersionRangeRequest( - toArtifact( artifact ).setVersion( - versionRange != null - ? versionRange.toString() - : "(,)" ), + toArtifact(artifact) + .setVersion(versionRange != null ? versionRange.toString() : "(,)"), usePluginRepositories - ? mavenSession.getCurrentProject().getRemotePluginRepositories() - : mavenSession.getCurrentProject().getRemoteProjectRepositories(), - "lookupArtifactVersions" ) ) + ? mavenSession + .getCurrentProject() + .getRemotePluginRepositories() + : mavenSession + .getCurrentProject() + .getRemoteProjectRepositories(), + "lookupArtifactVersions")) .getVersions() .parallelStream() - .filter( v -> ignoredVersions.stream() - .noneMatch( i -> - { - if ( TYPE_REGEX.equals( i.getType() ) - && Pattern.compile( i.getVersion() ).matcher( v.toString() ).matches() ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Version " + v + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) - + " found on ignore list: " - + i ); - } - return true; - } - - if ( TYPE_EXACT.equals( i.getType() ) - && i.getVersion().equals( v.toString() ) ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Version " + v + " for artifact " - + ArtifactUtils.versionlessKey( artifact ) - + " found on ignore list: " - + i ); - } - return true; - } - - return false; - } ) ) - .map( v -> new DefaultArtifactVersion( v.toString() ) ) - .collect( Collectors.toList() ), - getVersionComparator( artifact ) ); - } - catch ( VersionRangeResolutionException e ) - { - throw new VersionRetrievalException( e.getMessage(), e ); + .filter(v -> ignoredVersions.stream().noneMatch(i -> { + if (TYPE_REGEX.equals(i.getType()) + && Pattern.compile(i.getVersion()) + .matcher(v.toString()) + .matches()) { + if (getLog().isDebugEnabled()) { + getLog().debug("Version " + v + " for artifact " + + ArtifactUtils.versionlessKey(artifact) + + " found on ignore list: " + + i); + } + return true; + } + + if (TYPE_EXACT.equals(i.getType()) + && i.getVersion().equals(v.toString())) { + if (getLog().isDebugEnabled()) { + getLog().debug("Version " + v + " for artifact " + + ArtifactUtils.versionlessKey(artifact) + + " found on ignore list: " + + i); + } + return true; + } + + return false; + })) + .map(v -> new DefaultArtifactVersion(v.toString())) + .collect(Collectors.toList()), + getVersionComparator(artifact)); + } catch (VersionRangeResolutionException e) { + throw new VersionRetrievalException(e.getMessage(), e); } } @Override - public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) - throws VersionRetrievalException - { - return lookupArtifactVersions( artifact, null, usePluginRepositories ); + public ArtifactVersions lookupArtifactVersions(Artifact artifact, boolean usePluginRepositories) + throws VersionRetrievalException { + return lookupArtifactVersions(artifact, null, usePluginRepositories); } /** @@ -255,39 +242,29 @@ public ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePl * @param artifact The artifact * @return List of ignored version */ - private List getIgnoredVersions( Artifact artifact ) - { + private List getIgnoredVersions(Artifact artifact) { final List ret = new ArrayList<>(); - for ( final IgnoreVersion ignoreVersion : ruleSet.getIgnoreVersions() ) - { - if ( !TYPE_EXACT.equals( ignoreVersion.getType() ) && !TYPE_REGEX.equals( ignoreVersion.getType() ) ) - { - getLog().warn( "The type attribute '" + ignoreVersion.getType() + "' for global ignoreVersion[" - + ignoreVersion + "] is not valid." + " Please use either '" + TYPE_EXACT + "' or '" - + TYPE_REGEX - + "'." ); - } - else - { - ret.add( ignoreVersion ); + for (final IgnoreVersion ignoreVersion : ruleSet.getIgnoreVersions()) { + if (!TYPE_EXACT.equals(ignoreVersion.getType()) && !TYPE_REGEX.equals(ignoreVersion.getType())) { + getLog().warn("The type attribute '" + ignoreVersion.getType() + "' for global ignoreVersion[" + + ignoreVersion + "] is not valid." + " Please use either '" + TYPE_EXACT + "' or '" + + TYPE_REGEX + + "'."); + } else { + ret.add(ignoreVersion); } } - final Rule rule = getBestFitRule( artifact.getGroupId(), artifact.getArtifactId() ); + final Rule rule = getBestFitRule(artifact.getGroupId(), artifact.getArtifactId()); - if ( rule != null ) - { - for ( IgnoreVersion ignoreVersion : rule.getIgnoreVersions() ) - { - if ( !TYPE_EXACT.equals( ignoreVersion.getType() ) && !TYPE_REGEX.equals( ignoreVersion.getType() ) ) - { - getLog().warn( "The type attribute '" + ignoreVersion.getType() + "' for " + rule + " is not valid." - + " Please use either '" + TYPE_EXACT + "' or '" + TYPE_REGEX + "'." ); - } - else - { - ret.add( ignoreVersion ); + if (rule != null) { + for (IgnoreVersion ignoreVersion : rule.getIgnoreVersions()) { + if (!TYPE_EXACT.equals(ignoreVersion.getType()) && !TYPE_REGEX.equals(ignoreVersion.getType())) { + getLog().warn("The type attribute '" + ignoreVersion.getType() + "' for " + rule + " is not valid." + + " Please use either '" + TYPE_EXACT + "' or '" + TYPE_REGEX + "'."); + } else { + ret.add(ignoreVersion); } } } @@ -296,39 +273,34 @@ private List getIgnoredVersions( Artifact artifact ) } @Override - public void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactResolutionException - { - try - { - ArtifactResult artifactResult = aetherRepositorySystem.resolveArtifact( mavenSession.getRepositorySession(), - new ArtifactRequest( toArtifact( artifact ), + public void resolveArtifact(Artifact artifact, boolean usePluginRepositories) throws ArtifactResolutionException { + try { + ArtifactResult artifactResult = aetherRepositorySystem.resolveArtifact( + mavenSession.getRepositorySession(), + new ArtifactRequest( + toArtifact(artifact), usePluginRepositories ? mavenSession.getCurrentProject().getRemotePluginRepositories() : mavenSession.getCurrentProject().getRemoteProjectRepositories(), - getClass().getName() ) ); - artifact.setFile( artifactResult.getArtifact().getFile() ); - artifact.setVersion( artifactResult.getArtifact().getVersion() ); - artifact.setResolved( artifactResult.isResolved() ); - } - catch ( org.eclipse.aether.resolution.ArtifactResolutionException e ) - { - throw new ArtifactResolutionException( e.getMessage(), artifact ); + getClass().getName())); + artifact.setFile(artifactResult.getArtifact().getFile()); + artifact.setVersion(artifactResult.getArtifact().getVersion()); + artifact.setResolved(artifactResult.isResolved()); + } catch (org.eclipse.aether.resolution.ArtifactResolutionException e) { + throw new ArtifactResolutionException(e.getMessage(), artifact); } } @Override - public VersionComparator getVersionComparator( Artifact artifact ) - { - return getVersionComparator( artifact.getGroupId(), artifact.getArtifactId() ); + public VersionComparator getVersionComparator(Artifact artifact) { + return getVersionComparator(artifact.getGroupId(), artifact.getArtifactId()); } @Override - public VersionComparator getVersionComparator( String groupId, String artifactId ) - { - Rule rule = getBestFitRule( groupId, artifactId ); + public VersionComparator getVersionComparator(String groupId, String artifactId) { + Rule rule = getBestFitRule(groupId, artifactId); final String comparisonMethod = rule == null ? ruleSet.getComparisonMethod() : rule.getComparisonMethod(); - return VersionComparators.getVersionComparator( comparisonMethod ); + return VersionComparators.getVersionComparator(comparisonMethod); } /** @@ -338,12 +310,10 @@ public VersionComparator getVersionComparator( String groupId, String artifactId * @param artifactId Artifact id of the artifact * @return Rule which best describes the given artifact */ - protected Rule getBestFitRule( String groupId, String artifactId ) - { + protected Rule getBestFitRule(String groupId, String artifactId) { String groupArtifactId = groupId + ':' + artifactId; - if ( artifactBestFitRule.containsKey( groupArtifactId ) ) - { - return artifactBestFitRule.get( groupArtifactId ); + if (artifactBestFitRule.containsKey(groupArtifactId)) { + return artifactBestFitRule.get(groupArtifactId); } Rule bestFit = null; @@ -352,114 +322,104 @@ protected Rule getBestFitRule( String groupId, String artifactId ) int bestArtifactIdScore = Integer.MAX_VALUE; boolean exactGroupId = false; boolean exactArtifactId = false; - for ( Rule rule : rules ) - { - int groupIdScore = RegexUtils.getWildcardScore( rule.getGroupId() ); - if ( groupIdScore > bestGroupIdScore ) - { + for (Rule rule : rules) { + int groupIdScore = RegexUtils.getWildcardScore(rule.getGroupId()); + if (groupIdScore > bestGroupIdScore) { continue; } - boolean exactMatch = exactMatch( rule.getGroupId(), groupId ); - boolean match = exactMatch || match( rule.getGroupId(), groupId ); - if ( !match || ( exactGroupId && !exactMatch ) ) - { + boolean exactMatch = exactMatch(rule.getGroupId(), groupId); + boolean match = exactMatch || match(rule.getGroupId(), groupId); + if (!match || (exactGroupId && !exactMatch)) { continue; } - if ( bestGroupIdScore > groupIdScore ) - { + if (bestGroupIdScore > groupIdScore) { bestArtifactIdScore = Integer.MAX_VALUE; exactArtifactId = false; } bestGroupIdScore = groupIdScore; - if ( exactMatch && !exactGroupId ) - { + if (exactMatch && !exactGroupId) { exactGroupId = true; bestArtifactIdScore = Integer.MAX_VALUE; exactArtifactId = false; } - int artifactIdScore = RegexUtils.getWildcardScore( rule.getArtifactId() ); - if ( artifactIdScore > bestArtifactIdScore ) - { + int artifactIdScore = RegexUtils.getWildcardScore(rule.getArtifactId()); + if (artifactIdScore > bestArtifactIdScore) { continue; } - exactMatch = exactMatch( rule.getArtifactId(), artifactId ); - match = exactMatch || match( rule.getArtifactId(), artifactId ); - if ( !match || ( exactArtifactId && !exactMatch ) ) - { + exactMatch = exactMatch(rule.getArtifactId(), artifactId); + match = exactMatch || match(rule.getArtifactId(), artifactId); + if (!match || (exactArtifactId && !exactMatch)) { continue; } bestArtifactIdScore = artifactIdScore; - if ( exactMatch && !exactArtifactId ) - { + if (exactMatch && !exactArtifactId) { exactArtifactId = true; } bestFit = rule; } - artifactBestFitRule.put( groupArtifactId, bestFit ); + artifactBestFitRule.put(groupArtifactId, bestFit); return bestFit; } @Override - public Artifact createPluginArtifact( String groupId, String artifactId, String version ) - { + public Artifact createPluginArtifact(String groupId, String artifactId, String version) { Plugin plugin = new Plugin(); - plugin.setGroupId( groupId ); - plugin.setArtifactId( artifactId ); - plugin.setVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ); - return repositorySystem.createPluginArtifact( plugin ); + plugin.setGroupId(groupId); + plugin.setArtifactId(artifactId); + plugin.setVersion(StringUtils.isNotBlank(version) ? version : "[0,]"); + return repositorySystem.createPluginArtifact(plugin); } @Override - public Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, - String classifier, String scope, boolean optional ) - { - return repositorySystem.createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withType( type ) - .withClassifier( classifier ) - .withScope( scope ) - .withOptional( optional ) - .withVersion( StringUtils.isNotBlank( version ) ? version : "[0,]" ) - .build() ); + public Artifact createDependencyArtifact( + String groupId, + String artifactId, + String version, + String type, + String classifier, + String scope, + boolean optional) { + return repositorySystem.createDependencyArtifact(DependencyBuilder.newBuilder() + .withGroupId(groupId) + .withArtifactId(artifactId) + .withType(type) + .withClassifier(classifier) + .withScope(scope) + .withOptional(optional) + .withVersion(StringUtils.isNotBlank(version) ? version : "[0,]") + .build()); } @Override - public Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, - String classifier, String scope ) - { - return createDependencyArtifact( groupId, artifactId, version, type, classifier, scope, false ); + public Artifact createDependencyArtifact( + String groupId, String artifactId, String version, String type, String classifier, String scope) { + return createDependencyArtifact(groupId, artifactId, version, type, classifier, scope, false); } @Override - public Artifact createDependencyArtifact( Dependency dependency ) - { - if ( StringUtils.isBlank( dependency.getVersion() ) ) - { + public Artifact createDependencyArtifact(Dependency dependency) { + if (StringUtils.isBlank(dependency.getVersion())) { dependency = dependency.clone(); - dependency.setVersion( "[,0]" ); + dependency.setVersion("[,0]"); } - return repositorySystem.createDependencyArtifact( dependency ); + return repositorySystem.createDependencyArtifact(dependency); } @Override - public Set extractArtifacts( Collection mavenProjects ) - { + public Set extractArtifacts(Collection mavenProjects) { Set result = new HashSet<>(); - for ( MavenProject project : mavenProjects ) - { - result.add( project.getArtifact() ); + for (MavenProject project : mavenProjects) { + result.add(project.getArtifact()); } return result; } @Override - public ArtifactVersion createArtifactVersion( String version ) - { - return new DefaultArtifactVersion( version ); + public ArtifactVersion createArtifactVersion(String version) { + return new DefaultArtifactVersion(version); } /** @@ -471,219 +431,179 @@ public ArtifactVersion createArtifactVersion( String version ) * @return map containing the ArtifactVersions object per dependency */ @Override - public Map lookupDependenciesUpdates( Set dependencies, - boolean usePluginRepositories ) - throws VersionRetrievalException - { - ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); - try - { - Map dependencyUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); + public Map lookupDependenciesUpdates( + Set dependencies, boolean usePluginRepositories) throws VersionRetrievalException { + ExecutorService executor = Executors.newFixedThreadPool(LOOKUP_PARALLEL_THREADS); + try { + Map dependencyUpdates = new TreeMap<>(DependencyComparator.INSTANCE); List>> futures = dependencies.stream() - .map( dependency -> executor.submit( () -> new ImmutablePair<> - ( dependency, lookupDependencyUpdates( dependency, usePluginRepositories ) ) ) ) - .collect( Collectors.toList() ); - for ( Future> details : futures ) - { + .map(dependency -> executor.submit(() -> new ImmutablePair<>( + dependency, lookupDependencyUpdates(dependency, usePluginRepositories)))) + .collect(Collectors.toList()); + for (Future> details : futures) { Pair pair = details.get(); - dependencyUpdates.put( pair.getKey(), pair.getValue() ); + dependencyUpdates.put(pair.getKey(), pair.getValue()); } return dependencyUpdates; - } - catch ( ExecutionException | InterruptedException ie ) - { - throw new VersionRetrievalException( "Unable to acquire metadata for dependencies " - + dependencies + ": " + ie.getMessage(), ie ); - } - finally - { + } catch (ExecutionException | InterruptedException ie) { + throw new VersionRetrievalException( + "Unable to acquire metadata for dependencies " + dependencies + ": " + ie.getMessage(), ie); + } finally { executor.shutdown(); } } @Override - public ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) - throws VersionRetrievalException - { - ArtifactVersions allVersions = lookupArtifactVersions( createDependencyArtifact( dependency ), - usePluginRepositories ); - return new ArtifactVersions( allVersions.getArtifact(), Arrays.stream( allVersions.getAllUpdates() ) - .collect( Collectors.toList() ), allVersions.getVersionComparator() ); + public ArtifactVersions lookupDependencyUpdates(Dependency dependency, boolean usePluginRepositories) + throws VersionRetrievalException { + ArtifactVersions allVersions = + lookupArtifactVersions(createDependencyArtifact(dependency), usePluginRepositories); + return new ArtifactVersions( + allVersions.getArtifact(), + Arrays.stream(allVersions.getAllUpdates()).collect(Collectors.toList()), + allVersions.getVersionComparator()); } @Override - public Map lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) - throws VersionRetrievalException - { - ExecutorService executor = Executors.newFixedThreadPool( LOOKUP_PARALLEL_THREADS ); - try - { - Map pluginUpdates = new TreeMap<>( PluginComparator.INSTANCE ); + public Map lookupPluginsUpdates(Set plugins, boolean allowSnapshots) + throws VersionRetrievalException { + ExecutorService executor = Executors.newFixedThreadPool(LOOKUP_PARALLEL_THREADS); + try { + Map pluginUpdates = new TreeMap<>(PluginComparator.INSTANCE); List>> futures = plugins.stream() - .map( p -> executor.submit( () -> new ImmutablePair<> - ( p, lookupPluginUpdates( p, allowSnapshots ) ) ) ) - .collect( Collectors.toList() ); - for ( Future> details : futures ) - { + .map(p -> executor.submit(() -> new ImmutablePair<>(p, lookupPluginUpdates(p, allowSnapshots)))) + .collect(Collectors.toList()); + for (Future> details : futures) { Pair pair = details.get(); - pluginUpdates.put( pair.getKey(), pair.getValue() ); + pluginUpdates.put(pair.getKey(), pair.getValue()); } return pluginUpdates; - } - catch ( ExecutionException | InterruptedException ie ) - { - throw new VersionRetrievalException( "Unable to acquire metadata for plugins " + plugins + ": " - + ie.getMessage(), ie ); - } - finally - { + } catch (ExecutionException | InterruptedException ie) { + throw new VersionRetrievalException( + "Unable to acquire metadata for plugins " + plugins + ": " + ie.getMessage(), ie); + } finally { executor.shutdown(); } } @Override - public PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) - throws VersionRetrievalException - { - String version = plugin.getVersion() != null - ? plugin.getVersion() - : "LATEST"; - - Set pluginDependencies = new TreeSet<>( DependencyComparator.INSTANCE ); - if ( plugin.getDependencies() != null ) - { - pluginDependencies.addAll( plugin.getDependencies() ); + public PluginUpdatesDetails lookupPluginUpdates(Plugin plugin, boolean allowSnapshots) + throws VersionRetrievalException { + String version = plugin.getVersion() != null ? plugin.getVersion() : "LATEST"; + + Set pluginDependencies = new TreeSet<>(DependencyComparator.INSTANCE); + if (plugin.getDependencies() != null) { + pluginDependencies.addAll(plugin.getDependencies()); } Map pluginDependencyDetails = - lookupDependenciesUpdates( pluginDependencies, false ); - - ArtifactVersions allVersions = - lookupArtifactVersions( createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), version ), - true ); - ArtifactVersions updatedVersions = new ArtifactVersions( allVersions.getArtifact(), - Arrays.stream( allVersions.getAllUpdates() ).collect( Collectors.toList() ), - allVersions.getVersionComparator() ); - return new PluginUpdatesDetails( updatedVersions, pluginDependencyDetails, allowSnapshots ); + lookupDependenciesUpdates(pluginDependencies, false); + + ArtifactVersions allVersions = lookupArtifactVersions( + createPluginArtifact(plugin.getGroupId(), plugin.getArtifactId(), version), true); + ArtifactVersions updatedVersions = new ArtifactVersions( + allVersions.getArtifact(), + Arrays.stream(allVersions.getAllUpdates()).collect(Collectors.toList()), + allVersions.getVersionComparator()); + return new PluginUpdatesDetails(updatedVersions, pluginDependencyDetails, allowSnapshots); } @Override - public ExpressionEvaluator getExpressionEvaluator( MavenProject project ) - { - return new VersionsExpressionEvaluator( mavenSession, mojoExecution ); + public ExpressionEvaluator getExpressionEvaluator(MavenProject project) { + return new VersionsExpressionEvaluator(mavenSession, mojoExecution); } @Override - public Map getVersionPropertiesMap( VersionPropertiesMapRequest request ) - throws MojoExecutionException - { + public Map getVersionPropertiesMap(VersionPropertiesMapRequest request) + throws MojoExecutionException { Map properties = new HashMap<>(); - if ( request.getPropertyDefinitions() != null ) - { - Arrays.stream( request.getPropertyDefinitions() ).forEach( p -> properties.put( p.getName(), p ) ); + if (request.getPropertyDefinitions() != null) { + Arrays.stream(request.getPropertyDefinitions()).forEach(p -> properties.put(p.getName(), p)); } Map builders = new HashMap<>(); - if ( request.isAutoLinkItems() ) - { + if (request.isAutoLinkItems()) { final PropertyVersionsBuilder[] propertyVersionsBuilders; - try - { - propertyVersionsBuilders = PomHelper.getPropertyVersionsBuilders( this, request.getMavenProject(), - request.isIncludeParent() ); - } - catch ( ExpressionEvaluationException | IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + try { + propertyVersionsBuilders = PomHelper.getPropertyVersionsBuilders( + this, request.getMavenProject(), request.isIncludeParent()); + } catch (ExpressionEvaluationException | IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } - for ( PropertyVersionsBuilder propertyVersionsBuilder : propertyVersionsBuilders ) - { + for (PropertyVersionsBuilder propertyVersionsBuilder : propertyVersionsBuilders) { final String name = propertyVersionsBuilder.getName(); - builders.put( name, propertyVersionsBuilder ); - if ( !properties.containsKey( name ) ) - { - final Property value = new Property( name ); - getLog().debug( "Property ${" + name + "}: Adding inferred version range of " - + propertyVersionsBuilder.getVersionRange() ); - value.setVersion( propertyVersionsBuilder.getVersionRange() ); - properties.put( name, value ); + builders.put(name, propertyVersionsBuilder); + if (!properties.containsKey(name)) { + final Property value = new Property(name); + getLog().debug("Property ${" + name + "}: Adding inferred version range of " + + propertyVersionsBuilder.getVersionRange()); + value.setVersion(propertyVersionsBuilder.getVersionRange()); + properties.put(name, value); } } } List includePropertiesList = request.getIncludeProperties() != null - ? Arrays.asList( request.getIncludeProperties().split( "\\s*,\\s*" ) ) - : Collections.emptyList(); + ? Arrays.asList(request.getIncludeProperties().split("\\s*,\\s*")) + : Collections.emptyList(); List excludePropertiesList = request.getExcludeProperties() != null - ? Arrays.asList( request.getExcludeProperties().split( "\\s*,\\s*" ) ) + ? Arrays.asList(request.getExcludeProperties().split("\\s*,\\s*")) : Collections.emptyList(); - getLog().debug( "Searching for properties associated with builders" ); + getLog().debug("Searching for properties associated with builders"); Iterator i = properties.values().iterator(); - while ( i.hasNext() ) - { + while (i.hasNext()) { Property property = i.next(); - getLog().debug( "includePropertiesList:" + includePropertiesList + " property: " + property.getName() ); - getLog().debug( "excludePropertiesList:" + excludePropertiesList + " property: " + property.getName() ); - if ( !includePropertiesList.isEmpty() && !includePropertiesList.contains( property.getName() ) ) - { - getLog().debug( "Skipping property ${" + property.getName() + "}" ); + getLog().debug("includePropertiesList:" + includePropertiesList + " property: " + property.getName()); + getLog().debug("excludePropertiesList:" + excludePropertiesList + " property: " + property.getName()); + if (!includePropertiesList.isEmpty() && !includePropertiesList.contains(property.getName())) { + getLog().debug("Skipping property ${" + property.getName() + "}"); i.remove(); - } - else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( property.getName() ) ) - { - getLog().debug( "Ignoring property ${" + property.getName() + "}" ); + } else if (!excludePropertiesList.isEmpty() && excludePropertiesList.contains(property.getName())) { + getLog().debug("Ignoring property ${" + property.getName() + "}"); i.remove(); } } i = properties.values().iterator(); - Map propertyVersions = new LinkedHashMap<>( properties.size() ); - while ( i.hasNext() ) - { + Map propertyVersions = new LinkedHashMap<>(properties.size()); + while (i.hasNext()) { Property property = i.next(); - getLog().debug( "Property ${" + property.getName() + "}" ); - PropertyVersionsBuilder builder = builders.get( property.getName() ); - if ( builder == null || !builder.isAssociated() ) - { - getLog().debug( "Property ${" + property.getName() + "}: Looks like this property is not " - + "associated with any dependency..." ); - builder = new PropertyVersionsBuilder( null, property.getName(), this ); - } - if ( !property.isAutoLinkDependencies() ) - { - getLog().debug( "Property ${" + property.getName() + "}: Removing any autoLinkDependencies" ); + getLog().debug("Property ${" + property.getName() + "}"); + PropertyVersionsBuilder builder = builders.get(property.getName()); + if (builder == null || !builder.isAssociated()) { + getLog().debug("Property ${" + property.getName() + "}: Looks like this property is not " + + "associated with any dependency..."); + builder = new PropertyVersionsBuilder(null, property.getName(), this); + } + if (!property.isAutoLinkDependencies()) { + getLog().debug("Property ${" + property.getName() + "}: Removing any autoLinkDependencies"); builder.clearAssociations(); } Dependency[] dependencies = property.getDependencies(); - if ( dependencies != null ) - { - for ( Dependency dependency : dependencies ) - { - getLog().debug( "Property ${" + property.getName() + "}: Adding association to " + dependency ); - builder.addAssociation( this.createDependencyArtifact( dependency ), false ); + if (dependencies != null) { + for (Dependency dependency : dependencies) { + getLog().debug("Property ${" + property.getName() + "}: Adding association to " + dependency); + builder.addAssociation(this.createDependencyArtifact(dependency), false); } } - try - { + try { final PropertyVersions versions = builder.newPropertyVersions(); - if ( property.isAutoLinkDependencies() && StringUtils.isEmpty( property.getVersion() ) - && !StringUtils.isEmpty( builder.getVersionRange() ) ) - { - getLog().debug( "Property ${" + property.getName() + "}: Adding inferred version range of " - + builder.getVersionRange() ); - property.setVersion( builder.getVersionRange() ); + if (property.isAutoLinkDependencies() + && StringUtils.isEmpty(property.getVersion()) + && !StringUtils.isEmpty(builder.getVersionRange())) { + getLog().debug("Property ${" + property.getName() + "}: Adding inferred version range of " + + builder.getVersionRange()); + property.setVersion(builder.getVersionRange()); } - final String currentVersion = request.getMavenProject().getProperties() - .getProperty( property.getName() ); - versions.setCurrentVersion( currentVersion ); - property.setValue( currentVersion ); - propertyVersions.put( property, versions ); - } - catch ( VersionRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + final String currentVersion = + request.getMavenProject().getProperties().getProperty(property.getName()); + versions.setCurrentVersion(currentVersion); + property.setValue(currentVersion); + propertyVersions.put(property, versions); + } catch (VersionRetrievalException e) { + throw new MojoExecutionException(e.getMessage(), e); } } return propertyVersions; @@ -692,8 +612,7 @@ else if ( !excludePropertiesList.isEmpty() && excludePropertiesList.contains( pr /** * Builder class for {@linkplain DefaultVersionsHelper} */ - public static class Builder - { + public static class Builder { private RepositorySystem repositorySystem; private Collection ignoredVersions; private RuleSet ruleSet; @@ -705,30 +624,22 @@ public static class Builder private org.eclipse.aether.RepositorySystem aetherRepositorySystem; private Map wagonMap; - public Builder() - { - } + public Builder() {} - private static RuleSet getRulesFromClasspath( String uri, Log logger ) - throws MojoExecutionException - { - logger.debug( "Going to load rules from \"" + uri + "\"" ); - String choppedUrl = uri.substring( CLASSPATH_PROTOCOL.length() + 3 ); - URL url = DefaultVersionsHelper.class.getResource( choppedUrl ); - if ( url == null ) - { - throw new MojoExecutionException( "Resource \"" + uri + "\" not found in classpath." ); + private static RuleSet getRulesFromClasspath(String uri, Log logger) throws MojoExecutionException { + logger.debug("Going to load rules from \"" + uri + "\""); + String choppedUrl = uri.substring(CLASSPATH_PROTOCOL.length() + 3); + URL url = DefaultVersionsHelper.class.getResource(choppedUrl); + if (url == null) { + throw new MojoExecutionException("Resource \"" + uri + "\" not found in classpath."); } - try ( BufferedInputStream bis = new BufferedInputStream( url.openStream() ) ) - { - RuleSet result = new RuleXpp3Reader().read( bis ); - logger.debug( "Loaded rules from \"" + uri + "\" successfully" ); + try (BufferedInputStream bis = new BufferedInputStream(url.openStream())) { + RuleSet result = new RuleXpp3Reader().read(bis); + logger.debug("Loaded rules from \"" + uri + "\" successfully"); return result; - } - catch ( IOException | XmlPullParserException e ) - { - throw new MojoExecutionException( "Could not load specified rules from " + uri, e ); + } catch (IOException | XmlPullParserException e) { + throw new MojoExecutionException("Could not load specified rules from " + uri, e); } } @@ -746,257 +657,217 @@ private static RuleSet getRulesFromClasspath( String uri, Log logger ) * @return new RuleSet object containing the (if passed) cloned version of the rule set, enriched with * the given set of ignored versions */ - @SuppressWarnings( "checkstyle:AvoidNestedBlocks" ) - private static RuleSet enrichRuleSet( Collection ignoredVersions, RuleSet originalRuleSet ) - { + @SuppressWarnings("checkstyle:AvoidNestedBlocks") + private static RuleSet enrichRuleSet(Collection ignoredVersions, RuleSet originalRuleSet) { RuleSet ruleSet = new RuleSet(); - if ( originalRuleSet != null ) - { - ruleSet.setComparisonMethod( originalRuleSet.getComparisonMethod() ); - if ( originalRuleSet.getRules() != null ) - { - ruleSet.setRules( new ArrayList<>( originalRuleSet.getRules() ) ); + if (originalRuleSet != null) { + ruleSet.setComparisonMethod(originalRuleSet.getComparisonMethod()); + if (originalRuleSet.getRules() != null) { + ruleSet.setRules(new ArrayList<>(originalRuleSet.getRules())); } - if ( originalRuleSet.getIgnoreVersions() != null ) - { - ruleSet.setIgnoreVersions( new ArrayList<>( originalRuleSet.getIgnoreVersions() ) ); + if (originalRuleSet.getIgnoreVersions() != null) { + ruleSet.setIgnoreVersions(new ArrayList<>(originalRuleSet.getIgnoreVersions())); } } - if ( ruleSet.getIgnoreVersions() == null ) - { - ruleSet.setIgnoreVersions( new ArrayList<>() ); + if (ruleSet.getIgnoreVersions() == null) { + ruleSet.setIgnoreVersions(new ArrayList<>()); } - ruleSet.getIgnoreVersions().addAll( ignoredVersions.stream().map( v -> - { - IgnoreVersion ignoreVersion = new IgnoreVersion(); - ignoreVersion.setType( TYPE_REGEX ); - ignoreVersion.setVersion( v ); - return ignoreVersion; - } ).collect( Collectors.toList() ) ); + ruleSet.getIgnoreVersions() + .addAll(ignoredVersions.stream() + .map(v -> { + IgnoreVersion ignoreVersion = new IgnoreVersion(); + ignoreVersion.setType(TYPE_REGEX); + ignoreVersion.setVersion(v); + return ignoreVersion; + }) + .collect(Collectors.toList())); return ruleSet; } - private static class RulesUri - { + private static class RulesUri { String basePath; String resource; - private RulesUri( String basePath, String resource ) - { + private RulesUri(String basePath, String resource) { this.basePath = basePath; this.resource = resource; } - static RulesUri build( String rulesUri ) throws URISyntaxException - { - int split = rulesUri.lastIndexOf( '/' ); + static RulesUri build(String rulesUri) throws URISyntaxException { + int split = rulesUri.lastIndexOf('/'); return split == -1 - ? new RulesUri( rulesUri, "" ) - : new RulesUri( rulesUri.substring( 0, split ) + '/', - split + 1 < rulesUri.length() - ? rulesUri.substring( split + 1 ) - : "" ) ; - } - } - - private RemoteRepository remoteRepository( RulesUri uri ) - { - RemoteRepository prototype = new RemoteRepository.Builder( serverId, null, uri.basePath ).build(); - RemoteRepository.Builder builder = new RemoteRepository.Builder( prototype ); - ofNullable( mavenSession.getRepositorySession().getProxySelector().getProxy( prototype ) ) - .ifPresent( builder::setProxy ); - ofNullable( mavenSession.getRepositorySession().getAuthenticationSelector().getAuthentication( prototype ) ) - .ifPresent( builder::setAuthentication ); - ofNullable( mavenSession.getRepositorySession().getMirrorSelector().getMirror( prototype ) ) - .ifPresent( mirror -> builder.setMirroredRepositories( singletonList( mirror ) ) ); + ? new RulesUri(rulesUri, "") + : new RulesUri( + rulesUri.substring(0, split) + '/', + split + 1 < rulesUri.length() ? rulesUri.substring(split + 1) : ""); + } + } + + private RemoteRepository remoteRepository(RulesUri uri) { + RemoteRepository prototype = new RemoteRepository.Builder(serverId, null, uri.basePath).build(); + RemoteRepository.Builder builder = new RemoteRepository.Builder(prototype); + ofNullable(mavenSession.getRepositorySession().getProxySelector().getProxy(prototype)) + .ifPresent(builder::setProxy); + ofNullable(mavenSession + .getRepositorySession() + .getAuthenticationSelector() + .getAuthentication(prototype)) + .ifPresent(builder::setAuthentication); + ofNullable(mavenSession.getRepositorySession().getMirrorSelector().getMirror(prototype)) + .ifPresent(mirror -> builder.setMirroredRepositories(singletonList(mirror))); return builder.build(); } - private Optional getProxyInfo( RemoteRepository repository ) - { - return ofNullable( repository.getProxy() ) - .map( proxy -> new ProxyInfo() - {{ - setHost( proxy.getHost() ); - setPort( proxy.getPort() ); - setType( proxy.getType() ); - ofNullable( proxy.getAuthentication() ) - .ifPresent( auth -> - { - try ( AuthenticationContext authCtx = AuthenticationContext - .forProxy( mavenSession.getRepositorySession(), repository ) ) - { - ofNullable( authCtx.get( AuthenticationContext.USERNAME ) ) - .ifPresent( this::setUserName ); - ofNullable( authCtx.get( AuthenticationContext.PASSWORD ) ) - .ifPresent( this::setPassword ); - ofNullable( authCtx.get( AuthenticationContext.NTLM_DOMAIN ) ) - .ifPresent( this::setNtlmDomain ); - ofNullable( authCtx.get( AuthenticationContext - .NTLM_WORKSTATION ) ).ifPresent( this::setNtlmHost ); - } - } ); - }} ); + private Optional getProxyInfo(RemoteRepository repository) { + return ofNullable(repository.getProxy()).map(proxy -> new ProxyInfo() { + { + setHost(proxy.getHost()); + setPort(proxy.getPort()); + setType(proxy.getType()); + ofNullable(proxy.getAuthentication()).ifPresent(auth -> { + try (AuthenticationContext authCtx = + AuthenticationContext.forProxy(mavenSession.getRepositorySession(), repository)) { + ofNullable(authCtx.get(AuthenticationContext.USERNAME)) + .ifPresent(this::setUserName); + ofNullable(authCtx.get(AuthenticationContext.PASSWORD)) + .ifPresent(this::setPassword); + ofNullable(authCtx.get(AuthenticationContext.NTLM_DOMAIN)) + .ifPresent(this::setNtlmDomain); + ofNullable(authCtx.get(AuthenticationContext.NTLM_WORKSTATION)) + .ifPresent(this::setNtlmHost); + } + }); + } + }); } - private Optional getAuthenticationInfo( RemoteRepository repository ) - { - return ofNullable( repository.getAuthentication() ) - .map( authentication -> new AuthenticationInfo() - {{ - try ( AuthenticationContext authCtx = AuthenticationContext - .forRepository( mavenSession.getRepositorySession(), repository ) ) - { - ofNullable( authCtx.get( AuthenticationContext.USERNAME ) ) - .ifPresent( this::setUserName ); - ofNullable( authCtx.get( AuthenticationContext.PASSWORD ) ) - .ifPresent( this::setPassword ); - ofNullable( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) ) - .ifPresent( this::setPassphrase ); - ofNullable( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) ) - .ifPresent( this::setPrivateKey ); - } - }} ); + private Optional getAuthenticationInfo(RemoteRepository repository) { + return ofNullable(repository.getAuthentication()).map(authentication -> new AuthenticationInfo() { + { + try (AuthenticationContext authCtx = + AuthenticationContext.forRepository(mavenSession.getRepositorySession(), repository)) { + ofNullable(authCtx.get(AuthenticationContext.USERNAME)).ifPresent(this::setUserName); + ofNullable(authCtx.get(AuthenticationContext.PASSWORD)).ifPresent(this::setPassword); + ofNullable(authCtx.get(AuthenticationContext.PRIVATE_KEY_PASSPHRASE)) + .ifPresent(this::setPassphrase); + ofNullable(authCtx.get(AuthenticationContext.PRIVATE_KEY_PATH)) + .ifPresent(this::setPrivateKey); + } + } + }); } - private org.apache.maven.wagon.repository.Repository wagonRepository( RemoteRepository repository ) - { - return new org.apache.maven.wagon.repository.Repository( repository.getId(), repository.getUrl() ); + private org.apache.maven.wagon.repository.Repository wagonRepository(RemoteRepository repository) { + return new org.apache.maven.wagon.repository.Repository(repository.getId(), repository.getUrl()); } - private RuleSet getRulesUsingWagon() throws MojoExecutionException - { + private RuleSet getRulesUsingWagon() throws MojoExecutionException { RulesUri uri; - try - { - uri = RulesUri.build( rulesUri ); - } - catch ( URISyntaxException e ) - { - log.warn( "Invalid rulesUri protocol: " + e.getMessage() ); + try { + uri = RulesUri.build(rulesUri); + } catch (URISyntaxException e) { + log.warn("Invalid rulesUri protocol: " + e.getMessage()); return null; } - RemoteRepository repository = remoteRepository( uri ); - return ofNullable( wagonMap.get( repository.getProtocol() ) ) - .map( wagon -> - { - if ( log.isDebugEnabled() ) - { + RemoteRepository repository = remoteRepository(uri); + return ofNullable(wagonMap.get(repository.getProtocol())) + .map(wagon -> { + if (log.isDebugEnabled()) { Debug debug = new Debug(); - wagon.addSessionListener( debug ); - wagon.addTransferListener( debug ); + wagon.addSessionListener(debug); + wagon.addTransferListener(debug); } - try - { - Optional proxyInfo = getProxyInfo( repository ); - Optional authenticationInfo = getAuthenticationInfo( repository ); - if ( log.isDebugEnabled() ) - { - log.debug( "Connecting to remote repository \"" + repository.getId() + "\"" - + proxyInfo.map( pi -> " using proxy " + pi.getHost() + ":" - + pi.getPort() ).orElse( "" ) - + authenticationInfo.map( ai -> " as " + ai.getUserName() ).orElse( "" ) ); + try { + Optional proxyInfo = getProxyInfo(repository); + Optional authenticationInfo = getAuthenticationInfo(repository); + if (log.isDebugEnabled()) { + log.debug("Connecting to remote repository \"" + repository.getId() + "\"" + + proxyInfo + .map(pi -> " using proxy " + pi.getHost() + ":" + pi.getPort()) + .orElse("") + + authenticationInfo + .map(ai -> " as " + ai.getUserName()) + .orElse("")); } - wagon.connect( wagonRepository( repository ), getAuthenticationInfo( repository ) - .orElse( null ), getProxyInfo( repository ).orElse( null ) ); - try - { - Path tempFile = Files.createTempFile( "rules-", ".xml" ); - wagon.get( uri.resource, tempFile.toFile() ); - try ( BufferedInputStream is = new BufferedInputStream( - Files.newInputStream( tempFile ) ) ) - { - return new RuleXpp3Reader().read( is ); - } - finally - { - Files.deleteIfExists( tempFile ); + wagon.connect( + wagonRepository(repository), + getAuthenticationInfo(repository).orElse(null), + getProxyInfo(repository).orElse(null)); + try { + Path tempFile = Files.createTempFile("rules-", ".xml"); + wagon.get(uri.resource, tempFile.toFile()); + try (BufferedInputStream is = new BufferedInputStream(Files.newInputStream(tempFile))) { + return new RuleXpp3Reader().read(is); + } finally { + Files.deleteIfExists(tempFile); } - } - finally - { + } finally { wagon.disconnect(); } - } - catch ( Exception e ) - { - log.warn( e.getMessage() ); + } catch (Exception e) { + log.warn(e.getMessage()); return null; } - } ) - .orElseThrow( () -> new MojoExecutionException( "Could not load specified rules from " - + rulesUri ) ); + }) + .orElseThrow(() -> new MojoExecutionException("Could not load specified rules from " + rulesUri)); } - public static Optional protocol( final String url ) - { - int pos = url.indexOf( ":" ); - return pos == -1 - ? empty() - : of( url.substring( 0, pos ).trim() ); + public static Optional protocol(final String url) { + int pos = url.indexOf(":"); + return pos == -1 ? empty() : of(url.substring(0, pos).trim()); } - public Builder withRepositorySystem( RepositorySystem repositorySystem ) - { + public Builder withRepositorySystem(RepositorySystem repositorySystem) { this.repositorySystem = repositorySystem; return this; } - public Builder withIgnoredVersions( Collection ignoredVersions ) - { + public Builder withIgnoredVersions(Collection ignoredVersions) { this.ignoredVersions = ignoredVersions; return this; } - public Builder withRuleSet( RuleSet ruleSet ) - { + public Builder withRuleSet(RuleSet ruleSet) { this.ruleSet = ruleSet; return this; } - public Builder withServerId( String serverId ) - { + public Builder withServerId(String serverId) { this.serverId = serverId; return this; } - public Builder withRulesUri( String rulesUri ) - { + public Builder withRulesUri(String rulesUri) { this.rulesUri = rulesUri; return this; } - public Builder withLog( Log log ) - { + public Builder withLog(Log log) { this.log = log; return this; } - public Builder withMavenSession( MavenSession mavenSession ) - { + public Builder withMavenSession(MavenSession mavenSession) { this.mavenSession = mavenSession; return this; } - public Builder withMojoExecution( MojoExecution mojoExecution ) - { + public Builder withMojoExecution(MojoExecution mojoExecution) { this.mojoExecution = mojoExecution; return this; } - public Builder withAetherRepositorySystem( org.eclipse.aether.RepositorySystem aetherRepositorySystem ) - { + public Builder withAetherRepositorySystem(org.eclipse.aether.RepositorySystem aetherRepositorySystem) { this.aetherRepositorySystem = aetherRepositorySystem; return this; } - public Builder withWagonMap( Map wagonMap ) - { + public Builder withWagonMap(Map wagonMap) { this.wagonMap = wagonMap; return this; } @@ -1006,39 +877,30 @@ public Builder withWagonMap( Map wagonMap ) * @return constructed {@linkplain DefaultVersionsHelper} * @throws MojoExecutionException should the constructor with the RuleSet retrieval doesn't succeed */ - public DefaultVersionsHelper build() throws MojoExecutionException - { + public DefaultVersionsHelper build() throws MojoExecutionException { DefaultVersionsHelper instance = new DefaultVersionsHelper(); instance.repositorySystem = repositorySystem; instance.mavenSession = mavenSession; instance.mojoExecution = mojoExecution; - if ( ruleSet != null ) - { - if ( !isBlank( rulesUri ) ) - { - log.warn( "rulesUri is ignored if rules are specified in pom or as parameters" ); + if (ruleSet != null) { + if (!isBlank(rulesUri)) { + log.warn("rulesUri is ignored if rules are specified in pom or as parameters"); } instance.ruleSet = ruleSet; - } - else - { - instance.ruleSet = isBlank( rulesUri ) + } else { + instance.ruleSet = isBlank(rulesUri) ? new RuleSet() - : isClasspathUri( rulesUri ) - ? getRulesFromClasspath( rulesUri, log ) - : getRulesUsingWagon(); + : isClasspathUri(rulesUri) ? getRulesFromClasspath(rulesUri, log) : getRulesUsingWagon(); } - if ( ignoredVersions != null && !ignoredVersions.isEmpty() ) - { - instance.ruleSet = enrichRuleSet( ignoredVersions, instance.ruleSet ); + if (ignoredVersions != null && !ignoredVersions.isEmpty()) { + instance.ruleSet = enrichRuleSet(ignoredVersions, instance.ruleSet); } instance.aetherRepositorySystem = aetherRepositorySystem; instance.log = log; return instance; } - private static boolean isBlank( String s ) - { + private static boolean isBlank(String s) { return s == null || s.trim().isEmpty(); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java index 6376f5c2d6..ca7b3cbe73 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PluginUpdatesDetails.java @@ -30,25 +30,24 @@ /** * Details of a plugin's updates. */ -public class PluginUpdatesDetails extends ArtifactVersions -{ +public class PluginUpdatesDetails extends ArtifactVersions { private final Map dependencyVersions; private final boolean includeSnapshots; - public PluginUpdatesDetails( ArtifactVersions artifactVersions, - Map dependencyVersions, boolean includeSnapshots ) - { - super( artifactVersions ); - Objects.requireNonNull( artifactVersions ); - Objects.requireNonNull( dependencyVersions ); + public PluginUpdatesDetails( + ArtifactVersions artifactVersions, + Map dependencyVersions, + boolean includeSnapshots) { + super(artifactVersions); + Objects.requireNonNull(artifactVersions); + Objects.requireNonNull(dependencyVersions); this.dependencyVersions = dependencyVersions; this.includeSnapshots = includeSnapshots; } - public Map getDependencyVersions() - { + public Map getDependencyVersions() { return dependencyVersions; } @@ -57,9 +56,8 @@ public Map getDependencyVersions() * * @return true if a new version can be found */ - public boolean isArtifactUpdateAvailable() - { - ArtifactVersion[] updates = getAllUpdates( empty(), includeSnapshots ); + public boolean isArtifactUpdateAvailable() { + ArtifactVersion[] updates = getAllUpdates(empty(), includeSnapshots); return updates != null && updates.length > 0; } @@ -68,13 +66,11 @@ public boolean isArtifactUpdateAvailable() * * @return true if a new version can be found */ - public boolean isDependencyUpdateAvailable() - { - return dependencyVersions.values().stream().anyMatch( versions -> - { - ArtifactVersion[] dependencyUpdates = versions.getAllUpdates( empty(), includeSnapshots ); + public boolean isDependencyUpdateAvailable() { + return dependencyVersions.values().stream().anyMatch(versions -> { + ArtifactVersion[] dependencyUpdates = versions.getAllUpdates(empty(), includeSnapshots); return dependencyUpdates != null && dependencyUpdates.length > 0; - } ); + }); } /** @@ -82,8 +78,7 @@ public boolean isDependencyUpdateAvailable() * * @return true if a new version can be found */ - public boolean isUpdateAvailable() - { + public boolean isUpdateAvailable() { return isArtifactUpdateAvailable() || isDependencyUpdateAvailable(); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java index cc1d1126c1..9583bf28c7 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PomHelper.java @@ -82,8 +82,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class PomHelper -{ +public class PomHelper { public static final String APACHE_MAVEN_PLUGINS_GROUPID = "org.apache.maven.plugins"; /** @@ -93,10 +92,8 @@ public class PomHelper * @return The raw model. * @throws IOException if the file is not found or if the file does not parse. */ - public static Model getRawModel( MavenProject project ) - throws IOException - { - return getRawModel( project.getFile() ); + public static Model getRawModel(MavenProject project) throws IOException { + return getRawModel(project.getFile()); } /** @@ -106,13 +103,10 @@ public static Model getRawModel( MavenProject project ) * @return The raw model. * @throws IOException if the file is not found or if the file does not parse. */ - public static Model getRawModel( File moduleProjectFile ) - throws IOException - { - try ( Reader reader = new BufferedReader( new InputStreamReader( Files.newInputStream( moduleProjectFile - .toPath() ) ) ) ) - { - return getRawModel( reader ); + public static Model getRawModel(File moduleProjectFile) throws IOException { + try (Reader reader = + new BufferedReader(new InputStreamReader(Files.newInputStream(moduleProjectFile.toPath())))) { + return getRawModel(reader); } } @@ -123,12 +117,10 @@ public static Model getRawModel( File moduleProjectFile ) * @return The raw model. * @throws IOException if the file is not found or if the file does not parse. */ - public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventReader ) - throws IOException - { - try ( Reader reader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() ) ) - { - return getRawModel( reader ); + public static Model getRawModel(ModifiedPomXMLEventReader modifiedPomXMLEventReader) throws IOException { + try (Reader reader = + new StringReader(modifiedPomXMLEventReader.asStringBuilder().toString())) { + return getRawModel(reader); } } @@ -139,16 +131,11 @@ public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventRe * @return The raw model. * @throws IOException if the file is not found or if the file does not parse. */ - public static Model getRawModel( Reader reader ) - throws IOException - { - try - { - return new MavenXpp3Reader().read( reader ); - } - catch ( XmlPullParserException e ) - { - throw new IOException( e.getMessage(), e ); + public static Model getRawModel(Reader reader) throws IOException { + try { + return new MavenXpp3Reader().read(reader); + } catch (XmlPullParserException e) { + throw new IOException(e.getMessage(), e); } } @@ -162,10 +149,9 @@ public static Model getRawModel( Reader reader ) * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. */ - public static boolean setPropertyVersion( final ModifiedPomXMLEventReader pom, final String profileId, - final String property, final String value ) - throws XMLStreamException - { + public static boolean setPropertyVersion( + final ModifiedPomXMLEventReader pom, final String profileId, final String property, final String value) + throws XMLStreamException { Stack stack = new Stack<>(); String path = ""; final Pattern propertyRegex; @@ -173,64 +159,49 @@ public static boolean setPropertyVersion( final ModifiedPomXMLEventReader pom, f final Pattern projectProfileId; boolean inMatchScope = false; boolean madeReplacement = false; - if ( profileId == null ) - { - propertyRegex = Pattern.compile( "/project/properties/" + RegexUtils.quote( property ) ); - matchScopeRegex = Pattern.compile( "/project/properties" ); + if (profileId == null) { + propertyRegex = Pattern.compile("/project/properties/" + RegexUtils.quote(property)); + matchScopeRegex = Pattern.compile("/project/properties"); projectProfileId = null; - } - else - { - propertyRegex = Pattern.compile( "/project/profiles/profile/properties/" + RegexUtils.quote( property ) ); - matchScopeRegex = Pattern.compile( "/project/profiles/profile" ); - projectProfileId = Pattern.compile( "/project/profiles/profile/id" ); + } else { + propertyRegex = Pattern.compile("/project/profiles/profile/properties/" + RegexUtils.quote(property)); + matchScopeRegex = Pattern.compile("/project/profiles/profile"); + projectProfileId = Pattern.compile("/project/profiles/profile/id"); } pom.rewind(); - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); path = path + "/" + event.asStartElement().getName().getLocalPart(); - if ( propertyRegex.matcher( path ).matches() ) - { - pom.mark( 0 ); - } - else if ( matchScopeRegex.matcher( path ).matches() ) - { + if (propertyRegex.matcher(path).matches()) { + pom.mark(0); + } else if (matchScopeRegex.matcher(path).matches()) { // we're in a new match scope // reset any previous partial matches inMatchScope = profileId == null; - pom.clearMark( 0 ); - pom.clearMark( 1 ); - } - else if ( profileId != null && projectProfileId.matcher( path ).matches() ) - { + pom.clearMark(0); + pom.clearMark(1); + } else if (profileId != null && projectProfileId.matcher(path).matches()) { String candidateId = pom.getElementText(); path = stack.pop(); // since getElementText will be after the end element - inMatchScope = profileId.trim().equals( candidateId.trim() ); + inMatchScope = profileId.trim().equals(candidateId.trim()); } } - if ( event.isEndElement() ) - { - if ( propertyRegex.matcher( path ).matches() ) - { - pom.mark( 1 ); - } - else if ( matchScopeRegex.matcher( path ).matches() ) - { - if ( inMatchScope && pom.hasMark( 0 ) && pom.hasMark( 1 ) ) - { - pom.replaceBetween( 0, 1, value ); + if (event.isEndElement()) { + if (propertyRegex.matcher(path).matches()) { + pom.mark(1); + } else if (matchScopeRegex.matcher(path).matches()) { + if (inMatchScope && pom.hasMark(0) && pom.hasMark(1)) { + pom.replaceBetween(0, 1, value); madeReplacement = true; } - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); inMatchScope = false; } path = stack.pop(); @@ -247,10 +218,9 @@ else if ( matchScopeRegex.matcher( path ).matches() ) * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. */ - public static boolean setProjectVersion( final ModifiedPomXMLEventReader pom, final String value ) - throws XMLStreamException - { - return setElementValue( pom, "/project", "version", value, false ); + public static boolean setProjectVersion(final ModifiedPomXMLEventReader pom, final String value) + throws XMLStreamException { + return setElementValue(pom, "/project", "version", value, false); } /** @@ -265,12 +235,11 @@ public static boolean setProjectVersion( final ModifiedPomXMLEventReader pom, fi * @return {@code true} if the element was created or replaced * @throws XMLStreamException if something went wrong */ - public static boolean setElementValue( ModifiedPomXMLEventReader pom, String parentPath, - String elementName, String value ) - throws XMLStreamException - { + public static boolean setElementValue( + ModifiedPomXMLEventReader pom, String parentPath, String elementName, String value) + throws XMLStreamException { pom.rewind(); - return setElementValue( pom, parentPath, elementName, value, true ); + return setElementValue(pom, parentPath, elementName, value, true); } /** @@ -288,12 +257,10 @@ public static boolean setElementValue( ModifiedPomXMLEventReader pom, String par * @return {@code true} if the element was created or replaced * @throws XMLStreamException if something went wrong */ - public static boolean setElementValue( ModifiedPomXMLEventReader pom, String parentPath, - String elementName, String value, boolean shouldCreate ) - throws XMLStreamException - { - class ElementValueInternal - { + public static boolean setElementValue( + ModifiedPomXMLEventReader pom, String parentPath, String elementName, String value, boolean shouldCreate) + throws XMLStreamException { + class ElementValueInternal { private final String parentName; private final String superParentPath; @@ -301,52 +268,39 @@ class ElementValueInternal private static final int MARK_OPTION = 1; private static final int PARENT_BEGIN = 2; - ElementValueInternal() - { - int lastDelimeterIndex = parentPath.lastIndexOf( '/' ); - parentName = parentPath.substring( lastDelimeterIndex + 1 ); - superParentPath = parentPath.substring( 0, lastDelimeterIndex ); + ElementValueInternal() { + int lastDelimeterIndex = parentPath.lastIndexOf('/'); + parentName = parentPath.substring(lastDelimeterIndex + 1); + superParentPath = parentPath.substring(0, lastDelimeterIndex); } - boolean process( String currentPath ) throws XMLStreamException - { + boolean process(String currentPath) throws XMLStreamException { boolean replacementMade = false; - while ( !replacementMade && pom.hasNext() ) - { + while (!replacementMade && pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - String currentElementName = event.asStartElement().getName().getLocalPart(); + if (event.isStartElement()) { + String currentElementName = + event.asStartElement().getName().getLocalPart(); // here, we will only mark the beginning of the child or the parent element - if ( currentPath.equals( parentPath ) && elementName.equals( currentElementName ) ) - { - pom.mark( MARK_CHILD_BEGIN ); - } - else if ( currentPath.equals( superParentPath ) && currentElementName.equals( parentName ) ) - { - pom.mark( PARENT_BEGIN ); + if (currentPath.equals(parentPath) && elementName.equals(currentElementName)) { + pom.mark(MARK_CHILD_BEGIN); + } else if (currentPath.equals(superParentPath) && currentElementName.equals(parentName)) { + pom.mark(PARENT_BEGIN); } // process child element - replacementMade = process( currentPath + "/" + currentElementName ); - } - else if ( event.isEndElement() ) - { + replacementMade = process(currentPath + "/" + currentElementName); + } else if (event.isEndElement()) { // here we're doing the replacement - if ( currentPath.equals( parentPath + "/" + elementName ) ) - { + if (currentPath.equals(parentPath + "/" + elementName)) { // end of the child replaceValueInChild(); replacementMade = true; - } - else if ( shouldCreate && currentPath.equals( parentPath ) ) - { + } else if (shouldCreate && currentPath.equals(parentPath)) { // end of the parent replaceValueInParent(); replacementMade = true; - } - else - { + } else { return false; } } @@ -354,51 +308,34 @@ else if ( shouldCreate && currentPath.equals( parentPath ) ) return replacementMade; } - private void replaceValueInChild() - { - pom.mark( MARK_OPTION ); - if ( pom.getBetween( MARK_CHILD_BEGIN, MARK_OPTION ).length() > 0 ) - { - pom.replaceBetween( 0, 1, value ); - } - else - { - pom.replace( String.format( "<%1$s>%2$s", elementName, value ) ); + private void replaceValueInChild() { + pom.mark(MARK_OPTION); + if (pom.getBetween(MARK_CHILD_BEGIN, MARK_OPTION).length() > 0) { + pom.replaceBetween(0, 1, value); + } else { + pom.replace(String.format("<%1$s>%2$s", elementName, value)); } } - private void replaceValueInParent() - { - pom.mark( MARK_OPTION ); - if ( pom.hasMark( PARENT_BEGIN ) ) - { - if ( pom.getBetween( PARENT_BEGIN, MARK_OPTION ).length() > 0 ) - { - pom.replace( String.format( "<%2$s>%3$s", - parentName, elementName, value ) ); - } - else - { - pom.replace( String.format( "<%1$s><%2$s>%3$s", - parentName, elementName, value ) ); + private void replaceValueInParent() { + pom.mark(MARK_OPTION); + if (pom.hasMark(PARENT_BEGIN)) { + if (pom.getBetween(PARENT_BEGIN, MARK_OPTION).length() > 0) { + pom.replace(String.format("<%2$s>%3$s", parentName, elementName, value)); + } else { + pom.replace(String.format("<%1$s><%2$s>%3$s", parentName, elementName, value)); } - } - else - { - pom.replace( String.format( "<%1$s><%2$s>%3$s", - parentName, elementName, value ) ); + } else { + pom.replace(String.format("<%1$s><%2$s>%3$s", parentName, elementName, value)); } } } - try - { + try { pom.rewind(); - return new ElementValueInternal().process( "" ); - } - finally - { - range( 0, 3 ).forEach( pom::clearMark ); + return new ElementValueInternal().process(""); + } finally { + range(0, 3).forEach(pom::clearMark); } } @@ -410,39 +347,31 @@ private void replaceValueInParent() * parent version). * @throws XMLStreamException if something went wrong. */ - public static String getProjectVersion( final ModifiedPomXMLEventReader pom ) - throws XMLStreamException - { + public static String getProjectVersion(final ModifiedPomXMLEventReader pom) throws XMLStreamException { Stack stack = new Stack<>(); String path = ""; - final Pattern matchScopeRegex = Pattern.compile( "/project/version" ); + final Pattern matchScopeRegex = Pattern.compile("/project/version"); pom.rewind(); - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); path = path + "/" + event.asStartElement().getName().getLocalPart(); - if ( matchScopeRegex.matcher( path ).matches() ) - { - pom.mark( 0 ); + if (matchScopeRegex.matcher(path).matches()) { + pom.mark(0); } } - if ( event.isEndElement() ) - { - if ( matchScopeRegex.matcher( path ).matches() ) - { - pom.mark( 1 ); - if ( pom.hasMark( 0 ) && pom.hasMark( 1 ) ) - { - return pom.getBetween( 0, 1 ).trim(); + if (event.isEndElement()) { + if (matchScopeRegex.matcher(path).matches()) { + pom.mark(1); + if (pom.hasMark(0) && pom.hasMark(1)) { + return pom.getBetween(0, 1).trim(); } - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); } path = stack.pop(); } @@ -458,42 +387,35 @@ public static String getProjectVersion( final ModifiedPomXMLEventReader pom ) * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. */ - public static boolean setProjectParentVersion( final ModifiedPomXMLEventReader pom, final String value ) - throws XMLStreamException - { + public static boolean setProjectParentVersion(final ModifiedPomXMLEventReader pom, final String value) + throws XMLStreamException { Stack stack = new Stack<>(); String path = ""; final Pattern matchScopeRegex; boolean madeReplacement = false; - matchScopeRegex = Pattern.compile( "/project/parent/version" ); + matchScopeRegex = Pattern.compile("/project/parent/version"); pom.rewind(); - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); path = path + "/" + event.asStartElement().getName().getLocalPart(); - if ( matchScopeRegex.matcher( path ).matches() ) - { - pom.mark( 0 ); + if (matchScopeRegex.matcher(path).matches()) { + pom.mark(0); } } - if ( event.isEndElement() ) - { - if ( matchScopeRegex.matcher( path ).matches() ) - { - pom.mark( 1 ); - if ( pom.hasMark( 0 ) && pom.hasMark( 1 ) ) - { - pom.replaceBetween( 0, 1, value ); + if (event.isEndElement()) { + if (matchScopeRegex.matcher(path).matches()) { + pom.mark(1); + if (pom.hasMark(0) && pom.hasMark(1)) { + pom.replaceBetween(0, 1, value); madeReplacement = true; } - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); } path = stack.pop(); } @@ -513,65 +435,58 @@ public static boolean setProjectParentVersion( final ModifiedPomXMLEventReader p * @return true if a replacement was made. * @throws XMLStreamException if something went wrong. */ - @SuppressWarnings( "checkstyle:MethodLength" ) - public static boolean setDependencyVersion( final ModifiedPomXMLEventReader pom, final String groupId, - final String artifactId, final String oldVersion, - final String newVersion, final Model model ) - throws XMLStreamException - { + @SuppressWarnings("checkstyle:MethodLength") + public static boolean setDependencyVersion( + final ModifiedPomXMLEventReader pom, + final String groupId, + final String artifactId, + final String oldVersion, + final String newVersion, + final Model model) + throws XMLStreamException { Stack stack = new Stack<>(); String path = ""; - Set implicitPaths = - new HashSet<>( Arrays.asList( "/project/parent/groupId", "/project/parent/artifactId", - "/project/parent/version", "/project/groupId", - "/project/artifactId", "/project/version" ) ); + Set implicitPaths = new HashSet<>(Arrays.asList( + "/project/parent/groupId", "/project/parent/artifactId", + "/project/parent/version", "/project/groupId", + "/project/artifactId", "/project/version")); Map implicitProperties = new HashMap<>(); - for ( Map.Entry entry : model.getProperties().entrySet() ) - { - implicitProperties.put( (String) entry.getKey(), (String) entry.getValue() ); + for (Map.Entry entry : model.getProperties().entrySet()) { + implicitProperties.put((String) entry.getKey(), (String) entry.getValue()); } pom.rewind(); - while ( pom.hasNext() ) - { - while ( pom.hasNext() ) - { + while (pom.hasNext()) { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); final String elementName = event.asStartElement().getName().getLocalPart(); path = path + "/" + elementName; - if ( implicitPaths.contains( path ) ) - { + if (implicitPaths.contains(path)) { final String elementText = pom.getElementText().trim(); - implicitProperties.put( path.substring( 1 ).replace( '/', '.' ), elementText ); + implicitProperties.put(path.substring(1).replace('/', '.'), elementText); path = stack.pop(); } } - if ( event.isEndElement() ) - { + if (event.isEndElement()) { path = stack.pop(); } } } boolean modified = true; - while ( modified ) - { + while (modified) { modified = false; - for ( Map.Entry entry : implicitProperties.entrySet() ) - { - if ( entry.getKey().contains( ".parent" ) ) - { - String child = entry.getKey().replace( ".parent", "" ); - if ( !implicitProperties.containsKey( child ) ) - { - implicitProperties.put( child, entry.getValue() ); + for (Map.Entry entry : implicitProperties.entrySet()) { + if (entry.getKey().contains(".parent")) { + String child = entry.getKey().replace(".parent", ""); + if (!implicitProperties.containsKey(child)) { + implicitProperties.put(child, entry.getValue()); modified = true; break; } @@ -587,88 +502,74 @@ public static boolean setDependencyVersion( final ModifiedPomXMLEventReader pom, boolean haveArtifactId = false; boolean haveOldVersion = false; - final Pattern matchScopeRegex = Pattern.compile( - "/project" + "(/profiles/profile)?" + final Pattern matchScopeRegex = Pattern.compile("/project" + "(/profiles/profile)?" + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" - + "/dependencies/dependency" ); + + "/dependencies/dependency"); - final Pattern matchTargetRegex = Pattern.compile( - "/project" + "(/profiles/profile)?" + final Pattern matchTargetRegex = Pattern.compile("/project" + "(/profiles/profile)?" + "((/dependencyManagement)|(/build(/pluginManagement)?/plugins/plugin))?" + "/dependencies/dependency" - + "((/groupId)|(/artifactId)|(/version))" ); + + "((/groupId)|(/artifactId)|(/version))"); pom.rewind(); - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); final String elementName = event.asStartElement().getName().getLocalPart(); path = path + "/" + elementName; - if ( matchScopeRegex.matcher( path ).matches() ) - { + if (matchScopeRegex.matcher(path).matches()) { // we're in a new match scope // reset any previous partial matches inMatchScope = true; - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); haveGroupId = false; haveArtifactId = false; haveOldVersion = false; - } - else if ( inMatchScope && matchTargetRegex.matcher( path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { - haveGroupId = groupId.equals( evaluate( pom.getElementText().trim(), implicitProperties ) ); + } else if (inMatchScope && matchTargetRegex.matcher(path).matches()) { + if ("groupId".equals(elementName)) { + haveGroupId = + groupId.equals(evaluate(pom.getElementText().trim(), implicitProperties)); path = stack.pop(); - } - else if ( "artifactId".equals( elementName ) ) - { + } else if ("artifactId".equals(elementName)) { haveArtifactId = - artifactId.equals( evaluate( pom.getElementText().trim(), implicitProperties ) ); + artifactId.equals(evaluate(pom.getElementText().trim(), implicitProperties)); path = stack.pop(); - } - else if ( "version".equals( elementName ) ) - { - pom.mark( 0 ); + } else if ("version".equals(elementName)) { + pom.mark(0); } } } - if ( event.isEndElement() ) - { - if ( matchTargetRegex.matcher( path ).matches() - && "version".equals( event.asEndElement().getName().getLocalPart() ) ) - { - pom.mark( 1 ); - String compressedPomVersion = StringUtils.deleteWhitespace( pom.getBetween( 0, 1 ).trim() ); - String compressedOldVersion = StringUtils.deleteWhitespace( oldVersion ); - - try - { - haveOldVersion = isVersionOverlap( compressedOldVersion, compressedPomVersion ); - } - catch ( InvalidVersionSpecificationException e ) - { + if (event.isEndElement()) { + if (matchTargetRegex.matcher(path).matches() + && "version".equals(event.asEndElement().getName().getLocalPart())) { + pom.mark(1); + String compressedPomVersion = + StringUtils.deleteWhitespace(pom.getBetween(0, 1).trim()); + String compressedOldVersion = StringUtils.deleteWhitespace(oldVersion); + + try { + haveOldVersion = isVersionOverlap(compressedOldVersion, compressedPomVersion); + } catch (InvalidVersionSpecificationException e) { // fall back to string comparison - haveOldVersion = compressedOldVersion.equals( compressedPomVersion ); + haveOldVersion = compressedOldVersion.equals(compressedPomVersion); } - } - else if ( matchScopeRegex.matcher( path ).matches() ) - { - if ( inMatchScope && pom.hasMark( 0 ) && pom.hasMark( 1 ) && haveGroupId && haveArtifactId - && haveOldVersion ) - { - pom.replaceBetween( 0, 1, newVersion ); + } else if (matchScopeRegex.matcher(path).matches()) { + if (inMatchScope + && pom.hasMark(0) + && pom.hasMark(1) + && haveGroupId + && haveArtifactId + && haveOldVersion) { + pom.replaceBetween(0, 1, newVersion); madeReplacement = true; } - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); haveArtifactId = false; haveGroupId = false; haveOldVersion = false; @@ -687,73 +588,55 @@ else if ( matchScopeRegex.matcher( path ).matches() ) * @param properties The properties to substitute. * @return The evaluated expression. */ - public static String evaluate( String expr, Map properties ) - { - if ( expr == null ) - { + public static String evaluate(String expr, Map properties) { + if (expr == null) { return null; } - String expression = stripTokens( expr ); - if ( expression.equals( expr ) ) - { - int index = expr.indexOf( "${" ); - if ( index >= 0 ) - { - int lastIndex = expr.indexOf( "}", index ); - if ( lastIndex >= 0 ) - { - String retVal = expr.substring( 0, index ); - - if ( index > 0 && expr.charAt( index - 1 ) == '$' ) - { - retVal += expr.substring( index + 1, lastIndex + 1 ); - } - else - { - retVal += evaluate( expr.substring( index, lastIndex + 1 ), properties ); + String expression = stripTokens(expr); + if (expression.equals(expr)) { + int index = expr.indexOf("${"); + if (index >= 0) { + int lastIndex = expr.indexOf("}", index); + if (lastIndex >= 0) { + String retVal = expr.substring(0, index); + + if (index > 0 && expr.charAt(index - 1) == '$') { + retVal += expr.substring(index + 1, lastIndex + 1); + } else { + retVal += evaluate(expr.substring(index, lastIndex + 1), properties); } - retVal += evaluate( expr.substring( lastIndex + 1 ), properties ); + retVal += evaluate(expr.substring(lastIndex + 1), properties); return retVal; } } // Was not an expression - if ( expression.contains( "$$" ) ) - { - return expression.replaceAll( "\\$\\$", "\\$" ); - } - else - { + if (expression.contains("$$")) { + return expression.replaceAll("\\$\\$", "\\$"); + } else { return expression; } } - String value = properties.get( expression ); + String value = properties.get(expression); - if ( value != null ) - { - int exprStartDelimiter = value.indexOf( "${" ); + if (value != null) { + int exprStartDelimiter = value.indexOf("${"); - if ( exprStartDelimiter >= 0 ) - { - if ( exprStartDelimiter > 0 ) - { - value = value.substring( 0, exprStartDelimiter ) - + evaluate( value.substring( exprStartDelimiter ), properties ); - } - else - { - value = evaluate( value.substring( exprStartDelimiter ), properties ); + if (exprStartDelimiter >= 0) { + if (exprStartDelimiter > 0) { + value = value.substring(0, exprStartDelimiter) + + evaluate(value.substring(exprStartDelimiter), properties); + } else { + value = evaluate(value.substring(exprStartDelimiter), properties); } } - } - else - { + } else { // TODO find a way to log that and not use this System.out!! // this class could be a component with logger injected !! - System.out.println( "expression: " + expression + " no value " ); + System.out.println("expression: " + expression + " no value "); } return value == null ? expr : value; } @@ -764,11 +647,9 @@ public static String evaluate( String expr, Map properties ) * @param expr the string (perhaps with token markers) * @return the string (definately without token markers) */ - private static String stripTokens( String expr ) - { - if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 ) - { - expr = expr.substring( 2, expr.length() - 1 ); + private static String stripTokens(String expr) { + if (expr.startsWith("${") && expr.indexOf("}") == expr.length() - 1) { + expr = expr.substring(2, expr.length() - 1); } return expr; } @@ -781,32 +662,26 @@ private static String stripTokens( String expr ) * @return true if both versions have an overlap * @throws InvalidVersionSpecificationException if the versions can't be parsed to a range */ - public static boolean isVersionOverlap( String leftVersionOrRange, String rightVersionOrRange ) - throws InvalidVersionSpecificationException - { - VersionRange pomVersionRange = createVersionRange( leftVersionOrRange ); - if ( !pomVersionRange.hasRestrictions() ) - { + public static boolean isVersionOverlap(String leftVersionOrRange, String rightVersionOrRange) + throws InvalidVersionSpecificationException { + VersionRange pomVersionRange = createVersionRange(leftVersionOrRange); + if (!pomVersionRange.hasRestrictions()) { return true; } - VersionRange oldVersionRange = createVersionRange( rightVersionOrRange ); - if ( !oldVersionRange.hasRestrictions() ) - { + VersionRange oldVersionRange = createVersionRange(rightVersionOrRange); + if (!oldVersionRange.hasRestrictions()) { return true; } - VersionRange result = oldVersionRange.restrict( pomVersionRange ); + VersionRange result = oldVersionRange.restrict(pomVersionRange); return result.hasRestrictions(); } - private static VersionRange createVersionRange( String versionOrRange ) - throws InvalidVersionSpecificationException - { - VersionRange versionRange = VersionRange.createFromVersionSpec( versionOrRange ); - if ( versionRange.getRecommendedVersion() != null ) - { - versionRange = VersionRange.createFromVersionSpec( "[" + versionOrRange + "]" ); + private static VersionRange createVersionRange(String versionOrRange) throws InvalidVersionSpecificationException { + VersionRange versionRange = VersionRange.createFromVersionSpec(versionOrRange); + if (versionRange.getRecommendedVersion() != null) { + versionRange = VersionRange.createFromVersionSpec("[" + versionOrRange + "]"); } return versionRange; } @@ -822,10 +697,13 @@ private static VersionRange createVersionRange( String versionOrRange ) * @return true if a replacement was made. * @throws XMLStreamException if somethinh went wrong. */ - public static boolean setPluginVersion( final ModifiedPomXMLEventReader pom, final String groupId, - final String artifactId, final String oldVersion, final String newVersion ) - throws XMLStreamException - { + public static boolean setPluginVersion( + final ModifiedPomXMLEventReader pom, + final String groupId, + final String artifactId, + final String oldVersion, + final String newVersion) + throws XMLStreamException { Stack stack = new Stack<>(); String path = ""; final Pattern matchScopeRegex; @@ -833,84 +711,71 @@ public static boolean setPluginVersion( final ModifiedPomXMLEventReader pom, fin boolean inMatchScope = false; boolean madeReplacement = false; boolean haveGroupId = false; - boolean needGroupId = groupId != null && !APACHE_MAVEN_PLUGINS_GROUPID.equals( groupId ); + boolean needGroupId = groupId != null && !APACHE_MAVEN_PLUGINS_GROUPID.equals(groupId); boolean haveArtifactId = false; boolean haveOldVersion = false; - matchScopeRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" ); + matchScopeRegex = Pattern.compile( + "/project" + "(/profiles/profile)?" + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin"); - matchTargetRegex = Pattern.compile( "/project" + "(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" - + "((/groupId)|(/artifactId)|(/version))" ); + matchTargetRegex = Pattern.compile("/project" + "(/profiles/profile)?" + + "((/build(/pluginManagement)?)|(/reporting))/plugins/plugin" + + "((/groupId)|(/artifactId)|(/version))"); pom.rewind(); - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); final String elementName = event.asStartElement().getName().getLocalPart(); path = path + "/" + elementName; - if ( matchScopeRegex.matcher( path ).matches() ) - { + if (matchScopeRegex.matcher(path).matches()) { // we're in a new match scope // reset any previous partial matches inMatchScope = true; - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); haveGroupId = false; haveArtifactId = false; haveOldVersion = false; - } - else if ( inMatchScope && matchTargetRegex.matcher( path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { - haveGroupId = pom.getElementText().trim().equals( groupId ); + } else if (inMatchScope && matchTargetRegex.matcher(path).matches()) { + if ("groupId".equals(elementName)) { + haveGroupId = pom.getElementText().trim().equals(groupId); path = stack.pop(); - } - else if ( "artifactId".equals( elementName ) ) - { - haveArtifactId = artifactId.equals( pom.getElementText().trim() ); + } else if ("artifactId".equals(elementName)) { + haveArtifactId = artifactId.equals(pom.getElementText().trim()); path = stack.pop(); - } - else if ( "version".equals( elementName ) ) - { - pom.mark( 0 ); + } else if ("version".equals(elementName)) { + pom.mark(0); } } } - if ( event.isEndElement() ) - { - if ( matchTargetRegex.matcher( path ).matches() - && "version".equals( event.asEndElement().getName().getLocalPart() ) ) - { - pom.mark( 1 ); - - try - { - haveOldVersion = isVersionOverlap( oldVersion, pom.getBetween( 0, 1 ).trim() ); - } - catch ( InvalidVersionSpecificationException e ) - { + if (event.isEndElement()) { + if (matchTargetRegex.matcher(path).matches() + && "version".equals(event.asEndElement().getName().getLocalPart())) { + pom.mark(1); + + try { + haveOldVersion = isVersionOverlap( + oldVersion, pom.getBetween(0, 1).trim()); + } catch (InvalidVersionSpecificationException e) { // fall back to string comparison - haveOldVersion = oldVersion.equals( pom.getBetween( 0, 1 ).trim() ); + haveOldVersion = oldVersion.equals(pom.getBetween(0, 1).trim()); } - } - else if ( matchScopeRegex.matcher( path ).matches() ) - { - if ( inMatchScope && pom.hasMark( 0 ) && pom.hasMark( 1 ) && ( haveGroupId || !needGroupId ) - && haveArtifactId && haveOldVersion ) - { - pom.replaceBetween( 0, 1, newVersion ); + } else if (matchScopeRegex.matcher(path).matches()) { + if (inMatchScope + && pom.hasMark(0) + && pom.hasMark(1) + && (haveGroupId || !needGroupId) + && haveArtifactId + && haveOldVersion) { + pom.replaceBetween(0, 1, newVersion); madeReplacement = true; - pom.clearMark( 0 ); - pom.clearMark( 1 ); + pom.clearMark(0); + pom.clearMark(1); haveArtifactId = false; haveGroupId = false; haveOldVersion = false; @@ -929,27 +794,19 @@ else if ( matchScopeRegex.matcher( path ).matches() ) * @param project maven project of the child for which the models need to be gathered * @return gathered map of raw models per project */ - private static Map getRawModelWithParents( MavenProject project ) throws IOException - { + private static Map getRawModelWithParents(MavenProject project) throws IOException { // constructs a tree sorted from children to parents - Map models = new TreeMap<>( ( p1, p2 ) -> - { - for ( MavenProject p = p1; p != null; p = p.getParent() ) - { - if ( p == p2 ) // meaning p2 is an ancestor to p1 or p1 == p2 + Map models = new TreeMap<>((p1, p2) -> { + for (MavenProject p = p1; p != null; p = p.getParent()) { + if (p == p2) // meaning p2 is an ancestor to p1 or p1 == p2 { - return p == p1 - ? 0 - : -1; // p1 is the child + return p == p1 ? 0 : -1; // p1 is the child } } return 1; - } ); - for ( MavenProject p = project; p != null; p = p.getParent() ) - { - models.put( p, p.getFile() != null - ? getRawModel( p ) - : p.getOriginalModel() ); + }); + for (MavenProject p = project; p != null; p = p.getParent()) { + models.put(p, p.getFile() != null ? getRawModel(p) : p.getOriginalModel()); } return models; } @@ -965,130 +822,145 @@ private static Map getRawModelWithParents( MavenProject pro * @throws IOException if the project's pom file cannot be parsed. * @since 1.0-alpha-3 */ - public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHelper helper, MavenProject project, - boolean includeParent ) - throws ExpressionEvaluationException, IOException - { - ExpressionEvaluator expressionEvaluator = helper.getExpressionEvaluator( project ); - Map reactorModels = includeParent - ? getRawModelWithParents( project ) - : singletonMap( project, getRawModel( project ) ); + public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( + VersionsHelper helper, MavenProject project, boolean includeParent) + throws ExpressionEvaluationException, IOException { + ExpressionEvaluator expressionEvaluator = helper.getExpressionEvaluator(project); + Map reactorModels = + includeParent ? getRawModelWithParents(project) : singletonMap(project, getRawModel(project)); Map propertiesMap = new TreeMap<>(); Set activeProfiles = new TreeSet<>(); - for ( Profile profile : project.getActiveProfiles() ) - { - activeProfiles.add( profile.getId() ); + for (Profile profile : project.getActiveProfiles()) { + activeProfiles.add(profile.getId()); } // add any properties from profiles first (as they override properties from the project - for ( Iterator it = reactorModels.values().stream() - .flatMap( model -> model.getProfiles().stream() ) - .filter( profile -> activeProfiles.contains( profile.getId() ) ) - .iterator(); it.hasNext(); ) - { + for (Iterator it = reactorModels.values().stream() + .flatMap(model -> model.getProfiles().stream()) + .filter(profile -> activeProfiles.contains(profile.getId())) + .iterator(); + it.hasNext(); ) { Profile profile = it.next(); - try - { - addProperties( helper, propertiesMap, profile.getId(), profile.getProperties() ); - if ( profile.getDependencyManagement() != null ) - { - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, - profile.getDependencyManagement().getDependencies(), false ); + try { + addProperties(helper, propertiesMap, profile.getId(), profile.getProperties()); + if (profile.getDependencyManagement() != null) { + addDependencyAssocations( + helper, + expressionEvaluator, + propertiesMap, + profile.getDependencyManagement().getDependencies(), + false); } - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, - profile.getDependencies(), - false ); - if ( profile.getBuild() != null ) - { - if ( profile.getBuild().getPluginManagement() != null ) - { - addPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getBuild().getPluginManagement().getPlugins() ); + addDependencyAssocations(helper, expressionEvaluator, propertiesMap, profile.getDependencies(), false); + if (profile.getBuild() != null) { + if (profile.getBuild().getPluginManagement() != null) { + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getBuild().getPluginManagement().getPlugins()); } - addPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getBuild().getPlugins() ); + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getBuild().getPlugins()); } - if ( profile.getReporting() != null ) - { - addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getReporting().getPlugins() ); + if (profile.getReporting() != null) { + addReportPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getReporting().getPlugins()); } - } - catch ( ExpressionEvaluationException e ) - { - throw new RuntimeException( e ); + } catch (ExpressionEvaluationException e) { + throw new RuntimeException(e); } } // second, we add all the properties in the pom - reactorModels.values().forEach( model -> addProperties( helper, propertiesMap, null, model.getProperties() ) ); - - - for ( MavenProject currentPrj = project; currentPrj != null; currentPrj = includeParent - ? currentPrj.getParent() - : null ) - { - Model model = reactorModels.get( currentPrj ); - - if ( model.getDependencyManagement() != null ) - { - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, - model.getDependencyManagement().getDependencies(), false ); + reactorModels.values().forEach(model -> addProperties(helper, propertiesMap, null, model.getProperties())); + + for (MavenProject currentPrj = project; + currentPrj != null; + currentPrj = includeParent ? currentPrj.getParent() : null) { + Model model = reactorModels.get(currentPrj); + + if (model.getDependencyManagement() != null) { + addDependencyAssocations( + helper, + expressionEvaluator, + propertiesMap, + model.getDependencyManagement().getDependencies(), + false); } - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, model.getDependencies(), false ); - if ( model.getBuild() != null ) - { - if ( model.getBuild().getPluginManagement() != null ) - { - addPluginAssociations( helper, expressionEvaluator, propertiesMap, - model.getBuild().getPluginManagement().getPlugins() ); + addDependencyAssocations(helper, expressionEvaluator, propertiesMap, model.getDependencies(), false); + if (model.getBuild() != null) { + if (model.getBuild().getPluginManagement() != null) { + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + model.getBuild().getPluginManagement().getPlugins()); } - addPluginAssociations( helper, expressionEvaluator, propertiesMap, model.getBuild().getPlugins() ); + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + model.getBuild().getPlugins()); } - if ( model.getReporting() != null ) - { - addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, - model.getReporting().getPlugins() ); + if (model.getReporting() != null) { + addReportPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + model.getReporting().getPlugins()); } // third, we add any associations from the active profiles - for ( Profile profile : model.getProfiles() ) - { - if ( !activeProfiles.contains( profile.getId() ) ) - { + for (Profile profile : model.getProfiles()) { + if (!activeProfiles.contains(profile.getId())) { continue; } - if ( profile.getDependencyManagement() != null ) - { - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, - profile.getDependencyManagement().getDependencies(), false ); + if (profile.getDependencyManagement() != null) { + addDependencyAssocations( + helper, + expressionEvaluator, + propertiesMap, + profile.getDependencyManagement().getDependencies(), + false); } - addDependencyAssocations( helper, expressionEvaluator, propertiesMap, profile.getDependencies(), - false ); - if ( profile.getBuild() != null ) - { - if ( profile.getBuild().getPluginManagement() != null ) - { - addPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getBuild().getPluginManagement().getPlugins() ); + addDependencyAssocations(helper, expressionEvaluator, propertiesMap, profile.getDependencies(), false); + if (profile.getBuild() != null) { + if (profile.getBuild().getPluginManagement() != null) { + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getBuild().getPluginManagement().getPlugins()); } - addPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getBuild().getPlugins() ); + addPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getBuild().getPlugins()); } - if ( profile.getReporting() != null ) - { - addReportPluginAssociations( helper, expressionEvaluator, propertiesMap, - profile.getReporting().getPlugins() ); + if (profile.getReporting() != null) { + addReportPluginAssociations( + helper, + expressionEvaluator, + propertiesMap, + profile.getReporting().getPlugins()); } } } // finally, remove any properties without associations - purgeProperties( propertiesMap ); + purgeProperties(propertiesMap); - return propertiesMap.values().toArray( new PropertyVersionsBuilder[0] ); + return propertiesMap.values().toArray(new PropertyVersionsBuilder[0]); } /** @@ -1102,109 +974,88 @@ public static PropertyVersionsBuilder[] getPropertyVersionsBuilders( VersionsHel * @param plugins The list of {@link org.apache.maven.model.Plugin}. * @throws ExpressionEvaluationException if an expression cannot be evaluated. */ - private static void addPluginAssociations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator, - Map result, List plugins ) - throws ExpressionEvaluationException - { - if ( plugins == null ) - { + private static void addPluginAssociations( + VersionsHelper helper, + ExpressionEvaluator expressionEvaluator, + Map result, + List plugins) + throws ExpressionEvaluationException { + if (plugins == null) { return; } - for ( Plugin plugin : plugins ) - { + for (Plugin plugin : plugins) { String version = plugin.getVersion(); - if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 ) - { - version = StringUtils.deleteWhitespace( version ); - for ( PropertyVersionsBuilder property : result.values() ) - { + if (version != null && version.contains("${") && version.indexOf('}') != -1) { + version = StringUtils.deleteWhitespace(version); + for (PropertyVersionsBuilder property : result.values()) { // any of these could be defined by a property final String propertyRef = "${" + property.getName() + "}"; - if ( version.contains( propertyRef ) ) - { + if (version.contains(propertyRef)) { String groupId = plugin.getGroupId(); - if ( groupId == null || groupId.trim().length() == 0 ) - { + if (groupId == null || groupId.trim().length() == 0) { // group Id has a special default groupId = APACHE_MAVEN_PLUGINS_GROUPID; - } - else - { - groupId = (String) expressionEvaluator.evaluate( groupId ); + } else { + groupId = (String) expressionEvaluator.evaluate(groupId); } String artifactId = plugin.getArtifactId(); - if ( artifactId == null || artifactId.trim().length() == 0 ) - { + if (artifactId == null || artifactId.trim().length() == 0) { // malformed pom continue; - } - else - { - artifactId = (String) expressionEvaluator.evaluate( artifactId ); + } else { + artifactId = (String) expressionEvaluator.evaluate(artifactId); } // might as well capture the current value - String evaluatedVersion = (String) expressionEvaluator.evaluate( plugin.getVersion() ); - property.addAssociation( helper.createPluginArtifact( groupId, artifactId, evaluatedVersion ), - true ); - if ( !propertyRef.equals( version ) ) - { - addBounds( property, version, propertyRef ); + String evaluatedVersion = (String) expressionEvaluator.evaluate(plugin.getVersion()); + property.addAssociation( + helper.createPluginArtifact(groupId, artifactId, evaluatedVersion), true); + if (!propertyRef.equals(version)) { + addBounds(property, version, propertyRef); } } } } - addDependencyAssocations( helper, expressionEvaluator, result, plugin.getDependencies(), true ); + addDependencyAssocations(helper, expressionEvaluator, result, plugin.getDependencies(), true); } } - private static void addReportPluginAssociations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator, - Map result, - List reportPlugins ) - throws ExpressionEvaluationException - { - if ( reportPlugins == null ) - { + private static void addReportPluginAssociations( + VersionsHelper helper, + ExpressionEvaluator expressionEvaluator, + Map result, + List reportPlugins) + throws ExpressionEvaluationException { + if (reportPlugins == null) { return; } - for ( ReportPlugin plugin : reportPlugins ) - { + for (ReportPlugin plugin : reportPlugins) { String version = plugin.getVersion(); - if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 ) - { - version = StringUtils.deleteWhitespace( version ); - for ( PropertyVersionsBuilder property : result.values() ) - { + if (version != null && version.contains("${") && version.indexOf('}') != -1) { + version = StringUtils.deleteWhitespace(version); + for (PropertyVersionsBuilder property : result.values()) { final String propertyRef = "${" + property.getName() + "}"; - if ( version.contains( propertyRef ) ) - { + if (version.contains(propertyRef)) { // any of these could be defined by a property String groupId = plugin.getGroupId(); - if ( groupId == null || groupId.trim().length() == 0 ) - { + if (groupId == null || groupId.trim().length() == 0) { // group Id has a special default groupId = APACHE_MAVEN_PLUGINS_GROUPID; - } - else - { - groupId = (String) expressionEvaluator.evaluate( groupId ); + } else { + groupId = (String) expressionEvaluator.evaluate(groupId); } String artifactId = plugin.getArtifactId(); - if ( artifactId == null || artifactId.trim().length() == 0 ) - { + if (artifactId == null || artifactId.trim().length() == 0) { // malformed pom continue; - } - else - { - artifactId = (String) expressionEvaluator.evaluate( artifactId ); + } else { + artifactId = (String) expressionEvaluator.evaluate(artifactId); } // might as well capture the current value - String versionEvaluated = (String) expressionEvaluator.evaluate( plugin.getVersion() ); - property.addAssociation( helper.createPluginArtifact( groupId, artifactId, versionEvaluated ), - true ); - if ( !propertyRef.equals( version ) ) - { - addBounds( property, version, propertyRef ); + String versionEvaluated = (String) expressionEvaluator.evaluate(plugin.getVersion()); + property.addAssociation( + helper.createPluginArtifact(groupId, artifactId, versionEvaluated), true); + if (!propertyRef.equals(version)) { + addBounds(property, version, propertyRef); } } } @@ -1212,58 +1063,52 @@ private static void addReportPluginAssociations( VersionsHelper helper, Expressi } } - private static void addDependencyAssocations( VersionsHelper helper, ExpressionEvaluator expressionEvaluator, - Map result, - List dependencies, boolean usePluginRepositories ) - throws ExpressionEvaluationException - { - if ( dependencies == null ) - { + private static void addDependencyAssocations( + VersionsHelper helper, + ExpressionEvaluator expressionEvaluator, + Map result, + List dependencies, + boolean usePluginRepositories) + throws ExpressionEvaluationException { + if (dependencies == null) { return; } - for ( Dependency dependency : dependencies ) - { + for (Dependency dependency : dependencies) { String version = dependency.getVersion(); - if ( version != null && version.contains( "${" ) && version.indexOf( '}' ) != -1 ) - { - version = StringUtils.deleteWhitespace( version ); - for ( PropertyVersionsBuilder property : result.values() ) - { + if (version != null && version.contains("${") && version.indexOf('}') != -1) { + version = StringUtils.deleteWhitespace(version); + for (PropertyVersionsBuilder property : result.values()) { final String propertyRef = "${" + property.getName() + "}"; - if ( version.contains( propertyRef ) ) - { + if (version.contains(propertyRef)) { // Any of these could be defined by a property String groupId = dependency.getGroupId(); - if ( groupId == null || groupId.trim().length() == 0 ) - { + if (groupId == null || groupId.trim().length() == 0) { // malformed pom continue; - } - else - { - groupId = (String) expressionEvaluator.evaluate( groupId ); + } else { + groupId = (String) expressionEvaluator.evaluate(groupId); } String artifactId = dependency.getArtifactId(); - if ( artifactId == null || artifactId.trim().length() == 0 ) - { + if (artifactId == null || artifactId.trim().length() == 0) { // malformed pom continue; - } - else - { - artifactId = (String) expressionEvaluator.evaluate( artifactId ); + } else { + artifactId = (String) expressionEvaluator.evaluate(artifactId); } // might as well capture the current value - String versionEvaluated = (String) expressionEvaluator.evaluate( dependency.getVersion() ); - property.addAssociation( helper.createDependencyArtifact( groupId, artifactId, versionEvaluated, - dependency.getType(), - dependency.getClassifier(), - dependency.getScope(), - dependency.isOptional() ), - usePluginRepositories ); - if ( !propertyRef.equals( version ) ) - { - addBounds( property, version, propertyRef ); + String versionEvaluated = (String) expressionEvaluator.evaluate(dependency.getVersion()); + property.addAssociation( + helper.createDependencyArtifact( + groupId, + artifactId, + versionEvaluated, + dependency.getType(), + dependency.getClassifier(), + dependency.getScope(), + dependency.isOptional()), + usePluginRepositories); + if (!propertyRef.equals(version)) { + addBounds(property, version, propertyRef); } } } @@ -1271,51 +1116,44 @@ private static void addDependencyAssocations( VersionsHelper helper, ExpressionE } } - private static void addBounds( PropertyVersionsBuilder builder, String rawVersionRange, String propertyRef ) - { - Pattern lowerBound = Pattern.compile( "([(\\[])([^,]*)," + RegexUtils.quote( propertyRef ) + "([)\\]])" ); - Pattern upperBound = Pattern.compile( "([(\\[])" + RegexUtils.quote( propertyRef ) + ",([^,]*)([)\\]])" ); - Matcher m = lowerBound.matcher( rawVersionRange ); - if ( m.find() ) - { - boolean includeLower = "[".equals( m.group( 1 ) ); - String lowerLimit = m.group( 2 ); - if ( StringUtils.isNotEmpty( lowerLimit ) ) - { - builder.addLowerBound( lowerLimit, includeLower ); + private static void addBounds(PropertyVersionsBuilder builder, String rawVersionRange, String propertyRef) { + Pattern lowerBound = Pattern.compile("([(\\[])([^,]*)," + RegexUtils.quote(propertyRef) + "([)\\]])"); + Pattern upperBound = Pattern.compile("([(\\[])" + RegexUtils.quote(propertyRef) + ",([^,]*)([)\\]])"); + Matcher m = lowerBound.matcher(rawVersionRange); + if (m.find()) { + boolean includeLower = "[".equals(m.group(1)); + String lowerLimit = m.group(2); + if (StringUtils.isNotEmpty(lowerLimit)) { + builder.addLowerBound(lowerLimit, includeLower); } } - m = upperBound.matcher( rawVersionRange ); - if ( m.find() ) - { - boolean includeUpper = "[".equals( m.group( 3 ) ); - String upperLimit = m.group( 2 ); - if ( StringUtils.isNotEmpty( upperLimit ) ) - { - builder.addUpperBound( upperLimit, includeUpper ); + m = upperBound.matcher(rawVersionRange); + if (m.find()) { + boolean includeUpper = "[".equals(m.group(3)); + String upperLimit = m.group(2); + if (StringUtils.isNotEmpty(upperLimit)) { + builder.addUpperBound(upperLimit, includeUpper); } } } - private static void addProperties( VersionsHelper helper, Map result, - String profileId, Properties properties ) - { - if ( properties == null ) - { + private static void addProperties( + VersionsHelper helper, + Map result, + String profileId, + Properties properties) { + if (properties == null) { return; } - for ( String propertyName : properties.stringPropertyNames() ) - { - if ( !result.containsKey( propertyName ) ) - { - result.put( propertyName, new PropertyVersionsBuilder( profileId, propertyName, helper ) ); + for (String propertyName : properties.stringPropertyNames()) { + if (!result.containsKey(propertyName)) { + result.put(propertyName, new PropertyVersionsBuilder(profileId, propertyName, helper)); } } } - private static void purgeProperties( Map result ) - { - result.values().removeIf( versions -> versions.getAssociations().length == 0 ); + private static void purgeProperties(Map result) { + result.values().removeIf(versions -> versions.getAssociations().length == 0); } /** @@ -1326,9 +1164,8 @@ private static void purgeProperties( Map result * @param logger The logger to use. * @return the set of all child modules of the project. */ - public static Set getAllChildModules( MavenProject project, Log logger ) - { - return getAllChildModules( project.getOriginalModel(), logger ); + public static Set getAllChildModules(MavenProject project, Log logger) { + return getAllChildModules(project.getOriginalModel(), logger); } /** @@ -1339,12 +1176,11 @@ public static Set getAllChildModules( MavenProject project, Log logger ) * @param logger The logger to use. * @return the set of all child modules of the project. */ - public static Set getAllChildModules( Model model, Log logger ) - { - logger.debug( "Finding child modules..." ); - Set childModules = new TreeSet<>( model.getModules() ); - model.getProfiles().forEach( profile -> childModules.addAll( profile.getModules() ) ); - debugModules( logger, "Child modules:", childModules ); + public static Set getAllChildModules(Model model, Log logger) { + logger.debug("Finding child modules..."); + Set childModules = new TreeSet<>(model.getModules()); + model.getProfiles().forEach(profile -> childModules.addAll(profile.getModules())); + debugModules(logger, "Child modules:", childModules); return childModules; } @@ -1355,20 +1191,14 @@ public static Set getAllChildModules( Model model, Log logger ) * @param message The message to display. * @param modules The modules to append to the message. */ - public static void debugModules( Log logger, String message, Collection modules ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( message ); - if ( modules.isEmpty() ) - { - logger.debug( "None." ); - } - else - { - modules.forEach( module -> logger.debug( " " + module ) ); + public static void debugModules(Log logger, String message, Collection modules) { + if (logger.isDebugEnabled()) { + logger.debug(message); + if (modules.isEmpty()) { + logger.debug("None."); + } else { + modules.forEach(module -> logger.debug(" " + module)); } - } } @@ -1379,31 +1209,27 @@ public static void debugModules( Log logger, String message, Collection * @param basedir the project basedir. * @param childModules the child modules. */ - public static void removeMissingChildModules( Log logger, File basedir, Collection childModules ) - { - logger.debug( "Removing child modules which are missing..." ); + public static void removeMissingChildModules(Log logger, File basedir, Collection childModules) { + logger.debug("Removing child modules which are missing..."); Iterator i = childModules.iterator(); - while ( i.hasNext() ) - { + while (i.hasNext()) { String modulePath = i.next(); - File moduleFile = new File( basedir, modulePath ); + File moduleFile = new File(basedir, modulePath); - if ( moduleFile.isDirectory() && new File( moduleFile, "pom.xml" ).isFile() ) - { + if (moduleFile.isDirectory() && new File(moduleFile, "pom.xml").isFile()) { // it's a directory that exists continue; } - if ( moduleFile.isFile() ) - { + if (moduleFile.isFile()) { // it's the pom.xml file directly referenced and it exists. continue; } - logger.debug( "Removing missing child module " + modulePath ); + logger.debug("Removing missing child module " + modulePath); i.remove(); } - debugModules( logger, "After removing missing", childModules ); + debugModules(logger, "After removing missing", childModules); } /** @@ -1412,11 +1238,9 @@ public static void removeMissingChildModules( Log logger, File basedir, Collecti * @param model The model. * @return The version. */ - public static String getVersion( Model model ) - { + public static String getVersion(Model model) { String targetVersion = model.getVersion(); - if ( targetVersion == null && model.getParent() != null ) - { + if (targetVersion == null && model.getParent() != null) { targetVersion = model.getParent().getVersion(); } return targetVersion; @@ -1428,8 +1252,7 @@ public static String getVersion( Model model ) * @param model The model. * @return {@code true} if the model explicitly specifies the project version, i.e. /project/version */ - public static boolean isExplicitVersion( Model model ) - { + public static boolean isExplicitVersion(Model model) { return model.getVersion() != null; } @@ -1439,11 +1262,9 @@ public static boolean isExplicitVersion( Model model ) * @param model The model. * @return The artifactId. */ - public static String getArtifactId( Model model ) - { + public static String getArtifactId(Model model) { String sourceArtifactId = model.getArtifactId(); - if ( sourceArtifactId == null && model.getParent() != null ) - { + if (sourceArtifactId == null && model.getParent() != null) { sourceArtifactId = model.getParent().getArtifactId(); } return sourceArtifactId; @@ -1455,11 +1276,9 @@ public static String getArtifactId( Model model ) * @param model The model. * @return The groupId. */ - public static String getGroupId( Model model ) - { + public static String getGroupId(Model model) { String targetGroupId = model.getGroupId(); - if ( targetGroupId == null && model.getParent() != null ) - { + if (targetGroupId == null && model.getParent() != null) { targetGroupId = model.getParent().getGroupId(); } return targetGroupId; @@ -1473,50 +1292,36 @@ public static String getGroupId( Model model ) * @param logger The logger to log tog * @return The local root (note this may be the project passed as an argument). */ - public static MavenProject getLocalRoot( ProjectBuilder projectBuilder, - MavenSession mavenSession, - Log logger ) - { - logger.info( "Searching for local aggregator root..." ); + public static MavenProject getLocalRoot(ProjectBuilder projectBuilder, MavenSession mavenSession, Log logger) { + logger.info("Searching for local aggregator root..."); MavenProject project = mavenSession.getCurrentProject(); - while ( true ) - { + while (true) { final File parentDir = project.getBasedir().getParentFile(); - if ( parentDir != null && parentDir.isDirectory() ) - { - logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" ); - File parentFile = new File( parentDir, "pom.xml" ); - if ( parentFile.isFile() ) - { - try - { - ProjectBuildingResult result = projectBuilder.build( parentFile, - createProjectBuilderRequest( mavenSession ) ); - if ( !result.getProblems().isEmpty() ) - { - logger.warn( "Problems encountered during the computation of the local aggregation root." ); - result.getProblems().forEach( p -> - logger.warn( "\t" + p.getMessage() ) ); + if (parentDir != null && parentDir.isDirectory()) { + logger.debug("Checking to see if " + parentDir + " is an aggregator parent"); + File parentFile = new File(parentDir, "pom.xml"); + if (parentFile.isFile()) { + try { + ProjectBuildingResult result = + projectBuilder.build(parentFile, createProjectBuilderRequest(mavenSession)); + if (!result.getProblems().isEmpty()) { + logger.warn("Problems encountered during the computation of the local aggregation root."); + result.getProblems().forEach(p -> logger.warn("\t" + p.getMessage())); } - if ( getAllChildModules( result.getProject(), logger ) - .contains( project.getBasedir().getName() ) ) - { - logger.debug( parentDir + " is an aggregator parent" ); + if (getAllChildModules(result.getProject(), logger) + .contains(project.getBasedir().getName())) { + logger.debug(parentDir + " is an aggregator parent"); project = result.getProject(); continue; + } else { + logger.debug(parentDir + " is not an aggregator parent"); } - else - { - logger.debug( parentDir + " is not an aggregator parent" ); - } - } - catch ( ProjectBuildingException e ) - { - logger.warn( e ); + } catch (ProjectBuildingException e) { + logger.warn(e); } } } - logger.debug( "Local aggregation root is " + project.getBasedir() ); + logger.debug("Local aggregation root is " + project.getBasedir()); return project; } } @@ -1530,23 +1335,23 @@ public static MavenProject getLocalRoot( ProjectBuilder projectBuilder, * @return constructed builder request */ @SafeVarargs - public static ProjectBuildingRequest createProjectBuilderRequest( MavenSession mavenSession, - Consumer... initializers ) - { - return new DefaultProjectBuildingRequest() - {{ - setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); - setResolveDependencies( false ); - setLocalRepository( mavenSession.getLocalRepository() ); - setRemoteRepositories( mavenSession.getCurrentProject().getRemoteArtifactRepositories() ); - setBuildStartTime( mavenSession.getStartTime() ); - setUserProperties( mavenSession.getUserProperties() ); - setSystemProperties( mavenSession.getSystemProperties() ); - setActiveProfileIds( mavenSession.getRequest().getActiveProfiles() ); - setInactiveProfileIds( mavenSession.getRequest().getInactiveProfiles() ); - setRepositorySession( mavenSession.getRepositorySession() ); - Arrays.stream( initializers ).forEach( i -> i.accept( this ) ); - }}; + public static ProjectBuildingRequest createProjectBuilderRequest( + MavenSession mavenSession, Consumer... initializers) { + return new DefaultProjectBuildingRequest() { + { + setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); + setResolveDependencies(false); + setLocalRepository(mavenSession.getLocalRepository()); + setRemoteRepositories(mavenSession.getCurrentProject().getRemoteArtifactRepositories()); + setBuildStartTime(mavenSession.getStartTime()); + setUserProperties(mavenSession.getUserProperties()); + setSystemProperties(mavenSession.getSystemProperties()); + setActiveProfileIds(mavenSession.getRequest().getActiveProfiles()); + setInactiveProfileIds(mavenSession.getRequest().getInactiveProfiles()); + setRepositorySession(mavenSession.getRepositorySession()); + Arrays.stream(initializers).forEach(i -> i.accept(this)); + } + }; } /** @@ -1557,14 +1362,12 @@ public static ProjectBuildingRequest createProjectBuilderRequest( MavenSession m * @return A map of raw models keyed by path relative to the project's basedir. * @throws IOException if things go wrong. */ - public static Map getReactorModels( MavenProject project, Log logger ) - throws IOException - { + public static Map getReactorModels(MavenProject project, Log logger) throws IOException { Map result = new LinkedHashMap<>(); - final Model model = getRawModel( project ); + final Model model = getRawModel(project); final String path = ""; - result.put( path, model ); - result.putAll( getReactorModels( path, model, project, logger ) ); + result.put(path, model); + result.putAll(getReactorModels(path, model, project, logger)); return result; } @@ -1578,46 +1381,35 @@ public static Map getReactorModels( MavenProject project, Log log * @return A map of raw models keyed by path relative to the project's basedir. * @throws IOException if things go wrong. */ - private static Map getReactorModels( String path, Model model, MavenProject project, Log logger ) - throws IOException - { + private static Map getReactorModels(String path, Model model, MavenProject project, Log logger) + throws IOException { Map result = new LinkedHashMap<>(); Map childResults = new LinkedHashMap<>(); - Set childModules = getAllChildModules( model, logger ); + Set childModules = getAllChildModules(model, logger); - File baseDir = path.length() > 0 - ? new File( project.getBasedir(), path ) - : project.getBasedir(); - removeMissingChildModules( logger, baseDir, childModules ); + File baseDir = path.length() > 0 ? new File(project.getBasedir(), path) : project.getBasedir(); + removeMissingChildModules(logger, baseDir, childModules); childModules.stream() - .map( moduleName -> new File( baseDir, moduleName ) ) - .filter( File::exists ) - .forEach( moduleFile -> - { - File pomFile = moduleFile.isDirectory() - ? new File( moduleFile, "/pom.xml" ) - : moduleFile; - String modulePath = ( !path.isEmpty() && !path.endsWith( "/" ) - ? path + "/" - : path ) + .map(moduleName -> new File(baseDir, moduleName)) + .filter(File::exists) + .forEach(moduleFile -> { + File pomFile = moduleFile.isDirectory() ? new File(moduleFile, "/pom.xml") : moduleFile; + String modulePath = (!path.isEmpty() && !path.endsWith("/") ? path + "/" : path) + pomFile.getParentFile().getName(); - try - { + try { // the aim of this goal is to fix problems when the project cannot be parsed by Maven, // so we have to work with the raw model and not the interpolated parsed model from maven - Model moduleModel = getRawModel( pomFile ); - result.put( modulePath, moduleModel ); - childResults.putAll( getReactorModels( modulePath, moduleModel, project, logger ) ); - } - catch ( IOException e ) - { - logger.debug( "Could not parse " + pomFile.getPath(), e ); + Model moduleModel = getRawModel(pomFile); + result.put(modulePath, moduleModel); + childResults.putAll(getReactorModels(modulePath, moduleModel, project, logger)); + } catch (IOException e) { + logger.debug("Could not parse " + pomFile.getPath(), e); } - } ); + }); - result.putAll( childResults ); // more efficient update order if all children are added after siblings + result.putAll(childResults); // more efficient update order if all children are added after siblings return result; } @@ -1629,18 +1421,14 @@ private static Map getReactorModels( String path, Model model, Ma * @param artifactId The artifactId of the parent. * @return a map of models that have a specified groupId and artifactId as parent keyed by path. */ - public static Map getChildModels( Map reactor, String groupId, String artifactId ) - { + public static Map getChildModels(Map reactor, String groupId, String artifactId) { final Map result = new LinkedHashMap<>(); - for ( Map.Entry entry : reactor.entrySet() ) - { + for (Map.Entry entry : reactor.entrySet()) { final String path = entry.getKey(); final Model model = entry.getValue(); final Parent parent = model.getParent(); - if ( parent != null && groupId.equals( parent.getGroupId() ) - && artifactId.equals( parent.getArtifactId() ) ) - { - result.put( path, model ); + if (parent != null && groupId.equals(parent.getGroupId()) && artifactId.equals(parent.getArtifactId())) { + result.put(path, model); } } return result; @@ -1654,11 +1442,12 @@ public static Map getChildModels( Map reactor, Str * @param artifactId The artifactId to match. * @return The model or null if the model was not in the reactor. */ - public static Model getModel( Map reactor, String groupId, String artifactId ) - { - return reactor.values().stream().filter( - model -> ( groupId == null || groupId.equals( getGroupId( model ) ) ) && artifactId.equals( - getArtifactId( model ) ) ).findAny().orElse( null ); + public static Model getModel(Map reactor, String groupId, String artifactId) { + return reactor.values().stream() + .filter(model -> (groupId == null || groupId.equals(getGroupId(model))) + && artifactId.equals(getArtifactId(model))) + .findAny() + .orElse(null); } /** @@ -1670,12 +1459,13 @@ public static Model getModel( Map reactor, String groupId, String * @param artifactId The artifactId to match. * @return The model entry or null if the model was not in the reactor. */ - public static Map.Entry getModelEntry( Map reactor, String groupId, - String artifactId ) - { - return reactor.entrySet().stream().filter( - e -> ( groupId == null || groupId.equals( PomHelper.getGroupId( e.getValue() ) ) ) && artifactId.equals( - PomHelper.getArtifactId( e.getValue() ) ) ).findAny().orElse( null ); + public static Map.Entry getModelEntry( + Map reactor, String groupId, String artifactId) { + return reactor.entrySet().stream() + .filter(e -> (groupId == null || groupId.equals(PomHelper.getGroupId(e.getValue()))) + && artifactId.equals(PomHelper.getArtifactId(e.getValue()))) + .findAny() + .orElse(null); } /** @@ -1685,18 +1475,16 @@ public static Map.Entry getModelEntry( Map reactor * @param model The model. * @return The number of parents of this model in the reactor. */ - public static int getReactorParentCount( Map reactor, Model model ) - { - if ( model.getParent() == null ) - { + public static int getReactorParentCount(Map reactor, Model model) { + if (model.getParent() == null) { return 0; } - Model parentModel = getModel( reactor, model.getParent().getGroupId(), model.getParent().getArtifactId() ); - if ( parentModel == null ) - { + Model parentModel = getModel( + reactor, model.getParent().getGroupId(), model.getParent().getArtifactId()); + if (parentModel == null) { return 0; } - return getReactorParentCount( reactor, parentModel ) + 1; + return getReactorParentCount(reactor, parentModel) + 1; } /** @@ -1706,12 +1494,9 @@ public static int getReactorParentCount( Map reactor, Model model * @return String The content of the file. * @throws java.io.IOException when things go wrong. */ - public static StringBuilder readXmlFile( File outFile ) - throws IOException - { - try ( Reader reader = ReaderFactory.newXmlReader( outFile ) ) - { - return new StringBuilder( IOUtil.toString( reader ) ); + public static StringBuilder readXmlFile(File outFile) throws IOException { + try (Reader reader = ReaderFactory.newXmlReader(outFile)) { + return new StringBuilder(IOUtil.toString(reader)); } } @@ -1721,8 +1506,7 @@ public static StringBuilder readXmlFile( File outFile ) * @param model the model. * @return the GAV coordinates of a model. */ - public static String getGAV( Model model ) - { - return getGroupId( model ) + ":" + getArtifactId( model ) + ":" + getVersion( model ); + public static String getGAV(Model model) { + return getGroupId(model) + ":" + getArtifactId(model) + ":" + getVersion(model); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java index 395121df9f..e7263939c1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Property.java @@ -27,8 +27,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class Property -{ +public class Property { /** * The property that defines the version of the artifact to use. * @@ -98,13 +97,11 @@ public class Property private static final Dependency[] EMPTY_DEPENDENCY_ARRAY = new Dependency[0]; - public Property() - { + public Property() { this.autoLinkDependencies = true; } - public Property( String name ) - { + public Property(String name) { this.name = name; this.autoLinkDependencies = true; this.dependencies = EMPTY_DEPENDENCY_ARRAY; @@ -115,83 +112,67 @@ public Property( String name ) this.value = null; } - public String getName() - { + public String getName() { return name; } - public void setName( String name ) - { + public void setName(String name) { this.name = name; } - public String getVersion() - { + public String getVersion() { return version; } - public void setVersion( String version ) - { + public void setVersion(String version) { this.version = version; } - public boolean isAutoLinkDependencies() - { + public boolean isAutoLinkDependencies() { return autoLinkDependencies; } - public void setAutoLinkDependencies( boolean autoLinkDependencies ) - { + public void setAutoLinkDependencies(boolean autoLinkDependencies) { this.autoLinkDependencies = autoLinkDependencies; } - public Dependency[] getDependencies() - { + public Dependency[] getDependencies() { return dependencies; } - public void setDependencies( Dependency[] dependencies ) - { + public void setDependencies(Dependency[] dependencies) { this.dependencies = dependencies; } - public boolean isSearchReactor() - { + public boolean isSearchReactor() { return searchReactor; } - public void setSearchReactor( boolean searchReactor ) - { + public void setSearchReactor(boolean searchReactor) { this.searchReactor = searchReactor; } - public boolean isPreferReactor() - { + public boolean isPreferReactor() { return preferReactor; } - public void setPreferReactor( boolean preferReactor ) - { + public void setPreferReactor(boolean preferReactor) { this.preferReactor = preferReactor; } - public boolean isBanSnapshots() - { + public boolean isBanSnapshots() { return banSnapshots; } - public void setBanSnapshots( boolean banSnapshots ) - { + public void setBanSnapshots(boolean banSnapshots) { this.banSnapshots = banSnapshots; } - public String getValue() - { + public String getValue() { return value; } - public void setValue( String value ) - { + public void setValue(String value) { this.value = value; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java index cfef7f9cd4..eecff4b98a 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersions.java @@ -52,9 +52,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class PropertyVersions - extends AbstractVersionDetails -{ +public class PropertyVersions extends AbstractVersionDetails { private final String name; private final String profileId; @@ -72,63 +70,50 @@ public class PropertyVersions private final PropertyVersions.PropertyVersionComparator comparator; - PropertyVersions( String profileId, String name, VersionsHelper helper, Set associations ) - throws VersionRetrievalException - { + PropertyVersions(String profileId, String name, VersionsHelper helper, Set associations) + throws VersionRetrievalException { this.profileId = profileId; this.name = name; this.helper = helper; - this.associations = new TreeSet<>( associations ); + this.associations = new TreeSet<>(associations); this.comparator = new PropertyVersionComparator(); - this.versions = resolveAssociatedVersions( helper, associations, comparator ); - + this.versions = resolveAssociatedVersions(helper, associations, comparator); } - private static SortedSet resolveAssociatedVersions( VersionsHelper helper, - Set associations, - VersionComparator versionComparator ) - throws VersionRetrievalException - { + private static SortedSet resolveAssociatedVersions( + VersionsHelper helper, Set associations, VersionComparator versionComparator) + throws VersionRetrievalException { SortedSet versions = null; - for ( ArtifactAssociation association : associations ) - { + for (ArtifactAssociation association : associations) { final ArtifactVersions associatedVersions = - helper.lookupArtifactVersions( association.getArtifact(), association.isUsePluginRepositories() ); - if ( versions != null ) - { - final ArtifactVersion[] artifactVersions = associatedVersions.getVersions( true ); + helper.lookupArtifactVersions(association.getArtifact(), association.isUsePluginRepositories()); + if (versions != null) { + final ArtifactVersion[] artifactVersions = associatedVersions.getVersions(true); // since ArtifactVersion does not override equals, we have to do this the hard way // result.retainAll( Arrays.asList( artifactVersions ) ); Iterator j = versions.iterator(); - while ( j.hasNext() ) - { + while (j.hasNext()) { boolean contains = false; ArtifactVersion version = j.next(); - for ( ArtifactVersion artifactVersion : artifactVersions ) - { - if ( version.compareTo( artifactVersion ) == 0 ) - { + for (ArtifactVersion artifactVersion : artifactVersions) { + if (version.compareTo(artifactVersion) == 0) { contains = true; break; } } - if ( !contains ) - { + if (!contains) { j.remove(); } } - } - else - { - versions = new TreeSet<>( versionComparator ); - versions.addAll( Arrays.asList( associatedVersions.getVersions( true ) ) ); + } else { + versions = new TreeSet<>(versionComparator); + versions.addAll(Arrays.asList(associatedVersions.getVersions(true))); } } - if ( versions == null ) - { - versions = new TreeSet<>( versionComparator ); + if (versions == null) { + versions = new TreeSet<>(versionComparator); } - return Collections.unmodifiableSortedSet( versions ); + return Collections.unmodifiableSortedSet(versions); } /** @@ -137,20 +122,19 @@ private static SortedSet resolveAssociatedVersions( VersionsHel * @return the rule for version comparison of this artifact. * @since 1.0-beta-1 */ - public VersionComparator getVersionComparator() - { + public VersionComparator getVersionComparator() { return comparator; } - public ArtifactAssociation[] getAssociations() - { - return associations.toArray( new ArtifactAssociation[0] ); + public ArtifactAssociation[] getAssociations() { + return associations.toArray(new ArtifactAssociation[0]); } - private VersionComparator[] lookupComparators() - { - return associations.stream().map( association -> helper.getVersionComparator( association.getArtifact() ) ) - .distinct().toArray( VersionComparator[]::new ); + private VersionComparator[] lookupComparators() { + return associations.stream() + .map(association -> helper.getVersionComparator(association.getArtifact())) + .distinct() + .toArray(VersionComparator[]::new); } /** @@ -162,27 +146,20 @@ private VersionComparator[] lookupComparators() * is also associated to an artifact that has not been provided). * @since 1.0-alpha-3 */ - public ArtifactVersion[] getVersions( Collection artifacts ) - { + public ArtifactVersion[] getVersions(Collection artifacts) { List result = new ArrayList<>(); // go through all the associations // see if they are met from the collection // add the version if they are // go through all the versions // see if the version is available for all associations - for ( ArtifactAssociation association : associations ) - { - for ( Artifact artifact : artifacts ) - { - if ( association.getGroupId().equals( artifact.getGroupId() ) - && association.getArtifactId().equals( artifact.getArtifactId() ) ) - { - try - { - result.add( artifact.getSelectedVersion() ); - } - catch ( OverConstrainedVersionException e ) - { + for (ArtifactAssociation association : associations) { + for (Artifact artifact : artifacts) { + if (association.getGroupId().equals(artifact.getGroupId()) + && association.getArtifactId().equals(artifact.getArtifactId())) { + try { + result.add(artifact.getSelectedVersion()); + } catch (OverConstrainedVersionException e) { // ignore this one as we cannot resolve a valid version } } @@ -191,27 +168,21 @@ public ArtifactVersion[] getVersions( Collection artifacts ) // we now have a list of all the versions that partially satisfy the association requirements Iterator k = result.iterator(); versions: - while ( k.hasNext() ) - { + while (k.hasNext()) { ArtifactVersion candidate = k.next(); associations: - for ( ArtifactAssociation association : associations ) - { - for ( Artifact artifact : artifacts ) - { - if ( association.getGroupId().equals( artifact.getGroupId() ) - && association.getArtifactId().equals( artifact.getArtifactId() ) ) - { - try - { - if ( candidate.toString().equals( artifact.getSelectedVersion().toString() ) ) - { + for (ArtifactAssociation association : associations) { + for (Artifact artifact : artifacts) { + if (association.getGroupId().equals(artifact.getGroupId()) + && association.getArtifactId().equals(artifact.getArtifactId())) { + try { + if (candidate + .toString() + .equals(artifact.getSelectedVersion().toString())) { // this association can be met, try the next continue associations; } - } - catch ( OverConstrainedVersionException e ) - { + } catch (OverConstrainedVersionException e) { // ignore this one again } } @@ -221,7 +192,7 @@ public ArtifactVersion[] getVersions( Collection artifacts ) continue versions; } } - return asArtifactVersionArray( result ); + return asArtifactVersionArray(result); } /** @@ -231,90 +202,74 @@ public ArtifactVersion[] getVersions( Collection artifacts ) * @param includeSnapshots Whether to include snapshot versions in our search. * @return The (possibly empty) array of versions. */ - public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots ) - { + public synchronized ArtifactVersion[] getVersions(boolean includeSnapshots) { Set result; - if ( includeSnapshots ) - { + if (includeSnapshots) { result = versions; - } - else - { - result = new TreeSet<>( getVersionComparator() ); - for ( ArtifactVersion candidate : versions ) - { - if ( ArtifactUtils.isSnapshot( candidate.toString() ) ) - { + } else { + result = new TreeSet<>(getVersionComparator()); + for (ArtifactVersion candidate : versions) { + if (ArtifactUtils.isSnapshot(candidate.toString())) { continue; } - result.add( candidate ); + result.add(candidate); } } - return asArtifactVersionArray( result ); + return asArtifactVersionArray(result); } - private ArtifactVersion[] asArtifactVersionArray( Collection result ) - { - if ( result == null || result.isEmpty() ) - { + private ArtifactVersion[] asArtifactVersionArray(Collection result) { + if (result == null || result.isEmpty()) { return new ArtifactVersion[0]; - } - else - { - final ArtifactVersion[] answer = result.toArray( new ArtifactVersion[0] ); + } else { + final ArtifactVersion[] answer = result.toArray(new ArtifactVersion[0]); VersionComparator[] rules = lookupComparators(); assert rules.length > 0; - Arrays.sort( answer, rules[0] ); - if ( rules.length == 1 || answer.length == 1 ) - { + Arrays.sort(answer, rules[0]); + if (rules.length == 1 || answer.length == 1) { // only one rule... return answer; } ArtifactVersion[] alt = answer.clone(); - for ( int j = 1; j < rules.length; j++ ) - { - Arrays.sort( alt, rules[j] ); - if ( !Arrays.equals( alt, answer ) ) - { - throw new IllegalStateException( - "Property " + name + " is associated with multiple artifacts" + for (int j = 1; j < rules.length; j++) { + Arrays.sort(alt, rules[j]); + if (!Arrays.equals(alt, answer)) { + throw new IllegalStateException("Property " + name + " is associated with multiple artifacts" + " and these artifacts use different version sorting rules and these rules are effectively" + " incompatible for the set of versions available to this property.\nFirst rule says: " - + Arrays.asList( answer ) + "\nSecond rule says: " - + Arrays.asList( alt ) ); + + Arrays.asList(answer) + "\nSecond rule says: " + + Arrays.asList(alt)); } } return answer; } } - public String getName() - { + public String getName() { return name; } - public String getProfileId() - { + public String getProfileId() { return profileId; } - public boolean isAssociated() - { + public boolean isAssociated() { return !associations.isEmpty(); } - public String toString() - { - return "PropertyVersions{" + ( profileId == null ? "" : "profileId='" + profileId + "', " ) + "name='" + name - + '\'' + ", associations=" + associations + '}'; + public String toString() { + return "PropertyVersions{" + (profileId == null ? "" : "profileId='" + profileId + "', ") + "name='" + name + + '\'' + ", associations=" + associations + '}'; } - public ArtifactVersion getNewestVersion( String currentVersion, Property property, boolean allowSnapshots, - List reactorProjects, VersionsHelper helper ) - throws InvalidVersionSpecificationException, InvalidSegmentException - { - return getNewestVersion( currentVersion, property, allowSnapshots, reactorProjects, helper, - false, empty() ); + public ArtifactVersion getNewestVersion( + String currentVersion, + Property property, + boolean allowSnapshots, + List reactorProjects, + VersionsHelper helper) + throws InvalidVersionSpecificationException, InvalidSegmentException { + return getNewestVersion(currentVersion, property, allowSnapshots, reactorProjects, helper, false, empty()); } /** @@ -333,96 +288,84 @@ public ArtifactVersion getNewestVersion( String currentVersion, Property propert * of segments in the version string) * @throws InvalidVersionSpecificationException thrown if the version string in the property is not valid */ - public ArtifactVersion getNewestVersion( String versionString, Property property, boolean allowSnapshots, - Collection reactorProjects, VersionsHelper helper, - boolean allowDowngrade, Optional upperBoundSegment ) - throws InvalidSegmentException, InvalidVersionSpecificationException - { + public ArtifactVersion getNewestVersion( + String versionString, + Property property, + boolean allowSnapshots, + Collection reactorProjects, + VersionsHelper helper, + boolean allowDowngrade, + Optional upperBoundSegment) + throws InvalidSegmentException, InvalidVersionSpecificationException { final boolean includeSnapshots = !property.isBanSnapshots() && allowSnapshots; - helper.getLog().debug( "getNewestVersion(): includeSnapshots='" + includeSnapshots + "'" ); - helper.getLog().debug( "Property ${" + property.getName() + "}: Set of valid available versions is " - + Arrays.asList( getVersions( includeSnapshots ) ) ); - VersionRange range = property.getVersion() != null - ? VersionRange.createFromVersionSpec( property.getVersion() ) : null; - helper.getLog().debug( "Property ${" + property.getName() + "}: Restricting results to " + range ); - - - ArtifactVersion currentVersion = new DefaultArtifactVersion( versionString ); + helper.getLog().debug("getNewestVersion(): includeSnapshots='" + includeSnapshots + "'"); + helper.getLog() + .debug("Property ${" + property.getName() + "}: Set of valid available versions is " + + Arrays.asList(getVersions(includeSnapshots))); + VersionRange range = + property.getVersion() != null ? VersionRange.createFromVersionSpec(property.getVersion()) : null; + helper.getLog().debug("Property ${" + property.getName() + "}: Restricting results to " + range); + + ArtifactVersion currentVersion = new DefaultArtifactVersion(versionString); ArtifactVersion lowerBound = allowDowngrade - ? getLowerBound( currentVersion, upperBoundSegment ) - .map( DefaultArtifactVersion::new ) - .orElse( null ) + ? getLowerBound(currentVersion, upperBoundSegment) + .map(DefaultArtifactVersion::new) + .orElse(null) : currentVersion; - if ( helper.getLog().isDebugEnabled() ) - { - helper.getLog().debug( "lowerBoundArtifactVersion: " + lowerBound ); + if (helper.getLog().isDebugEnabled()) { + helper.getLog().debug("lowerBoundArtifactVersion: " + lowerBound); } - ArtifactVersion upperBound = - !upperBoundSegment.isPresent() - ? null - : upperBoundSegment - .map( s -> (ArtifactVersion) new BoundArtifactVersion( currentVersion, - s.isMajorTo( SUBINCREMENTAL ) - ? Segment.of( s.value() + 1 ) - : s ) ) - .orElse( null ); - if ( helper.getLog().isDebugEnabled() ) - { - helper.getLog().debug( "Property ${" + property.getName() + "}: upperBound is: " + upperBound ); + ArtifactVersion upperBound = !upperBoundSegment.isPresent() + ? null + : upperBoundSegment + .map(s -> (ArtifactVersion) new BoundArtifactVersion( + currentVersion, s.isMajorTo(SUBINCREMENTAL) ? Segment.of(s.value() + 1) : s)) + .orElse(null); + if (helper.getLog().isDebugEnabled()) { + helper.getLog().debug("Property ${" + property.getName() + "}: upperBound is: " + upperBound); } - Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade ); - ArtifactVersion result = getNewestVersion( range, restriction, includeSnapshots ); + Restriction restriction = new Restriction(lowerBound, allowDowngrade, upperBound, allowDowngrade); + ArtifactVersion result = getNewestVersion(range, restriction, includeSnapshots); - helper.getLog().debug( "Property ${" + property.getName() + "}: Current winner is: " + result ); + helper.getLog().debug("Property ${" + property.getName() + "}: Current winner is: " + result); - if ( property.isSearchReactor() ) - { - helper.getLog().debug( "Property ${" + property.getName() + "}: Searching reactor for a valid version..." ); - Set reactorArtifacts = helper.extractArtifacts( reactorProjects ); - ArtifactVersion[] reactorVersions = getVersions( reactorArtifacts ); - helper.getLog().debug( "Property ${" + property.getName() - + "}: Set of valid available versions from the reactor is " + Arrays.asList( - reactorVersions ) ); + if (property.isSearchReactor()) { + helper.getLog().debug("Property ${" + property.getName() + "}: Searching reactor for a valid version..."); + Set reactorArtifacts = helper.extractArtifacts(reactorProjects); + ArtifactVersion[] reactorVersions = getVersions(reactorArtifacts); + helper.getLog() + .debug("Property ${" + property.getName() + + "}: Set of valid available versions from the reactor is " + + Arrays.asList(reactorVersions)); ArtifactVersion fromReactor = null; - if ( reactorVersions.length > 0 ) - { - for ( int j = reactorVersions.length - 1; j >= 0; j-- ) - { - if ( range == null || ArtifactVersions.isVersionInRange( reactorVersions[j], range ) ) - { + if (reactorVersions.length > 0) { + for (int j = reactorVersions.length - 1; j >= 0; j--) { + if (range == null || ArtifactVersions.isVersionInRange(reactorVersions[j], range)) { fromReactor = reactorVersions[j]; - helper.getLog().debug( "Property ${" + property.getName() + "}: Reactor has version " - + fromReactor ); + helper.getLog() + .debug("Property ${" + property.getName() + "}: Reactor has version " + fromReactor); break; } } } - if ( fromReactor != null && ( result != null || !currentVersion.equals( fromReactor.toString() ) ) ) - { - if ( property.isPreferReactor() ) - { - helper.getLog().debug( "Property ${" + property.getName() - + "}: Reactor has a version and we prefer the reactor" ); + if (fromReactor != null && (result != null || !currentVersion.equals(fromReactor.toString()))) { + if (property.isPreferReactor()) { + helper.getLog() + .debug("Property ${" + property.getName() + + "}: Reactor has a version and we prefer the reactor"); result = fromReactor; - } - else - { - if ( result == null ) - { - helper.getLog().debug( "Property ${" + property.getName() + "}: Reactor has the only version" ); + } else { + if (result == null) { + helper.getLog().debug("Property ${" + property.getName() + "}: Reactor has the only version"); result = fromReactor; - } - else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) - { - helper.getLog().debug( "Property ${" + property.getName() + "}: Reactor has a newer version" ); + } else if (getVersionComparator().compare(result, fromReactor) < 0) { + helper.getLog().debug("Property ${" + property.getName() + "}: Reactor has a newer version"); result = fromReactor; - } - else - { - helper.getLog().debug( "Property ${" + property.getName() - + "}: Reactor has the same or older version" ); + } else { + helper.getLog() + .debug("Property ${" + property.getName() + "}: Reactor has the same or older version"); } } } @@ -430,66 +373,53 @@ else if ( getVersionComparator().compare( result, fromReactor ) < 0 ) return result; } - private final class PropertyVersionComparator implements VersionComparator - { - public int compare( ArtifactVersion v1, ArtifactVersion v2 ) - { - return innerCompare( v1, v2 ); + private final class PropertyVersionComparator implements VersionComparator { + public int compare(ArtifactVersion v1, ArtifactVersion v2) { + return innerCompare(v1, v2); } - private int innerCompare( ArtifactVersion v1, ArtifactVersion v2 ) - { - if ( !isAssociated() ) - { - throw new IllegalStateException( "Cannot compare versions for a property with no associations" ); + private int innerCompare(ArtifactVersion v1, ArtifactVersion v2) { + if (!isAssociated()) { + throw new IllegalStateException("Cannot compare versions for a property with no associations"); } VersionComparator[] comparators = lookupComparators(); assert comparators.length >= 1 : "we have at least one association => at least one comparator"; - int result = comparators[0].compare( v1, v2 ); - for ( int i = 1; i < comparators.length; i++ ) - { - int alt = comparators[i].compare( v1, v2 ); - if ( result != alt && ( result >= 0 && alt < 0 ) || ( result <= 0 && alt > 0 ) ) - { - throw new IllegalStateException( - "Property " + name + " is associated with multiple artifacts" + int result = comparators[0].compare(v1, v2); + for (int i = 1; i < comparators.length; i++) { + int alt = comparators[i].compare(v1, v2); + if (result != alt && (result >= 0 && alt < 0) || (result <= 0 && alt > 0)) { + throw new IllegalStateException("Property " + name + " is associated with multiple artifacts" + " and these artifacts use different version sorting rules and these rules are effectively" + " incompatible for the two of versions being compared.\nFirst rule says compare(\"" + v1 + "\", \"" + v2 + "\") = " + result + "\nSecond rule says compare(\"" + v1 + "\", \"" + v2 - + "\") = " + alt ); + + "\") = " + alt); } } return result; } - public int getSegmentCount( ArtifactVersion v ) - { - if ( !isAssociated() ) - { - throw new IllegalStateException( "Cannot compare versions for a property with no associations" ); + public int getSegmentCount(ArtifactVersion v) { + if (!isAssociated()) { + throw new IllegalStateException("Cannot compare versions for a property with no associations"); } VersionComparator[] comparators = lookupComparators(); assert comparators.length >= 1 : "we have at least one association => at least one comparator"; - int result = comparators[0].getSegmentCount( v ); - for ( int i = 1; i < comparators.length; i++ ) - { - int alt = comparators[i].getSegmentCount( v ); - if ( result != alt ) - { - throw new IllegalStateException( - "Property " + name + " is associated with multiple artifacts" + int result = comparators[0].getSegmentCount(v); + for (int i = 1; i < comparators.length; i++) { + int alt = comparators[i].getSegmentCount(v); + if (result != alt) { + throw new IllegalStateException("Property " + name + " is associated with multiple artifacts" + " and these artifacts use different version sorting rules and these rules are effectively" + " incompatible for the two of versions being compared.\n" + "First rule says getSegmentCount(\"" + v + "\") = " + result + "\nSecond rule says getSegmentCount(\"" + v + "\") = " - + alt ); + + alt); } } return result; } } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java index 2fe8963834..3e32efecf2 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/PropertyVersionsBuilder.java @@ -35,8 +35,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -class PropertyVersionsBuilder -{ +class PropertyVersionsBuilder { private final String name; private final String profileId; @@ -56,202 +55,151 @@ class PropertyVersionsBuilder * @param name The property name. * @param helper The {@link org.codehaus.mojo.versions.api.DefaultVersionsHelper}. */ - PropertyVersionsBuilder( String profileId, String name, VersionsHelper helper ) - { + PropertyVersionsBuilder(String profileId, String name, VersionsHelper helper) { this.profileId = profileId; this.name = name; this.associations = new TreeSet<>(); this.helper = helper; } - public void addAssociation( Artifact artifact, boolean usePluginRepositories ) - { - associations.add( new DefaultArtifactAssociation( artifact, usePluginRepositories ) ); + public void addAssociation(Artifact artifact, boolean usePluginRepositories) { + associations.add(new DefaultArtifactAssociation(artifact, usePluginRepositories)); } - public void removeAssociation( Artifact artifact, boolean usePluginRepositories ) - { - associations.remove( new DefaultArtifactAssociation( artifact, usePluginRepositories ) ); + public void removeAssociation(Artifact artifact, boolean usePluginRepositories) { + associations.remove(new DefaultArtifactAssociation(artifact, usePluginRepositories)); } - public void clearAssociations() - { + public void clearAssociations() { associations.clear(); } - public boolean isAssociated() - { + public boolean isAssociated() { return !associations.isEmpty(); } - public ArtifactAssociation[] getAssociations() - { - return associations.toArray( new ArtifactAssociation[0] ); + public ArtifactAssociation[] getAssociations() { + return associations.toArray(new ArtifactAssociation[0]); } - public PropertyVersions newPropertyVersions() - throws VersionRetrievalException - { - return new PropertyVersions( profileId, name, helper, associations ); + public PropertyVersions newPropertyVersions() throws VersionRetrievalException { + return new PropertyVersions(profileId, name, helper, associations); } - public String getName() - { + public String getName() { return name; } - public String getVersionRange() - { + public String getVersionRange() { Comparator comparator = new PropertyVersionComparator(); - if ( lowerBounds.isEmpty() && upperBounds.isEmpty() ) - { + if (lowerBounds.isEmpty() && upperBounds.isEmpty()) { return null; } ArtifactVersion lowerBound = null; boolean includeLower = true; - for ( Map.Entry entry : lowerBounds.entrySet() ) - { - ArtifactVersion candidate = helper.createArtifactVersion( entry.getKey() ); - if ( lowerBound == null ) - { + for (Map.Entry entry : lowerBounds.entrySet()) { + ArtifactVersion candidate = helper.createArtifactVersion(entry.getKey()); + if (lowerBound == null) { lowerBound = candidate; includeLower = entry.getValue(); - } - else - { - final int result = comparator.compare( lowerBound, candidate ); - if ( result > 0 ) - { + } else { + final int result = comparator.compare(lowerBound, candidate); + if (result > 0) { lowerBound = candidate; includeLower = entry.getValue(); - } - else if ( result == 0 ) - { + } else if (result == 0) { includeLower = includeLower && entry.getValue(); } } } ArtifactVersion upperBound = null; boolean includeUpper = true; - for ( Map.Entry entry : upperBounds.entrySet() ) - { - ArtifactVersion candidate = helper.createArtifactVersion( entry.getKey() ); - if ( upperBound == null ) - { + for (Map.Entry entry : upperBounds.entrySet()) { + ArtifactVersion candidate = helper.createArtifactVersion(entry.getKey()); + if (upperBound == null) { upperBound = candidate; includeUpper = entry.getValue(); - } - else - { - final int result = comparator.compare( upperBound, candidate ); - if ( result < 0 ) - { + } else { + final int result = comparator.compare(upperBound, candidate); + if (result < 0) { upperBound = candidate; includeUpper = entry.getValue(); - } - else if ( result == 0 ) - { + } else if (result == 0) { includeUpper = includeUpper && entry.getValue(); } } } StringBuilder buf = new StringBuilder(); - if ( includeLower ) - { - buf.append( '[' ); - } - else - { - buf.append( '(' ); + if (includeLower) { + buf.append('['); + } else { + buf.append('('); } - if ( lowerBound != null ) - { - buf.append( lowerBound ); + if (lowerBound != null) { + buf.append(lowerBound); } - buf.append( ',' ); - if ( upperBound != null ) - { - buf.append( upperBound ); + buf.append(','); + if (upperBound != null) { + buf.append(upperBound); } - if ( includeUpper ) - { - buf.append( ']' ); - } - else - { - buf.append( ')' ); + if (includeUpper) { + buf.append(']'); + } else { + buf.append(')'); } return buf.toString(); } - public void addLowerBound( String lowerBound, boolean includeLower ) - { - Boolean value = lowerBounds.get( lowerBound ); - if ( value == null ) - { + public void addLowerBound(String lowerBound, boolean includeLower) { + Boolean value = lowerBounds.get(lowerBound); + if (value == null) { value = includeLower; - } - else - { + } else { value = includeLower && value; } - lowerBounds.put( lowerBound, value ); + lowerBounds.put(lowerBound, value); } - public void addUpperBound( String upperBound, boolean includeUpper ) - { - Boolean value = upperBounds.get( upperBound ); - if ( value == null ) - { + public void addUpperBound(String upperBound, boolean includeUpper) { + Boolean value = upperBounds.get(upperBound); + if (value == null) { value = includeUpper; - } - else - { + } else { value = includeUpper && value; } - upperBounds.put( upperBound, value ); + upperBounds.put(upperBound, value); } - private VersionComparator[] lookupComparators() - { - return associations.stream().map( - association -> helper.getVersionComparator( association.getArtifact() ) ) - .distinct() - .toArray( VersionComparator[]::new ); + private VersionComparator[] lookupComparators() { + return associations.stream() + .map(association -> helper.getVersionComparator(association.getArtifact())) + .distinct() + .toArray(VersionComparator[]::new); } - private final class PropertyVersionComparator - implements Comparator - { - public int compare( ArtifactVersion v1, ArtifactVersion v2 ) - { - return innerCompare( v1, v2 ); + private final class PropertyVersionComparator implements Comparator { + public int compare(ArtifactVersion v1, ArtifactVersion v2) { + return innerCompare(v1, v2); } - private int innerCompare( ArtifactVersion v1, ArtifactVersion v2 ) - { - if ( !isAssociated() ) - { - throw new IllegalStateException( "Cannot compare versions for a property with no associations" ); + private int innerCompare(ArtifactVersion v1, ArtifactVersion v2) { + if (!isAssociated()) { + throw new IllegalStateException("Cannot compare versions for a property with no associations"); } VersionComparator[] comparators = lookupComparators(); assert comparators.length >= 1 : "we have at least one association => at least one comparator"; - int result = comparators[0].compare( v1, v2 ); - for ( int i = 1; i < comparators.length; i++ ) - { - int alt = comparators[i].compare( v1, v2 ); - if ( result != alt && ( result >= 0 && alt < 0 ) || ( result <= 0 && alt > 0 ) ) - { - throw new IllegalStateException( "Property " + name + " is associated with multiple artifacts" - + " and these artifacts use different version sorting rules and these rules are effectively" - + " incompatible for the two of versions being compared.\nFirst rule says compare(\"" + v1 - + "\", \"" + v2 + "\") = " + result + "\nSecond rule says compare(\"" + v1 + "\", \"" + v2 - + "\") = " + alt ); + int result = comparators[0].compare(v1, v2); + for (int i = 1; i < comparators.length; i++) { + int alt = comparators[i].compare(v1, v2); + if (result != alt && (result >= 0 && alt < 0) || (result <= 0 && alt > 0)) { + throw new IllegalStateException("Property " + name + " is associated with multiple artifacts" + + " and these artifacts use different version sorting rules and these rules are effectively" + + " incompatible for the two of versions being compared.\nFirst rule says compare(\"" + v1 + + "\", \"" + v2 + "\") = " + result + "\nSecond rule says compare(\"" + v1 + "\", \"" + v2 + + "\") = " + alt); } } return result; } - } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java index 376985ef93..37d8639af6 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/ReportRenderer.java @@ -22,8 +22,7 @@ /** * Common interface for reporting components */ -public interface ReportRenderer -{ +public interface ReportRenderer { /** * Renders the report */ diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java index f72acdf223..9aa90ca057 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/Segment.java @@ -24,25 +24,24 @@ * * @author Andrzej Jarmoniuk */ -public enum Segment implements Comparable -{ - MAJOR, MINOR, INCREMENTAL, SUBINCREMENTAL; +public enum Segment implements Comparable { + MAJOR, + MINOR, + INCREMENTAL, + SUBINCREMENTAL; /** * Returns the 0-based sendex index * * @return 0-based sendex index */ - public int value() - { + public int value() { return ordinal(); } - public static Segment of( int index ) - { - if ( index < 0 || index > 3 ) - { - throw new IllegalArgumentException( "Wrong segment index: " + index ); + public static Segment of(int index) { + if (index < 0 || index > 3) { + throw new IllegalArgumentException("Wrong segment index: " + index); } return values()[index]; } @@ -52,14 +51,12 @@ public static Segment of( int index ) * @param other other segment to compare * @return true if the given segment is more major */ - public boolean isMajorTo( Segment other ) - { + public boolean isMajorTo(Segment other) { return value() < other.value(); } @Override - public String toString() - { + public String toString() { return name(); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java index 6acedce8df..d0365bfd80 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java @@ -33,8 +33,7 @@ * @author connollys * @since 1.0-beta-1 */ -public interface VersionDetails -{ +public interface VersionDetails { /** * Returns true if the specific version is in the list of versions. * @@ -42,7 +41,7 @@ public interface VersionDetails * @return true if the specific version is in the list of versions. * @since 1.0-beta-1 */ - boolean containsVersion( String version ); + boolean containsVersion(String version); /** * Returns true if and only if getCurrentVersion() != null. @@ -58,7 +57,7 @@ public interface VersionDetails * @param currentVersion The new current version. * @since 1.0-beta-1 */ - void setCurrentVersion( ArtifactVersion currentVersion ); + void setCurrentVersion(ArtifactVersion currentVersion); /** * Sets the current version. @@ -66,11 +65,11 @@ public interface VersionDetails * @param currentVersion The new current version. * @since 1.0-beta-1 */ - void setCurrentVersion( String currentVersion ); + void setCurrentVersion(String currentVersion); boolean isIncludeSnapshots(); - void setIncludeSnapshots( boolean includeSnapshots ); + void setIncludeSnapshots(boolean includeSnapshots); /** * Retrieves the current version. @@ -103,7 +102,7 @@ public interface VersionDetails * @return all available versions in increasing order. * @since 1.0-alpha-3 */ - ArtifactVersion[] getVersions( boolean includeSnapshots ); + ArtifactVersion[] getVersions(boolean includeSnapshots); /** * Returns all available versions within the specified version range. @@ -113,7 +112,7 @@ public interface VersionDetails * @return all available versions within the specified version range. * @since 1.0-alpha-3 */ - ArtifactVersion[] getVersions( VersionRange versionRange, boolean includeSnapshots ); + ArtifactVersion[] getVersions(VersionRange versionRange, boolean includeSnapshots); /** * Returns all available versions within the specified bounds. @@ -123,7 +122,7 @@ public interface VersionDetails * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound ); + ArtifactVersion[] getVersions(ArtifactVersion lowerBound, ArtifactVersion upperBound); /** * Returns all available versions within the specified bounds. @@ -134,7 +133,7 @@ public interface VersionDetails * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots ); + ArtifactVersion[] getVersions(ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots); /** * Returns all available versions within the specified bounds. @@ -144,7 +143,7 @@ public interface VersionDetails * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots ); + ArtifactVersion[] getVersions(Restriction restriction, boolean includeSnapshots); /** * Returns all available versions within the specified bounds. @@ -156,7 +155,7 @@ public interface VersionDetails * @return all available versions within the specified version range. * @since 1.0-beta-1 */ - ArtifactVersion[] getVersions( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); + ArtifactVersion[] getVersions(VersionRange versionRange, Restriction restriction, boolean includeSnapshots); /** * Returns the latest version given the version range, restricition, whether to include snapshots and/or @@ -168,8 +167,8 @@ public interface VersionDetails * @param allowDowngrade whether downgrades are allowed * @return the latest version satisfying the conditions or null if no version is available. */ - ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, - boolean includeSnapshots, boolean allowDowngrade ); + ArtifactVersion getNewestVersion( + VersionRange versionRange, Restriction restriction, boolean includeSnapshots, boolean allowDowngrade); /** * Returns the latest version newer than the specified lowerBound, but less than the specified upper bound or @@ -180,7 +179,7 @@ ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restric * @return the latest version between lowerBound and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound ); + ArtifactVersion getNewestVersion(ArtifactVersion lowerBound, ArtifactVersion upperBound); /** * Returns the latest version newer than the specified lowerBound, but less than the specified upper bound or @@ -192,8 +191,7 @@ ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restric * @return the latest version between currentVersion and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion upperBound, - boolean includeSnapshots ); + ArtifactVersion getNewestVersion(ArtifactVersion lowerBound, ArtifactVersion upperBound, boolean includeSnapshots); /** * Returns the latest version newer than the specified current version, but less than the specified upper bound or @@ -204,7 +202,7 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * @return the latest version between lowerBound and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( Restriction restriction, boolean includeSnapshots ); + ArtifactVersion getNewestVersion(Restriction restriction, boolean includeSnapshots); /** * Returns the latest version newer than the specified current version, but less than the specified upper bound or @@ -217,7 +215,7 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * @return the latest version between lowerBound and upperBound or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots ); + ArtifactVersion getNewestVersion(VersionRange versionRange, Restriction restriction, boolean includeSnapshots); /** * Returns the latest version within the specified version range or null if no such version exists. @@ -227,7 +225,7 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * @return the latest version within the version range or null if no version is available. * @since 1.0-alpha-3 */ - ArtifactVersion getNewestVersion( VersionRange versionRange, boolean includeSnapshots ); + ArtifactVersion getNewestVersion(VersionRange versionRange, boolean includeSnapshots); /** * Returns the latest version, newer than the given version, given the upper bound segment and whether snapshots @@ -242,8 +240,8 @@ ArtifactVersion getNewestVersion( ArtifactVersion lowerBound, ArtifactVersion up * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than * the segment count) */ - Optional getNewestVersion( String versionString, Optional upperBoundSegment, - boolean includeSnapshots, boolean allowDowngrade ) + Optional getNewestVersion( + String versionString, Optional upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade) throws InvalidSegmentException; /** @@ -258,8 +256,9 @@ Optional getNewestVersion( String versionString, Optional updateScope, - boolean includeSnapshots ) throws InvalidSegmentException; + ArtifactVersion getNewestUpdate( + ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots) + throws InvalidSegmentException; /** * Returns an array of newer versions than the given version, given whether snapshots @@ -269,7 +268,7 @@ ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional upperBoundSegment, - boolean includeSnapshots ) throws InvalidSegmentException; + ArtifactVersion[] getNewerVersions(String version, Optional upperBoundSegment, boolean includeSnapshots) + throws InvalidSegmentException; /** * Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots @@ -300,8 +299,8 @@ ArtifactVersion[] getNewerVersions( String version, Optional upperBound * @throws InvalidSegmentException if the requested segment is outside the bounds (less than 1 or greater than * the segment count) */ - ArtifactVersion[] getNewerVersions( String versionString, Optional upperBoundSegment, - boolean includeSnapshots, boolean allowDowngrade ) + ArtifactVersion[] getNewerVersions( + String versionString, Optional upperBoundSegment, boolean includeSnapshots, boolean allowDowngrade) throws InvalidSegmentException; /** @@ -314,8 +313,9 @@ ArtifactVersion[] getNewerVersions( String versionString, Optional uppe * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, - boolean includeSnapshots ) throws InvalidSegmentException; + ArtifactVersion[] getAllUpdates( + ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots) + throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the specified update scope or @@ -327,7 +327,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; + ArtifactVersion getNewestUpdate(Optional updateScope) throws InvalidSegmentException; /** * Returns the all versions newer than the specified current version, but within the specified update scope. @@ -337,7 +337,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope ) throws InvalidSegmentException; + ArtifactVersion[] getAllUpdates(Optional updateScope) throws InvalidSegmentException; /** * Returns the newest version newer than the specified current version, but within the specified update scope or @@ -350,7 +350,7 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional updateScope, boolean includeSnapshots ) + ArtifactVersion getNewestUpdate(Optional updateScope, boolean includeSnapshots) throws InvalidSegmentException; /** @@ -362,7 +362,7 @@ ArtifactVersion getNewestUpdate( Optional updateScope, boolean includeS * @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeSnapshots ) + ArtifactVersion[] getAllUpdates(Optional updateScope, boolean includeSnapshots) throws InvalidSegmentException; /** @@ -380,7 +380,7 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( VersionRange versionRange ); + ArtifactVersion[] getAllUpdates(VersionRange versionRange); /** * Returns the all versions newer than the specified current version, but within the specified update scope. @@ -390,7 +390,7 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS * @return the all versions after currentVersion within the specified update scope. * @since 1.0-beta-1 */ - ArtifactVersion[] getAllUpdates( VersionRange versionRange, boolean includeSnapshots ); + ArtifactVersion[] getAllUpdates(VersionRange versionRange, boolean includeSnapshots); /** *

    Returns a {@linkplain Restriction} object for computing version upgrades @@ -406,8 +406,7 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS * @param scope most major segment where updates are allowed Optional.empty() for no restriction * @return {@linkplain Restriction} object based on the arguments */ - Restriction restrictionFor( Optional scope ) throws InvalidSegmentException; - + Restriction restrictionFor(Optional scope) throws InvalidSegmentException; /** * Returns the {@link Restriction} objects for a segemnt scope which is to be ignored. @@ -415,5 +414,5 @@ ArtifactVersion[] getAllUpdates( Optional updateScope, boolean includeS * @param ignored most major segment where updates are to be ignored; Optional.empty() for no ignored segments * @return {@linkplain Restriction} object based on the arguments */ - Restriction restrictionForIgnoreScope( Optional ignored ); + Restriction restrictionForIgnoreScope(Optional ignored); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java index c1f1a4138e..483e57f82b 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionRetrievalException.java @@ -22,15 +22,13 @@ /** * Exception thrown if version information cannot be retrieved */ -public class VersionRetrievalException extends Exception -{ +public class VersionRetrievalException extends Exception { /** * Constructs a new exception with {@code null} as its detail message. * The cause is not initialized, and may subsequently be initialized by a * call to {@link #initCause}. */ - public VersionRetrievalException() - { + public VersionRetrievalException() { super(); } @@ -42,9 +40,8 @@ public VersionRetrievalException() * @param message the detail message. The detail message is saved for * later retrieval by the {@link #getMessage()} method. */ - public VersionRetrievalException( String message ) - { - super( message ); + public VersionRetrievalException(String message) { + super(message); } /** @@ -60,9 +57,8 @@ public VersionRetrievalException( String message ) * permitted, and indicates that the cause is nonexistent or * unknown.) */ - public VersionRetrievalException( Throwable cause ) - { - super( cause ); + public VersionRetrievalException(Throwable cause) { + super(cause); } /** @@ -78,8 +74,7 @@ public VersionRetrievalException( Throwable cause ) * permitted, and indicates that the cause is nonexistent or * unknown.) */ - public VersionRetrievalException( String message, Throwable cause ) - { - super( message, cause ); + public VersionRetrievalException(String message, Throwable cause) { + super(message, cause); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java index 8e66f93223..1004e11bee 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/api/VersionsHelper.java @@ -42,8 +42,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public interface VersionsHelper -{ +public interface VersionsHelper { /** * Gets the logger used by this helper. * @@ -58,7 +57,7 @@ public interface VersionsHelper * @return the version comparator to use. * @since 1.0-alpha-3 */ - VersionComparator getVersionComparator( Artifact artifact ); + VersionComparator getVersionComparator(Artifact artifact); /** * Returns the version comparator to use for the specified groupId and artifactId. @@ -68,7 +67,7 @@ public interface VersionsHelper * @return the version comparator to use. * @since 1.0-alpha-3 */ - VersionComparator getVersionComparator( String groupId, String artifactId ); + VersionComparator getVersionComparator(String groupId, String artifactId); /** * Shorthand method for repositorySystem.createPluginArtifact(...). @@ -79,7 +78,7 @@ public interface VersionsHelper * @return the corresponding plugin artifact. * @since 1.0-alpha-3 */ - Artifact createPluginArtifact( String groupId, String artifactId, String version ); + Artifact createPluginArtifact(String groupId, String artifactId, String version); /** * Shorthand method for repositorySystem.createDependencyArtifact(...). @@ -94,8 +93,14 @@ public interface VersionsHelper * @return The corresponding dependency artifact. * @since 1.0-alpha-3 */ - Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, - String classifier, String scope, boolean optional ); + Artifact createDependencyArtifact( + String groupId, + String artifactId, + String version, + String type, + String classifier, + String scope, + boolean optional); /** * Shorthand method for getArtifactFactory().createDependencyArtifact(...). @@ -109,8 +114,8 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @return The corresponding dependency artifact. * @since 1.0-beta-1 */ - Artifact createDependencyArtifact( String groupId, String artifactId, String version, String type, - String classifier, String scope ); + Artifact createDependencyArtifact( + String groupId, String artifactId, String version, String type, String classifier, String scope); /** * Shorthand method for repositorySystem.createDependencyArtifact(...) which extracts the @@ -120,7 +125,7 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @return The corresponding dependency artifact. * @since 1.0-alpha-3 */ - Artifact createDependencyArtifact( Dependency dependency ); + Artifact createDependencyArtifact(Dependency dependency); /** * Takes a {@link List} of {@link org.apache.maven.project.MavenProject} instances and converts it into a @@ -130,7 +135,7 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @return a {@link Set} of {@link Artifact} instances. * @since 1.0-alpha-3 */ - Set extractArtifacts( Collection mavenProjects ); + Set extractArtifacts(Collection mavenProjects); /** * Creates an {@link ArtifactVersion} instance from a string. @@ -139,7 +144,7 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @return The artifact version. * @since 1.0-beta-1 */ - ArtifactVersion createArtifactVersion( String version ); + ArtifactVersion createArtifactVersion(String version); /** * Looks up the versions of the specified artifact that are available in either the local repository, or the @@ -152,7 +157,7 @@ Artifact createDependencyArtifact( String groupId, String artifactId, String ver * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-alpha-3 */ - ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRepositories ) + ArtifactVersions lookupArtifactVersions(Artifact artifact, boolean usePluginRepositories) throws VersionRetrievalException; /** @@ -167,8 +172,7 @@ ArtifactVersions lookupArtifactVersions( Artifact artifact, boolean usePluginRep * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-alpha-3 */ - ArtifactVersions lookupArtifactVersions( Artifact artifact, VersionRange versionRange, - boolean usePluginRepositories ) + ArtifactVersions lookupArtifactVersions(Artifact artifact, VersionRange versionRange, boolean usePluginRepositories) throws VersionRetrievalException; /** @@ -180,9 +184,8 @@ ArtifactVersions lookupArtifactVersions( Artifact artifact, VersionRange version * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ - Map lookupDependenciesUpdates( Set dependencies, - boolean usePluginRepositories ) - throws VersionRetrievalException; + Map lookupDependenciesUpdates( + Set dependencies, boolean usePluginRepositories) throws VersionRetrievalException; /** * Creates an {@link org.codehaus.mojo.versions.api.ArtifactVersions} instance from a dependency. @@ -193,7 +196,7 @@ Map lookupDependenciesUpdates( Set dep * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ - ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePluginRepositories ) + ArtifactVersions lookupDependencyUpdates(Dependency dependency, boolean usePluginRepositories) throws VersionRetrievalException; /** @@ -205,7 +208,7 @@ ArtifactVersions lookupDependencyUpdates( Dependency dependency, boolean usePlug * @throws VersionRetrievalException thrown if version resolution fails * @since 1.0-beta-1 */ - Map lookupPluginsUpdates( Set plugins, boolean allowSnapshots ) + Map lookupPluginsUpdates(Set plugins, boolean allowSnapshots) throws VersionRetrievalException; /** @@ -216,7 +219,7 @@ Map lookupPluginsUpdates( Set plugins, boo * @return The plugin update details. * @since 1.0-beta-1 */ - PluginUpdatesDetails lookupPluginUpdates( Plugin plugin, boolean allowSnapshots ) throws VersionRetrievalException; + PluginUpdatesDetails lookupPluginUpdates(Plugin plugin, boolean allowSnapshots) throws VersionRetrievalException; /** * Returns an {@link ExpressionEvaluator} for the specified project. @@ -225,7 +228,7 @@ Map lookupPluginsUpdates( Set plugins, boo * @return an {@link ExpressionEvaluator} for the specified project. * @since 1.0-beta-1 */ - ExpressionEvaluator getExpressionEvaluator( MavenProject project ); + ExpressionEvaluator getExpressionEvaluator(MavenProject project); /** * Returns a map of {@link org.codehaus.mojo.versions.api.PropertyVersions} values keyed by @@ -237,15 +240,14 @@ Map lookupPluginsUpdates( Set plugins, boo * {@link Property} instances. * @throws MojoExecutionException if something goes wrong. */ - Map getVersionPropertiesMap( VersionPropertiesMapRequest request ) - throws MojoExecutionException; + Map getVersionPropertiesMap(VersionPropertiesMapRequest request) + throws MojoExecutionException; /** * Argument builder class for * {@link VersionsHelper#getVersionPropertiesMap(VersionPropertiesMapRequest)}. */ - class VersionPropertiesMapRequest - { + class VersionPropertiesMapRequest { private MavenProject mavenProject; private Property[] propertyDefinitions; private String includeProperties; @@ -257,8 +259,7 @@ class VersionPropertiesMapRequest * Returns the {@link MavenProject} object * @return {@link MavenProject} object */ - protected MavenProject getMavenProject() - { + protected MavenProject getMavenProject() { return mavenProject; } @@ -266,8 +267,7 @@ protected MavenProject getMavenProject() * Returns the {@link Property} array * @return {@link Property} array */ - protected Property[] getPropertyDefinitions() - { + protected Property[] getPropertyDefinitions() { return propertyDefinitions; } @@ -275,8 +275,7 @@ protected Property[] getPropertyDefinitions() * Returns the value of {@link #includeProperties} * @return value of {@link #includeProperties} */ - protected String getIncludeProperties() - { + protected String getIncludeProperties() { return includeProperties; } @@ -284,8 +283,7 @@ protected String getIncludeProperties() * Returns the value of {@link #excludeProperties} * @return value of {@link #excludeProperties} */ - protected String getExcludeProperties() - { + protected String getExcludeProperties() { return excludeProperties; } @@ -295,8 +293,7 @@ protected String getExcludeProperties() * * @return value of {@link #includeParent} */ - protected boolean isIncludeParent() - { + protected boolean isIncludeParent() { return includeParent; } @@ -305,8 +302,7 @@ protected boolean isIncludeParent() * If not set, it is assumed to be {@code true} * @return value of {@link #autoLinkItems} */ - protected boolean isAutoLinkItems() - { + protected boolean isAutoLinkItems() { return autoLinkItems; } @@ -314,16 +310,14 @@ protected boolean isAutoLinkItems() * Returns a new {@link Builder} instance * @return new {@link Builder} instance */ - public static Builder builder() - { + public static Builder builder() { return new Builder(); } /** * Builder class for {@link VersionPropertiesMapRequest} */ - public static class Builder - { + public static class Builder { private MavenProject mavenProject; private Property[] propertyDefinitions; private String includeProperties; @@ -331,17 +325,14 @@ public static class Builder private Boolean includeParent; private Boolean autoLinkItems; - private Builder() - { - } + private Builder() {} /** * Supplies the {@link MavenProject} instance * @param mavenProject {@link MavenProject} instance * @return {@link Builder} instance */ - public Builder withMavenProject( MavenProject mavenProject ) - { + public Builder withMavenProject(MavenProject mavenProject) { this.mavenProject = mavenProject; return this; } @@ -351,8 +342,7 @@ public Builder withMavenProject( MavenProject mavenProject ) * @param propertyDefinitions array of property definitions * @return {@link Builder} instance */ - public Builder withPropertyDefinitions( Property[] propertyDefinitions ) - { + public Builder withPropertyDefinitions(Property[] propertyDefinitions) { this.propertyDefinitions = propertyDefinitions; return this; } @@ -362,8 +352,7 @@ public Builder withPropertyDefinitions( Property[] propertyDefinitions ) * @param includeProperties comma-delimited properties to include * @return {@link Builder} instance */ - public Builder withIncludeProperties( String includeProperties ) - { + public Builder withIncludeProperties(String includeProperties) { this.includeProperties = includeProperties; return this; } @@ -373,8 +362,7 @@ public Builder withIncludeProperties( String includeProperties ) * @param excludeProperties comma-delimited properties to exclude * @return {@link Builder} instance */ - public Builder withExcludeProperties( String excludeProperties ) - { + public Builder withExcludeProperties(String excludeProperties) { this.excludeProperties = excludeProperties; return this; } @@ -384,8 +372,7 @@ public Builder withExcludeProperties( String excludeProperties ) * @param includeParent whether parent POMs should be included * @return {@link Builder} instance */ - public Builder withIncludeParent( boolean includeParent ) - { + public Builder withIncludeParent(boolean includeParent) { this.includeParent = includeParent; return this; } @@ -395,8 +382,7 @@ public Builder withIncludeParent( boolean includeParent ) * @param autoLinkItems whether to automatically infer associations * @return {@link Builder} instance */ - public Builder withAutoLinkItems( boolean autoLinkItems ) - { + public Builder withAutoLinkItems(boolean autoLinkItems) { this.autoLinkItems = autoLinkItems; return this; } @@ -405,8 +391,7 @@ public Builder withAutoLinkItems( boolean autoLinkItems ) * Returns the {@link VersionPropertiesMapRequest} instance * @return {@link VersionPropertiesMapRequest} instance */ - public VersionPropertiesMapRequest build() - { + public VersionPropertiesMapRequest build() { VersionPropertiesMapRequest instance = new VersionPropertiesMapRequest(); instance.mavenProject = this.mavenProject; instance.propertyDefinitions = propertyDefinitions; @@ -427,6 +412,5 @@ public VersionPropertiesMapRequest build() * @throws ArtifactResolutionException if resolution is unsuccessful * @since 1.3 */ - void resolveArtifact( Artifact artifact, boolean usePluginRepositories ) - throws ArtifactResolutionException; + void resolveArtifact(Artifact artifact, boolean usePluginRepositories) throws ArtifactResolutionException; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java index 3dbcc8862c..c1a46f1694 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/AbstractVersionChanger.java @@ -29,34 +29,28 @@ * @author Stephen Connolly * @since 15-Sep-2010 15:59:46 */ -public abstract class AbstractVersionChanger - implements VersionChanger -{ +public abstract class AbstractVersionChanger implements VersionChanger { private final Model model; private final ModifiedPomXMLEventReader pom; private final Log log; - public AbstractVersionChanger( Model model, ModifiedPomXMLEventReader pom, Log log ) - { + public AbstractVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log log) { this.model = model; this.pom = pom; this.log = log; } - public Model getModel() - { + public Model getModel() { return model; } - public ModifiedPomXMLEventReader getPom() - { + public ModifiedPomXMLEventReader getPom() { return pom; } - public void info( CharSequence charSequence ) - { - log.info( charSequence ); + public void info(CharSequence charSequence) { + log.info(charSequence); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java index b0bb3b9421..a3ad9c0b8a 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/CompositeVersionChanger.java @@ -33,27 +33,20 @@ * @author Stephen Connolly * @since 15-Sep-2010 16:01:35 */ -public class CompositeVersionChanger - implements VersionChanger -{ +public class CompositeVersionChanger implements VersionChanger { private final List composites; - public CompositeVersionChanger( VersionChanger[] composites ) - { - this.composites = new ArrayList<>( Arrays.asList( composites ) ); + public CompositeVersionChanger(VersionChanger[] composites) { + this.composites = new ArrayList<>(Arrays.asList(composites)); } - public CompositeVersionChanger( List composites ) - { - this.composites = new ArrayList<>( composites ); + public CompositeVersionChanger(List composites) { + this.composites = new ArrayList<>(composites); } - public void apply( VersionChange versionChange ) - throws XMLStreamException - { - for ( VersionChanger delegate : composites ) - { - delegate.apply( versionChange ); + public void apply(VersionChange versionChange) throws XMLStreamException { + for (VersionChanger delegate : composites) { + delegate.apply(versionChange); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java index f0f43ba25e..105f67f902 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DefaultVersionChange.java @@ -29,8 +29,7 @@ * @author Stephen Connolly * @since 15-Sep-2010 14:48:10 */ -public final class DefaultVersionChange implements VersionChange -{ +public final class DefaultVersionChange implements VersionChange { private final String groupId; private final String artifactId; @@ -39,73 +38,60 @@ public final class DefaultVersionChange implements VersionChange private final String newVersion; - public DefaultVersionChange( String groupId, String artifactId, String oldVersion, String newVersion ) - { + public DefaultVersionChange(String groupId, String artifactId, String oldVersion, String newVersion) { this.groupId = groupId; this.artifactId = artifactId; this.oldVersion = oldVersion; this.newVersion = newVersion; } - public String getGroupId() - { + public String getGroupId() { return groupId; } - public String getArtifactId() - { + public String getArtifactId() { return artifactId; } - public String getOldVersion() - { + public String getOldVersion() { return oldVersion; } - public String getNewVersion() - { + public String getNewVersion() { return newVersion; } - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( o == null || getClass() != o.getClass() ) - { + if (o == null || getClass() != o.getClass()) { return false; } DefaultVersionChange versionChange = (DefaultVersionChange) o; - if ( !Objects.equals( artifactId, versionChange.artifactId ) ) - { + if (!Objects.equals(artifactId, versionChange.artifactId)) { return false; } - if ( !Objects.equals( groupId, versionChange.groupId ) ) - { + if (!Objects.equals(groupId, versionChange.groupId)) { return false; } - if ( !Objects.equals( newVersion, versionChange.newVersion ) ) - { + if (!Objects.equals(newVersion, versionChange.newVersion)) { return false; } - return Objects.equals( oldVersion, versionChange.oldVersion ); + return Objects.equals(oldVersion, versionChange.oldVersion); } - public int hashCode() - { + public int hashCode() { int result = groupId != null ? groupId.hashCode() : 0; - result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 ); - result = 31 * result + ( oldVersion != null ? oldVersion.hashCode() : 0 ); - result = 31 * result + ( newVersion != null ? newVersion.hashCode() : 0 ); + result = 31 * result + (artifactId != null ? artifactId.hashCode() : 0); + result = 31 * result + (oldVersion != null ? oldVersion.hashCode() : 0); + result = 31 * result + (newVersion != null ? newVersion.hashCode() : 0); return result; } - public String toString() - { + public String toString() { return "DefaultVersionChange(" + groupId + ':' + artifactId + ":" + oldVersion + "-->" + newVersion + ')'; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java index a106150773..9995d47fce 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/DependencyVersionChanger.java @@ -33,24 +33,22 @@ * @author Stephen Connolly * @since 15-Sep-2010 16:00:32 */ -public class DependencyVersionChanger - extends AbstractVersionChanger -{ +public class DependencyVersionChanger extends AbstractVersionChanger { - public DependencyVersionChanger( Model model, ModifiedPomXMLEventReader pom, Log reporter ) - { - super( model, pom, reporter ); + public DependencyVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log reporter) { + super(model, pom, reporter); } - public void apply( VersionChange versionChange ) - throws XMLStreamException - { - if ( PomHelper.setDependencyVersion( getPom(), versionChange.getGroupId(), versionChange.getArtifactId(), - versionChange.getOldVersion(), versionChange.getNewVersion(), - getModel() ) ) - { - info( " Updating dependency " + versionChange.getGroupId() + ":" + versionChange.getArtifactId() ); - info( " from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion() ); + public void apply(VersionChange versionChange) throws XMLStreamException { + if (PomHelper.setDependencyVersion( + getPom(), + versionChange.getGroupId(), + versionChange.getArtifactId(), + versionChange.getOldVersion(), + versionChange.getNewVersion(), + getModel())) { + info(" Updating dependency " + versionChange.getGroupId() + ":" + versionChange.getArtifactId()); + info(" from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion()); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java index a0220049b1..fea98f8649 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ParentVersionChanger.java @@ -30,26 +30,19 @@ /** * */ -public class ParentVersionChanger - extends AbstractVersionChanger -{ +public class ParentVersionChanger extends AbstractVersionChanger { - public ParentVersionChanger( Model model, ModifiedPomXMLEventReader pom, Log reporter ) - { - super( model, pom, reporter ); + public ParentVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log reporter) { + super(model, pom, reporter); } - public void apply( VersionChange versionChange ) - throws XMLStreamException - { - if ( getModel().getParent() != null && versionChange.getGroupId().equals( getModel().getParent().getGroupId() ) - && versionChange.getArtifactId().equals( getModel().getParent().getArtifactId() ) ) - { - if ( PomHelper.setProjectParentVersion( getPom(), versionChange.getNewVersion() ) ) - { - info( " Updating parent " + versionChange.getGroupId() + ":" + versionChange.getArtifactId() ); - info( " from version " + versionChange.getOldVersion() + " to " - + versionChange.getNewVersion() ); + public void apply(VersionChange versionChange) throws XMLStreamException { + if (getModel().getParent() != null + && versionChange.getGroupId().equals(getModel().getParent().getGroupId()) + && versionChange.getArtifactId().equals(getModel().getParent().getArtifactId())) { + if (PomHelper.setProjectParentVersion(getPom(), versionChange.getNewVersion())) { + info(" Updating parent " + versionChange.getGroupId() + ":" + versionChange.getArtifactId()); + info(" from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion()); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java index 60ddce5831..279fee78dd 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/PluginVersionChanger.java @@ -33,23 +33,21 @@ * @author Stephen Connolly * @since 15-Sep-2010 16:00:54 */ -public class PluginVersionChanger - extends AbstractVersionChanger -{ +public class PluginVersionChanger extends AbstractVersionChanger { - public PluginVersionChanger( Model model, ModifiedPomXMLEventReader pom, Log reporter ) - { - super( model, pom, reporter ); + public PluginVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log reporter) { + super(model, pom, reporter); } - public void apply( VersionChange versionChange ) - throws XMLStreamException - { - if ( PomHelper.setPluginVersion( getPom(), versionChange.getGroupId(), versionChange.getArtifactId(), - versionChange.getOldVersion(), versionChange.getNewVersion() ) ) - { - info( " Updating plugin " + versionChange.getGroupId() + ":" + versionChange.getArtifactId() ); - info( " from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion() ); + public void apply(VersionChange versionChange) throws XMLStreamException { + if (PomHelper.setPluginVersion( + getPom(), + versionChange.getGroupId(), + versionChange.getArtifactId(), + versionChange.getOldVersion(), + versionChange.getNewVersion())) { + info(" Updating plugin " + versionChange.getGroupId() + ":" + versionChange.getArtifactId()); + info(" from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion()); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java index 64e8a87605..f75013251e 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/ProjectVersionChanger.java @@ -33,26 +33,18 @@ * @author Stephen Connolly * @since 15-Sep-2010 16:00:17 */ -public class ProjectVersionChanger - extends AbstractVersionChanger -{ +public class ProjectVersionChanger extends AbstractVersionChanger { - public ProjectVersionChanger( Model model, ModifiedPomXMLEventReader pom, Log reporter ) - { - super( model, pom, reporter ); + public ProjectVersionChanger(Model model, ModifiedPomXMLEventReader pom, Log reporter) { + super(model, pom, reporter); } - public void apply( VersionChange versionChange ) - throws XMLStreamException - { - if ( versionChange.getGroupId().equals( PomHelper.getGroupId( getModel() ) ) - && versionChange.getArtifactId().equals( PomHelper.getArtifactId( getModel() ) ) ) - { - if ( PomHelper.setProjectVersion( getPom(), versionChange.getNewVersion() ) ) - { - info( " Updating project " + versionChange.getGroupId() + ":" + versionChange.getArtifactId() ); - info( " from version " + versionChange.getOldVersion() + " to " - + versionChange.getNewVersion() ); + public void apply(VersionChange versionChange) throws XMLStreamException { + if (versionChange.getGroupId().equals(PomHelper.getGroupId(getModel())) + && versionChange.getArtifactId().equals(PomHelper.getArtifactId(getModel()))) { + if (PomHelper.setProjectVersion(getPom(), versionChange.getNewVersion())) { + info(" Updating project " + versionChange.getGroupId() + ":" + versionChange.getArtifactId()); + info(" from version " + versionChange.getOldVersion() + " to " + versionChange.getNewVersion()); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java index dd86e8e8b1..b2a91a68f1 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChanger.java @@ -29,8 +29,6 @@ * @author Stephen Connolly * @since 15-Sep-2010 15:59:00 */ -public interface VersionChanger -{ - void apply( VersionChange versionChange ) - throws XMLStreamException; +public interface VersionChanger { + void apply(VersionChange versionChange) throws XMLStreamException; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java index 1f1d543d6c..8e91d8fb64 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/change/VersionChangerFactory.java @@ -32,116 +32,99 @@ * @author Stephen Connolly * @since 15-Sep-2010 16:05:27 */ -public class VersionChangerFactory -{ +public class VersionChangerFactory { private Model model = null; private ModifiedPomXMLEventReader pom = null; private Log log = null; - public synchronized Model getModel() - { + public synchronized Model getModel() { return model; } - public synchronized void setModel( Model model ) - { + public synchronized void setModel(Model model) { this.model = model; } - public synchronized ModifiedPomXMLEventReader getPom() - { + public synchronized ModifiedPomXMLEventReader getPom() { return pom; } - public synchronized void setPom( ModifiedPomXMLEventReader pom ) - { + public synchronized void setPom(ModifiedPomXMLEventReader pom) { this.pom = pom; } - public synchronized Log getLog() - { + public synchronized Log getLog() { return log; } - public synchronized void setLog( Log log ) - { + public synchronized void setLog(Log log) { this.log = log; } - private synchronized void checkState() - { - if ( model == null ) - { - throw new IllegalStateException( "Model has not been specified" ); + private synchronized void checkState() { + if (model == null) { + throw new IllegalStateException("Model has not been specified"); } - if ( pom == null ) - { - throw new IllegalStateException( "Pom has not been specified" ); + if (pom == null) { + throw new IllegalStateException("Pom has not been specified"); } - if ( log == null ) - { - throw new IllegalStateException( "Log has not been specified" ); + if (log == null) { + throw new IllegalStateException("Log has not been specified"); } } - public synchronized VersionChanger newPluginVersionChanger() - { + public synchronized VersionChanger newPluginVersionChanger() { checkState(); - return new PluginVersionChanger( model, pom, log ); + return new PluginVersionChanger(model, pom, log); } - public synchronized VersionChanger newDependencyVersionChanger() - { + public synchronized VersionChanger newDependencyVersionChanger() { checkState(); - return new DependencyVersionChanger( model, pom, log ); + return new DependencyVersionChanger(model, pom, log); } - public synchronized VersionChanger newProjectVersionChanger() - { + public synchronized VersionChanger newProjectVersionChanger() { checkState(); - return new ProjectVersionChanger( model, pom, log ); + return new ProjectVersionChanger(model, pom, log); } - public synchronized VersionChanger newParentVersionChanger() - { + public synchronized VersionChanger newParentVersionChanger() { checkState(); - return new ParentVersionChanger( model, pom, log ); + return new ParentVersionChanger(model, pom, log); } - public synchronized VersionChanger newVersionChanger() - { + public synchronized VersionChanger newVersionChanger() { checkState(); - VersionChanger[] delegates = new VersionChanger[] { newParentVersionChanger(), newProjectVersionChanger(), - newDependencyVersionChanger(), newPluginVersionChanger() }; - return new CompositeVersionChanger( delegates ); + VersionChanger[] delegates = new VersionChanger[] { + newParentVersionChanger(), + newProjectVersionChanger(), + newDependencyVersionChanger(), + newPluginVersionChanger() + }; + return new CompositeVersionChanger(delegates); } - public synchronized VersionChanger newVersionChanger( boolean processParent, boolean processProject, - boolean processDependencies, boolean processPlugins ) - { + public synchronized VersionChanger newVersionChanger( + boolean processParent, boolean processProject, boolean processDependencies, boolean processPlugins) { checkState(); List delegates = new ArrayList<>(); - if ( processParent ) - { - delegates.add( newParentVersionChanger() ); + if (processParent) { + delegates.add(newParentVersionChanger()); } - if ( processProject ) - { - delegates.add( newProjectVersionChanger() ); + if (processProject) { + delegates.add(newProjectVersionChanger()); } - if ( processDependencies ) - { - delegates.add( newDependencyVersionChanger() ); + if (processDependencies) { + delegates.add(newDependencyVersionChanger()); } - if ( processPlugins ) - { - delegates.add( newPluginVersionChanger() ); + if (processPlugins) { + delegates.add(newPluginVersionChanger()); } - return new CompositeVersionChanger( delegates ); + return new CompositeVersionChanger(delegates); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java index 00f58cb00c..4af2a4fbfa 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/DependencyFilter.java @@ -30,60 +30,50 @@ import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.versions.utils.DependencyComparator; -public class DependencyFilter -{ +public class DependencyFilter { private final String pattern; private final List matchers; - DependencyFilter( String pattern, List matchers ) - { + DependencyFilter(String pattern, List matchers) { this.pattern = pattern; this.matchers = matchers; } - public static DependencyFilter parseFrom( List dependencies ) - { - List matchers = dependencies.stream() - .map( TokenizedMatcher::parse ) - .collect( Collectors.toList() ); + public static DependencyFilter parseFrom(List dependencies) { + List matchers = + dependencies.stream().map(TokenizedMatcher::parse).collect(Collectors.toList()); - String debugPattern = String.join( ",", dependencies ); + String debugPattern = String.join(",", dependencies); - return new DependencyFilter( debugPattern, matchers ); + return new DependencyFilter(debugPattern, matchers); } - private static Predicate not( Predicate predicate ) - { - return x -> !predicate.test( x ); + private static Predicate not(Predicate predicate) { + return x -> !predicate.test(x); } @Override - public String toString() - { - return String.format( "%s{%s}", getClass().getSimpleName(), pattern ); + public String toString() { + return String.format("%s{%s}", getClass().getSimpleName(), pattern); } - public Set retainingIn( Collection dependencies ) - { - return filterBy( dependencies, this::matchersMatch ); + public Set retainingIn(Collection dependencies) { + return filterBy(dependencies, this::matchersMatch); } - public Set removingFrom( Collection dependencies ) - { - return filterBy( dependencies, not( this::matchersMatch ) ); + public Set removingFrom(Collection dependencies) { + return filterBy(dependencies, not(this::matchersMatch)); } - private boolean matchersMatch( Dependency dependency ) - { - return matchers.stream().anyMatch( m -> m.test( dependency ) ); + private boolean matchersMatch(Dependency dependency) { + return matchers.stream().anyMatch(m -> m.test(dependency)); } - private TreeSet filterBy( Collection dependencies, Predicate predicate ) - { + private TreeSet filterBy(Collection dependencies, Predicate predicate) { return dependencies.stream() - .filter( predicate ) - .collect( Collectors.toCollection( () -> new TreeSet<>( DependencyComparator.INSTANCE ) ) ); + .filter(predicate) + .collect(Collectors.toCollection(() -> new TreeSet<>(DependencyComparator.INSTANCE))); } /** @@ -100,30 +90,26 @@ public static Set filterDependencies( List includes, List excludes, String section, - Log log - ) - { - DependencyFilter includeDeps = DependencyFilter.parseFrom( includes ); - DependencyFilter excludeDeps = DependencyFilter.parseFrom( excludes ); - - Set filtered = includeDeps.retainingIn( dependencies ); - filtered = excludeDeps.removingFrom( filtered ); - - if ( log != null && log.isDebugEnabled() ) - { - log.debug( String.format( "parsed includes in %s: %s -> %s", section, includes, includeDeps ) ); - log.debug( String.format( "parsed excludes in %s: %s -> %s", section, excludes, excludeDeps ) ); - log.debug( String.format( "Unfiltered %s: ", section ) + output( dependencies ) ); - log.debug( String.format( "Filtered %s: ", section ) + output( filtered ) ); + Log log) { + DependencyFilter includeDeps = DependencyFilter.parseFrom(includes); + DependencyFilter excludeDeps = DependencyFilter.parseFrom(excludes); + + Set filtered = includeDeps.retainingIn(dependencies); + filtered = excludeDeps.removingFrom(filtered); + + if (log != null && log.isDebugEnabled()) { + log.debug(String.format("parsed includes in %s: %s -> %s", section, includes, includeDeps)); + log.debug(String.format("parsed excludes in %s: %s -> %s", section, excludes, excludeDeps)); + log.debug(String.format("Unfiltered %s: ", section) + output(dependencies)); + log.debug(String.format("Filtered %s: ", section) + output(filtered)); } return filtered; } - private static String output( Collection dependencies ) - { + private static String output(Collection dependencies) { return dependencies.stream() - .map( d -> String.format( "%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion() ) ) - .collect( Collectors.joining( ", " ) ); + .map(d -> String.format("%s:%s:%s", d.getGroupId(), d.getArtifactId(), d.getVersion())) + .collect(Collectors.joining(", ")); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java index 1db96c0d99..f5c984af68 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/NullAwareWildcardMatcher.java @@ -19,23 +19,19 @@ * under the License. */ -public class NullAwareWildcardMatcher extends WildcardMatcher -{ +public class NullAwareWildcardMatcher extends WildcardMatcher { public static final String NULL_KEYWORD = "null"; - public NullAwareWildcardMatcher( String pattern ) - { - super( pattern ); + public NullAwareWildcardMatcher(String pattern) { + super(pattern); } @Override - public boolean test( String token ) - { - if ( NULL_KEYWORD.equals( getPattern() ) ) - { + public boolean test(String token) { + if (NULL_KEYWORD.equals(getPattern())) { return token == null; } - return super.test( token ); + return super.test(token); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java index 336c9f7e82..b5cae8f60e 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/TokenizedMatcher.java @@ -8,49 +8,41 @@ import org.apache.maven.model.Dependency; -public class TokenizedMatcher implements Predicate -{ - public enum Tokens - { - GROUP_ID( Dependency::getGroupId ), - ARTIFACT_ID( Dependency::getArtifactId ), - VERSION( Dependency::getVersion ), - TYPE( Dependency::getType ), - CLASSIFIER( Dependency::getClassifier ), - SCOPE( Dependency::getScope ); +public class TokenizedMatcher implements Predicate { + public enum Tokens { + GROUP_ID(Dependency::getGroupId), + ARTIFACT_ID(Dependency::getArtifactId), + VERSION(Dependency::getVersion), + TYPE(Dependency::getType), + CLASSIFIER(Dependency::getClassifier), + SCOPE(Dependency::getScope); private final Function tokenExtractor; - Tokens( Function tokenExtractor ) - { + Tokens(Function tokenExtractor) { this.tokenExtractor = tokenExtractor; } - public Function getTokenExtractor() - { + public Function getTokenExtractor() { return tokenExtractor; } } private final Map> matchers; - private TokenizedMatcher( Map> matchers ) - { + private TokenizedMatcher(Map> matchers) { this.matchers = matchers; } @Override - public boolean test( Dependency dependency ) - { - for ( Tokens token : Tokens.values() ) - { - String tokenValue = token.getTokenExtractor().apply( dependency ); + public boolean test(Dependency dependency) { + for (Tokens token : Tokens.values()) { + String tokenValue = token.getTokenExtractor().apply(dependency); - Predicate matcher = matchers.get( token ); - boolean matches = matcher.test( tokenValue ); + Predicate matcher = matchers.get(token); + boolean matches = matcher.test(tokenValue); - if ( !matches ) - { + if (!matches) { return false; } } @@ -58,50 +50,34 @@ public boolean test( Dependency dependency ) return true; } - public static TokenizedMatcher parse( String pattern ) - { - EnumMap> matchers = new EnumMap<>( Tokens.class ); - - String[] split = pattern == null - ? new String[0] - : pattern.split( ":" ); - - String groupIdPattern = split.length >= 1 - ? split[0] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.GROUP_ID, WildcardMatcher.parse( groupIdPattern ) ); - - String artifactIdPattern = split.length >= 2 - ? split[1] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.ARTIFACT_ID, WildcardMatcher.parse( artifactIdPattern ) ); - - String versionPattern = split.length >= 3 - ? split[2] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.VERSION, WildcardMatcher.parse( versionPattern ) ); - - String typePattern = split.length >= 4 - ? split[3] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.TYPE, WildcardMatcher.parse( typePattern ) ); - - String classifierPattern = split.length >= 5 - ? split[4] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.CLASSIFIER, new NullAwareWildcardMatcher( classifierPattern ) ); - - String scopePattern = split.length >= 6 - ? split[5] - : WildcardMatcher.WILDCARD; - matchers.put( Tokens.SCOPE, new NullAwareWildcardMatcher( scopePattern ) ); - - return new TokenizedMatcher( Collections.unmodifiableMap( matchers ) ); + public static TokenizedMatcher parse(String pattern) { + EnumMap> matchers = new EnumMap<>(Tokens.class); + + String[] split = pattern == null ? new String[0] : pattern.split(":"); + + String groupIdPattern = split.length >= 1 ? split[0] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.GROUP_ID, WildcardMatcher.parse(groupIdPattern)); + + String artifactIdPattern = split.length >= 2 ? split[1] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.ARTIFACT_ID, WildcardMatcher.parse(artifactIdPattern)); + + String versionPattern = split.length >= 3 ? split[2] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.VERSION, WildcardMatcher.parse(versionPattern)); + + String typePattern = split.length >= 4 ? split[3] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.TYPE, WildcardMatcher.parse(typePattern)); + + String classifierPattern = split.length >= 5 ? split[4] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.CLASSIFIER, new NullAwareWildcardMatcher(classifierPattern)); + + String scopePattern = split.length >= 6 ? split[5] : WildcardMatcher.WILDCARD; + matchers.put(Tokens.SCOPE, new NullAwareWildcardMatcher(scopePattern)); + + return new TokenizedMatcher(Collections.unmodifiableMap(matchers)); } @Override - public String toString() - { - return String.format( "%s{%s}", getClass().getSimpleName(), matchers ); + public String toString() { + return String.format("%s{%s}", getClass().getSimpleName(), matchers); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java index f63f5e88bc..5b4905636f 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/filtering/WildcardMatcher.java @@ -6,90 +6,73 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; -public class WildcardMatcher implements Predicate -{ +public class WildcardMatcher implements Predicate { public static final String WILDCARD = "*"; private final String pattern; - protected WildcardMatcher( String pattern ) - { + protected WildcardMatcher(String pattern) { this.pattern = pattern; } - public static WildcardMatcher parse( String pattern ) - { - return new WildcardMatcher( pattern ); + public static WildcardMatcher parse(String pattern) { + return new WildcardMatcher(pattern); } @Override - public boolean test( String token ) - { - if ( token == null ) - { - return WILDCARD.equals( pattern ); + public boolean test(String token) { + if (token == null) { + return WILDCARD.equals(pattern); } boolean matches; // support full wildcard and implied wildcard - if ( WILDCARD.equals( pattern ) || pattern.isEmpty() ) - { + if (WILDCARD.equals(pattern) || pattern.isEmpty()) { matches = true; } // support contains wildcard - else if ( pattern.startsWith( WILDCARD ) && pattern.endsWith( WILDCARD ) ) - { - String contains = pattern.substring( 1, pattern.length() - 1 ); + else if (pattern.startsWith(WILDCARD) && pattern.endsWith(WILDCARD)) { + String contains = pattern.substring(1, pattern.length() - 1); - matches = token.contains( contains ); + matches = token.contains(contains); } // support leading wildcard - else if ( pattern.startsWith( WILDCARD ) ) - { - matches = token.endsWith( pattern.substring( 1 ) ); + else if (pattern.startsWith(WILDCARD)) { + matches = token.endsWith(pattern.substring(1)); } // support trailing wildcard - else if ( pattern.endsWith( WILDCARD ) ) - { - String prefix = pattern.substring( 0, pattern.length() - 1 ); + else if (pattern.endsWith(WILDCARD)) { + String prefix = pattern.substring(0, pattern.length() - 1); - matches = token.startsWith( prefix ); + matches = token.startsWith(prefix); } // support versions range - else if ( pattern.startsWith( "[" ) || pattern.startsWith( "(" ) ) - { - matches = isVersionIncludedInRange( token, pattern ); + else if (pattern.startsWith("[") || pattern.startsWith("(")) { + matches = isVersionIncludedInRange(token, pattern); } // support exact match - else - { - matches = token.equals( pattern ); + else { + matches = token.equals(pattern); } return matches; } - private boolean isVersionIncludedInRange( final String version, final String range ) - { - try - { - return VersionRange.createFromVersionSpec( range ).containsVersion( new DefaultArtifactVersion( version ) ); - } - catch ( InvalidVersionSpecificationException e ) - { + private boolean isVersionIncludedInRange(final String version, final String range) { + try { + return VersionRange.createFromVersionSpec(range).containsVersion(new DefaultArtifactVersion(version)); + } catch (InvalidVersionSpecificationException e) { return false; } } - public String getPattern() - { + public String getPattern() { return pattern; } @Override - public String toString() - { - return String.format( "%s{%s}", getClass().getSimpleName(), pattern ); + public String toString() { + return String.format("%s{%s}", getClass().getSimpleName(), pattern); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 75b659e047..23ea3269fd 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -26,28 +26,22 @@ * * @since 1.0-beta-1 */ -public abstract class AbstractVersionComparator - implements VersionComparator -{ +public abstract class AbstractVersionComparator implements VersionComparator { @Override - public abstract int compare( ArtifactVersion o1, ArtifactVersion o2 ); + public abstract int compare(ArtifactVersion o1, ArtifactVersion o2); @Override - public final int getSegmentCount( ArtifactVersion v ) - { - if ( v == null ) - { + public final int getSegmentCount(ArtifactVersion v) { + if (v == null) { return 0; } - if ( VersionComparators.isSnapshot( v ) ) - { - return innerGetSegmentCount( VersionComparators.stripSnapshot( v ) ); + if (VersionComparators.isSnapshot(v)) { + return innerGetSegmentCount(VersionComparators.stripSnapshot(v)); } - return innerGetSegmentCount( v ); - + return innerGetSegmentCount(v); } - protected abstract int innerGetSegmentCount( ArtifactVersion v ); + protected abstract int innerGetSegmentCount(ArtifactVersion v); /** * Returns a hash code value for the comparator class. @@ -55,8 +49,7 @@ public final int getSegmentCount( ArtifactVersion v ) * @return the hash code. */ @Override - public int hashCode() - { + public int hashCode() { return getClass().hashCode(); } @@ -69,9 +62,7 @@ public int hashCode() * @see java.util.Hashtable */ @Override - public boolean equals( Object obj ) - { - return obj == this || ( obj != null && getClass().equals( obj.getClass() ) ); + public boolean equals(Object obj) { + return obj == this || (obj != null && getClass().equals(obj.getClass())); } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java index 49b043e82e..b98dc85118 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersion.java @@ -21,13 +21,13 @@ *

    This is particularly helpful for -SNAPSHOT and other versions with qualifiers, which * are lower than version 0 in the Maven versioning system.

    */ -public class BoundArtifactVersion extends DefaultArtifactVersion -{ +public class BoundArtifactVersion extends DefaultArtifactVersion { /** * Most major segment that can change, i.e. not held in place. * All segments that are more major than this one are held in place. */ private final Segment segment; + private final BoundComparableVersion comparator; /** @@ -35,11 +35,10 @@ public class BoundArtifactVersion extends DefaultArtifactVersion * @param artifactVersion artifact version containing the segment version values * @param segment most major segment that can change, i.e. not held in place */ - public BoundArtifactVersion( ArtifactVersion artifactVersion, Segment segment ) - { - super( artifactVersion.toString() ); + public BoundArtifactVersion(ArtifactVersion artifactVersion, Segment segment) { + super(artifactVersion.toString()); this.segment = segment; - this.comparator = new BoundComparableVersion( this ); + this.comparator = new BoundComparableVersion(this); } /** @@ -47,104 +46,85 @@ public BoundArtifactVersion( ArtifactVersion artifactVersion, Segment segment ) * All segments that are more major than this one are held in place. * @return segment that can change */ - public Segment getSegment() - { + public Segment getSegment() { return segment; } @Override - public int compareTo( ArtifactVersion other ) - { - if ( other == null ) - { + public int compareTo(ArtifactVersion other) { + if (other == null) { return -1; } - return comparator.compareTo( new ComparableVersion( other.toString() ) ); + return comparator.compareTo(new ComparableVersion(other.toString())); } @Override - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( !( o instanceof BoundArtifactVersion ) ) - { + if (!(o instanceof BoundArtifactVersion)) { return false; } BoundArtifactVersion that = (BoundArtifactVersion) o; return new EqualsBuilder() - .appendSuper( super.equals( o ) ) - .append( getSegment(), that.getSegment() ) - .append( comparator, that.comparator ) + .appendSuper(super.equals(o)) + .append(getSegment(), that.getSegment()) + .append(comparator, that.comparator) .isEquals(); } @Override - public int hashCode() - { - return new HashCodeBuilder( 17, 37 ) - .appendSuper( super.hashCode() ) - .append( getSegment() ) - .append( comparator ) + public int hashCode() { + return new HashCodeBuilder(17, 37) + .appendSuper(super.hashCode()) + .append(getSegment()) + .append(comparator) .toHashCode(); } - protected static class BoundComparableVersion extends ComparableVersion - { + protected static class BoundComparableVersion extends ComparableVersion { private BoundArtifactVersion artifactVersion; - protected BoundComparableVersion( BoundArtifactVersion artifactVersion ) - { - super( artifactVersion.toString() ); + protected BoundComparableVersion(BoundArtifactVersion artifactVersion) { + super(artifactVersion.toString()); this.artifactVersion = artifactVersion; } @Override - public int compareTo( ComparableVersion o ) - { + public int compareTo(ComparableVersion o) { // all segments more or equally major than artifactVersion.segment can change - return compareTo( ( (List) items ).iterator(), - ( (Iterable) o.items ).iterator(), artifactVersion.segment.value() ); - + return compareTo( + ((List) items).iterator(), + ((Iterable) o.items).iterator(), + artifactVersion.segment.value()); } - private int compareTo( Iterator left, Iterator right, int comparisonsLeft ) - { - if ( comparisonsLeft <= 0 ) - { + private int compareTo(Iterator left, Iterator right, int comparisonsLeft) { + if (comparisonsLeft <= 0) { // always greater than the other version if all more major segments are equal return 1; } int result = left.hasNext() && right.hasNext() - ? integerItemOrZero( left.next() ).compareTo( right.next() ) - : left.hasNext() || right.hasNext() - ? compareToZero( left, right ) - : 1; - - return result != 0 - ? result - : compareTo( left, right, comparisonsLeft - 1 ); + ? integerItemOrZero(left.next()).compareTo(right.next()) + : left.hasNext() || right.hasNext() ? compareToZero(left, right) : 1; + + return result != 0 ? result : compareTo(left, right, comparisonsLeft - 1); } - private static int compareToZero( Iterator left, Iterator right ) - { + private static int compareToZero(Iterator left, Iterator right) { return left.hasNext() - ? integerItemOrZero( left.next() ).compareTo( ZERO ) - : -right.next().compareTo( ZERO ); + ? integerItemOrZero(left.next()).compareTo(ZERO) + : -right.next().compareTo(ZERO); } - private static Item integerItemOrZero( Item item ) - { - return item instanceof IntegerItem - ? item - : ZERO; + private static Item integerItemOrZero(Item item) { + return item instanceof IntegerItem ? item : ZERO; } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java index 55327cfaf3..38dcd79993 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ComparableVersion.java @@ -36,24 +36,21 @@ * @author Herve Boutemy * Note: The implementation of the maven core should be used. */ -public class ComparableVersion - implements Comparable -{ +public class ComparableVersion implements Comparable { private String value; private String canonical; protected ListItem items; - protected interface Item - { + protected interface Item { int INTEGER_ITEM = 0; int STRING_ITEM = 1; int LIST_ITEM = 2; - int compareTo( Item item ); + int compareTo(Item item); int getType(); @@ -63,46 +60,37 @@ protected interface Item /** * Represents a numeric item in the version item list. */ - protected static class IntegerItem - implements Item - { - private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" ); + protected static class IntegerItem implements Item { + private static final BigInteger BIG_INTEGER_ZERO = new BigInteger("0"); private final BigInteger value; public static final IntegerItem ZERO = new IntegerItem(); - private IntegerItem() - { + private IntegerItem() { this.value = BIG_INTEGER_ZERO; } - IntegerItem( String str ) - { - this.value = new BigInteger( str ); + IntegerItem(String str) { + this.value = new BigInteger(str); } - public int getType() - { + public int getType() { return INTEGER_ITEM; } - public boolean isNull() - { - return BIG_INTEGER_ZERO.equals( value ); + public boolean isNull() { + return BIG_INTEGER_ZERO.equals(value); } - public int compareTo( Item item ) - { - if ( item == null ) - { - return BIG_INTEGER_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 + public int compareTo(Item item) { + if (item == null) { + return BIG_INTEGER_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } - switch ( item.getType() ) - { + switch (item.getType()) { case INTEGER_ITEM: - return value.compareTo( ( (IntegerItem) item ).value ); + return value.compareTo(((IntegerItem) item).value); case STRING_ITEM: return 1; // 1.1 > 1-sp @@ -111,12 +99,11 @@ public int compareTo( Item item ) return 1; // 1.1 > 1-1 default: - throw new RuntimeException( "invalid item: " + item.getClass() ); + throw new RuntimeException("invalid item: " + item.getClass()); } } - public String toString() - { + public String toString() { return value.toString(); } } @@ -124,39 +111,33 @@ public String toString() /** * Represents a string in the version item list, usually a qualifier. */ - private static class StringItem - implements Item - { - private static final String[] QUALIFIERS = { - "snapshot", "alpha", "beta", "milestone", "preview", "rc", "", "sp" }; + private static class StringItem implements Item { + private static final String[] QUALIFIERS = {"snapshot", "alpha", "beta", "milestone", "preview", "rc", "", "sp" + }; - private static final List QUALIFIERS_LIST = Arrays.asList( QUALIFIERS ); + private static final List QUALIFIERS_LIST = Arrays.asList(QUALIFIERS); private static final Properties ALIASES = new Properties(); - static - { - ALIASES.put( "mr", "milestone" ); - ALIASES.put( "cr", "rc" ); - ALIASES.put( "final", "" ); - ALIASES.put( "ga", "" ); + static { + ALIASES.put("mr", "milestone"); + ALIASES.put("cr", "rc"); + ALIASES.put("final", ""); + ALIASES.put("ga", ""); } /** * A comparable for the empty-string qualifier. This one is used to determine if a given qualifier makes the * version older than one without a qualifier, or more recent. */ - private static final Comparable RELEASE_VERSION_INDEX = String.valueOf( QUALIFIERS_LIST.indexOf( "" ) ); + private static final Comparable RELEASE_VERSION_INDEX = String.valueOf(QUALIFIERS_LIST.indexOf("")); private final String value; - StringItem( String value, boolean followedByDigit ) - { - if ( followedByDigit && value.length() == 1 ) - { + StringItem(String value, boolean followedByDigit) { + if (followedByDigit && value.length() == 1) { // a1 = alpha-1, b1 = beta-1, m1 = milestone-1 - switch ( value.charAt( 0 ) ) - { + switch (value.charAt(0)) { case 'a': value = "alpha"; break; @@ -171,17 +152,15 @@ private static class StringItem break; } } - this.value = ALIASES.getProperty( value, value ); + this.value = ALIASES.getProperty(value, value); } - public int getType() - { + public int getType() { return STRING_ITEM; } - public boolean isNull() - { - return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 ); + public boolean isNull() { + return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0); } /** @@ -197,38 +176,33 @@ public boolean isNull() * @param qualifier * @return */ - public static Comparable comparableQualifier( String qualifier ) - { - int i = QUALIFIERS_LIST.indexOf( qualifier ); + public static Comparable comparableQualifier(String qualifier) { + int i = QUALIFIERS_LIST.indexOf(qualifier); - return i == -1 ? QUALIFIERS_LIST.size() + "-" + qualifier : String.valueOf( i ); + return i == -1 ? QUALIFIERS_LIST.size() + "-" + qualifier : String.valueOf(i); } - public int compareTo( Item item ) - { - if ( item == null ) - { + public int compareTo(Item item) { + if (item == null) { // 1-rc < 1, 1-ga > 1 - return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ); + return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX); } - switch ( item.getType() ) - { + switch (item.getType()) { case INTEGER_ITEM: return -1; // 1.any < 1.1 ? case STRING_ITEM: - return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) ); + return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value)); case LIST_ITEM: return -1; // 1.any < 1-1 default: - throw new RuntimeException( "invalid item: " + item.getClass() ); + throw new RuntimeException("invalid item: " + item.getClass()); } } - public String toString() - { + public String toString() { return value; } } @@ -237,50 +211,36 @@ public String toString() * Represents a version list item. This class is used both for the global item list and for sub-lists (which start * with '-(number)' in the version specification). */ - private static class ListItem - extends ArrayList - implements Item - { - public int getType() - { + private static class ListItem extends ArrayList implements Item { + public int getType() { return LIST_ITEM; } - public boolean isNull() - { - return ( size() == 0 ); + public boolean isNull() { + return (size() == 0); } - void normalize() - { - for ( ListIterator iterator = listIterator( size() ); iterator.hasPrevious(); ) - { + void normalize() { + for (ListIterator iterator = listIterator(size()); iterator.hasPrevious(); ) { Item item = iterator.previous(); - if ( item.isNull() ) - { + if (item.isNull()) { iterator.remove(); // remove null trailing items: 0, "", empty list - } - else - { + } else { break; } } } - public int compareTo( Item item ) - { - if ( item == null ) - { - if ( size() == 0 ) - { + public int compareTo(Item item) { + if (item == null) { + if (size() == 0) { return 0; // 1-0 = 1- (normalize) = 1 } - Item first = get( 0 ); - return first.compareTo( null ); + Item first = get(0); + return first.compareTo(null); } - switch ( item.getType() ) - { + switch (item.getType()) { case INTEGER_ITEM: return -1; // 1-1 < 1.0.x @@ -289,18 +249,16 @@ public int compareTo( Item item ) case LIST_ITEM: Iterator left = iterator(); - Iterator right = ( (ListItem) item ).iterator(); + Iterator right = ((ListItem) item).iterator(); - while ( left.hasNext() || right.hasNext() ) - { + while (left.hasNext() || right.hasNext()) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 - int result = l == null ? -1 * r.compareTo( l ) : l.compareTo( r ); + int result = l == null ? -1 * r.compareTo(l) : l.compareTo(r); - if ( result != 0 ) - { + if (result != 0) { return result; } } @@ -308,107 +266,84 @@ public int compareTo( Item item ) return 0; default: - throw new RuntimeException( "invalid item: " + item.getClass() ); + throw new RuntimeException("invalid item: " + item.getClass()); } } - public String toString() - { - StringBuilder buffer = new StringBuilder( "(" ); - for ( Iterator iter = iterator(); iter.hasNext(); ) - { - buffer.append( iter.next() ); - if ( iter.hasNext() ) - { - buffer.append( ',' ); + public String toString() { + StringBuilder buffer = new StringBuilder("("); + for (Iterator iter = iterator(); iter.hasNext(); ) { + buffer.append(iter.next()); + if (iter.hasNext()) { + buffer.append(','); } } - buffer.append( ')' ); + buffer.append(')'); return buffer.toString(); } } - public ComparableVersion( String version ) - { - parseVersion( version ); + public ComparableVersion(String version) { + parseVersion(version); } - public final void parseVersion( String version ) - { + public final void parseVersion(String version) { this.value = version; items = new ListItem(); - version = version.toLowerCase( Locale.ENGLISH ); + version = version.toLowerCase(Locale.ENGLISH); ListItem list = items; Stack stack = new Stack<>(); - stack.push( list ); + stack.push(list); boolean isDigit = false; int startIndex = 0; - for ( int i = 0; i < version.length(); i++ ) - { - char c = version.charAt( i ); + for (int i = 0; i < version.length(); i++) { + char c = version.charAt(i); - if ( c == '.' ) - { - if ( i == startIndex ) - { - list.add( IntegerItem.ZERO ); - } - else - { - list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); + if (c == '.') { + if (i == startIndex) { + list.add(IntegerItem.ZERO); + } else { + list.add(parseItem(isDigit, version.substring(startIndex, i))); } startIndex = i + 1; - } - else if ( c == '-' ) - { - if ( i == startIndex ) - { - list.add( IntegerItem.ZERO ); - } - else - { - list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); + } else if (c == '-') { + if (i == startIndex) { + list.add(IntegerItem.ZERO); + } else { + list.add(parseItem(isDigit, version.substring(startIndex, i))); } startIndex = i + 1; - if ( isDigit ) - { + if (isDigit) { list.normalize(); // 1.0-* = 1-* - if ( ( i + 1 < version.length() ) && Character.isDigit( version.charAt( i + 1 ) ) ) - { + if ((i + 1 < version.length()) && Character.isDigit(version.charAt(i + 1))) { // new ListItem only if previous were digits and new char is a digit, // ie need to differentiate only 1.1 from 1-1 // CHECKSTYLE_OFF: InnerAssignment - list.add( list = new ListItem() ); + list.add(list = new ListItem()); // CHECKSTYLE_ON: InnerAssignment - stack.push( list ); + stack.push(list); } } - } - else if ( Character.isDigit( c ) ) - { - if ( !isDigit && i > startIndex ) - { - list.add( new StringItem( version.substring( startIndex, i ), true ) ); + } else if (Character.isDigit(c)) { + if (!isDigit && i > startIndex) { + list.add(new StringItem(version.substring(startIndex, i), true)); startIndex = i; } isDigit = true; - } - else - { - if ( isDigit && i > startIndex ) - { - list.add( parseItem( true, version.substring( startIndex, i ) ) ); + } else { + if (isDigit && i > startIndex) { + list.add(parseItem(true, version.substring(startIndex, i))); startIndex = i; } @@ -416,13 +351,11 @@ else if ( Character.isDigit( c ) ) } } - if ( version.length() > startIndex ) - { - list.add( parseItem( isDigit, version.substring( startIndex ) ) ); + if (version.length() > startIndex) { + list.add(parseItem(isDigit, version.substring(startIndex))); } - while ( !stack.isEmpty() ) - { + while (!stack.isEmpty()) { list = stack.pop(); list.normalize(); } @@ -430,28 +363,23 @@ else if ( Character.isDigit( c ) ) canonical = items.toString(); } - private static Item parseItem( boolean isDigit, String buf ) - { - return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false ); + private static Item parseItem(boolean isDigit, String buf) { + return isDigit ? new IntegerItem(buf) : new StringItem(buf, false); } - public int compareTo( ComparableVersion o ) - { - return items.compareTo( ( o ).items ); + public int compareTo(ComparableVersion o) { + return items.compareTo((o).items); } - public String toString() - { + public String toString() { return value; } - public boolean equals( Object o ) - { - return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical ); + public boolean equals(Object o) { + return (o instanceof ComparableVersion) && canonical.equals(((ComparableVersion) o).canonical); } - public int hashCode() - { + public int hashCode() { return canonical.hashCode(); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java index ad656cfe63..2be0171684 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/InvalidSegmentException.java @@ -25,8 +25,7 @@ /** * Represents an invalid segment being identified within a version. */ -public class InvalidSegmentException extends Exception -{ +public class InvalidSegmentException extends Exception { private final Segment segment; private final int segmentCount; @@ -40,10 +39,10 @@ public class InvalidSegmentException extends Exception * @param segmentCount the number of segments. * @param version the version object. */ - public InvalidSegmentException( Segment segment, int segmentCount, ArtifactVersion version ) - { - super( String.format( "Invalid segment %s for the %d segment version: '%s'", segment.toString(), segmentCount, - version.toString() ) ); + public InvalidSegmentException(Segment segment, int segmentCount, ArtifactVersion version) { + super(String.format( + "Invalid segment %s for the %d segment version: '%s'", + segment.toString(), segmentCount, version.toString())); this.segment = segment; this.segmentCount = segmentCount; this.version = version; @@ -52,24 +51,21 @@ public InvalidSegmentException( Segment segment, int segmentCount, ArtifactVersi /** * @return segment */ - public Segment getSegment() - { + public Segment getSegment() { return segment; } /** * @return segment count */ - public int getSegmentCount() - { + public int getSegmentCount() { return segmentCount; } /** * @return version object */ - public ArtifactVersion getVersion() - { + public ArtifactVersion getVersion() { return version; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java index c4f5332ed9..2b6fde15f5 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MavenVersionComparator.java @@ -30,65 +30,53 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public class MavenVersionComparator extends AbstractVersionComparator -{ +public class MavenVersionComparator extends AbstractVersionComparator { /** * {@inheritDoc} */ - public int compare( ArtifactVersion o1, ArtifactVersion o2 ) - { - if ( o1 instanceof BoundArtifactVersion ) - { - return o1.compareTo( o2 ); + public int compare(ArtifactVersion o1, ArtifactVersion o2) { + if (o1 instanceof BoundArtifactVersion) { + return o1.compareTo(o2); } - return new ComparableVersion( o1.toString() ).compareTo( new ComparableVersion( o2.toString() ) ); + return new ComparableVersion(o1.toString()).compareTo(new ComparableVersion(o2.toString())); } /** * {@inheritDoc} */ - protected int innerGetSegmentCount( ArtifactVersion v ) - { + protected int innerGetSegmentCount(ArtifactVersion v) { // if the version does not match the maven rules, then we have only one segment // i.e. the qualifier - if ( v.getBuildNumber() != 0 ) - { + if (v.getBuildNumber() != 0) { // the version was successfully parsed, and we have a build number // have to have four segments return 4; } - if ( ( v.getMajorVersion() != 0 || v.getMinorVersion() != 0 || v.getIncrementalVersion() != 0 ) - && v.getQualifier() != null ) - { + if ((v.getMajorVersion() != 0 || v.getMinorVersion() != 0 || v.getIncrementalVersion() != 0) + && v.getQualifier() != null) { // the version was successfully parsed, and we have a qualifier // have to have four segments return 4; } final String version = v.toString(); - if ( version.indexOf( '-' ) != -1 ) - { + if (version.indexOf('-') != -1) { // the version has parts and was not parsed successfully // have to have one segment - return version.equals( v.getQualifier() ) ? 1 : 4; + return version.equals(v.getQualifier()) ? 1 : 4; } - if ( version.indexOf( '.' ) != -1 ) - { + if (version.indexOf('.') != -1) { // the version has parts and was not parsed successfully // have to have one segment - return version.equals( v.getQualifier() ) ? 1 : 3; + return version.equals(v.getQualifier()) ? 1 : 3; } - if ( StringUtils.isEmpty( version ) ) - { + if (StringUtils.isEmpty(version)) { return 3; } - try - { - Integer.parseInt( version ); + try { + Integer.parseInt(version); return 3; - } - catch ( NumberFormatException e ) - { + } catch (NumberFormatException e) { return 1; } } @@ -96,33 +84,28 @@ protected int innerGetSegmentCount( ArtifactVersion v ) /** * {@inheritDoc} */ - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException - { + protected ArtifactVersion innerIncrementSegment(ArtifactVersion v, Segment segment) throws InvalidSegmentException { String version = v.toString(); - if ( innerGetSegmentCount( v ) == 1 ) - { + if (innerGetSegmentCount(v) == 1) { // only the qualifier - version = VersionComparators.alphaNumIncrement( version ); - return new DefaultArtifactVersion( version ); - } - else - { + version = VersionComparators.alphaNumIncrement(version); + return new DefaultArtifactVersion(version); + } else { int major = v.getMajorVersion(); int minor = v.getMinorVersion(); int incremental = v.getIncrementalVersion(); int build = v.getBuildNumber(); String qualifier = v.getQualifier(); - int minorIndex = version.indexOf( '.' ); + int minorIndex = version.indexOf('.'); boolean haveMinor = minorIndex != -1; - int incrementalIndex = haveMinor ? version.indexOf( '.', minorIndex + 1 ) : -1; + int incrementalIndex = haveMinor ? version.indexOf('.', minorIndex + 1) : -1; boolean haveIncremental = incrementalIndex != -1; - int buildIndex = version.indexOf( '-' ); + int buildIndex = version.indexOf('-'); boolean haveBuild = buildIndex != -1 && qualifier == null; boolean haveQualifier = buildIndex != -1 && qualifier != null; - switch ( segment ) - { + switch (segment) { case MAJOR: major++; minor = 0; @@ -134,8 +117,7 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segm minor++; incremental = 0; build = 0; - if ( haveQualifier && qualifier.endsWith( "SNAPSHOT" ) ) - { + if (haveQualifier && qualifier.endsWith("SNAPSHOT")) { qualifier = "SNAPSHOT"; } break; @@ -145,12 +127,9 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segm qualifier = null; break; case SUBINCREMENTAL: - if ( haveQualifier ) - { - qualifier = qualifierIncrement( qualifier ); - } - else - { + if (haveQualifier) { + qualifier = qualifierIncrement(qualifier); + } else { build++; } break; @@ -159,50 +138,41 @@ protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segm break; } StringBuilder result = new StringBuilder(); - result.append( major ); - if ( haveMinor || minor > 0 || incremental > 0 ) - { - result.append( '.' ); - result.append( minor ); - } - if ( haveIncremental || incremental > 0 ) - { - result.append( '.' ); - result.append( incremental ); + result.append(major); + if (haveMinor || minor > 0 || incremental > 0) { + result.append('.'); + result.append(minor); } - if ( haveQualifier && qualifier != null ) - { - result.append( '-' ); - result.append( qualifier ); + if (haveIncremental || incremental > 0) { + result.append('.'); + result.append(incremental); } - else if ( haveBuild || build > 0 ) - { - result.append( '-' ); - result.append( build ); + if (haveQualifier && qualifier != null) { + result.append('-'); + result.append(qualifier); + } else if (haveBuild || build > 0) { + result.append('-'); + result.append(build); } - return new DefaultArtifactVersion( result.toString() ); + return new DefaultArtifactVersion(result.toString()); } } - private String qualifierIncrement( String qualifier ) - { - if ( qualifier.toLowerCase().startsWith( "alpha" ) ) - { - return qualifier.substring( 0, 5 ) + VersionComparators.alphaNumIncrement( qualifier.substring( 5 ) ); + private String qualifierIncrement(String qualifier) { + if (qualifier.toLowerCase().startsWith("alpha")) { + return qualifier.substring(0, 5) + VersionComparators.alphaNumIncrement(qualifier.substring(5)); } - if ( qualifier.toLowerCase().startsWith( "beta" ) ) - { - return qualifier.substring( 0, 4 ) + VersionComparators.alphaNumIncrement( qualifier.substring( 4 ) ); + if (qualifier.toLowerCase().startsWith("beta")) { + return qualifier.substring(0, 4) + VersionComparators.alphaNumIncrement(qualifier.substring(4)); } - if ( qualifier.toLowerCase().startsWith( "milestone" ) ) - { - return qualifier.substring( 0, 8 ) + VersionComparators.alphaNumIncrement( qualifier.substring( 8 ) ); + if (qualifier.toLowerCase().startsWith("milestone")) { + return qualifier.substring(0, 8) + VersionComparators.alphaNumIncrement(qualifier.substring(8)); } - if ( qualifier.toLowerCase().startsWith( "cr" ) || qualifier.toLowerCase().startsWith( "rc" ) - || qualifier.toLowerCase().startsWith( "sp" ) ) - { - return qualifier.substring( 0, 2 ) + VersionComparators.alphaNumIncrement( qualifier.substring( 2 ) ); + if (qualifier.toLowerCase().startsWith("cr") + || qualifier.toLowerCase().startsWith("rc") + || qualifier.toLowerCase().startsWith("sp")) { + return qualifier.substring(0, 2) + VersionComparators.alphaNumIncrement(qualifier.substring(2)); } - return VersionComparators.alphaNumIncrement( qualifier ); + return VersionComparators.alphaNumIncrement(qualifier); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java index bccc150462..2f6e4a8bf0 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparator.java @@ -33,115 +33,87 @@ * @since 1.0-alpha-3 * @deprecated */ -public class MercuryVersionComparator - extends AbstractVersionComparator -{ - private static final BigInteger BIG_INTEGER_ONE = new BigInteger( "1" ); +public class MercuryVersionComparator extends AbstractVersionComparator { + private static final BigInteger BIG_INTEGER_ONE = new BigInteger("1"); /** * {@inheritDoc} */ - public int compare( ArtifactVersion o1, ArtifactVersion o2 ) - { - return new ComparableVersion( o1.toString() ).compareTo( new ComparableVersion( o2.toString() ) ); + public int compare(ArtifactVersion o1, ArtifactVersion o2) { + return new ComparableVersion(o1.toString()).compareTo(new ComparableVersion(o2.toString())); } - protected int innerGetSegmentCount( ArtifactVersion v ) - { + protected int innerGetSegmentCount(ArtifactVersion v) { final String version = v.toString(); - StringTokenizer tok = new StringTokenizer( version, ".-" ); + StringTokenizer tok = new StringTokenizer(version, ".-"); return tok.countTokens(); } - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException - { + protected ArtifactVersion innerIncrementSegment(ArtifactVersion v, Segment segment) throws InvalidSegmentException { final String version = v.toString(); - StringBuilder result = new StringBuilder( version.length() + 10 ); - StringTokenizer tok = new StringTokenizer( version, ".-" ); + StringBuilder result = new StringBuilder(version.length() + 10); + StringTokenizer tok = new StringTokenizer(version, ".-"); int index = 0; - while ( tok.hasMoreTokens() && segment.value() > 0 ) - { + while (tok.hasMoreTokens() && segment.value() > 0) { String token = tok.nextToken(); - result.append( token ); + result.append(token); index += token.length(); - if ( tok.hasMoreTokens() ) - { + if (tok.hasMoreTokens()) { // grab the token separator - result.append( version.charAt( index ) ); + result.append(version.charAt(index)); index++; } - segment = Segment.of( segment.value() - 1 ); + segment = Segment.of(segment.value() - 1); } - if ( segment.value() == 0 ) - { - if ( tok.hasMoreTokens() ) - { + if (segment.value() == 0) { + if (tok.hasMoreTokens()) { String token = tok.nextToken(); String newToken; - try - { - BigInteger n = new BigInteger( token ); - newToken = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e ) - { + try { + BigInteger n = new BigInteger(token); + newToken = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e) { // ok, let's try some common tricks - if ( "alpha".equalsIgnoreCase( token ) ) - { + if ("alpha".equalsIgnoreCase(token)) { newToken = "beta"; - } - else if ( "beta".equalsIgnoreCase( token ) ) - { + } else if ("beta".equalsIgnoreCase(token)) { newToken = "milestone"; - } - else if ( "milestone".equalsIgnoreCase( token ) ) - { + } else if ("milestone".equalsIgnoreCase(token)) { newToken = "rc"; - } - else if ( "rc".equalsIgnoreCase( token ) || "cr".equalsIgnoreCase( token ) ) - { + } else if ("rc".equalsIgnoreCase(token) || "cr".equalsIgnoreCase(token)) { newToken = "ga"; - } - else if ( "final".equalsIgnoreCase( token ) || "ga".equalsIgnoreCase( token ) - || "".equalsIgnoreCase( token ) ) - { + } else if ("final".equalsIgnoreCase(token) + || "ga".equalsIgnoreCase(token) + || "".equalsIgnoreCase(token)) { newToken = "sp"; - } - else - { - newToken = VersionComparators.alphaNumIncrement( token ); + } else { + newToken = VersionComparators.alphaNumIncrement(token); } } - result.append( newToken ); + result.append(newToken); index += token.length(); - if ( tok.hasMoreTokens() ) - { + if (tok.hasMoreTokens()) { // grab the token separator - result.append( version.charAt( index ) ); + result.append(version.charAt(index)); index++; } - } - else - { + } else { // an empty part is equivalent to 0 for mercury version comparator - result.append( "1" ); + result.append("1"); } } - while ( tok.hasMoreTokens() ) - { + while (tok.hasMoreTokens()) { String token = tok.nextToken(); - result.append( "0" ); + result.append("0"); index += token.length(); - if ( tok.hasMoreTokens() ) - { + if (tok.hasMoreTokens()) { // grab the token separator - result.append( version.charAt( index ) ); + result.append(version.charAt(index)); index++; } } - return new DefaultArtifactVersion( result.toString() ); + return new DefaultArtifactVersion(result.toString()); } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java index 70a38f3011..71172f288b 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/NumericVersionComparator.java @@ -34,113 +34,86 @@ * @since 1.0-alpha-3 * @deprecated */ -public class NumericVersionComparator - extends AbstractVersionComparator -{ - private static final BigInteger BIG_INTEGER_ZERO = new BigInteger( "0" ); +public class NumericVersionComparator extends AbstractVersionComparator { + private static final BigInteger BIG_INTEGER_ZERO = new BigInteger("0"); - private static final BigInteger BIG_INTEGER_ONE = new BigInteger( "1" ); + private static final BigInteger BIG_INTEGER_ONE = new BigInteger("1"); /** * {@inheritDoc} */ - public int compare( ArtifactVersion o1, ArtifactVersion o2 ) - { + public int compare(ArtifactVersion o1, ArtifactVersion o2) { String v1 = o1.toString(); String v2 = o2.toString(); - StringTokenizer tok1 = new StringTokenizer( v1, "." ); - StringTokenizer tok2 = new StringTokenizer( v2, "." ); - while ( tok1.hasMoreTokens() && tok2.hasMoreTokens() ) - { + StringTokenizer tok1 = new StringTokenizer(v1, "."); + StringTokenizer tok2 = new StringTokenizer(v2, "."); + while (tok1.hasMoreTokens() && tok2.hasMoreTokens()) { String p1 = tok1.nextToken(); String p2 = tok2.nextToken(); String q1 = null; String q2 = null; - if ( p1.indexOf( '-' ) >= 0 ) - { - int index = p1.indexOf( '-' ); - q1 = p1.substring( index ); - p1 = p1.substring( 0, index ); - } - if ( p2.indexOf( '-' ) >= 0 ) - { - int index = p2.indexOf( '-' ); - q2 = p2.substring( index ); - p2 = p2.substring( 0, index ); - } - try - { - BigInteger n1 = new BigInteger( p1 ); - BigInteger n2 = new BigInteger( p2 ); - int result = n1.compareTo( n2 ); - if ( result != 0 ) - { + if (p1.indexOf('-') >= 0) { + int index = p1.indexOf('-'); + q1 = p1.substring(index); + p1 = p1.substring(0, index); + } + if (p2.indexOf('-') >= 0) { + int index = p2.indexOf('-'); + q2 = p2.substring(index); + p2 = p2.substring(0, index); + } + try { + BigInteger n1 = new BigInteger(p1); + BigInteger n2 = new BigInteger(p2); + int result = n1.compareTo(n2); + if (result != 0) { return result; } - } - catch ( NumberFormatException e ) - { - int result = p1.compareTo( p2 ); - if ( result != 0 ) - { + } catch (NumberFormatException e) { + int result = p1.compareTo(p2); + if (result != 0) { return result; } } - if ( q1 != null && q2 != null ) - { - final int result = q1.compareTo( q2 ); - if ( result != 0 ) - { + if (q1 != null && q2 != null) { + final int result = q1.compareTo(q2); + if (result != 0) { return result; } } - if ( q1 != null ) - { + if (q1 != null) { return -1; } - if ( q2 != null ) - { + if (q2 != null) { return +1; } } - if ( tok1.hasMoreTokens() ) - { + if (tok1.hasMoreTokens()) { BigInteger n2 = BIG_INTEGER_ZERO; - while ( tok1.hasMoreTokens() ) - { - try - { - BigInteger n1 = new BigInteger( tok1.nextToken() ); - int result = n1.compareTo( n2 ); - if ( result != 0 ) - { + while (tok1.hasMoreTokens()) { + try { + BigInteger n1 = new BigInteger(tok1.nextToken()); + int result = n1.compareTo(n2); + if (result != 0) { return result; } - } - catch ( NumberFormatException e ) - { + } catch (NumberFormatException e) { // any token is better than zero return +1; } } return -1; } - if ( tok2.hasMoreTokens() ) - { + if (tok2.hasMoreTokens()) { BigInteger n1 = BIG_INTEGER_ZERO; - while ( tok2.hasMoreTokens() ) - { - try - { - BigInteger n2 = new BigInteger( tok2.nextToken() ); - int result = n1.compareTo( n2 ); - if ( result != 0 ) - { + while (tok2.hasMoreTokens()) { + try { + BigInteger n2 = new BigInteger(tok2.nextToken()); + int result = n1.compareTo(n2); + if (result != 0) { return result; } - } - catch ( NumberFormatException e ) - { + } catch (NumberFormatException e) { // any token is better than zero return -1; } @@ -153,180 +126,123 @@ public int compare( ArtifactVersion o1, ArtifactVersion o2 ) /** * {@inheritDoc} */ - protected int innerGetSegmentCount( ArtifactVersion v ) - { + protected int innerGetSegmentCount(ArtifactVersion v) { final String version = v.toString(); - StringTokenizer tok = new StringTokenizer( version, "." ); + StringTokenizer tok = new StringTokenizer(version, "."); return tok.countTokens(); } /** * {@inheritDoc} */ - @SuppressWarnings( "checkstyle:MethodLength" ) - protected ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException - { + @SuppressWarnings("checkstyle:MethodLength") + protected ArtifactVersion innerIncrementSegment(ArtifactVersion v, Segment segment) throws InvalidSegmentException { final String version = v.toString(); StringBuilder buf = new StringBuilder(); - StringTokenizer tok = new StringTokenizer( version, "." ); + StringTokenizer tok = new StringTokenizer(version, "."); boolean first = true; - for ( int segmentIdx = segment.value(); segmentIdx >= 0 && tok.hasMoreTokens(); --segmentIdx ) - { - if ( first ) - { + for (int segmentIdx = segment.value(); segmentIdx >= 0 && tok.hasMoreTokens(); --segmentIdx) { + if (first) { first = false; - } - else - { - buf.append( '.' ); + } else { + buf.append('.'); } String p = tok.nextToken(); String q = null; - if ( p.indexOf( '-' ) >= 0 ) - { - int index = p.indexOf( '-' ); - q = p.substring( index + 1 ); - p = p.substring( 0, index ); + if (p.indexOf('-') >= 0) { + int index = p.indexOf('-'); + q = p.substring(index + 1); + p = p.substring(0, index); } - if ( segmentIdx == 0 ) - { - try - { - BigInteger n = new BigInteger( p ); - p = n.add( BIG_INTEGER_ONE ).toString(); + if (segmentIdx == 0) { + try { + BigInteger n = new BigInteger(p); + p = n.add(BIG_INTEGER_ONE).toString(); q = null; - } - catch ( NumberFormatException e ) - { + } catch (NumberFormatException e) { // ok, let's try some common tricks - if ( "alpha".equalsIgnoreCase( p ) ) - { - if ( q == null ) - { + if ("alpha".equalsIgnoreCase(p)) { + if (q == null) { p = "beta"; - } - else - { - try - { - BigInteger n = new BigInteger( q ); - q = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e1 ) - { + } else { + try { + BigInteger n = new BigInteger(q); + q = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e1) { p = "beta"; q = null; } } - } - else if ( "beta".equalsIgnoreCase( p ) ) - { - if ( q == null ) - { + } else if ("beta".equalsIgnoreCase(p)) { + if (q == null) { p = "milestone"; - } - else - { - try - { - BigInteger n = new BigInteger( q ); - q = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e1 ) - { + } else { + try { + BigInteger n = new BigInteger(q); + q = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e1) { p = "milestone"; q = null; } } - } - else if ( "milestone".equalsIgnoreCase( p ) ) - { - if ( q == null ) - { + } else if ("milestone".equalsIgnoreCase(p)) { + if (q == null) { p = "rc"; - } - else - { - try - { - BigInteger n = new BigInteger( q ); - q = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e1 ) - { + } else { + try { + BigInteger n = new BigInteger(q); + q = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e1) { p = "rc"; q = null; } } - } - else if ( "cr".equalsIgnoreCase( p ) || "rc".equalsIgnoreCase( p ) ) - { - if ( q == null ) - { + } else if ("cr".equalsIgnoreCase(p) || "rc".equalsIgnoreCase(p)) { + if (q == null) { p = "ga"; - } - else - { - try - { - BigInteger n = new BigInteger( q ); - q = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e1 ) - { + } else { + try { + BigInteger n = new BigInteger(q); + q = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e1) { p = "ga"; q = null; } } - } - else if ( "ga".equalsIgnoreCase( p ) || "final".equalsIgnoreCase( p ) ) - { - if ( q == null ) - { + } else if ("ga".equalsIgnoreCase(p) || "final".equalsIgnoreCase(p)) { + if (q == null) { p = "sp"; q = "1"; - } - else - { - try - { - BigInteger n = new BigInteger( q ); - q = n.add( BIG_INTEGER_ONE ).toString(); - } - catch ( NumberFormatException e1 ) - { + } else { + try { + BigInteger n = new BigInteger(q); + q = n.add(BIG_INTEGER_ONE).toString(); + } catch (NumberFormatException e1) { p = "sp"; q = "1"; } } - } - else - { - p = VersionComparators.alphaNumIncrement( p ); + } else { + p = VersionComparators.alphaNumIncrement(p); } } } - buf.append( p ); - if ( q != null ) - { - buf.append( '-' ); - buf.append( q ); + buf.append(p); + if (q != null) { + buf.append('-'); + buf.append(q); } } - while ( tok.hasMoreTokens() ) - { - if ( first ) - { + while (tok.hasMoreTokens()) { + if (first) { first = false; - } - else - { - buf.append( '.' ); + } else { + buf.append('.'); } tok.nextToken(); - buf.append( "0" ); + buf.append("0"); } - return new DefaultArtifactVersion( buf.toString() ); + return new DefaultArtifactVersion(buf.toString()); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java index b9e0e7199b..25124511d5 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/ReactorDepthComparator.java @@ -31,30 +31,23 @@ * @author Stephen Connolly * @since 15-Sep-2010 14:54:42 */ -public class ReactorDepthComparator - implements Comparator -{ +public class ReactorDepthComparator implements Comparator { private final Map reactor; - public ReactorDepthComparator( Map reactor ) - { + public ReactorDepthComparator(Map reactor) { this.reactor = reactor; } - public int compare( String o1, String o2 ) - { - final Model m1 = reactor.get( o1 ); - final Model m2 = reactor.get( o2 ); - final int d1 = PomHelper.getReactorParentCount( reactor, m1 ); - final int d2 = PomHelper.getReactorParentCount( reactor, m2 ); - if ( d1 < d2 ) - { + public int compare(String o1, String o2) { + final Model m1 = reactor.get(o1); + final Model m2 = reactor.get(o2); + final int d1 = PomHelper.getReactorParentCount(reactor, m1); + final int d2 = PomHelper.getReactorParentCount(reactor, m2); + if (d1 < d2) { return -1; - } - else if ( d1 > d2 ) - { + } else if (d1 > d2) { return 1; } - return PomHelper.getGAV( m1 ).compareTo( PomHelper.getGAV( m2 ) ); + return PomHelper.getGAV(m1).compareTo(PomHelper.getGAV(m2)); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java index 1ca3e6b075..2b7fa449f7 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparator.java @@ -26,9 +26,7 @@ /** * A rule for comparing and manipulating versions. */ -public interface VersionComparator - extends Comparator -{ +public interface VersionComparator extends Comparator { /** * Returns the number of segments specified or specifiable in the supplied artifact version. * @@ -36,5 +34,5 @@ public interface VersionComparator * @return The number of segments. * @since 1.0-beta-1 */ - int getSegmentCount( ArtifactVersion artifactVersion ); + int getSegmentCount(ArtifactVersion artifactVersion); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java index 2693bb6a51..9e00ab02a7 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/ordering/VersionComparators.java @@ -33,13 +33,11 @@ * @deprecated * Note: This comparator should be replaced by using the one of Maven core instead. */ -public final class VersionComparators -{ - private static final Pattern SNAPSHOT_PATTERN = Pattern.compile( "(-((\\d{8}\\.\\d{6})-(\\d+))|(SNAPSHOT))$" ); +public final class VersionComparators { + private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("(-((\\d{8}\\.\\d{6})-(\\d+))|(SNAPSHOT))$"); - private VersionComparators() - { - throw new IllegalAccessError( "Utility classes should never be instantiated" ); + private VersionComparators() { + throw new IllegalAccessError("Utility classes should never be instantiated"); } /** @@ -49,131 +47,93 @@ private VersionComparators() * @return the version comparator to use. * @since 1.0-alpha-1 */ - public static VersionComparator getVersionComparator( String comparisonMethod ) - { - if ( "numeric".equalsIgnoreCase( comparisonMethod ) ) - { + public static VersionComparator getVersionComparator(String comparisonMethod) { + if ("numeric".equalsIgnoreCase(comparisonMethod)) { return new NumericVersionComparator(); - } - else if ( "mercury".equalsIgnoreCase( comparisonMethod ) ) - { + } else if ("mercury".equalsIgnoreCase(comparisonMethod)) { return new MercuryVersionComparator(); } return new MavenVersionComparator(); } - public static String alphaNumIncrement( String token ) - { + public static String alphaNumIncrement(String token) { String newToken; int i = token.length(); boolean done = false; newToken = token; - while ( !done && i > 0 ) - { + while (!done && i > 0) { i--; - char c = token.charAt( i ); - if ( '0' <= c && c < '9' ) - { + char c = token.charAt(i); + if ('0' <= c && c < '9') { c++; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); done = true; - } - else if ( c == '9' ) - { + } else if (c == '9') { c = '0'; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); - } - else if ( 'A' <= c && c < 'Z' ) - { + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); + } else if ('A' <= c && c < 'Z') { c++; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); done = true; - } - else if ( c == 'Z' ) - { + } else if (c == 'Z') { c = 'A'; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); - } - else if ( 'a' <= c && c < 'z' ) - { + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); + } else if ('a' <= c && c < 'z') { c++; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); done = true; - } - else if ( c == 'z' ) - { + } else if (c == 'z') { c = 'a'; - newToken = - newToken.substring( 0, i ) + c + ( i + 1 < newToken.length() ? newToken.substring( i + 1 ) : "" ); + newToken = newToken.substring(0, i) + c + (i + 1 < newToken.length() ? newToken.substring(i + 1) : ""); } } - if ( done ) - { + if (done) { return newToken; - } - else - { + } else { // ok this is roll-over time boolean lastNumeric = false; boolean lastAlpha = false; boolean lastUpper = false; i = token.length(); - while ( !lastAlpha && !lastNumeric && i > 0 ) - { + while (!lastAlpha && !lastNumeric && i > 0) { i--; - char c = token.charAt( i ); - lastAlpha = Character.isLetter( c ); - lastUpper = c == Character.toUpperCase( c ); - lastNumeric = Character.isDigit( c ); + char c = token.charAt(i); + lastAlpha = Character.isLetter(c); + lastUpper = c == Character.toUpperCase(c); + lastNumeric = Character.isDigit(c); } - if ( lastAlpha ) - { - if ( lastUpper ) - { + if (lastAlpha) { + if (lastUpper) { return token + 'A'; } return token + 'a'; } return token + '0'; - } } - static boolean isSnapshot( ArtifactVersion v ) - { - return v != null && SNAPSHOT_PATTERN.matcher( v.toString() ).find(); + static boolean isSnapshot(ArtifactVersion v) { + return v != null && SNAPSHOT_PATTERN.matcher(v.toString()).find(); } - static ArtifactVersion stripSnapshot( ArtifactVersion v ) - { + static ArtifactVersion stripSnapshot(ArtifactVersion v) { final String version = v.toString(); - final Matcher matcher = SNAPSHOT_PATTERN.matcher( version ); - if ( matcher.find() ) - { - return new DefaultArtifactVersion( version.substring( 0, matcher.start( 1 ) - 1 ) ); + final Matcher matcher = SNAPSHOT_PATTERN.matcher(version); + if (matcher.find()) { + return new DefaultArtifactVersion(version.substring(0, matcher.start(1) - 1)); } return v; } - static ArtifactVersion copySnapshot( ArtifactVersion source, ArtifactVersion destination ) - { - if ( isSnapshot( destination ) ) - { - destination = stripSnapshot( destination ); - } - final Matcher matcher = SNAPSHOT_PATTERN.matcher( source.toString() ); - if ( matcher.find() ) - { - return new DefaultArtifactVersion( destination.toString() + "-" + matcher.group( 0 ) ); + static ArtifactVersion copySnapshot(ArtifactVersion source, ArtifactVersion destination) { + if (isSnapshot(destination)) { + destination = stripSnapshot(destination); } - else - { - return new DefaultArtifactVersion( destination.toString() + "-SNAPSHOT" ); + final Matcher matcher = SNAPSHOT_PATTERN.matcher(source.toString()); + if (matcher.find()) { + return new DefaultArtifactVersion(destination.toString() + "-" + matcher.group(0)); + } else { + return new DefaultArtifactVersion(destination.toString() + "-SNAPSHOT"); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java index 46f1f798cb..d53025b4ef 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderNull.java @@ -29,23 +29,16 @@ /** * A recorder that ignores updates. */ -@Named( "none" ) -public class ChangeRecorderNull implements ChangeRecorder -{ +@Named("none") +public class ChangeRecorderNull implements ChangeRecorder { /** * Creates a new instance */ - public ChangeRecorderNull() - { - } + public ChangeRecorderNull() {} @Override - public final void recordChange( ChangeRecord changeRecord ) - { - } + public final void recordChange(ChangeRecord changeRecord) {} @Override - public final void writeReport( final Path outputPath ) - { - } + public final void writeReport(final Path outputPath) {} } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java index 19051c5438..b924a5dcbc 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/ChangeRecorderXML.java @@ -49,14 +49,11 @@ /** * A recorder of version updates. */ - -@Named( "xml" ) -public class ChangeRecorderXML implements ChangeRecorder -{ +@Named("xml") +public class ChangeRecorderXML implements ChangeRecorder { /** * The XML namespace used for serialized changes. */ - public static final String CHANGES_NAMESPACE = "http://www.mojohaus.org/versions-maven-plugin/schema/updates/1.0"; private final Document document; @@ -65,63 +62,52 @@ public class ChangeRecorderXML implements ChangeRecorder /** * Creates a new instance */ - public ChangeRecorderXML() - { - try - { + public ChangeRecorderXML() { + try { final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); document = documentBuilder.newDocument(); - root = document.createElementNS( CHANGES_NAMESPACE, "updates" ); - document.appendChild( root ); - } - catch ( final ParserConfigurationException | DOMException e ) - { - throw new IllegalStateException( e ); + root = document.createElementNS(CHANGES_NAMESPACE, "updates"); + document.appendChild(root); + } catch (final ParserConfigurationException | DOMException e) { + throw new IllegalStateException(e); } } @Override - public final void recordChange( ChangeRecord changeRecord ) - { - final Element update = this.document.createElementNS( CHANGES_NAMESPACE, "update" ); - update.setAttribute( "kind", changeRecord.getKind().getLabel() ); - update.setAttribute( "groupId", changeRecord.getVersionChange().getGroupId() ); - update.setAttribute( "artifactId", changeRecord.getVersionChange().getArtifactId() ); - update.setAttribute( "oldVersion", changeRecord.getVersionChange().getOldVersion() ); - update.setAttribute( "newVersion", changeRecord.getVersionChange().getNewVersion() ); - this.root.appendChild( update ); + public final void recordChange(ChangeRecord changeRecord) { + final Element update = this.document.createElementNS(CHANGES_NAMESPACE, "update"); + update.setAttribute("kind", changeRecord.getKind().getLabel()); + update.setAttribute("groupId", changeRecord.getVersionChange().getGroupId()); + update.setAttribute("artifactId", changeRecord.getVersionChange().getArtifactId()); + update.setAttribute("oldVersion", changeRecord.getVersionChange().getOldVersion()); + update.setAttribute("newVersion", changeRecord.getVersionChange().getNewVersion()); + this.root.appendChild(update); } @Override - public final void writeReport( final Path outputPath ) throws IOException - { - if ( outputPath == null ) - { - throw new IOException( "changeRecorderOutputFile not provided" ); + public final void writeReport(final Path outputPath) throws IOException { + if (outputPath == null) { + throw new IOException("changeRecorderOutputFile not provided"); } - if ( root.getChildNodes().getLength() == 0 ) - { + if (root.getChildNodes().getLength() == 0) { // don't generate empty file return; } - Files.createDirectories( outputPath.getParent() ); + Files.createDirectories(outputPath.getParent()); - try ( OutputStream outputStream = Files.newOutputStream( outputPath, CREATE, TRUNCATE_EXISTING, WRITE ) ) - { + try (OutputStream outputStream = Files.newOutputStream(outputPath, CREATE, TRUNCATE_EXISTING, WRITE)) { TransformerFactory transformerFactory = TransformerFactory.newInstance(); - transformerFactory.setAttribute( XMLConstants.ACCESS_EXTERNAL_DTD, "" ); - transformerFactory.setAttribute( XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "" ); + transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); + transformerFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); Transformer transformer = transformerFactory.newTransformer(); - Source source = new DOMSource( this.document ); - transformer.transform( source, new StreamResult( outputStream ) ); + Source source = new DOMSource(this.document); + transformer.transform(source, new StreamResult(outputStream)); outputStream.flush(); - } - catch ( final TransformerException ex ) - { - throw new IOException( ex ); + } catch (final TransformerException ex) { + throw new IOException(ex); } } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java index a3c8d82d7d..8334415fe7 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/recording/DefaultChangeRecord.java @@ -8,38 +8,30 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.change.DefaultVersionChange; -public class DefaultChangeRecord implements ChangeRecord -{ +public class DefaultChangeRecord implements ChangeRecord { private final ChangeKind kind; private final VersionChange versionChange; - private DefaultChangeRecord( ChangeKind kind, VersionChange versionChange ) - { - this.kind = Objects.requireNonNull( kind, "kind must not be null" ); - this.versionChange = Objects.requireNonNull( versionChange, "versionChange must not be null" ); - + private DefaultChangeRecord(ChangeKind kind, VersionChange versionChange) { + this.kind = Objects.requireNonNull(kind, "kind must not be null"); + this.versionChange = Objects.requireNonNull(versionChange, "versionChange must not be null"); } @Override - public ChangeKind getKind() - { + public ChangeKind getKind() { return kind; } @Override - public VersionChange getVersionChange() - { + public VersionChange getVersionChange() { return versionChange; } - - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - public static class Builder - { + public static class Builder { private ChangeKind kind; private String groupId; @@ -47,58 +39,47 @@ public static class Builder private String oldVersion; private String newVersion; - public Builder withKind( ChangeKind kind ) - { + public Builder withKind(ChangeKind kind) { this.kind = kind; return this; } - public Builder withGroupId( String groupId ) - { + public Builder withGroupId(String groupId) { this.groupId = groupId; return this; } - public Builder withArtifactId( String artifactId ) - { + public Builder withArtifactId(String artifactId) { this.artifactId = artifactId; return this; } - public Builder withOldVersion( String oldVersion ) - { + public Builder withOldVersion(String oldVersion) { this.oldVersion = oldVersion; return this; } - public Builder withNewVersion( String newVersion ) - { + public Builder withNewVersion(String newVersion) { this.newVersion = newVersion; return this; } - public Builder withDependency( Dependency dependency ) - { + public Builder withDependency(Dependency dependency) { groupId = dependency.getGroupId(); artifactId = dependency.getArtifactId(); oldVersion = dependency.getVersion(); return this; } - public Builder withArtifact( Artifact artifact ) - { + public Builder withArtifact(Artifact artifact) { groupId = artifact.getGroupId(); artifactId = artifact.getArtifactId(); oldVersion = artifact.getVersion(); return this; } - public ChangeRecord build() - { - return new DefaultChangeRecord( kind, - new DefaultVersionChange( groupId, artifactId, oldVersion, newVersion ) ); + public ChangeRecord build() { + return new DefaultChangeRecord(kind, new DefaultVersionChange(groupId, artifactId, oldVersion, newVersion)); } } - - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java b/versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java index ea430c47d9..99d0cb224f 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReader.java @@ -39,9 +39,7 @@ * * @author Stephen Connolly */ -public class ModifiedPomXMLEventReader - implements XMLEventReader -{ +public class ModifiedPomXMLEventReader implements XMLEventReader { // ------------------------------ FIELDS ------------------------------ @@ -135,9 +133,8 @@ public class ModifiedPomXMLEventReader * @param path Path pointing to source of XML * @throws XMLStreamException when */ - public ModifiedPomXMLEventReader( StringBuilder pom, XMLInputFactory factory, String path ) - throws XMLStreamException - { + public ModifiedPomXMLEventReader(StringBuilder pom, XMLInputFactory factory, String path) + throws XMLStreamException { this.pom = pom; this.factory = factory; this.path = path; @@ -149,14 +146,11 @@ public ModifiedPomXMLEventReader( StringBuilder pom, XMLInputFactory factory, St * * @throws XMLStreamException when things go wrong. */ - public void rewind() - throws XMLStreamException - { - backing = factory.createXMLEventReader( new StringReader( pom.toString() ) ); + public void rewind() throws XMLStreamException { + backing = factory.createXMLEventReader(new StringReader(pom.toString())); nextEnd = 0; nextDelta = 0; - for ( int i = 0; i < MAX_MARKS; i++ ) - { + for (int i = 0; i < MAX_MARKS; i++) { markStart[i] = -1; markEnd[i] = -1; markDelta[i] = 0; @@ -174,8 +168,7 @@ public void rewind() * * @return Value for property 'modified'. */ - public boolean isModified() - { + public boolean isModified() { return modified; } @@ -186,14 +179,10 @@ public boolean isModified() /** * {@inheritDoc} */ - public Object next() - { - try - { + public Object next() { + try { return nextEvent(); - } - catch ( XMLStreamException e ) - { + } catch (XMLStreamException e) { return null; } } @@ -201,8 +190,7 @@ public Object next() /** * {@inheritDoc} */ - public void remove() - { + public void remove() { throw new UnsupportedOperationException(); } @@ -211,15 +199,10 @@ public void remove() /** * {@inheritDoc} */ - public XMLEvent nextEvent() - throws XMLStreamException - { - try - { + public XMLEvent nextEvent() throws XMLStreamException { + try { return next; - } - finally - { + } finally { next = null; lastStart = nextStart; lastEnd = nextEnd; @@ -230,56 +213,44 @@ public XMLEvent nextEvent() /** * {@inheritDoc} */ - public XMLEvent peek() - throws XMLStreamException - { + public XMLEvent peek() throws XMLStreamException { return backing.peek(); } /** * {@inheritDoc} */ - public String getElementText() - throws XMLStreamException - { + public String getElementText() throws XMLStreamException { return backing.getElementText(); } /** * {@inheritDoc} */ - public XMLEvent nextTag() - throws XMLStreamException - { - while ( hasNext() ) - { + public XMLEvent nextTag() throws XMLStreamException { + while (hasNext()) { XMLEvent e = nextEvent(); - if ( e.isCharacters() && !( (Characters) e ).isWhiteSpace() ) - { - throw new XMLStreamException( "Unexpected text" ); + if (e.isCharacters() && !((Characters) e).isWhiteSpace()) { + throw new XMLStreamException("Unexpected text"); } - if ( e.isStartElement() || e.isEndElement() ) - { + if (e.isStartElement() || e.isEndElement()) { return e; } } - throw new XMLStreamException( "Unexpected end of Document" ); + throw new XMLStreamException("Unexpected end of Document"); } /** * {@inheritDoc} */ - public Object getProperty( String name ) - { - return backing.getProperty( name ); + public Object getProperty(String name) { + return backing.getProperty(name); } /** * {@inheritDoc} */ - public void close() - throws XMLStreamException - { + public void close() throws XMLStreamException { backing.close(); next = null; backing = null; @@ -292,9 +263,8 @@ public void close() * * @return a copy of the backing string buffer. */ - public StringBuilder asStringBuilder() - { - return new StringBuilder( pom.toString() ); + public StringBuilder asStringBuilder() { + return new StringBuilder(pom.toString()); } /** @@ -302,8 +272,7 @@ public StringBuilder asStringBuilder() * * @param index the mark to clear. */ - public void clearMark( int index ) - { + public void clearMark(int index) { markStart[index] = -1; } @@ -313,11 +282,9 @@ public void clearMark( int index ) * @param index The mark index. * @return the current element when {@link #mark(int)} was called. */ - public String getMarkVerbatim( int index ) - { - if ( hasMark( index ) ) - { - return pom.substring( markDelta[index] + markStart[index], markDelta[index] + markEnd[index] ); + public String getMarkVerbatim(int index) { + if (hasMark(index)) { + return pom.substring(markDelta[index] + markStart[index], markDelta[index] + markEnd[index]); } return ""; } @@ -327,11 +294,9 @@ public String getMarkVerbatim( int index ) * * @return the verbatim text of the element returned by {@link #peek()}. */ - public String getPeekVerbatim() - { - if ( hasNext() ) - { - return pom.substring( nextDelta + nextStart, nextDelta + nextEnd ); + public String getPeekVerbatim() { + if (hasNext()) { + return pom.substring(nextDelta + nextStart, nextDelta + nextEnd); } return ""; } @@ -339,50 +304,38 @@ public String getPeekVerbatim() /** * {@inheritDoc} */ - public boolean hasNext() - { - if ( next != null ) - { + public boolean hasNext() { + if (next != null) { // fast path return true; } - if ( !backing.hasNext() ) - { + if (!backing.hasNext()) { // fast path return false; } - try - { + try { next = backing.nextEvent(); nextStart = nextEnd; - if ( backing.hasNext() ) - { + if (backing.hasNext()) { nextEnd = backing.peek().getLocation().getCharacterOffset(); } - if ( nextEnd != -1 ) - { - if ( !next.isCharacters() ) - { - while ( nextStart < nextEnd && nextStart < pom.length() - && ( c( nextStart ) == '\n' || c( nextStart ) == '\r' ) ) - { + if (nextEnd != -1) { + if (!next.isCharacters()) { + while (nextStart < nextEnd + && nextStart < pom.length() + && (c(nextStart) == '\n' || c(nextStart) == '\r')) { nextStart++; } - } - else - { - while ( nextEndIncludesNextEvent() || nextEndIncludesNextEndElement() ) - { + } else { + while (nextEndIncludesNextEvent() || nextEndIncludesNextEndElement()) { nextEnd--; } } } return nextStart < pom.length(); - } - catch ( XMLStreamException e ) - { - throw new RuntimeException( "Error parsing " + path + ": " + e.getMessage(), e ); + } catch (XMLStreamException e) { + throw new RuntimeException("Error parsing " + path + ": " + e.getMessage(), e); } } @@ -391,11 +344,9 @@ public boolean hasNext() * * @return Value for property 'verbatim'. */ - public String getVerbatim() - { - if ( lastStart >= 0 && lastEnd >= lastStart ) - { - return pom.substring( lastDelta + lastStart, lastDelta + lastEnd ); + public String getVerbatim() { + if (lastStart >= 0 && lastEnd >= lastStart) { + return pom.substring(lastDelta + lastStart, lastDelta + lastEnd); } return ""; } @@ -405,8 +356,7 @@ public String getVerbatim() * * @param index the mark to set. */ - public void mark( int index ) - { + public void mark(int index) { markStart[index] = lastStart; markEnd[index] = lastEnd; markDelta[index] = lastDelta; @@ -417,9 +367,8 @@ public void mark( int index ) * * @return true if nextEnd is including the start of and end element. */ - private boolean nextEndIncludesNextEndElement() - { - return ( nextEnd > nextStart + 2 && nextEnd - 2 < pom.length() && c( nextEnd - 2 ) == '<' ); + private boolean nextEndIncludesNextEndElement() { + return (nextEnd > nextStart + 2 && nextEnd - 2 < pom.length() && c(nextEnd - 2) == '<'); } /** @@ -427,10 +376,10 @@ private boolean nextEndIncludesNextEndElement() * * @return true if nextEnd is including the start of the next event. */ - private boolean nextEndIncludesNextEvent() - { - return nextEnd > nextStart + 1 && nextEnd - 2 < pom.length() - && ( c( nextEnd - 1 ) == '<' || c( nextEnd - 1 ) == '&' ); + private boolean nextEndIncludesNextEvent() { + return nextEnd > nextStart + 1 + && nextEnd - 2 < pom.length() + && (c(nextEnd - 1) == '<' || c(nextEnd - 1) == '&'); } /** @@ -439,9 +388,8 @@ private boolean nextEndIncludesNextEvent() * @param index the index. * @return char The character. */ - private char c( int index ) - { - return pom.charAt( nextDelta + index ); + private char c(int index) { + return pom.charAt(nextDelta + index); } /** @@ -449,25 +397,20 @@ private char c( int index ) * * @param replacement The replacement. */ - public void replace( String replacement ) - { - if ( lastStart < 0 || lastEnd < lastStart ) - { + public void replace(String replacement) { + if (lastStart < 0 || lastEnd < lastStart) { throw new IllegalStateException(); } int start = lastDelta + lastStart; int end = lastDelta + lastEnd; - if ( replacement.equals( pom.substring( start, end ) ) ) - { + if (replacement.equals(pom.substring(start, end))) { return; } - pom.replace( start, end, replacement ); - int delta = replacement.length() - ( lastEnd - lastStart ); + pom.replace(start, end, replacement); + int delta = replacement.length() - (lastEnd - lastStart); nextDelta += delta; - for ( int i = 0; i < MAX_MARKS; i++ ) - { - if ( hasMark( i ) && lastStart == markStart[i] && markEnd[i] == lastEnd ) - { + for (int i = 0; i < MAX_MARKS; i++) { + if (hasMark(i) && lastStart == markStart[i] && markEnd[i] == lastEnd) { markEnd[i] += delta; } } @@ -481,21 +424,17 @@ public void replace( String replacement ) * @param index The mark. * @return true if the specified mark is defined. */ - public boolean hasMark( int index ) - { + public boolean hasMark(int index) { return markStart[index] != -1; } - public String getBetween( int index1, int index2 ) - { - if ( !hasMark( index1 ) || !hasMark( index2 ) || markStart[index1] > markStart[index2] ) - { + public String getBetween(int index1, int index2) { + if (!hasMark(index1) || !hasMark(index2) || markStart[index1] > markStart[index2]) { throw new IllegalStateException(); } int start = markDelta[index1] + markEnd[index1]; int end = markDelta[index2] + markStart[index2]; - return pom.substring( start, end ); - + return pom.substring(start, end); } /** @@ -505,38 +444,28 @@ public String getBetween( int index1, int index2 ) * @param index2 The event mark to replace before. * @param replacement The replacement. */ - public void replaceBetween( int index1, int index2, String replacement ) - { - if ( !hasMark( index1 ) || !hasMark( index2 ) || markStart[index1] > markStart[index2] ) - { + public void replaceBetween(int index1, int index2, String replacement) { + if (!hasMark(index1) || !hasMark(index2) || markStart[index1] > markStart[index2]) { throw new IllegalStateException(); } int start = markDelta[index1] + markEnd[index1]; int end = markDelta[index2] + markStart[index2]; - if ( replacement.equals( pom.substring( start, end ) ) ) - { + if (replacement.equals(pom.substring(start, end))) { return; } - pom.replace( start, end, replacement ); - int delta = replacement.length() - ( end - start ); + pom.replace(start, end, replacement); + int delta = replacement.length() - (end - start); nextDelta += delta; - for ( int i = 0; i < MAX_MARKS; i++ ) - { - if ( i == index1 || i == index2 || markStart[i] == -1 ) - { + for (int i = 0; i < MAX_MARKS; i++) { + if (i == index1 || i == index2 || markStart[i] == -1) { continue; } - if ( markStart[i] > markStart[index2] ) - { + if (markStart[i] > markStart[index2]) { markDelta[i] += delta; - } - else if ( markStart[i] == markEnd[index1] && markEnd[i] == markStart[index1] ) - { + } else if (markStart[i] == markEnd[index1] && markEnd[i] == markStart[index1]) { markDelta[i] += delta; - } - else if ( markStart[i] > markEnd[index1] || markEnd[i] < markStart[index2] ) - { + } else if (markStart[i] > markEnd[index1] || markEnd[i] < markStart[index2]) { markStart[i] = -1; } } @@ -550,41 +479,30 @@ else if ( markStart[i] > markEnd[index1] || markEnd[i] < markStart[index2] ) * @param index The mark. * @param replacement The replacement. */ - public void replaceMark( int index, String replacement ) - { - if ( !hasMark( index ) ) - { + public void replaceMark(int index, String replacement) { + if (!hasMark(index)) { throw new IllegalStateException(); } int start = markDelta[index] + markStart[index]; int end = markDelta[index] + markEnd[index]; - if ( replacement.equals( pom.substring( start, end ) ) ) - { + if (replacement.equals(pom.substring(start, end))) { return; } - pom.replace( start, end, replacement ); - int delta = replacement.length() - ( markEnd[index] - markStart[index] ); + pom.replace(start, end, replacement); + int delta = replacement.length() - (markEnd[index] - markStart[index]); nextDelta += delta; - if ( lastStart == markStart[index] && lastEnd == markEnd[index] ) - { + if (lastStart == markStart[index] && lastEnd == markEnd[index]) { lastEnd += delta; - } - else if ( lastStart > markStart[index] ) - { + } else if (lastStart > markStart[index]) { lastDelta += delta; } - for ( int i = 0; i < MAX_MARKS; i++ ) - { - if ( i == index || markStart[i] == -1 ) - { + for (int i = 0; i < MAX_MARKS; i++) { + if (i == index || markStart[i] == -1) { continue; } - if ( markStart[i] > markStart[index] ) - { + if (markStart[i] > markStart[index]) { markDelta[i] += delta; - } - else if ( markStart[i] == markStart[index] && markEnd[i] == markEnd[index] ) - { + } else if (markStart[i] == markStart[index] && markEnd[i] == markEnd[index]) { markDelta[i] += delta; } } @@ -592,11 +510,8 @@ else if ( markStart[i] == markStart[index] && markEnd[i] == markEnd[index] ) modified = true; } - public Model parse() - throws IOException, XmlPullParserException - { + public Model parse() throws IOException, XmlPullParserException { MavenXpp3Reader reader = new MavenXpp3Reader(); - return reader.read( new StringReader( pom.toString() ) ); + return reader.read(new StringReader(pom.toString())); } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java index f29d06964c..06d794ceac 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/ContextualLog.java @@ -28,11 +28,9 @@ * @author Stephen Connolly * @since 15-Sep-2010 15:51:06 */ -public interface ContextualLog - extends Log -{ +public interface ContextualLog extends Log { - void setContext( String context ); + void setContext(String context); void clearContext(); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java index fa856d1dab..eb9b7e7d8b 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DelegatingContextualLog.java @@ -28,9 +28,7 @@ * @author Stephen Connolly * @since 15-Sep-2010 15:52:21 */ -public class DelegatingContextualLog - implements ContextualLog -{ +public class DelegatingContextualLog implements ContextualLog { private final Log delegate; private String currentContext = null; @@ -43,19 +41,15 @@ public class DelegatingContextualLog private boolean currentContextReportedError = false; - public DelegatingContextualLog( Log delegate ) - { + public DelegatingContextualLog(Log delegate) { this.delegate = delegate; } - public synchronized void setContext( String context ) - { - if ( StringUtils.equals( currentContext, context ) ) - { + public synchronized void setContext(String context) { + if (StringUtils.equals(currentContext, context)) { return; } - if ( currentContext != null ) - { + if (currentContext != null) { clearContext(); } currentContext = context; @@ -65,23 +59,15 @@ public synchronized void setContext( String context ) currentContextReportedError = false; } - public synchronized void clearContext() - { - if ( currentContextReportedError ) - { - delegate.error( "" ); - } - else if ( currentContextReportedWarn ) - { - delegate.warn( "" ); - } - else if ( currentContextReportedInfo ) - { - delegate.info( "" ); - } - else if ( currentContextReportedDebug ) - { - delegate.debug( "" ); + public synchronized void clearContext() { + if (currentContextReportedError) { + delegate.error(""); + } else if (currentContextReportedWarn) { + delegate.warn(""); + } else if (currentContextReportedInfo) { + delegate.info(""); + } else if (currentContextReportedDebug) { + delegate.debug(""); } currentContextReportedDebug = false; currentContextReportedInfo = false; @@ -89,132 +75,110 @@ else if ( currentContextReportedDebug ) currentContextReportedError = false; } - private void enterContextDebug() - { - if ( !currentContextReportedDebug && !currentContextReportedInfo && !currentContextReportedWarn - && !currentContextReportedError ) - { - delegate.debug( currentContext ); + private void enterContextDebug() { + if (!currentContextReportedDebug + && !currentContextReportedInfo + && !currentContextReportedWarn + && !currentContextReportedError) { + delegate.debug(currentContext); currentContextReportedDebug = true; } } - private void enterContextInfo() - { - if ( !currentContextReportedInfo && !currentContextReportedWarn && !currentContextReportedError ) - { - delegate.info( currentContext ); + private void enterContextInfo() { + if (!currentContextReportedInfo && !currentContextReportedWarn && !currentContextReportedError) { + delegate.info(currentContext); currentContextReportedInfo = true; } } - private void enterContextWarn() - { - if ( !currentContextReportedWarn && !currentContextReportedError ) - { - delegate.warn( currentContext ); + private void enterContextWarn() { + if (!currentContextReportedWarn && !currentContextReportedError) { + delegate.warn(currentContext); currentContextReportedWarn = true; } } - private void enterContextError() - { - if ( !currentContextReportedError ) - { - delegate.error( currentContext ); + private void enterContextError() { + if (!currentContextReportedError) { + delegate.error(currentContext); currentContextReportedError = true; } } - public void debug( CharSequence charSequence ) - { + public void debug(CharSequence charSequence) { enterContextDebug(); - delegate.debug( charSequence ); + delegate.debug(charSequence); } - public void debug( CharSequence charSequence, Throwable throwable ) - { + public void debug(CharSequence charSequence, Throwable throwable) { enterContextDebug(); - delegate.debug( charSequence, throwable ); + delegate.debug(charSequence, throwable); } - public void debug( Throwable throwable ) - { + public void debug(Throwable throwable) { enterContextDebug(); - delegate.debug( throwable ); + delegate.debug(throwable); } - public void info( CharSequence charSequence ) - { + public void info(CharSequence charSequence) { enterContextInfo(); - delegate.info( charSequence ); + delegate.info(charSequence); } - public void info( CharSequence charSequence, Throwable throwable ) - { + public void info(CharSequence charSequence, Throwable throwable) { enterContextInfo(); - delegate.info( charSequence, throwable ); + delegate.info(charSequence, throwable); } - public void info( Throwable throwable ) - { + public void info(Throwable throwable) { enterContextInfo(); - delegate.info( throwable ); + delegate.info(throwable); } - public void warn( CharSequence charSequence ) - { + public void warn(CharSequence charSequence) { enterContextWarn(); - delegate.warn( charSequence ); + delegate.warn(charSequence); } - public void warn( CharSequence charSequence, Throwable throwable ) - { + public void warn(CharSequence charSequence, Throwable throwable) { enterContextWarn(); - delegate.warn( charSequence, throwable ); + delegate.warn(charSequence, throwable); } - public void warn( Throwable throwable ) - { + public void warn(Throwable throwable) { enterContextWarn(); - delegate.warn( throwable ); + delegate.warn(throwable); } - public void error( CharSequence charSequence ) - { + public void error(CharSequence charSequence) { enterContextError(); - delegate.error( charSequence ); + delegate.error(charSequence); } - public void error( CharSequence charSequence, Throwable throwable ) - { + public void error(CharSequence charSequence, Throwable throwable) { enterContextError(); - delegate.error( charSequence, throwable ); + delegate.error(charSequence, throwable); } - public void error( Throwable throwable ) - { + public void error(Throwable throwable) { enterContextError(); - delegate.error( throwable ); + delegate.error(throwable); } - public boolean isDebugEnabled() - { + public boolean isDebugEnabled() { return delegate.isDebugEnabled(); } - public boolean isInfoEnabled() - { + public boolean isInfoEnabled() { return delegate.isInfoEnabled(); } - public boolean isWarnEnabled() - { + public boolean isWarnEnabled() { return delegate.isWarnEnabled(); } - public boolean isErrorEnabled() - { + public boolean isErrorEnabled() { return delegate.isErrorEnabled(); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java index 24ad4df5a8..58ca87c2ff 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyBuilder.java @@ -30,9 +30,8 @@ /** * Builder class for {@linkplain Dependency} */ -@SuppressWarnings( "OptionalUsedAsFieldOrParameterType" ) -public class DependencyBuilder -{ +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") +public class DependencyBuilder { private Optional groupId = empty(); private Optional artifactId = empty(); private Optional version = empty(); @@ -41,18 +40,15 @@ public class DependencyBuilder private Optional scope = empty(); private Optional optional = empty(); - private DependencyBuilder() - { - } + private DependencyBuilder() {} /** * Passes groupId to the builder * @param groupId given groupId * @return builder instance */ - public DependencyBuilder withGroupId( String groupId ) - { - this.groupId = ofNullable( groupId ); + public DependencyBuilder withGroupId(String groupId) { + this.groupId = ofNullable(groupId); return this; } @@ -61,9 +57,8 @@ public DependencyBuilder withGroupId( String groupId ) * @param artifactId given artifactId * @return builder instance */ - public DependencyBuilder withArtifactId( String artifactId ) - { - this.artifactId = ofNullable( artifactId ); + public DependencyBuilder withArtifactId(String artifactId) { + this.artifactId = ofNullable(artifactId); return this; } @@ -72,9 +67,8 @@ public DependencyBuilder withArtifactId( String artifactId ) * @param version given version * @return builder instance */ - public DependencyBuilder withVersion( String version ) - { - this.version = ofNullable( version ); + public DependencyBuilder withVersion(String version) { + this.version = ofNullable(version); return this; } @@ -83,9 +77,8 @@ public DependencyBuilder withVersion( String version ) * @param type given type * @return builder instance */ - public DependencyBuilder withType( String type ) - { - this.type = ofNullable( type ); + public DependencyBuilder withType(String type) { + this.type = ofNullable(type); return this; } @@ -94,9 +87,8 @@ public DependencyBuilder withType( String type ) * @param classifier given classifier * @return builder instance */ - public DependencyBuilder withClassifier( String classifier ) - { - this.classifier = ofNullable( classifier ); + public DependencyBuilder withClassifier(String classifier) { + this.classifier = ofNullable(classifier); return this; } @@ -105,9 +97,8 @@ public DependencyBuilder withClassifier( String classifier ) * @param scope given scope * @return builder instance */ - public DependencyBuilder withScope( String scope ) - { - this.scope = ofNullable( scope ); + public DependencyBuilder withScope(String scope) { + this.scope = ofNullable(scope); return this; } @@ -116,9 +107,8 @@ public DependencyBuilder withScope( String scope ) * @param optional given optional as String * @return builder instance */ - public DependencyBuilder withOptional( String optional ) - { - this.optional = ofNullable( optional ); + public DependencyBuilder withOptional(String optional) { + this.optional = ofNullable(optional); return this; } @@ -127,9 +117,8 @@ public DependencyBuilder withOptional( String optional ) * @param optional given optional as boolean * @return builder instance */ - public DependencyBuilder withOptional( boolean optional ) - { - this.optional = of( String.valueOf( optional ) ); + public DependencyBuilder withOptional(boolean optional) { + this.optional = of(String.valueOf(optional)); return this; } @@ -137,8 +126,7 @@ public DependencyBuilder withOptional( boolean optional ) * Creates a new instance of the builder * @return new instance of the builder */ - public static DependencyBuilder newBuilder() - { + public static DependencyBuilder newBuilder() { return new DependencyBuilder(); } @@ -149,12 +137,11 @@ public static DependencyBuilder newBuilder() * @param version version of the dependency * @return new instance of {@linkplain Dependency} */ - public static Dependency dependencyWith( String groupId, String artifactId, String version ) - { + public static Dependency dependencyWith(String groupId, String artifactId, String version) { return newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ) + .withGroupId(groupId) + .withArtifactId(artifactId) + .withVersion(version) .build(); } @@ -168,16 +155,15 @@ public static Dependency dependencyWith( String groupId, String artifactId, Stri * @param scope scope of the dependency * @return new instance of {@linkplain Dependency} */ - public static Dependency dependencyWith( String groupId, String artifactId, String version, String type, - String classifier, String scope ) - { + public static Dependency dependencyWith( + String groupId, String artifactId, String version, String type, String classifier, String scope) { return newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ) - .withType( type ) - .withClassifier( classifier ) - .withScope( scope ) + .withGroupId(groupId) + .withArtifactId(artifactId) + .withVersion(version) + .withType(type) + .withClassifier(classifier) + .withScope(scope) .build(); } @@ -185,16 +171,15 @@ public static Dependency dependencyWith( String groupId, String artifactId, Stri * Builds the {@linkplain Dependency} instance * @return {@linkplain Dependency} instance */ - public Dependency build() - { + public Dependency build() { Dependency inst = new Dependency(); - groupId.ifPresent( inst::setGroupId ); - artifactId.ifPresent( inst::setArtifactId ); - version.ifPresent( inst::setVersion ); - type.ifPresent( inst::setType ); - classifier.ifPresent( inst::setClassifier ); - scope.ifPresent( inst::setScope ); - optional.ifPresent( inst::setOptional ); + groupId.ifPresent(inst::setGroupId); + artifactId.ifPresent(inst::setArtifactId); + version.ifPresent(inst::setVersion); + type.ifPresent(inst::setType); + classifier.ifPresent(inst::setClassifier); + scope.ifPresent(inst::setScope); + optional.ifPresent(inst::setOptional); return inst; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java index 8330fc4b28..641c27ef69 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/DependencyComparator.java @@ -29,8 +29,7 @@ * * @since 1.0-alpha-1 */ -public enum DependencyComparator implements Comparator -{ +public enum DependencyComparator implements Comparator { INSTANCE; /** @@ -40,21 +39,19 @@ public enum DependencyComparator implements Comparator * @see java.util.Comparator#compare(Object, Object) * @since 1.0-alpha-1 */ - @SuppressWarnings( "checkstyle:InnerAssignment" ) - public int compare( Dependency d1, Dependency d2 ) - { + @SuppressWarnings("checkstyle:InnerAssignment") + public int compare(Dependency d1, Dependency d2) { int r; return d1 == d2 ? 0 : d1 == null - ? 1 - : d2 == null - ? -1 - : ( r = StringUtils.compare( d1.getGroupId(), d2.getGroupId() ) ) != 0 - ? r - : ( r = StringUtils.compare( d1.getArtifactId(), d2.getArtifactId() ) ) != 0 - ? r - : StringUtils.compare( d1.getVersion(), d2.getVersion() ); + ? 1 + : d2 == null + ? -1 + : (r = StringUtils.compare(d1.getGroupId(), d2.getGroupId())) != 0 + ? r + : (r = StringUtils.compare(d1.getArtifactId(), d2.getArtifactId())) != 0 + ? r + : StringUtils.compare(d1.getVersion(), d2.getVersion()); } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java index fd51c9d37e..e1fd645070 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MavenProjectUtils.java @@ -36,24 +36,22 @@ /** * Utility methods for extracting dependencies from a {@link org.apache.maven.project.MavenProject} */ -public class MavenProjectUtils -{ +public class MavenProjectUtils { /** * Retrieves dependencies from the plugins section * @param project {@link MavenProject} instance * @return set of {@link Dependency} objects * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved */ - public static Set extractPluginDependenciesFromPluginsInPluginManagement( MavenProject project ) - { - return ofNullable( project.getBuild() ) - .map( Build::getPluginManagement ) - .map( PluginManagement::getPlugins ) - .orElse( emptyList() ) + public static Set extractPluginDependenciesFromPluginsInPluginManagement(MavenProject project) { + return ofNullable(project.getBuild()) + .map(Build::getPluginManagement) + .map(PluginManagement::getPlugins) + .orElse(emptyList()) .stream() - .filter( plugin -> plugin.getDependencies() != null ) - .flatMap( plugin -> plugin.getDependencies().stream() ) - .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ); + .filter(plugin -> plugin.getDependencies() != null) + .flatMap(plugin -> plugin.getDependencies().stream()) + .collect(() -> new TreeSet<>(DependencyComparator.INSTANCE), Set::add, Set::addAll); } /** @@ -62,12 +60,11 @@ public static Set extractPluginDependenciesFromPluginsInPluginManage * @return set of {@link Dependency} objects * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved */ - public static Set extractDependenciesFromPlugins( MavenProject project ) - { + public static Set extractDependenciesFromPlugins(MavenProject project) { return project.getBuildPlugins().parallelStream() - .filter( plugin -> plugin.getDependencies() != null ) - .flatMap( plugin -> plugin.getDependencies().stream() ) - .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ); + .filter(plugin -> plugin.getDependencies() != null) + .flatMap(plugin -> plugin.getDependencies().stream()) + .collect(() -> new TreeSet<>(DependencyComparator.INSTANCE), Set::add, Set::addAll); } /** @@ -81,60 +78,47 @@ public static Set extractDependenciesFromPlugins( MavenProject proje * @return set of {@link Dependency} objects * or an empty set if none have been retrieveddependencies or an empty set if none have been retrieved */ - public static Set extractDependenciesFromDependencyManagement( MavenProject project, - boolean processDependencyManagementTransitive, Log log ) - throws VersionRetrievalException - { - Set dependencyManagement = new TreeSet<>( DependencyComparator.INSTANCE ); + public static Set extractDependenciesFromDependencyManagement( + MavenProject project, boolean processDependencyManagementTransitive, Log log) + throws VersionRetrievalException { + Set dependencyManagement = new TreeSet<>(DependencyComparator.INSTANCE); DependencyManagement projectDependencyManagement = processDependencyManagementTransitive ? project.getDependencyManagement() : project.getOriginalModel().getDependencyManagement(); - if ( projectDependencyManagement != null ) - { + if (projectDependencyManagement != null) { List dependenciesFromPom = projectDependencyManagement.getDependencies(); - for ( Dependency dependency : dependenciesFromPom ) - { - log.debug( "dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() - + ":" + dependency.getVersion() + ":" + dependency.getScope() ); - if ( dependency.getVersion() == null ) - { + for (Dependency dependency : dependenciesFromPom) { + log.debug("dependency from pom: " + dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + + dependency.getVersion() + ":" + dependency.getScope()); + if (dependency.getVersion() == null) { // get parent and get the information from there. - if ( project.hasParent() ) - { - log.debug( "Reading parent dependencyManagement information" ); - DependencyManagement parentProjectDependencyManagement = - processDependencyManagementTransitive - ? project.getParent().getDependencyManagement() - : project.getParent().getOriginalModel().getDependencyManagement(); - if ( parentProjectDependencyManagement != null ) - { + if (project.hasParent()) { + log.debug("Reading parent dependencyManagement information"); + DependencyManagement parentProjectDependencyManagement = processDependencyManagementTransitive + ? project.getParent().getDependencyManagement() + : project.getParent().getOriginalModel().getDependencyManagement(); + if (parentProjectDependencyManagement != null) { List parentDeps = parentProjectDependencyManagement.getDependencies(); - for ( Dependency parentDep : parentDeps ) - { + for (Dependency parentDep : parentDeps) { // only groupId && artifactId needed cause version is null - if ( dependency.getGroupId().equals( parentDep.getGroupId() ) - && dependency.getArtifactId().equals( parentDep.getArtifactId() ) - && dependency.getType().equals( parentDep.getType() ) ) - { - dependencyManagement.add( parentDep ); + if (dependency.getGroupId().equals(parentDep.getGroupId()) + && dependency.getArtifactId().equals(parentDep.getArtifactId()) + && dependency.getType().equals(parentDep.getType())) { + dependencyManagement.add(parentDep); } } } - } - else - { + } else { String message = "We can't get the version for the dependency " + dependency.getGroupId() + ":" - + dependency.getArtifactId() + " because there does not exist a parent."; - log.error( message ); + + dependency.getArtifactId() + " because there does not exist a parent."; + log.error(message); // Throw error because we will not able to get a version for a dependency. - throw new VersionRetrievalException( message ); + throw new VersionRetrievalException(message); } - } - else - { - dependency = interpolateVersion( dependency, project ); - dependencyManagement.add( dependency ); + } else { + dependency = interpolateVersion(dependency, project); + dependencyManagement.add(dependency); } } } @@ -149,18 +133,17 @@ public static Set extractDependenciesFromDependencyManagement( Maven * @return the dependency with interpolated property (as far as possible) * @since 2.14.0 */ - public static Dependency interpolateVersion( final Dependency dependency, final MavenProject project ) - { + public static Dependency interpolateVersion(final Dependency dependency, final MavenProject project) { // resolve version from model properties if necessary (e.g. "${mycomponent.myversion}" - if ( dependency.getVersion().startsWith( "${" ) ) - { + if (dependency.getVersion().startsWith("${")) { final String resolvedVersion = project.getOriginalModel() - .getProperties().getProperty( - dependency.getVersion().substring( 2, dependency.getVersion().length() - 1 ) ); - if ( resolvedVersion != null && !resolvedVersion.isEmpty() ) - { - dependency.setVersion( resolvedVersion ); + .getProperties() + .getProperty(dependency + .getVersion() + .substring(2, dependency.getVersion().length() - 1)); + if (resolvedVersion != null && !resolvedVersion.isEmpty()) { + dependency.setVersion(resolvedVersion); } } return dependency; diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java index 215ae598a9..fb50f51c67 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/MiscUtils.java @@ -7,8 +7,7 @@ /** * Miscellaneous utility class. */ -public class MiscUtils -{ +public class MiscUtils { /** * Filters a given map leaving only elements fulfilling a predicate. Does not change the input map, * the filtered map is returned as output. @@ -19,10 +18,9 @@ public class MiscUtils * @param value type * @return map such that every element comforms with the predicate */ - public static Map filter( Map map, - Function predicate ) - { - return map.entrySet().stream().filter( e -> predicate.apply( e.getValue() ) ) - .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue ) ); + public static Map filter(Map map, Function predicate) { + return map.entrySet().stream() + .filter(e -> predicate.apply(e.getValue())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java index d4efe84646..221ccaf2c7 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PluginComparator.java @@ -29,8 +29,7 @@ * * @since 1.0-beta-1 */ -public enum PluginComparator implements Comparator -{ +public enum PluginComparator implements Comparator { INSTANCE; /** @@ -42,44 +41,36 @@ public enum PluginComparator implements Comparator * @see java.util.Comparator#compare(Object, Object) * @since 1.0-beta-1 */ - public int compare( Object o1, Object o2 ) - { - if ( !( o1 instanceof Plugin || o1 instanceof ReportPlugin ) ) - { + public int compare(Object o1, Object o2) { + if (!(o1 instanceof Plugin || o1 instanceof ReportPlugin)) { throw new IllegalArgumentException( - "This comparator can only be used to compare Plugin and ReportPlugin instances" ); + "This comparator can only be used to compare Plugin and ReportPlugin instances"); } - if ( !( o2 instanceof Plugin || o2 instanceof ReportPlugin ) ) - { + if (!(o2 instanceof Plugin || o2 instanceof ReportPlugin)) { throw new IllegalArgumentException( - "This comparator can only be used to compare Plugin and ReportPlugin instances" ); + "This comparator can only be used to compare Plugin and ReportPlugin instances"); } - String g1 = o1 instanceof Plugin ? ( (Plugin) o1 ).getGroupId() : ( (ReportPlugin) o1 ).getGroupId(); - String g2 = o2 instanceof Plugin ? ( (Plugin) o2 ).getGroupId() : ( (ReportPlugin) o2 ).getGroupId(); + String g1 = o1 instanceof Plugin ? ((Plugin) o1).getGroupId() : ((ReportPlugin) o1).getGroupId(); + String g2 = o2 instanceof Plugin ? ((Plugin) o2).getGroupId() : ((ReportPlugin) o2).getGroupId(); - int r = g1.compareTo( g2 ); - if ( r == 0 ) - { - String a1 = o1 instanceof Plugin ? ( (Plugin) o1 ).getArtifactId() : ( (ReportPlugin) o1 ).getArtifactId(); - String a2 = o2 instanceof Plugin ? ( (Plugin) o2 ).getArtifactId() : ( (ReportPlugin) o2 ).getArtifactId(); - r = a1.compareTo( a2 ); + int r = g1.compareTo(g2); + if (r == 0) { + String a1 = o1 instanceof Plugin ? ((Plugin) o1).getArtifactId() : ((ReportPlugin) o1).getArtifactId(); + String a2 = o2 instanceof Plugin ? ((Plugin) o2).getArtifactId() : ((ReportPlugin) o2).getArtifactId(); + r = a1.compareTo(a2); } - if ( r == 0 ) - { - String v1 = o1 instanceof Plugin ? ( (Plugin) o1 ).getVersion() : ( (ReportPlugin) o1 ).getVersion(); - String v2 = o2 instanceof Plugin ? ( (Plugin) o2 ).getVersion() : ( (ReportPlugin) o2 ).getVersion(); - if ( v1 == null ) - { + if (r == 0) { + String v1 = o1 instanceof Plugin ? ((Plugin) o1).getVersion() : ((ReportPlugin) o1).getVersion(); + String v2 = o2 instanceof Plugin ? ((Plugin) o2).getVersion() : ((ReportPlugin) o2).getVersion(); + if (v1 == null) { // hope I got the +1/-1 the right way around return v2 == null ? 0 : -1; } - if ( v2 == null ) - { + if (v2 == null) { return 1; } - r = v1.compareTo( v2 ); + r = v1.compareTo(v2); } return r; } - } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java index 95dc0b654a..0754b981bd 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReader.java @@ -8,9 +8,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -33,8 +33,7 @@ /** * Reader class for reading property files */ -public class PropertiesVersionsFileReader -{ +public class PropertiesVersionsFileReader { /** * Commas-separated list of properties @@ -49,8 +48,7 @@ public class PropertiesVersionsFileReader * Creates an instance of the object with the given path to the property file * @param filePath path to the property file */ - public PropertiesVersionsFileReader( String filePath ) - { + public PropertiesVersionsFileReader(String filePath) { propertyFilePath = filePath; } @@ -58,30 +56,26 @@ public PropertiesVersionsFileReader( String filePath ) * Reads the property file * @throws IOException thrown if an I/O exception occurs during the read operation */ - public void read() throws IOException - { - try ( InputStream input = Files.newInputStream( Paths.get( propertyFilePath ) ) ) - { + public void read() throws IOException { + try (InputStream input = Files.newInputStream(Paths.get(propertyFilePath))) { Properties prop = new Properties(); // load a properties file - prop.load( input ); + prop.load(input); prop.propertyNames(); - propertiesCsv = prop.keySet().stream().map( Object::toString ).collect( Collectors.joining( "," ) ); + propertiesCsv = prop.keySet().stream().map(Object::toString).collect(Collectors.joining(",")); List propertiesConfigList = new ArrayList<>(); - prop.forEach( - ( name, version ) -> - { - Property propertyConfig = new Property( (String) name ); - propertyConfig.setVersion( (String) version ); - propertiesConfigList.add( propertyConfig ); - } ); - - propertiesConfig = propertiesConfigList.toArray( new Property[0] ); + prop.forEach((name, version) -> { + Property propertyConfig = new Property((String) name); + propertyConfig.setVersion((String) version); + propertiesConfigList.add(propertyConfig); + }); + + propertiesConfig = propertiesConfigList.toArray(new Property[0]); } } @@ -89,8 +83,7 @@ public void read() throws IOException * Returns the string contents of the property file * @return contents of the property file */ - public String getProperties() - { + public String getProperties() { return propertiesCsv; } @@ -98,8 +91,7 @@ public String getProperties() * Returns the array of {@link Property} objects * @return array of properties */ - public Property[] getPropertiesConfig() - { + public Property[] getPropertiesConfig() { return propertiesConfig; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java index 88112eec75..14833f7e57 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/PropertyComparator.java @@ -20,6 +20,7 @@ */ import java.util.Comparator; + import org.apache.commons.lang3.StringUtils; import org.codehaus.mojo.versions.api.Property; @@ -28,10 +29,9 @@ * * @since 1.0-beta-1 */ -public enum PropertyComparator implements Comparator -{ +public enum PropertyComparator implements Comparator { INSTANCE; - + /** * Compares to {@link Property} instances. * @@ -41,9 +41,8 @@ public enum PropertyComparator implements Comparator * @see java.util.Comparator#compare(Object, Object) * @since 1.0-beta-1 */ - @SuppressWarnings( "checkstyle:InnerAssignment" ) - public int compare( Property p1, Property p2 ) - { + @SuppressWarnings("checkstyle:InnerAssignment") + public int compare(Property p1, Property p2) { int r; return p1 == p2 ? 0 @@ -51,8 +50,8 @@ public int compare( Property p1, Property p2 ) ? 1 : p2 == null ? -1 - : ( r = StringUtils.compare( p1.getName(), p2.getName() ) ) == 0 - ? StringUtils.compare( p1.getValue(), p2.getValue() ) - : r ; + : (r = StringUtils.compare(p1.getName(), p2.getName())) == 0 + ? StringUtils.compare(p1.getValue(), p2.getValue()) + : r; } } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java index a9da7cfb42..b6f5081ead 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/RegexUtils.java @@ -25,8 +25,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public final class RegexUtils -{ +public final class RegexUtils { /** * The end of a regex literal sequence. * @@ -48,9 +47,8 @@ public final class RegexUtils */ public static final String REGEX_QUOTE_END_ESCAPED = REGEX_QUOTE_END + '\\' + REGEX_QUOTE_END + REGEX_QUOTE_START; - private RegexUtils() - { - throw new IllegalAccessError( "Utility classes should never be instantiated" ); + private RegexUtils() { + throw new IllegalAccessError("Utility classes should never be instantiated"); } /** @@ -60,53 +58,43 @@ private RegexUtils() * @return The regex that will match the string exactly. * @since 1.0-alpha-1 */ - public static String quote( String s ) - { - int i = s.indexOf( REGEX_QUOTE_END ); - if ( i == -1 ) - { + public static String quote(String s) { + int i = s.indexOf(REGEX_QUOTE_END); + if (i == -1) { // we're safe as nobody has a crazy \E in the string return REGEX_QUOTE_START + s + REGEX_QUOTE_END; } // damn there's at least one \E in the string - StringBuilder sb = new StringBuilder( s.length() + 32 ); + StringBuilder sb = new StringBuilder(s.length() + 32); // each escape-escape takes 10 chars... // hope there's less than 4 of them - sb.append( REGEX_QUOTE_START ); + sb.append(REGEX_QUOTE_START); int pos = 0; - do - { + do { // we are safe from pos to i - sb.append( s, pos, i ); + sb.append(s, pos, i); // now escape-escape - sb.append( REGEX_QUOTE_END_ESCAPED ); + sb.append(REGEX_QUOTE_END_ESCAPED); // move the working start pos = i + REGEX_QUOTE_END.length(); - i = s.indexOf( REGEX_QUOTE_END, pos ); - } - while ( i != -1 ); + i = s.indexOf(REGEX_QUOTE_END, pos); + } while (i != -1); - sb.append( s.substring( pos ) ); - sb.append( REGEX_QUOTE_END ); + sb.append(s.substring(pos)); + sb.append(REGEX_QUOTE_END); return sb.toString(); } - public static int getWildcardScore( String wildcardRule ) - { + public static int getWildcardScore(String wildcardRule) { int score = 0; - if ( wildcardRule != null ) - { - for ( char c : wildcardRule.toCharArray() ) - { - if ( c == '?' ) - { + if (wildcardRule != null) { + for (char c : wildcardRule.toCharArray()) { + if (c == '?') { score++; - } - else if ( c == '*' ) - { + } else if (c == '*') { score += 1000; } } @@ -122,52 +110,39 @@ else if ( c == '*' ) * false will match the start of the string. * @return The regex rule. */ - public static String convertWildcardsToRegex( String wildcardRule, boolean exactMatch ) - { + public static String convertWildcardsToRegex(String wildcardRule, boolean exactMatch) { StringBuilder regex = new StringBuilder(); int index = 0; final int len = wildcardRule.length(); - while ( index < len ) - { - final int nextQ = wildcardRule.indexOf( '?', index ); - final int nextS = wildcardRule.indexOf( '*', index ); - if ( nextQ == -1 && nextS == -1 ) - { - regex.append( quote( wildcardRule.substring( index ) ) ); + while (index < len) { + final int nextQ = wildcardRule.indexOf('?', index); + final int nextS = wildcardRule.indexOf('*', index); + if (nextQ == -1 && nextS == -1) { + regex.append(quote(wildcardRule.substring(index))); break; } int nextIndex; - if ( nextQ == -1 ) - { + if (nextQ == -1) { nextIndex = nextS; - } - else if ( nextS == -1 ) - { + } else if (nextS == -1) { nextIndex = nextQ; + } else { + nextIndex = Math.min(nextQ, nextS); } - else - { - nextIndex = Math.min( nextQ, nextS ); - } - if ( index < nextIndex ) - { + if (index < nextIndex) { // we have some characters to match - regex.append( quote( wildcardRule.substring( index, nextIndex ) ) ); - } - char c = wildcardRule.charAt( nextIndex ); - if ( c == '?' ) - { - regex.append( '.' ); + regex.append(quote(wildcardRule.substring(index, nextIndex))); } - else - { - regex.append( ".*" ); + char c = wildcardRule.charAt(nextIndex); + if (c == '?') { + regex.append('.'); + } else { + regex.append(".*"); } index = nextIndex + 1; } - if ( !exactMatch ) - { - regex.append( ".*" ); + if (!exactMatch) { + regex.append(".*"); } return regex.toString(); } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java index 1331890d8e..791d954a86 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/SegmentUtils.java @@ -1,6 +1,5 @@ package org.codehaus.mojo.versions.utils; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -34,8 +33,7 @@ /** * Utility class for manipulating with {@link Segment} objects */ -public class SegmentUtils -{ +public class SegmentUtils { /** *

    Based on the passed flags, determines which segment which is not to be changed.

    * @@ -64,31 +62,25 @@ public class SegmentUtils * @param log If not null, the {@linkplain Log} object to log the selected scope * @return Returns the segment (0-based) that is unchangeable. If any segment can change, returns -1. */ - public static Optional determineUnchangedSegment( boolean allowMajorUpdates, boolean allowMinorUpdates, - boolean allowIncrementalUpdates, Log log ) - { - if ( log != null && !allowIncrementalUpdates ) - { - log.info( "Assuming allowMinorUpdates false because allowIncrementalUpdates is false." ); + public static Optional determineUnchangedSegment( + boolean allowMajorUpdates, boolean allowMinorUpdates, boolean allowIncrementalUpdates, Log log) { + if (log != null && !allowIncrementalUpdates) { + log.info("Assuming allowMinorUpdates false because allowIncrementalUpdates is false."); } - if ( log != null && !allowMinorUpdates ) - { - log.info( "Assuming allowMajorUpdates false because allowMinorUpdates is false." ); + if (log != null && !allowMinorUpdates) { + log.info("Assuming allowMajorUpdates false because allowMinorUpdates is false."); } Optional unchangedSegment = allowMajorUpdates && allowMinorUpdates && allowIncrementalUpdates ? empty() : allowMinorUpdates && allowIncrementalUpdates - ? of( MAJOR ) - : allowIncrementalUpdates - ? of( MINOR ) - : of( INCREMENTAL ); - if ( log != null && log.isDebugEnabled() ) - { - log.debug( - unchangedSegment.map( s -> Segment.of( s.value() + 1 ).toString() ) - .orElse( "ALL" ) + " version changes allowed" ); + ? of(MAJOR) + : allowIncrementalUpdates ? of(MINOR) : of(INCREMENTAL); + if (log != null && log.isDebugEnabled()) { + log.debug(unchangedSegment + .map(s -> Segment.of(s.value() + 1).toString()) + .orElse("ALL") + " version changes allowed"); } return unchangedSegment; } diff --git a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java index 7ab86be342..22aa75d6cb 100644 --- a/versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java +++ b/versions-common/src/main/java/org/codehaus/mojo/versions/utils/VersionsExpressionEvaluator.java @@ -30,12 +30,8 @@ * @author Stephen Connolly * @since 17-Mar-2009 08:51:42 */ -public class VersionsExpressionEvaluator - extends PluginParameterExpressionEvaluator - implements ExpressionEvaluator -{ - public VersionsExpressionEvaluator( MavenSession mavenSession, MojoExecution mojoExecution ) - { - super( mavenSession, mojoExecution ); +public class VersionsExpressionEvaluator extends PluginParameterExpressionEvaluator implements ExpressionEvaluator { + public VersionsExpressionEvaluator(MavenSession mavenSession, MojoExecution mojoExecution) { + super(mavenSession, mojoExecution); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java index 25913f0af8..9809bfb7bd 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/ArtifactVersionsTest.java @@ -45,163 +45,169 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -public class ArtifactVersionsTest -{ +public class ArtifactVersionsTest { @Test - public void test4DigitVersions() throws Exception - { - ArtifactVersion[] versions = versions( "1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1" ); - final DefaultArtifact artifact = - new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", - "jar", new DefaultArtifactHandler() ); + public void test4DigitVersions() throws Exception { + ArtifactVersion[] versions = versions("1.0.0.1", "1.0.0.2", "2.121.2.1", "2.100.0.1", "3.1.0.1", "1.1.1"); + final DefaultArtifact artifact = new DefaultArtifact( + "group", + "artifact", + VersionRange.createFromVersionSpec("[1.0,3.0]"), + "foo", + "bar", + "jar", + new DefaultArtifactHandler()); // TODO This should also work for the MavenVersionComparator when using maven 3.x libraries ArtifactVersions instance = - new ArtifactVersions( artifact, Arrays.asList( versions ), new MercuryVersionComparator() ); - assertEquals( "artifact", instance.getArtifactId() ); - assertEquals( "group", instance.getGroupId() ); - assertThat( instance.getVersions(), - arrayContaining( versions( "1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", - "3.1.0.1" ) ) ); - assertThat( instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ), - arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); - - assertThat( instance.getVersions( new DefaultArtifactVersion( "1.0.0.2" ), null ), - //Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); - arrayContaining( versions( "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1" ) ) ); - - assertEquals( new DefaultArtifactVersion( "2.121.2.1" ), - instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), - new DefaultArtifactVersion( "3.0" ) ) ); - assertNull( - instance.getNewestVersion( new DefaultArtifactVersion( "1.1.1" ), - new DefaultArtifactVersion( "2.0" ) ) ); + new ArtifactVersions(artifact, Arrays.asList(versions), new MercuryVersionComparator()); + assertEquals("artifact", instance.getArtifactId()); + assertEquals("group", instance.getGroupId()); + assertThat( + instance.getVersions(), + arrayContaining(versions("1.0.0.1", "1.0.0.2", "1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); + assertThat( + instance.getVersions(new DefaultArtifactVersion("1.1"), null), + arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); + + assertThat( + instance.getVersions(new DefaultArtifactVersion("1.0.0.2"), null), + // Matchers.arrayContaining(versions("1.1.1", "2.121.2.1", "2.100.0.1", "3.1.0.1"))); + arrayContaining(versions("1.1.1", "2.100.0.1", "2.121.2.1", "3.1.0.1"))); + + assertEquals( + new DefaultArtifactVersion("2.121.2.1"), + instance.getNewestVersion(new DefaultArtifactVersion("1.0"), new DefaultArtifactVersion("3.0"))); + assertNull(instance.getNewestVersion(new DefaultArtifactVersion("1.1.1"), new DefaultArtifactVersion("2.0"))); } @Test - public void testSmokes() - throws Exception - { - ArtifactVersion[] versions = versions( "1.0", "3.0", "1.1", "1.0", "1.0.1" ); - final DefaultArtifact artifact = - new DefaultArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.0,3.0]" ), "foo", "bar", - "jar", new DefaultArtifactHandler() ); + public void testSmokes() throws Exception { + ArtifactVersion[] versions = versions("1.0", "3.0", "1.1", "1.0", "1.0.1"); + final DefaultArtifact artifact = new DefaultArtifact( + "group", + "artifact", + VersionRange.createFromVersionSpec("[1.0,3.0]"), + "foo", + "bar", + "jar", + new DefaultArtifactHandler()); ArtifactVersions instance = - new ArtifactVersions( artifact, Arrays.asList( versions ), new MavenVersionComparator() ); - assertEquals( "artifact", instance.getArtifactId() ); - assertEquals( "group", instance.getGroupId() ); - assertArrayEquals( - versions( "1.0", "1.0.1", "1.1", "3.0" ), - instance.getVersions() ); - assertArrayEquals( versions( "3.0" ), - instance.getVersions( new DefaultArtifactVersion( "1.1" ), null ) ); - assertArrayEquals( - versions( "1.1", "3.0" ), - instance.getVersions( new DefaultArtifactVersion( "1.0.1" ), null ) ); - assertEquals( new DefaultArtifactVersion( "1.1" ), - instance.getNewestVersion( new DefaultArtifactVersion( "1.0" ), - new DefaultArtifactVersion( "3.0" ) ) ); - assertNull( - instance.getNewestVersion( new DefaultArtifactVersion( "1.1" ), new DefaultArtifactVersion( "3.0" ) ) ); + new ArtifactVersions(artifact, Arrays.asList(versions), new MavenVersionComparator()); + assertEquals("artifact", instance.getArtifactId()); + assertEquals("group", instance.getGroupId()); + assertArrayEquals(versions("1.0", "1.0.1", "1.1", "3.0"), instance.getVersions()); + assertArrayEquals(versions("3.0"), instance.getVersions(new DefaultArtifactVersion("1.1"), null)); + assertArrayEquals(versions("1.1", "3.0"), instance.getVersions(new DefaultArtifactVersion("1.0.1"), null)); + assertEquals( + new DefaultArtifactVersion("1.1"), + instance.getNewestVersion(new DefaultArtifactVersion("1.0"), new DefaultArtifactVersion("3.0"))); + assertNull(instance.getNewestVersion(new DefaultArtifactVersion("1.1"), new DefaultArtifactVersion("3.0"))); } - private ArtifactVersion[] versions( String... versions ) - { + private ArtifactVersion[] versions(String... versions) { ArtifactVersion[] artifactVersions = new ArtifactVersion[versions.length]; - for ( int i = 0; i < versions.length; i++ ) - { - artifactVersions[i] = new DefaultArtifactVersion( versions[i] ); + for (int i = 0; i < versions.length; i++) { + artifactVersions[i] = new DefaultArtifactVersion(versions[i]); } return artifactVersions; } @Test - public void testReportLabels() - { - ArtifactVersion[] versions = versions( "1.0.1", "1.0", "1.1.0-2", "1.1.1", "1.1.1-2", "1.1.2", - "1.1.2-SNAPSHOT", "1.1.3", "1.1", "1.1-SNAPSHOT", "1.2.1", "1.2.2", "1.2", "1.3", - "1.9.1-SNAPSHOT", "2.0", "2.1.1-SNAPSHOT", "2.1", "3.0", "3.1.1-SNAPSHOT", - "3.1.5-SNAPSHOT", "3.4.0-SNAPSHOT" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.1", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - - assertThat( instance.getNewestUpdate( of( SUBINCREMENTAL ) ).toString(), is( "1.1.0-2" ) ); - assertThat( instance.getNewestUpdate( of( INCREMENTAL ) ).toString(), is( "1.1.3" ) ); + public void testReportLabels() { + ArtifactVersion[] versions = versions( + "1.0.1", + "1.0", + "1.1.0-2", + "1.1.1", + "1.1.1-2", + "1.1.2", + "1.1.2-SNAPSHOT", + "1.1.3", + "1.1", + "1.1-SNAPSHOT", + "1.2.1", + "1.2.2", + "1.2", + "1.3", + "1.9.1-SNAPSHOT", + "2.0", + "2.1.1-SNAPSHOT", + "2.1", + "3.0", + "3.1.1-SNAPSHOT", + "3.1.5-SNAPSHOT", + "3.4.0-SNAPSHOT"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.1", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + + assertThat(instance.getNewestUpdate(of(SUBINCREMENTAL)).toString(), is("1.1.0-2")); + assertThat(instance.getNewestUpdate(of(INCREMENTAL)).toString(), is("1.1.3")); } @Test - public void testGetNewerVersionsWithSnapshot() throws InvalidSegmentException - { - ArtifactVersion[] versions = versions( "1.0.0-SNAPSHOT", "1.0.0" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.0.0-SNAPSHOT", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - - assertThat( instance.getNewerVersions( "1.0.0-SNAPSHOT", of( SUBINCREMENTAL ), false, false ), - arrayContaining( new DefaultArtifactVersion( "1.0.0" ) ) ); + public void testGetNewerVersionsWithSnapshot() throws InvalidSegmentException { + ArtifactVersion[] versions = versions("1.0.0-SNAPSHOT", "1.0.0"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.0.0-SNAPSHOT", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + + assertThat( + instance.getNewerVersions("1.0.0-SNAPSHOT", of(SUBINCREMENTAL), false, false), + arrayContaining(new DefaultArtifactVersion("1.0.0"))); } @Test - public void testAllVersionsForIgnoreScopeSubIncremental() - { - ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.0.0", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - Restriction restriction = instance.restrictionForIgnoreScope( of( SUBINCREMENTAL ) ); - ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); - assertThat( filteredVersions, arrayWithSize( 1 ) ); - assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "1.0.1" ) ) ); + public void testAllVersionsForIgnoreScopeSubIncremental() { + ArtifactVersion[] versions = versions("1.0.0", "1.0.0-1", "1.0.1"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.0.0", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + Restriction restriction = instance.restrictionForIgnoreScope(of(SUBINCREMENTAL)); + ArtifactVersion[] filteredVersions = instance.getVersions(restriction, false); + assertThat(filteredVersions, arrayWithSize(1)); + assertThat(filteredVersions, arrayContaining(new DefaultArtifactVersion("1.0.1"))); } @Test - public void testAllVersionsForIgnoreScopeIncremental() - { - ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.0.0", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - Restriction restriction = instance.restrictionForIgnoreScope( of( INCREMENTAL ) ); - ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); - assertThat( filteredVersions, arrayWithSize( 1 ) ); - assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "1.1.0" ) ) ); + public void testAllVersionsForIgnoreScopeIncremental() { + ArtifactVersion[] versions = versions("1.0.0", "1.0.0-1", "1.0.1", "1.1.0"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.0.0", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + Restriction restriction = instance.restrictionForIgnoreScope(of(INCREMENTAL)); + ArtifactVersion[] filteredVersions = instance.getVersions(restriction, false); + assertThat(filteredVersions, arrayWithSize(1)); + assertThat(filteredVersions, arrayContaining(new DefaultArtifactVersion("1.1.0"))); } @Test - public void testAllVersionsForIgnoreScopeMinor() - { - ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.0.0", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - Restriction restriction = instance.restrictionForIgnoreScope( of( MINOR ) ); - ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); - assertThat( filteredVersions, arrayWithSize( 1 ) ); - assertThat( filteredVersions, arrayContaining( new DefaultArtifactVersion( "2.0.0" ) ) ); + public void testAllVersionsForIgnoreScopeMinor() { + ArtifactVersion[] versions = versions("1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.0.0", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + Restriction restriction = instance.restrictionForIgnoreScope(of(MINOR)); + ArtifactVersion[] filteredVersions = instance.getVersions(restriction, false); + assertThat(filteredVersions, arrayWithSize(1)); + assertThat(filteredVersions, arrayContaining(new DefaultArtifactVersion("2.0.0"))); } @Test - public void testAllVersionsForIgnoreScopeMajor() - { - ArtifactVersion[] versions = versions( "1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0" ); - ArtifactVersions instance = - new ArtifactVersions( new DefaultArtifact( "default-group", "dummy-api", - "1.0.0", "foo", "bar", - "jar", null ), - Arrays.asList( versions ), new MavenVersionComparator() ); - Restriction restriction = instance.restrictionForIgnoreScope( of( MAJOR ) ); - ArtifactVersion[] filteredVersions = instance.getVersions( restriction, false ); - assertThat( filteredVersions, arrayWithSize( 0 ) ); + public void testAllVersionsForIgnoreScopeMajor() { + ArtifactVersion[] versions = versions("1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"); + ArtifactVersions instance = new ArtifactVersions( + new DefaultArtifact("default-group", "dummy-api", "1.0.0", "foo", "bar", "jar", null), + Arrays.asList(versions), + new MavenVersionComparator()); + Restriction restriction = instance.restrictionForIgnoreScope(of(MAJOR)); + ArtifactVersion[] filteredVersions = instance.getVersions(restriction, false); + assertThat(filteredVersions, arrayWithSize(0)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java index 47ee52d3ac..5a0d4534e3 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/DefaultVersionsHelperTest.java @@ -80,253 +80,252 @@ /** * Test {@link DefaultVersionsHelper} */ -public class DefaultVersionsHelperTest extends AbstractMojoTestCase -{ +public class DefaultVersionsHelperTest extends AbstractMojoTestCase { @Test - public void testPerRuleVersionsIgnored() throws Exception - { - final org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); - final Artifact artifact = mock( Artifact.class ); - when( artifact.getGroupId() ).thenReturn( "com.mycompany.maven" ); - when( artifact.getArtifactId() ).thenReturn( "artifact-one" ); - when( artifact.getType() ).thenReturn( "jar" ); - when( artifact.getArtifactHandler() ).thenReturn( new DefaultArtifactHandlerStub( "default" ) ); - when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) - .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) - .setVersions( Arrays.asList( - new VersionStub( "one" ), - new VersionStub( "two" ), - new VersionStub( "three" ), - new VersionStub( "1.200" ), - new VersionStub( "illegalVersion" ) ) ) ); - - VersionsHelper helper = createHelper( repositorySystem ); - - final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); - - final List actual = Arrays.stream( versions.getVersions( true ) ) - .map( ArtifactVersion::toString ) - .collect( Collectors.toList() ); - - assertEquals( 3, actual.size() ); - assertThat( actual, hasItems( "three", "1.200", "illegalVersion" ) ); + public void testPerRuleVersionsIgnored() throws Exception { + final org.eclipse.aether.RepositorySystem repositorySystem = mock(org.eclipse.aether.RepositorySystem.class); + final Artifact artifact = mock(Artifact.class); + when(artifact.getGroupId()).thenReturn("com.mycompany.maven"); + when(artifact.getArtifactId()).thenReturn("artifact-one"); + when(artifact.getType()).thenReturn("jar"); + when(artifact.getArtifactHandler()).thenReturn(new DefaultArtifactHandlerStub("default")); + when(repositorySystem.resolveVersionRange(any(), any(VersionRangeRequest.class))) + .then(i -> new VersionRangeResult(i.getArgument(1)) + .setVersions(Arrays.asList( + new VersionStub("one"), + new VersionStub("two"), + new VersionStub("three"), + new VersionStub("1.200"), + new VersionStub("illegalVersion")))); + + VersionsHelper helper = createHelper(repositorySystem); + + final ArtifactVersions versions = helper.lookupArtifactVersions(artifact, true); + + final List actual = Arrays.stream(versions.getVersions(true)) + .map(ArtifactVersion::toString) + .collect(Collectors.toList()); + + assertEquals(3, actual.size()); + assertThat(actual, hasItems("three", "1.200", "illegalVersion")); } @Test - public void testGlobalRuleVersionsIgnored() throws Exception - { - final org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); - final Artifact artifact = mock( Artifact.class ); - when( artifact.getGroupId() ).thenReturn( "other.company" ); - when( artifact.getArtifactId() ).thenReturn( "artifact-two" ); - when( artifact.getType() ).thenReturn( "jar" ); - when( artifact.getArtifactHandler() ).thenReturn( new DefaultArtifactHandlerStub( "default" ) ); + public void testGlobalRuleVersionsIgnored() throws Exception { + final org.eclipse.aether.RepositorySystem repositorySystem = mock(org.eclipse.aether.RepositorySystem.class); + final Artifact artifact = mock(Artifact.class); + when(artifact.getGroupId()).thenReturn("other.company"); + when(artifact.getArtifactId()).thenReturn("artifact-two"); + when(artifact.getType()).thenReturn("jar"); + when(artifact.getArtifactHandler()).thenReturn(new DefaultArtifactHandlerStub("default")); final List artifactVersions = new ArrayList<>(); - final Version one = new VersionStub( "one" ); - final Version two = new VersionStub( "two" ); - final Version three = new VersionStub( "three" ); - artifactVersions.add( one ); - artifactVersions.add( two ); - artifactVersions.add( new VersionStub( "three-alpha" ) ); - artifactVersions.add( new VersionStub( "three-beta" ) ); - artifactVersions.add( three ); - final Version illegal = new VersionStub( "illegalVersion" ); - artifactVersions.add( illegal ); + final Version one = new VersionStub("one"); + final Version two = new VersionStub("two"); + final Version three = new VersionStub("three"); + artifactVersions.add(one); + artifactVersions.add(two); + artifactVersions.add(new VersionStub("three-alpha")); + artifactVersions.add(new VersionStub("three-beta")); + artifactVersions.add(three); + final Version illegal = new VersionStub("illegalVersion"); + artifactVersions.add(illegal); - when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) - .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) - .setVersions( artifactVersions ) ); + when(repositorySystem.resolveVersionRange(any(), any(VersionRangeRequest.class))) + .then(i -> new VersionRangeResult(i.getArgument(1)).setVersions(artifactVersions)); - VersionsHelper helper = createHelper( repositorySystem ); + VersionsHelper helper = createHelper(repositorySystem); - final ArtifactVersions versions = helper.lookupArtifactVersions( artifact, true ); + final ArtifactVersions versions = helper.lookupArtifactVersions(artifact, true); - final List actual = Arrays.stream( versions.getVersions( true ) ) - .map( ArtifactVersion::toString ) - .map( VersionStub::new ) - .collect( Collectors.toList() ); + final List actual = Arrays.stream(versions.getVersions(true)) + .map(ArtifactVersion::toString) + .map(VersionStub::new) + .collect(Collectors.toList()); - assertEquals( 4, actual.size() ); - assertThat( actual, hasItems( one, two, three, illegal ) ); + assertEquals(4, actual.size()); + assertThat(actual, hasItems(one, two, three, illegal)); } @Test - public void testWildcardMatching() - throws Exception - { - assertTrue( DefaultVersionsHelper.exactMatch( "*", "com.foo.bar" ) ); - assertFalse( DefaultVersionsHelper.exactMatch( "com.bar*", "com-bar" ) ); - assertTrue( DefaultVersionsHelper.exactMatch( "com?foo.bar", "com.foo.bar" ) ); - assertTrue( DefaultVersionsHelper.exactMatch( "co*.foo.b?r", "com.foo.bar" ) ); - assertTrue( DefaultVersionsHelper.exactMatch( "c*oo*r", "com.foo.bar" ) ); + public void testWildcardMatching() throws Exception { + assertTrue(DefaultVersionsHelper.exactMatch("*", "com.foo.bar")); + assertFalse(DefaultVersionsHelper.exactMatch("com.bar*", "com-bar")); + assertTrue(DefaultVersionsHelper.exactMatch("com?foo.bar", "com.foo.bar")); + assertTrue(DefaultVersionsHelper.exactMatch("co*.foo.b?r", "com.foo.bar")); + assertTrue(DefaultVersionsHelper.exactMatch("c*oo*r", "com.foo.bar")); } @Test - public void testRuleSets() - throws Exception - { + public void testRuleSets() throws Exception { VersionsHelper helper = createHelper(); - assertEquals( "no match gives default", VersionComparators.getVersionComparator( "maven" ), - helper.getVersionComparator( "net.foo", "bar" ) ); - assertEquals( "matches wildcard", VersionComparators.getVersionComparator( "mercury" ), - helper.getVersionComparator( "org.apache.maven", "plugins" ) ); - assertEquals( "exact match wins over initial match", VersionComparators.getVersionComparator( "mercury" ), - helper.getVersionComparator( "com.mycompany.custom.maven", "plugins" ) ); - assertEquals( "non-wildcard prefix wins over wildcard prefix match", - VersionComparators.getVersionComparator( "maven" ), - helper.getVersionComparator( "com.mycompany.maven.plugins", "plugins" ) ); - assertEquals( VersionComparators.getVersionComparator( "maven" ), - helper.getVersionComparator( "com.mycompany.maven", "new-maven-plugin" ) ); - assertEquals( VersionComparators.getVersionComparator( "mercury" ), - helper.getVersionComparator( "com.mycompany.maven", "old-maven-plugin" ) ); + assertEquals( + "no match gives default", + VersionComparators.getVersionComparator("maven"), + helper.getVersionComparator("net.foo", "bar")); + assertEquals( + "matches wildcard", + VersionComparators.getVersionComparator("mercury"), + helper.getVersionComparator("org.apache.maven", "plugins")); + assertEquals( + "exact match wins over initial match", + VersionComparators.getVersionComparator("mercury"), + helper.getVersionComparator("com.mycompany.custom.maven", "plugins")); + assertEquals( + "non-wildcard prefix wins over wildcard prefix match", + VersionComparators.getVersionComparator("maven"), + helper.getVersionComparator("com.mycompany.maven.plugins", "plugins")); + assertEquals( + VersionComparators.getVersionComparator("maven"), + helper.getVersionComparator("com.mycompany.maven", "new-maven-plugin")); + assertEquals( + VersionComparators.getVersionComparator("mercury"), + helper.getVersionComparator("com.mycompany.maven", "old-maven-plugin")); } - @Test - public void testMVERSIONS159ExcludedAndNotIncluded() - throws Exception - { + public void testMVERSIONS159ExcludedAndNotIncluded() throws Exception { VersionsHelper helper = createHelper(); MavenProject project = null; - Property[] propertyDefinitions = new Property[] { - new Property( "bar.version" ) - }; + Property[] propertyDefinitions = new Property[] {new Property("bar.version")}; // should not throw an IllegalStateException Map result = - helper.getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( project ) - .withPropertyDefinitions( propertyDefinitions ) - .withIncludeProperties( "foo.version" ) - .withExcludeProperties( "bar.version" ) - .withIncludeParent( false ) - .withAutoLinkItems( false ) - .build() ); - assertTrue( result.isEmpty() ); + helper.getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(project) + .withPropertyDefinitions(propertyDefinitions) + .withIncludeProperties("foo.version") + .withExcludeProperties("bar.version") + .withIncludeParent(false) + .withAutoLinkItems(false) + .build()); + assertTrue(result.isEmpty()); } @Test - public void testIsClasspathUriDetectsClassPathProtocol() throws Exception - { + public void testIsClasspathUriDetectsClassPathProtocol() throws Exception { DefaultVersionsHelper helper = createHelper(); String uri = "classpath:/p/a/c/k/a/g/e/resource.res"; - assertThat( DefaultVersionsHelper.isClasspathUri( uri ), CoreMatchers.is( true ) ); + assertThat(DefaultVersionsHelper.isClasspathUri(uri), CoreMatchers.is(true)); } @Test - public void testIsClasspathUriDetectsThatItIsDifferentProtocol() throws Exception - { + public void testIsClasspathUriDetectsThatItIsDifferentProtocol() throws Exception { DefaultVersionsHelper helper = createHelper(); String uri = "http://10.10.10.10/p/a/c/k/a/g/e/resource.res"; - assertThat( DefaultVersionsHelper.isClasspathUri( uri ), CoreMatchers.is( false ) ); + assertThat(DefaultVersionsHelper.isClasspathUri(uri), CoreMatchers.is(false)); } - - private DefaultVersionsHelper createHelper() - throws Exception - { - return createHelper( null ); + private DefaultVersionsHelper createHelper() throws Exception { + return createHelper(null); } - private static Wagon mockFileWagon( URI rulesUri ) + private static Wagon mockFileWagon(URI rulesUri) throws AuthenticationException, ConnectionException, AuthorizationException, TransferFailedException, - ResourceDoesNotExistException - { - Wagon fileWagon = mock( Wagon.class ); - doNothing().when( fileWagon ).connect( any( org.apache.maven.wagon.repository.Repository.class ), - any( AuthenticationInfo.class ), any( ProxyInfo.class ) ); - doAnswer( i -> - { - File tempFile = i.getArgument( 1 ); - Files.copy( Paths.get( rulesUri ), tempFile.toPath(), REPLACE_EXISTING ); - return null; - } ).when( fileWagon ).get( anyString(), any( File.class ) ); + ResourceDoesNotExistException { + Wagon fileWagon = mock(Wagon.class); + doNothing() + .when(fileWagon) + .connect( + any(org.apache.maven.wagon.repository.Repository.class), + any(AuthenticationInfo.class), + any(ProxyInfo.class)); + doAnswer(i -> { + File tempFile = i.getArgument(1); + Files.copy(Paths.get(rulesUri), tempFile.toPath(), REPLACE_EXISTING); + return null; + }) + .when(fileWagon) + .get(anyString(), any(File.class)); return fileWagon; } - private DefaultVersionsHelper createHelper( org.eclipse.aether.RepositorySystem aetherRepositorySystem ) - throws Exception - { - final String resourcePath = "/" + getClass().getPackage().getName().replace( '.', '/' ) + "/rules.xml"; - final String rulesUri = Objects.requireNonNull( getClass().getResource( resourcePath ) ).toExternalForm(); - MavenSession mavenSession = mock( MavenSession.class ); - when( mavenSession.getCurrentProject() ).thenReturn( mock( MavenProject.class ) ); - when( mavenSession.getCurrentProject().getRemotePluginRepositories() ) - .thenReturn( emptyList() ); - when( mavenSession.getCurrentProject().getRemotePluginRepositories() ) - .thenReturn( emptyList() ); - when( mavenSession.getRepositorySession() ).thenReturn( new DefaultRepositorySystemSession() ); + private DefaultVersionsHelper createHelper(org.eclipse.aether.RepositorySystem aetherRepositorySystem) + throws Exception { + final String resourcePath = "/" + getClass().getPackage().getName().replace('.', '/') + "/rules.xml"; + final String rulesUri = + Objects.requireNonNull(getClass().getResource(resourcePath)).toExternalForm(); + MavenSession mavenSession = mock(MavenSession.class); + when(mavenSession.getCurrentProject()).thenReturn(mock(MavenProject.class)); + when(mavenSession.getCurrentProject().getRemotePluginRepositories()).thenReturn(emptyList()); + when(mavenSession.getCurrentProject().getRemotePluginRepositories()).thenReturn(emptyList()); + when(mavenSession.getRepositorySession()).thenReturn(new DefaultRepositorySystemSession()); return new DefaultVersionsHelper.Builder() - .withRepositorySystem( lookup( RepositorySystem.class ) ) - .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonMap( singletonMap( "file", mockFileWagon( new URI( rulesUri ) ) ) ) - .withServerId( "" ) - .withRulesUri( rulesUri ) - .withLog( mock( Log.class ) ) - .withMavenSession( mavenSession ) - .withMojoExecution( mock( MojoExecution.class ) ).build(); + .withRepositorySystem(lookup(RepositorySystem.class)) + .withAetherRepositorySystem(aetherRepositorySystem) + .withWagonMap(singletonMap("file", mockFileWagon(new URI(rulesUri)))) + .withServerId("") + .withRulesUri(rulesUri) + .withLog(mock(Log.class)) + .withMavenSession(mavenSession) + .withMojoExecution(mock(MojoExecution.class)) + .build(); } @Test public void testIgnoredVersionsShouldBeTheOnlyPresentInAnEmptyRuleSet() - throws MojoExecutionException, IllegalAccessException - { + throws MojoExecutionException, IllegalAccessException { DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() - .withLog( new SystemStreamLog() ) - .withIgnoredVersions( Arrays.asList( ".*-M.", ".*-SNAPSHOT" ) ) + .withLog(new SystemStreamLog()) + .withIgnoredVersions(Arrays.asList(".*-M.", ".*-SNAPSHOT")) .build(); - RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); - assertThat( ruleSet.getIgnoreVersions(), hasSize( 2 ) ); - assertThat( ruleSet.getIgnoreVersions().stream().map( IgnoreVersion::getVersion ) - .collect( Collectors.toList() ), containsInAnyOrder( ".*-M.", ".*-SNAPSHOT" ) ); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject(versionsHelper, "ruleSet"); + assertThat(ruleSet.getIgnoreVersions(), hasSize(2)); + assertThat( + ruleSet.getIgnoreVersions().stream() + .map(IgnoreVersion::getVersion) + .collect(Collectors.toList()), + containsInAnyOrder(".*-M.", ".*-SNAPSHOT")); } @Test - public void testDefaultsShouldBePresentInAnEmptyRuleSet() - throws MojoExecutionException, IllegalAccessException - { + public void testDefaultsShouldBePresentInAnEmptyRuleSet() throws MojoExecutionException, IllegalAccessException { DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() - .withLog( new SystemStreamLog() ) - .withIgnoredVersions( singletonList( ".*-M." ) ) + .withLog(new SystemStreamLog()) + .withIgnoredVersions(singletonList(".*-M.")) .build(); - RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); - assertThat( ruleSet.getComparisonMethod(), is( "maven" ) ); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject(versionsHelper, "ruleSet"); + assertThat(ruleSet.getComparisonMethod(), is("maven")); } @Test - public void testIgnoredVersionsShouldExtendTheRuleSet() throws MojoExecutionException, IllegalAccessException - { + public void testIgnoredVersionsShouldExtendTheRuleSet() throws MojoExecutionException, IllegalAccessException { DefaultVersionsHelper versionsHelper = new DefaultVersionsHelper.Builder() - .withLog( new SystemStreamLog() ) - .withRuleSet( new RuleSet() - {{ - setIgnoreVersions( new ArrayList<>( singletonList( new IgnoreVersion() - {{ - setVersion( "1.0.0" ); - }} ) ) ); - setRules( singletonList( new Rule() - {{ - setGroupId( "org.slf4j" ); - setArtifactId( "slf4j-api" ); - setIgnoreVersions( singletonList( new IgnoreVersion() - {{ - setType( "regex" ); - setVersion( "^[^1]\\.*" ); - }} ) ); - }} ) ); - }} ) - .withIgnoredVersions( Arrays.asList( ".*-M.", ".*-SNAPSHOT" ) ) + .withLog(new SystemStreamLog()) + .withRuleSet(new RuleSet() { + { + setIgnoreVersions(new ArrayList<>(singletonList(new IgnoreVersion() { + { + setVersion("1.0.0"); + } + }))); + setRules(singletonList(new Rule() { + { + setGroupId("org.slf4j"); + setArtifactId("slf4j-api"); + setIgnoreVersions(singletonList(new IgnoreVersion() { + { + setType("regex"); + setVersion("^[^1]\\.*"); + } + })); + } + })); + } + }) + .withIgnoredVersions(Arrays.asList(".*-M.", ".*-SNAPSHOT")) .build(); - RuleSet ruleSet = (RuleSet) getVariableValueFromObject( versionsHelper, "ruleSet" ); - assertThat( ruleSet.getIgnoreVersions(), hasSize( 3 ) ); - assertThat( ruleSet.getIgnoreVersions().stream().map( IgnoreVersion::getVersion ) - .collect( Collectors.toList() ), containsInAnyOrder( ".*-M.", ".*-SNAPSHOT", "1.0.0" ) ); + RuleSet ruleSet = (RuleSet) getVariableValueFromObject(versionsHelper, "ruleSet"); + assertThat(ruleSet.getIgnoreVersions(), hasSize(3)); + assertThat( + ruleSet.getIgnoreVersions().stream() + .map(IgnoreVersion::getVersion) + .collect(Collectors.toList()), + containsInAnyOrder(".*-M.", ".*-SNAPSHOT", "1.0.0")); } - } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java index 4e50637ec6..5b13ccbe2f 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java @@ -49,17 +49,15 @@ /** * Tests the methods of {@link PomHelper}. */ -public class PomHelperTest extends AbstractMojoTestCase -{ +public class PomHelperTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); private static final XMLInputFactory INPUT_FACTORY = XMLInputFactory2.newInstance(); @BeforeClass - public static void setUpClass() - { - INPUT_FACTORY.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); + public static void setUpClass() { + INPUT_FACTORY.setProperty(P_PRESERVE_LOCATION, Boolean.TRUE); } /** @@ -69,199 +67,158 @@ public static void setUpClass() * @throws Exception if the test fails. */ @Test - public void testLongProperties() - throws Exception - { - URL url = getClass().getResource( "PomHelperTest.testLongProperties.pom.xml" ); + public void testLongProperties() throws Exception { + URL url = getClass().getResource("PomHelperTest.testLongProperties.pom.xml"); assert url != null; - File file = new File( url.getPath() ); - StringBuilder input = PomHelper.readXmlFile( file ); + File file = new File(url.getPath()); + StringBuilder input = PomHelper.readXmlFile(file); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( P_PRESERVE_LOCATION, Boolean.TRUE ); + inputFactory.setProperty(P_PRESERVE_LOCATION, Boolean.TRUE); - ModifiedPomXMLEventReader pom = new ModifiedPomXMLEventReader( input, inputFactory, file.getAbsolutePath() ); + ModifiedPomXMLEventReader pom = new ModifiedPomXMLEventReader(input, inputFactory, file.getAbsolutePath()); - String oldVersion = PomHelper.getProjectVersion( pom ); + String oldVersion = PomHelper.getProjectVersion(pom); String newVersion = "1"; - assertTrue( "The pom has been modified", PomHelper.setProjectVersion( pom, newVersion ) ); + assertTrue("The pom has been modified", PomHelper.setProjectVersion(pom, newVersion)); - assertEquals( newVersion, PomHelper.getProjectVersion( pom ) ); + assertEquals(newVersion, PomHelper.getProjectVersion(pom)); - assertNotSame( oldVersion, newVersion ); + assertNotSame(oldVersion, newVersion); } @Test - public void testGroupIdNotOnChildPom() - throws Exception - { - URL url = getClass().getResource( "PomHelperTest.noGroupIdOnChild.pom.xml" ); + public void testGroupIdNotOnChildPom() throws Exception { + URL url = getClass().getResource("PomHelperTest.noGroupIdOnChild.pom.xml"); assert url != null; - StringBuilder input = PomHelper.readXmlFile( new File( url.getPath() ) ); + StringBuilder input = PomHelper.readXmlFile(new File(url.getPath())); MavenXpp3Reader reader = new MavenXpp3Reader(); - Model model = reader.read( new StringReader( input.toString() ) ); + Model model = reader.read(new StringReader(input.toString())); - assertEquals( "org.myorg", PomHelper.getGroupId( model ) ); + assertEquals("org.myorg", PomHelper.getGroupId(model)); } @Test - public void testVersionVersionEqual() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "1.0.8", "1.0.8" ) ); + public void testVersionVersionEqual() throws Exception { + assertTrue(PomHelper.isVersionOverlap("1.0.8", "1.0.8")); } @Test - public void testVersionVersionDiffer() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "1.0.8", "1.0.0" ) ); + public void testVersionVersionDiffer() throws Exception { + assertFalse(PomHelper.isVersionOverlap("1.0.8", "1.0.0")); } @Test - public void testVersionRangeIntersect() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "1.0.8", "[1.0.3,1.1.0]" ) ); + public void testVersionRangeIntersect() throws Exception { + assertTrue(PomHelper.isVersionOverlap("1.0.8", "[1.0.3,1.1.0]")); } @Test - public void testVersionRangeDisjoint() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[0.0.1,1.0.0]" ) ); + public void testVersionRangeDisjoint() throws Exception { + assertFalse(PomHelper.isVersionOverlap("1.0.8", "[0.0.1,1.0.0]")); } @Test - public void testVersionLeftOpenRangeDisjoint() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[,1.0.0]" ) ); + public void testVersionLeftOpenRangeDisjoint() throws Exception { + assertFalse(PomHelper.isVersionOverlap("1.0.8", "[,1.0.0]")); } @Test - public void testVersionRightOpenRangeDisjoint() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "1.0.8", "[1.1.0,)" ) ); + public void testVersionRightOpenRangeDisjoint() throws Exception { + assertFalse(PomHelper.isVersionOverlap("1.0.8", "[1.1.0,)")); } @Test - public void testEmptyRange() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "1.0.8", "" ) ); + public void testEmptyRange() throws Exception { + assertTrue(PomHelper.isVersionOverlap("1.0.8", "")); } @Test - public void testRangeEmpty() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "[1.0.5,1.0.8]", "" ) ); + public void testRangeEmpty() throws Exception { + assertTrue(PomHelper.isVersionOverlap("[1.0.5,1.0.8]", "")); } @Test - public void testRangeRangeIntersect() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "[1.0.5,1.0.8]", "[1.0.7,1.1.0]" ) ); - + public void testRangeRangeIntersect() throws Exception { + assertTrue(PomHelper.isVersionOverlap("[1.0.5,1.0.8]", "[1.0.7,1.1.0]")); } @Test - public void testRangeRangeDisjoint() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "[1.0.5,1.0.6]", "[1.0.7,1.1.0]" ) ); - + public void testRangeRangeDisjoint() throws Exception { + assertFalse(PomHelper.isVersionOverlap("[1.0.5,1.0.6]", "[1.0.7,1.1.0]")); } @Test - public void testRangeVersionDisjoint() - throws Exception - { - assertFalse( PomHelper.isVersionOverlap( "[1.0.5,1.0.6]", "1.0.8" ) ); - + public void testRangeVersionDisjoint() throws Exception { + assertFalse(PomHelper.isVersionOverlap("[1.0.5,1.0.6]", "1.0.8")); } @Test - public void testRangeVersionIntersect() - throws Exception - { - assertTrue( PomHelper.isVersionOverlap( "[1.0.0,2.0.0]", "1.0.8" ) ); - + public void testRangeVersionIntersect() throws Exception { + assertTrue(PomHelper.isVersionOverlap("[1.0.0,2.0.0]", "1.0.8")); } @Test - public void testSetElementValueExistingValue() throws XMLStreamException - { + public void testSetElementValueExistingValue() throws XMLStreamException { ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( - new StringBuilder( "test" ), - INPUT_FACTORY, null ); + new StringBuilder("test"), + INPUT_FACTORY, + null); - assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", - "child", "value" ), is( true ) ); - MatcherAssert.assertThat( xmlEventReader, - matches( "value" ) ); + assertThat(PomHelper.setElementValue(xmlEventReader, "/super-parent/parent", "child", "value"), is(true)); + MatcherAssert.assertThat( + xmlEventReader, matches("value")); } @Test - public void testSetElementValueEmptyChild() throws XMLStreamException - { + public void testSetElementValueEmptyChild() throws XMLStreamException { ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( - new StringBuilder( "" ), INPUT_FACTORY, null ); + new StringBuilder(""), INPUT_FACTORY, null); - assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", - "child", "value" ), is( true ) ); - MatcherAssert.assertThat( xmlEventReader, - matches( "value" ) ); + assertThat(PomHelper.setElementValue(xmlEventReader, "/super-parent/parent", "child", "value"), is(true)); + MatcherAssert.assertThat( + xmlEventReader, matches("value")); } @Test - public void testSetElementValueNewValueEmptyParent() throws XMLStreamException - { + public void testSetElementValueNewValueEmptyParent() throws XMLStreamException { ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( - new StringBuilder( "" ), INPUT_FACTORY, null ); + new StringBuilder(""), INPUT_FACTORY, null); - assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", - "child", "value" ), is( true ) ); - MatcherAssert.assertThat( xmlEventReader, - matches( "value" ) ); + assertThat(PomHelper.setElementValue(xmlEventReader, "/super-parent/parent", "child", "value"), is(true)); + MatcherAssert.assertThat( + xmlEventReader, matches("value")); } @Test - public void testSetElementValueNewValueNoChild() throws XMLStreamException - { + public void testSetElementValueNewValueNoChild() throws XMLStreamException { ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( - new StringBuilder( "" ), INPUT_FACTORY, null ); + new StringBuilder(""), INPUT_FACTORY, null); - assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", - "child", "value" ), is( true ) ); - MatcherAssert.assertThat( xmlEventReader, - matches( "value" ) ); + assertThat(PomHelper.setElementValue(xmlEventReader, "/super-parent/parent", "child", "value"), is(true)); + MatcherAssert.assertThat( + xmlEventReader, matches("value")); } @Test - public void testSetProjectValueNewValueNonEmptyParent() throws XMLStreamException - { + public void testSetProjectValueNewValueNonEmptyParent() throws XMLStreamException { ModifiedPomXMLEventReader xmlEventReader = new ModifiedPomXMLEventReader( - new StringBuilder( "test" ), INPUT_FACTORY, - null ); + new StringBuilder("test"), + INPUT_FACTORY, + null); - assertThat( PomHelper.setElementValue( xmlEventReader, "/super-parent/parent", - "child", "value" ), is( true ) ); - MatcherAssert.assertThat( xmlEventReader, - matches( "value" ) ); + assertThat(PomHelper.setElementValue(xmlEventReader, "/super-parent/parent", "child", "value"), is(true)); + MatcherAssert.assertThat( + xmlEventReader, matches("value")); } @Test - public void testIssue505ChildModules() throws Exception - { - MavenProject project = mojoRule.readMavenProject( - new File( "src/test/resources/org/codehaus/mojo/versions/api/issue-505" ) ); - Map reactorModels = PomHelper.getReactorModels( project, new SystemStreamLog() ); - assertThat( reactorModels.keySet(), hasSize( 3 ) ); + public void testIssue505ChildModules() throws Exception { + MavenProject project = + mojoRule.readMavenProject(new File("src/test/resources/org/codehaus/mojo/versions/api/issue-505")); + Map reactorModels = PomHelper.getReactorModels(project, new SystemStreamLog()); + assertThat(reactorModels.keySet(), hasSize(3)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java index 422323bebd..67678c23d9 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/DependencyFilterTest.java @@ -34,193 +34,132 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.empty; -class DependencyFilterTest -{ +class DependencyFilterTest { @Nested - class RemoveFromTest - { - private final Set input = new HashSet<>( asList( - DependencyBuilder.dependencyWith( "foo", "bar", "1" ), - DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), - DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) - ) ); + class RemoveFromTest { + private final Set input = new HashSet<>(asList( + DependencyBuilder.dependencyWith("foo", "bar", "1"), + DependencyBuilder.dependencyWith("localhost", "my-api", "2"), + DependencyBuilder.dependencyWith("localhost", "my-impl", "3"))); @Test - void removesExcludedDepsWithExactMatch() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( - Collections.singletonList( "localhost:my-impl:3" ) ); + void removesExcludedDepsWithExactMatch() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:my-impl:3")); - Set actual = exclusions.removingFrom( input ); + Set actual = exclusions.removingFrom(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "foo", "bar", "1" ), - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) - ) - ); + actual, + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV("foo", "bar", "1"), HasGAVMatcher.hasGAV("localhost", "my-api", "2"))); } @Test - void removesExcludedDepsWithWildcardInVersion() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( - Collections.singletonList( "localhost:my-impl:*" ) ); + void removesExcludedDepsWithWildcardInVersion() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:my-impl:*")); - Set actual = exclusions.removingFrom( input ); + Set actual = exclusions.removingFrom(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "foo", "bar", "1" ), - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) - ) - ); + actual, + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV("foo", "bar", "1"), HasGAVMatcher.hasGAV("localhost", "my-api", "2"))); } @Test - void removesExcludedDepsWithWildcardInGroupId() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "localhost:*:*" ) ); + void removesExcludedDepsWithWildcardInGroupId() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:*:*")); - Set actual = exclusions.removingFrom( input ); + Set actual = exclusions.removingFrom(input); - MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "foo", "bar", "1" ) - ) - ); + MatcherAssert.assertThat(actual, Matchers.containsInAnyOrder(HasGAVMatcher.hasGAV("foo", "bar", "1"))); } @Test - void removesExcludedDepsWithAllWildcards() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "*:*:*" ) ); + void removesExcludedDepsWithAllWildcards() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("*:*:*")); - Set actual = exclusions.removingFrom( input ); + Set actual = exclusions.removingFrom(input); - assertThat( - actual, - empty() - ); + assertThat(actual, empty()); } @Test - void removesMultiplePatterns() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( - "*:my-api", - "*:my-impl" - ) ); + void removesMultiplePatterns() { + DependencyFilter exclusions = DependencyFilter.parseFrom(asList("*:my-api", "*:my-impl")); - Set actual = exclusions.removingFrom( input ); + Set actual = exclusions.removingFrom(input); - MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "foo", "bar", "1" ) - ) - ); + MatcherAssert.assertThat(actual, Matchers.containsInAnyOrder(HasGAVMatcher.hasGAV("foo", "bar", "1"))); } - } @Nested - class RetainingInTest - { - private final Set input = new HashSet<>( asList( - DependencyBuilder.dependencyWith( "foo", "bar", "1" ), - DependencyBuilder.dependencyWith( "localhost", "my-api", "2" ), - DependencyBuilder.dependencyWith( "localhost", "my-impl", "3" ) - ) ); + class RetainingInTest { + private final Set input = new HashSet<>(asList( + DependencyBuilder.dependencyWith("foo", "bar", "1"), + DependencyBuilder.dependencyWith("localhost", "my-api", "2"), + DependencyBuilder.dependencyWith("localhost", "my-impl", "3"))); @Test - void retainsOnlyDepsWithExactMatch() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( - Collections.singletonList( "localhost:my-impl:3" ) ); + void retainsOnlyDepsWithExactMatch() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:my-impl:3")); - Set actual = exclusions.retainingIn( input ); + Set actual = exclusions.retainingIn(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) - ) - ); + actual, Matchers.containsInAnyOrder(HasGAVMatcher.hasGAV("localhost", "my-impl", "3"))); } @Test - void retainsOnlyDepsMatchingWildcardInVersion() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( - Collections.singletonList( "localhost:my-api:*" ) ); + void retainsOnlyDepsMatchingWildcardInVersion() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:my-api:*")); - Set actual = exclusions.retainingIn( input ); + Set actual = exclusions.retainingIn(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ) - ) - ); + actual, Matchers.containsInAnyOrder(HasGAVMatcher.hasGAV("localhost", "my-api", "2"))); } @Test - void retainsOnlyDepsWithMultipleWildcards() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "localhost:my-*:*" ) ); + void retainsOnlyDepsWithMultipleWildcards() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("localhost:my-*:*")); - Set actual = exclusions.retainingIn( input ); + Set actual = exclusions.retainingIn(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), - HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) - ) - ); + actual, + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV("localhost", "my-api", "2"), + HasGAVMatcher.hasGAV("localhost", "my-impl", "3"))); } @Test - void retainsAllOnAllWildcards() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( Collections.singletonList( "*:*:*" ) ); + void retainsAllOnAllWildcards() { + DependencyFilter exclusions = DependencyFilter.parseFrom(Collections.singletonList("*:*:*")); - Set actual = exclusions.retainingIn( input ); + Set actual = exclusions.retainingIn(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "foo", "bar", "1" ), - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), - HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) - ) - ); + actual, + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV("foo", "bar", "1"), + HasGAVMatcher.hasGAV("localhost", "my-api", "2"), + HasGAVMatcher.hasGAV("localhost", "my-impl", "3"))); } - @Test - void retainsMultiplePatterns() - { - DependencyFilter exclusions = DependencyFilter.parseFrom( asList( - "*:my-api", - "*:my-impl" - ) ); + void retainsMultiplePatterns() { + DependencyFilter exclusions = DependencyFilter.parseFrom(asList("*:my-api", "*:my-impl")); - Set actual = exclusions.retainingIn( input ); + Set actual = exclusions.retainingIn(input); MatcherAssert.assertThat( - actual, - Matchers.containsInAnyOrder( - HasGAVMatcher.hasGAV( "localhost", "my-api", "2" ), - HasGAVMatcher.hasGAV( "localhost", "my-impl", "3" ) - ) - ); + actual, + Matchers.containsInAnyOrder( + HasGAVMatcher.hasGAV("localhost", "my-api", "2"), + HasGAVMatcher.hasGAV("localhost", "my-impl", "3"))); } } - } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java index e9dd54321f..07abd297f6 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/HasGAVMatcher.java @@ -28,42 +28,36 @@ /** * Hamcrest-Matcher that matches a {@link Dependency} GAV */ -public class HasGAVMatcher extends TypeSafeMatcher -{ +public class HasGAVMatcher extends TypeSafeMatcher { private final String groupId; private final String artifactId; private final String version; - public HasGAVMatcher( String groupId, String artifactId, String version ) - { + public HasGAVMatcher(String groupId, String artifactId, String version) { this.groupId = groupId; this.artifactId = artifactId; this.version = version; } - public static HasGAVMatcher hasGAVOf( Dependency dependency ) - { - return hasGAV( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ); + public static HasGAVMatcher hasGAVOf(Dependency dependency) { + return hasGAV(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion()); } - public static HasGAVMatcher hasGAV( String groupId, String artifactId, String version ) - { - return new HasGAVMatcher( groupId, artifactId, version ); + public static HasGAVMatcher hasGAV(String groupId, String artifactId, String version) { + return new HasGAVMatcher(groupId, artifactId, version); } @Override - protected boolean matchesSafely( Dependency item ) - { - boolean result = Objects.equals( groupId, item.getGroupId() ) - && Objects.equals( artifactId, item.getArtifactId() ) - && Objects.equals( version, item.getVersion() ); + protected boolean matchesSafely(Dependency item) { + boolean result = Objects.equals(groupId, item.getGroupId()) + && Objects.equals(artifactId, item.getArtifactId()) + && Objects.equals(version, item.getVersion()); return result; } @Override - public void describeTo( Description description ) - { - description.appendText( String.format( "has GAV %s:%s:%s", groupId, artifactId, version ) ); + public void describeTo(Description description) { + description.appendText(String.format("has GAV %s:%s:%s", groupId, artifactId, version)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java index 62dd78791c..a662ecabe7 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/TokenizedMatcherTest.java @@ -10,155 +10,116 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -class TokenizedMatcherTest -{ +class TokenizedMatcherTest { @Nested - class ExactMatchPattern - { - - private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "group:artifact:1.0:jar:tests:compile" ); + class ExactMatchPattern { + private final TokenizedMatcher matcher = TokenizedMatcher.parse("group:artifact:1.0:jar:tests:compile"); @Test - void acceptsExactMatch() - { - Dependency input = DependencyBuilder.dependencyWith( - "group", - "artifact", - "1.0", - "jar", - "tests", - "compile" ); - - boolean actual = matcher.test( input ); - - assertTrue( actual ); - } + void acceptsExactMatch() { + Dependency input = DependencyBuilder.dependencyWith("group", "artifact", "1.0", "jar", "tests", "compile"); + boolean actual = matcher.test(input); + + assertTrue(actual); + } @ParameterizedTest - @CsvSource( { + @CsvSource({ "xxxxx, artifact, 1.0, jar, tests, compile", "group, xxxxxxxx, 1.0, jar, tests, compile", "group, artifact, xxx, jar, tests, compile", "group, artifact, 1.0, xxx, tests, compile", "group, artifact, 1.0, jar, xxxxx, compile", "group, artifact, 1.0, jar, tests, xxxxxxx", - } ) + }) void rejectsDifferingFields( - String group, String artifact, String version, String type, String classifier, String scope - ) - { + String group, String artifact, String version, String type, String classifier, String scope) { - Dependency input = DependencyBuilder.dependencyWith( - group, - artifact, - version, - type, - classifier, - scope ); + Dependency input = DependencyBuilder.dependencyWith(group, artifact, version, type, classifier, scope); - boolean actual = matcher.test( input ); + boolean actual = matcher.test(input); - assertFalse( actual ); + assertFalse(actual); } } @Nested - class WildcardPattern - { + class WildcardPattern { @Test - void acceptsWildcards() - { - Dependency input = DependencyBuilder.dependencyWith( - "foo", - "my-api", - "foo", - "foo", - "foo", - "foo" ); - - TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:my-api" ); - - boolean actual = matcher.test( input ); - - assertTrue( actual ); + void acceptsWildcards() { + Dependency input = DependencyBuilder.dependencyWith("foo", "my-api", "foo", "foo", "foo", "foo"); + + TokenizedMatcher matcher = TokenizedMatcher.parse("*:my-api"); + + boolean actual = matcher.test(input); + + assertTrue(actual); } @Nested - class NullClassifier - { + class NullClassifier { private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder() - .withGroupId( "foo" ) - .withArtifactId( "foo" ) - .withVersion( "foo" ) - .withType( "foo" ) - .withClassifier( "foo" ) - .withScope( "foo" ); + .withGroupId("foo") + .withArtifactId("foo") + .withVersion("foo") + .withType("foo") + .withClassifier("foo") + .withScope("foo"); - private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:*:*:*:null:*" ); + private final TokenizedMatcher matcher = TokenizedMatcher.parse("*:*:*:*:null:*"); @Test - void acceptsNullScope() - { - Dependency input = depBuilder.withClassifier( null ).build(); + void acceptsNullScope() { + Dependency input = depBuilder.withClassifier(null).build(); - boolean actual = matcher.test( input ); + boolean actual = matcher.test(input); - assertTrue( actual ); + assertTrue(actual); } @Test - void rejectsNonnullScope() - { - Dependency input = depBuilder.withClassifier( "tests" ).build(); + void rejectsNonnullScope() { + Dependency input = depBuilder.withClassifier("tests").build(); - boolean actual = matcher.test( input ); + boolean actual = matcher.test(input); - assertFalse( actual ); + assertFalse(actual); } } @Nested - class NullScope - { + class NullScope { private final DependencyBuilder depBuilder = DependencyBuilder.newBuilder() - .withGroupId( "foo" ) - .withArtifactId( "foo" ) - .withVersion( "foo" ) - .withType( "foo" ) - .withClassifier( "foo" ) - .withScope( "foo" ); + .withGroupId("foo") + .withArtifactId("foo") + .withVersion("foo") + .withType("foo") + .withClassifier("foo") + .withScope("foo"); - private final TokenizedMatcher matcher = TokenizedMatcher - .parse( "*:*:*:*:*:null" ); + private final TokenizedMatcher matcher = TokenizedMatcher.parse("*:*:*:*:*:null"); @Test - void acceptsNullScope() - { - Dependency input = depBuilder.withScope( null ).build(); + void acceptsNullScope() { + Dependency input = depBuilder.withScope(null).build(); - boolean actual = matcher.test( input ); + boolean actual = matcher.test(input); - assertTrue( actual ); + assertTrue(actual); } @Test - void rejectsNonnullScope() - { - Dependency input = depBuilder.withScope( "compile" ).build(); + void rejectsNonnullScope() { + Dependency input = depBuilder.withScope("compile").build(); - boolean actual = matcher.test( input ); + boolean actual = matcher.test(input); - assertFalse( actual ); + assertFalse(actual); } } - } - } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java index c6b4717cba..1b072b11c1 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/filtering/WildcardMatcherTest.java @@ -8,258 +8,219 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -class WildcardMatcherTest -{ +class WildcardMatcherTest { @Nested - class ExactValueTest - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf" ); + class ExactValueTest { + private final WildcardMatcher matcher = WildcardMatcher.parse("asdf"); @Test - void matchesTheExactInput() - { - boolean actual = matcher.test( "asdf" ); + void matchesTheExactInput() { + boolean actual = matcher.test("asdf"); - assertTrue( actual ); + assertTrue(actual); } @Test - void rejectsNull() - { - boolean actual = matcher.test( null ); + void rejectsNull() { + boolean actual = matcher.test(null); - assertFalse( actual ); + assertFalse(actual); } @ParameterizedTest - @ValueSource( strings = { - "", - " ", - "a", - "as", - "asf", - "asXf", - "asdfx", - } ) - void rejectsDifferentInput( String input ) - { - boolean actual = matcher.test( input ); - - assertFalse( actual ); + @ValueSource( + strings = { + "", " ", "a", "as", "asf", "asXf", "asdfx", + }) + void rejectsDifferentInput(String input) { + boolean actual = matcher.test(input); + + assertFalse(actual); } } @Nested - class WildcardOnlyPattern - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "*" ); + class WildcardOnlyPattern { + private final WildcardMatcher matcher = WildcardMatcher.parse("*"); @Test - void acceptsNull() - { - boolean actual = matcher.test( null ); + void acceptsNull() { + boolean actual = matcher.test(null); - assertTrue( actual ); + assertTrue(actual); } - @ParameterizedTest - @ValueSource( strings = { - "", - " ", - "a", - "asdfx", - } ) - void accepts( String input ) - { - boolean actual = matcher.test( input ); - - assertTrue( actual ); - } + @ValueSource( + strings = { + "", " ", "a", "asdfx", + }) + void accepts(String input) { + boolean actual = matcher.test(input); + assertTrue(actual); + } } - @Nested - class PatternWithWildcardAtStartAndEnd - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf*" ); + class PatternWithWildcardAtStartAndEnd { + private final WildcardMatcher matcher = WildcardMatcher.parse("*asdf*"); @Test - void rejectsNull() - { - boolean actual = matcher.test( null ); + void rejectsNull() { + boolean actual = matcher.test(null); - assertFalse( actual ); + assertFalse(actual); } - @ParameterizedTest - @ValueSource( strings = { - "asdf", - "fooasdf", - "asdfbar", - "fooasdfbar", - " asdf", - "asdf ", - " asdf ", - } ) - void accepts( String input ) - { - boolean actual = matcher.test( input ); - - assertTrue( actual ); + @ValueSource( + strings = { + "asdf", + "fooasdf", + "asdfbar", + "fooasdfbar", + " asdf", + "asdf ", + " asdf ", + }) + void accepts(String input) { + boolean actual = matcher.test(input); + + assertTrue(actual); } @ParameterizedTest - @ValueSource( strings = { - "", - " ", - "foo", - } ) - void rejects( String input ) - { - boolean actual = matcher.test( input ); - - assertFalse( actual ); - } + @ValueSource( + strings = { + "", " ", "foo", + }) + void rejects(String input) { + boolean actual = matcher.test(input); + assertFalse(actual); + } } @Nested - class PatternStartingWithWildcard - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "*asdf" ); + class PatternStartingWithWildcard { + private final WildcardMatcher matcher = WildcardMatcher.parse("*asdf"); @Test - void rejectsNull() - { - boolean actual = matcher.test( null ); + void rejectsNull() { + boolean actual = matcher.test(null); - assertFalse( actual ); + assertFalse(actual); } - @ParameterizedTest - @ValueSource( strings = { - "asdf", - "asdfasdf", - " asdf", - "Xasdf", - "99999999asdf", - } ) - void accepts( String input ) - { - boolean actual = matcher.test( input ); - - assertTrue( actual ); + @ValueSource( + strings = { + "asdf", + "asdfasdf", + " asdf", + "Xasdf", + "99999999asdf", + }) + void accepts(String input) { + boolean actual = matcher.test(input); + + assertTrue(actual); } @ParameterizedTest - @ValueSource( strings = { - "", - " ", - "asdf ", - "asdfx", - "asdfbanana", - } ) - void rejects( String input ) - { - boolean actual = matcher.test( input ); - - assertFalse( actual ); + @ValueSource( + strings = { + "", + " ", + "asdf ", + "asdfx", + "asdfbanana", + }) + void rejects(String input) { + boolean actual = matcher.test(input); + + assertFalse(actual); } - } @Nested - class PatternEndingWithWildcard - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "asdf*" ); + class PatternEndingWithWildcard { + private final WildcardMatcher matcher = WildcardMatcher.parse("asdf*"); @Test - void rejectsNull() - { - boolean actual = matcher.test( null ); + void rejectsNull() { + boolean actual = matcher.test(null); - assertFalse( actual ); + assertFalse(actual); } - @ParameterizedTest - @ValueSource( strings = { - "asdf", - "asdfasdf", - "asdf ", - "asdfx", - "asdfbanana", - } ) - void accepts( String input ) - { - boolean actual = matcher.test( input ); - - assertTrue( actual ); + @ValueSource( + strings = { + "asdf", + "asdfasdf", + "asdf ", + "asdfx", + "asdfbanana", + }) + void accepts(String input) { + boolean actual = matcher.test(input); + + assertTrue(actual); } @ParameterizedTest - @ValueSource( strings = { - "", - " ", - " asdf", - "Xasdf", - "99999999asdf", - } ) - void rejects( String input ) - { - boolean actual = matcher.test( input ); - - assertFalse( actual ); + @ValueSource( + strings = { + "", + " ", + " asdf", + "Xasdf", + "99999999asdf", + }) + void rejects(String input) { + boolean actual = matcher.test(input); + + assertFalse(actual); } - } @Nested - class PatternWithVersionRange - { - private final WildcardMatcher matcher = WildcardMatcher.parse( "[2.0,3.0]" ); + class PatternWithVersionRange { + private final WildcardMatcher matcher = WildcardMatcher.parse("[2.0,3.0]"); @Test - void rejectsNull() - { - boolean actual = matcher.test( null ); + void rejectsNull() { + boolean actual = matcher.test(null); - assertFalse( actual ); + assertFalse(actual); } - @ParameterizedTest - @ValueSource( strings = { - "2.0", - "2.1", - "3.0", - } ) - void accepts( String input ) - { - boolean actual = matcher.test( input ); - - assertTrue( actual ); + @ValueSource( + strings = { + "2.0", "2.1", "3.0", + }) + void accepts(String input) { + boolean actual = matcher.test(input); + + assertTrue(actual); } @ParameterizedTest - @ValueSource( strings = { - "", - " ", - "1.0", - "2.0-SNAPSHOT", - "4.0", - } ) - void rejects( String input ) - { - boolean actual = matcher.test( input ); - - assertFalse( actual ); + @ValueSource( + strings = { + "", + " ", + "1.0", + "2.0-SNAPSHOT", + "4.0", + }) + void rejects(String input) { + boolean actual = matcher.test(input); + + assertFalse(actual); } - } - } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java index 32b4f3db14..a172eac1d7 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/BoundArtifactVersionTest.java @@ -33,77 +33,60 @@ /** * Unit tests for {@link BoundArtifactVersion} */ -public class BoundArtifactVersionTest -{ +public class BoundArtifactVersionTest { @Test - public void testMajorUpperBoundGreaterThanNextMajor() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3" ), - MAJOR ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "2.0.0" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testMajorUpperBoundGreaterThanNextMajor() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.2.3"), MAJOR); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("2.0.0"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testSubIncrementalUpperBoundGreaterThanNextSubIncremental() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.2.3-2" ), - SUBINCREMENTAL ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.2.3-3" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testSubIncrementalUpperBoundGreaterThanNextSubIncremental() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.2.3-2"), SUBINCREMENTAL); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.2.3-3"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testVersionShorterThanSegment() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - INCREMENTAL ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testVersionShorterThanSegment() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.1"), INCREMENTAL); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.1.3"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testVersionBoundArtifactVersionShorterThanConcreteVersionAndSegment() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - SUBINCREMENTAL ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); - assertThat( bound.compareTo( artifactVersion ), lessThan( 0 ) ); + public void testVersionBoundArtifactVersionShorterThanConcreteVersionAndSegment() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.1"), SUBINCREMENTAL); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.1.3"); + assertThat(bound.compareTo(artifactVersion), lessThan(0)); } @Test - public void testVersionSubIncrementalBoundGreaterThanSubIncremental() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - SUBINCREMENTAL ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.0-2" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testVersionSubIncrementalBoundGreaterThanSubIncremental() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.1"), SUBINCREMENTAL); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.1.0-2"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testVersionSubIncrementalBoundGreaterThanIncremental() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - INCREMENTAL ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.1.3" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testVersionSubIncrementalBoundGreaterThanIncremental() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.1"), INCREMENTAL); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.1.3"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testVersionSubIncrementalBoundGreaterThanMinor() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.1" ), - MINOR ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.3" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testVersionSubIncrementalBoundGreaterThanMinor() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.1"), MINOR); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.3"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } @Test - public void testSnapshotWithSubIncremental() - { - BoundArtifactVersion bound = new BoundArtifactVersion( new DefaultArtifactVersion( "1.0.0-SNAPSHOT" ), - MINOR ); - ArtifactVersion artifactVersion = new DefaultArtifactVersion( "1.0.0" ); - assertThat( bound.compareTo( artifactVersion ), greaterThan( 0 ) ); + public void testSnapshotWithSubIncremental() { + BoundArtifactVersion bound = new BoundArtifactVersion(new DefaultArtifactVersion("1.0.0-SNAPSHOT"), MINOR); + ArtifactVersion artifactVersion = new DefaultArtifactVersion("1.0.0"); + assertThat(bound.compareTo(artifactVersion), greaterThan(0)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java index 452ef34786..1a072c2dc5 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MavenVersionComparatorTest.java @@ -29,54 +29,49 @@ import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.core.Is.is; -public class MavenVersionComparatorTest extends VersionComparatorTestBase -{ - public MavenVersionComparatorTest() - { - super( new MavenVersionComparator() ); +public class MavenVersionComparatorTest extends VersionComparatorTestBase { + public MavenVersionComparatorTest() { + super(new MavenVersionComparator()); } @Test - public void testSegmentCounting() - { - assertThat( 3, is( instance.getSegmentCount( version( "5" ) ) ) ); - assertThat( 3, is( instance.getSegmentCount( version( "5.0" ) ) ) ); - assertThat( 4, is( instance.getSegmentCount( version( "5-0" ) ) ) ); - assertThat( 1, is( instance.getSegmentCount( version( "5.3.a" ) ) ) ); - assertThat( 1, is( instance.getSegmentCount( version( "5.0.a.1.4.5" ) ) ) ); - assertThat( 3, is( instance.getSegmentCount( version( "" ) ) ) ); + public void testSegmentCounting() { + assertThat(3, is(instance.getSegmentCount(version("5")))); + assertThat(3, is(instance.getSegmentCount(version("5.0")))); + assertThat(4, is(instance.getSegmentCount(version("5-0")))); + assertThat(1, is(instance.getSegmentCount(version("5.3.a")))); + assertThat(1, is(instance.getSegmentCount(version("5.0.a.1.4.5")))); + assertThat(3, is(instance.getSegmentCount(version("")))); } @Test - public void testUpperBoundaryCustom() - { - assertThat( instance.compare( new BoundArtifactVersion( version( "1.2.3" ), - INCREMENTAL ), version( "1.2.3-ANDRZEJ" ) ), greaterThan( 0 ) ); + public void testUpperBoundaryCustom() { + assertThat( + instance.compare(new BoundArtifactVersion(version("1.2.3"), INCREMENTAL), version("1.2.3-ANDRZEJ")), + greaterThan(0)); } @Test - public void testUpperBoundaryRelease() - { - assertThat( instance.compare( new BoundArtifactVersion( version( "1.1.0" ), - INCREMENTAL ), version( "1.1.0" ) ), greaterThan( 0 ) ); + public void testUpperBoundaryRelease() { + assertThat( + instance.compare(new BoundArtifactVersion(version("1.1.0"), INCREMENTAL), version("1.1.0")), + greaterThan(0)); } @Test - public void testUpperBoundarySnapshot() - { - assertThat( instance.compare( new BoundArtifactVersion( version( "1.1.0" ), - INCREMENTAL ), version( "1.1.0-SNAPSHOT" ) ), greaterThan( 0 ) ); + public void testUpperBoundarySnapshot() { + assertThat( + instance.compare(new BoundArtifactVersion(version("1.1.0"), INCREMENTAL), version("1.1.0-SNAPSHOT")), + greaterThan(0)); } @Test - public void testScopeLessThanNumSegmentsUpper() - { - ArtifactVersion artifactVersion = new BoundArtifactVersion( version( "1.1" ), - SUBINCREMENTAL ); - assertThat( artifactVersion.compareTo( version( "1.0.1" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( version( "1.1-SNAPSHOT" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( version( "1.1" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( version( "1.1.0-2" ) ), greaterThan( 0 ) ); - assertThat( artifactVersion.compareTo( version( "1.1.1-2" ) ), lessThan( 0 ) ); + public void testScopeLessThanNumSegmentsUpper() { + ArtifactVersion artifactVersion = new BoundArtifactVersion(version("1.1"), SUBINCREMENTAL); + assertThat(artifactVersion.compareTo(version("1.0.1")), greaterThan(0)); + assertThat(artifactVersion.compareTo(version("1.1-SNAPSHOT")), greaterThan(0)); + assertThat(artifactVersion.compareTo(version("1.1")), greaterThan(0)); + assertThat(artifactVersion.compareTo(version("1.1.0-2")), greaterThan(0)); + assertThat(artifactVersion.compareTo(version("1.1.1-2")), lessThan(0)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java index 9af7bbc4c6..f5e8683cba 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/MercuryVersionComparatorTest.java @@ -24,23 +24,18 @@ import static org.junit.Assert.assertEquals; -public class MercuryVersionComparatorTest extends VersionComparatorTestBase -{ - public MercuryVersionComparatorTest() - { - super( new MercuryVersionComparator() ); +public class MercuryVersionComparatorTest extends VersionComparatorTestBase { + public MercuryVersionComparatorTest() { + super(new MercuryVersionComparator()); } @Test - public void testSegmentCounting() - { - assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); - assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); - assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5-0" ) ) ); - assertEquals( 3, instance.getSegmentCount( new DefaultArtifactVersion( "5.3.a" ) ) ); - assertEquals( 6, instance.getSegmentCount( new DefaultArtifactVersion( "5.0.a.1.4.5" ) ) ); - assertEquals( 0, instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ); + public void testSegmentCounting() { + assertEquals(1, instance.getSegmentCount(new DefaultArtifactVersion("5"))); + assertEquals(2, instance.getSegmentCount(new DefaultArtifactVersion("5.0"))); + assertEquals(2, instance.getSegmentCount(new DefaultArtifactVersion("5-0"))); + assertEquals(3, instance.getSegmentCount(new DefaultArtifactVersion("5.3.a"))); + assertEquals(6, instance.getSegmentCount(new DefaultArtifactVersion("5.0.a.1.4.5"))); + assertEquals(0, instance.getSegmentCount(new DefaultArtifactVersion(""))); } - - } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java index 3b858ee5d4..1200442d7c 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/NumericVersionComparatorTest.java @@ -25,87 +25,77 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -public class NumericVersionComparatorTest extends VersionComparatorTestBase -{ - public NumericVersionComparatorTest() - { - super( new NumericVersionComparator() ); +public class NumericVersionComparatorTest extends VersionComparatorTestBase { + public NumericVersionComparatorTest() { + super(new NumericVersionComparator()); } - private int instanceCompare( String v1, String v2 ) - { - return instance.compare( new DefaultArtifactVersion( v1 ), new DefaultArtifactVersion( v2 ) ); + private int instanceCompare(String v1, String v2) { + return instance.compare(new DefaultArtifactVersion(v1), new DefaultArtifactVersion(v2)); } @Test - public void testSmokes() - { - assertTrue( instanceCompare( "1.0.0.0.0", "1.0.0.0.1" ) < 0 ); - assertTrue( instanceCompare( "1.0.0.0.0", "2.0.0.0.1" ) < 0 ); - assertTrue( instanceCompare( "1.0.0.0.0", "1.0.0.0" ) < 0 ); - assertTrue( instanceCompare( "1.0.0.0.0", "1.0.0.0.0" ) == 0 ); - assertTrue( instanceCompare( "1.0.0.0", "1.0.0.0.0" ) > 0 ); + public void testSmokes() { + assertTrue(instanceCompare("1.0.0.0.0", "1.0.0.0.1") < 0); + assertTrue(instanceCompare("1.0.0.0.0", "2.0.0.0.1") < 0); + assertTrue(instanceCompare("1.0.0.0.0", "1.0.0.0") < 0); + assertTrue(instanceCompare("1.0.0.0.0", "1.0.0.0.0") == 0); + assertTrue(instanceCompare("1.0.0.0", "1.0.0.0.0") > 0); } @Test - public void testBigValues() - { - assertTrue( instanceCompare( "1.92.0", "1.100000000000000000000000.0" ) < 0 ); - assertTrue( instanceCompare( "1.100000000000000000000000.0", "1.92.0" ) > 0 ); - assertTrue( instanceCompare( "1.100000000000000000000000.0", "1.100000000000000000000000.0" ) == 0 ); + public void testBigValues() { + assertTrue(instanceCompare("1.92.0", "1.100000000000000000000000.0") < 0); + assertTrue(instanceCompare("1.100000000000000000000000.0", "1.92.0") > 0); + assertTrue(instanceCompare("1.100000000000000000000000.0", "1.100000000000000000000000.0") == 0); } @Test - public void testStringValues() - { - assertTrue( instanceCompare( "1.a20.0", "1.a3.0" ) < 0 ); - assertTrue( instanceCompare( "1.a20.0", "1.b10.0" ) < 0 ); - assertTrue( instanceCompare( "1.a.0.b.0", "1.a.0.b.1" ) < 0 ); - assertTrue( instanceCompare( "1.162%a.0.b.0", "1.162%a.0.b.1" ) < 0 ); - assertTrue( instanceCompare( "1.162%a.0.b.0", "1.2.0.b.1" ) < 0 ); - assertTrue( instanceCompare( "1.0a.0.b.0", "1.162%.0.b.1" ) < 0 ); - assertTrue( instanceCompare( "1.a.0.b.0", "2.a.0.b.1" ) < 0 ); - assertTrue( instanceCompare( "1.a.0.b.0", "1.a.0.b" ) < 0 ); - assertTrue( instanceCompare( "1.a.0.b.0", "1.a.0.b.0" ) == 0 ); - assertTrue( instanceCompare( "1.a.0.b", "1.a.0.b.0" ) > 0 ); - assertTrue( instanceCompare( "1.a.0.0", "1.a.0" ) < 0 ); - assertTrue( instanceCompare( "1.a.0", "1.a.0.0" ) > 0 ); - assertTrue( instanceCompare( "1.a.0.1", "1.a.0" ) > 0 ); - assertTrue( instanceCompare( "1.a.0", "1.a.0.1" ) < 0 ); - assertTrue( instanceCompare( "1.a.0.b", "1.a.0" ) > 0 ); - assertTrue( instanceCompare( "1.a.0", "1.a.0.b" ) < 0 ); + public void testStringValues() { + assertTrue(instanceCompare("1.a20.0", "1.a3.0") < 0); + assertTrue(instanceCompare("1.a20.0", "1.b10.0") < 0); + assertTrue(instanceCompare("1.a.0.b.0", "1.a.0.b.1") < 0); + assertTrue(instanceCompare("1.162%a.0.b.0", "1.162%a.0.b.1") < 0); + assertTrue(instanceCompare("1.162%a.0.b.0", "1.2.0.b.1") < 0); + assertTrue(instanceCompare("1.0a.0.b.0", "1.162%.0.b.1") < 0); + assertTrue(instanceCompare("1.a.0.b.0", "2.a.0.b.1") < 0); + assertTrue(instanceCompare("1.a.0.b.0", "1.a.0.b") < 0); + assertTrue(instanceCompare("1.a.0.b.0", "1.a.0.b.0") == 0); + assertTrue(instanceCompare("1.a.0.b", "1.a.0.b.0") > 0); + assertTrue(instanceCompare("1.a.0.0", "1.a.0") < 0); + assertTrue(instanceCompare("1.a.0", "1.a.0.0") > 0); + assertTrue(instanceCompare("1.a.0.1", "1.a.0") > 0); + assertTrue(instanceCompare("1.a.0", "1.a.0.1") < 0); + assertTrue(instanceCompare("1.a.0.b", "1.a.0") > 0); + assertTrue(instanceCompare("1.a.0", "1.a.0.b") < 0); } @Test - public void testQualifiers() - { - assertTrue( instanceCompare( "1.0-alpha.10", "1.0-alpha.20" ) < 0 ); - assertTrue( instanceCompare( "1.0-alpha.10", "1.0-beta.1" ) < 0 ); - assertTrue( instanceCompare( "1.0", "1.0-alpha.2" ) > 0 ); - assertTrue( instanceCompare( "1.0-alpha.10", "1.0" ) < 0 ); - assertTrue( instanceCompare( "1.0.10", "1.0-alpha.10" ) > 0 ); + public void testQualifiers() { + assertTrue(instanceCompare("1.0-alpha.10", "1.0-alpha.20") < 0); + assertTrue(instanceCompare("1.0-alpha.10", "1.0-beta.1") < 0); + assertTrue(instanceCompare("1.0", "1.0-alpha.2") > 0); + assertTrue(instanceCompare("1.0-alpha.10", "1.0") < 0); + assertTrue(instanceCompare("1.0.10", "1.0-alpha.10") > 0); } @Test - public void testSegmentCounting() - { - assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5" ) ) ); - assertEquals( 2, instance.getSegmentCount( new DefaultArtifactVersion( "5.0" ) ) ); - assertEquals( 1, instance.getSegmentCount( new DefaultArtifactVersion( "5-0" ) ) ); - assertEquals( 3, instance.getSegmentCount( new DefaultArtifactVersion( "5.3.a" ) ) ); - assertEquals( 6, instance.getSegmentCount( new DefaultArtifactVersion( "5.0.a.1.4.5" ) ) ); - assertEquals( 0, instance.getSegmentCount( new DefaultArtifactVersion( "" ) ) ); + public void testSegmentCounting() { + assertEquals(1, instance.getSegmentCount(new DefaultArtifactVersion("5"))); + assertEquals(2, instance.getSegmentCount(new DefaultArtifactVersion("5.0"))); + assertEquals(1, instance.getSegmentCount(new DefaultArtifactVersion("5-0"))); + assertEquals(3, instance.getSegmentCount(new DefaultArtifactVersion("5.3.a"))); + assertEquals(6, instance.getSegmentCount(new DefaultArtifactVersion("5.0.a.1.4.5"))); + assertEquals(0, instance.getSegmentCount(new DefaultArtifactVersion(""))); } @Override - public void testVersionComparatorRow5() - { + public void testVersionComparatorRow5() { // non-numeric -- does not apply } @Override - public void testVersionComparatorRow6() - { + public void testVersionComparatorRow6() { // non-numeric -- does not apply } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java index 28e326a2ec..69a71510f7 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/ordering/VersionComparatorTestBase.java @@ -29,72 +29,62 @@ * Abstract base class for {@link MavenVersionComparatorTest}, {@link MercuryVersionComparatorTest}, * and {@link NumericVersionComparatorTest} */ -public abstract class VersionComparatorTestBase -{ +public abstract class VersionComparatorTestBase { protected final VersionComparator instance; - public VersionComparatorTestBase( VersionComparator instance ) - { + public VersionComparatorTestBase(VersionComparator instance) { this.instance = instance; } - protected static ArtifactVersion version( String version ) - { - return new DefaultArtifactVersion( version ); + protected static ArtifactVersion version(String version) { + return new DefaultArtifactVersion(version); } @Test - public void testVersionComparatorRow1() - { - assertThat( instance.compare( version( "1" ), version( "2" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0" ), version( "2.0" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow1() { + assertThat(instance.compare(version("1"), version("2")), lessThan(0)); + assertThat(instance.compare(version("1.0"), version("2.0")), lessThan(0)); + assertThat(instance.compare(version("1.0"), version("1.1")), lessThan(0)); + assertThat(instance.compare(version("1.0"), version("1.1")), lessThan(0)); } @Test - public void testVersionComparatorRow2() - { - assertThat( instance.compare( version( "1.0" ), version( "2.0" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0" ), version( "1.1" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow2() { + assertThat(instance.compare(version("1.0"), version("2.0")), lessThan(0)); + assertThat(instance.compare(version("1.0"), version("1.1")), lessThan(0)); } @Test - public void testVersionComparatorRow3() - { - assertThat( instance.compare( version( "1.0.0" ), version( "2.0.0" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0" ), version( "1.1.0" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0" ), version( "1.0.1" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow3() { + assertThat(instance.compare(version("1.0.0"), version("2.0.0")), lessThan(0)); + assertThat(instance.compare(version("1.0.0"), version("1.1.0")), lessThan(0)); + assertThat(instance.compare(version("1.0.0"), version("1.0.1")), lessThan(0)); } @Test - public void testVersionComparatorRow4() - { - assertThat( instance.compare( version( "1.0.0-1" ), version( "2.0.0-1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-1" ), version( "1.1.0-1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-1" ), version( "1.0.1-1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-1" ), version( "1.0.0-2" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow4() { + assertThat(instance.compare(version("1.0.0-1"), version("2.0.0-1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-1"), version("1.1.0-1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-1"), version("1.0.1-1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-1"), version("1.0.0-2")), lessThan(0)); } @Test - public void testVersionComparatorRow5() - { - assertThat( instance.compare( version( "1.0.0-sp1" ), version( "2.0.0-sp1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.1.0-sp1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.0.1-sp1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1.0.0-sp1" ), version( "1.0.0-1-sp1" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow5() { + assertThat(instance.compare(version("1.0.0-sp1"), version("2.0.0-sp1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-sp1"), version("1.1.0-sp1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-sp1"), version("1.0.1-sp1")), lessThan(0)); + assertThat(instance.compare(version("1.0.0-sp1"), version("1.0.0-1-sp1")), lessThan(0)); } @Test - public void testVersionComparatorRow6() - { - assertThat( instance.compare( version( "foobar" ), version( "foobar-1" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow6() { + assertThat(instance.compare(version("foobar"), version("foobar-1")), lessThan(0)); } @Test - public void testVersionComparatorRow7() - { - assertThat( instance.compare( version( "1-alpha-1" ), version( "2-alpha-1" ) ), lessThan( 0 ) ); - assertThat( instance.compare( version( "1-alpha-1" ), version( "1-alpha-2" ) ), lessThan( 0 ) ); + public void testVersionComparatorRow7() { + assertThat(instance.compare(version("1-alpha-1"), version("2-alpha-1")), lessThan(0)); + assertThat(instance.compare(version("1-alpha-1"), version("1-alpha-2")), lessThan(0)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java index b852179d1b..7d49e2bcd6 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/recording/ChangeRecorderXMLTest.java @@ -38,89 +38,86 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -public final class ChangeRecorderXMLTest -{ - private static void copyResource( final String name, final Path output ) throws IOException - { - try ( InputStream inputStream = ChangeRecorderXMLTest.class.getResourceAsStream( name ) ) - { - Files.copy( inputStream, output, StandardCopyOption.REPLACE_EXISTING ); +public final class ChangeRecorderXMLTest { + private static void copyResource(final String name, final Path output) throws IOException { + try (InputStream inputStream = ChangeRecorderXMLTest.class.getResourceAsStream(name)) { + Files.copy(inputStream, output, StandardCopyOption.REPLACE_EXISTING); } } - private static Document parseXML( final Path path ) throws ParserConfigurationException, IOException, SAXException - { + private static Document parseXML(final Path path) throws ParserConfigurationException, IOException, SAXException { final DocumentBuilderFactory documentBuilders = DocumentBuilderFactory.newInstance(); final DocumentBuilder documentBuilder = documentBuilders.newDocumentBuilder(); - return documentBuilder.parse( path.toFile() ); + return documentBuilder.parse(path.toFile()); } @Test - public void testChanges() throws Exception - { - final Path path0 = Files.createTempFile( "ChangeRecorderTest", ".xml" ); - final Path path1 = Files.createTempDirectory( "ChangeRecorderTest" ) - .resolve( "subDirectory" ) - .resolve( "ChangeRecorderTest.xml" ); + public void testChanges() throws Exception { + final Path path0 = Files.createTempFile("ChangeRecorderTest", ".xml"); + final Path path1 = Files.createTempDirectory("ChangeRecorderTest") + .resolve("subDirectory") + .resolve("ChangeRecorderTest.xml"); - copyResource( "expectedFile.xml", path0 ); + copyResource("expectedFile.xml", path0); final ChangeRecorder recorder = new ChangeRecorderXML(); - recorder.recordChange( DefaultChangeRecord.builder() - .withKind( ChangeRecord.ChangeKind.DEPENDENCY ) - .withGroupId( "org.codehaus" ) - .withArtifactId( "example0" ) - .withOldVersion( "0.0.1" ) - .withNewVersion( "0.0.2" ) - .build() ); - - recorder.recordChange( DefaultChangeRecord.builder() - .withKind( ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ) - .withGroupId( "org.codehaus" ) - .withArtifactId( "example1" ) - .withOldVersion( "1.0.0" ) - .withNewVersion( "2.0.0" ) - .build() ); - - recorder.writeReport( path1 ); - - final Document document0 = parseXML( path0 ); - final Document document1 = parseXML( path1 ); - - final NodeList elements0 = document0.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); - final NodeList elements1 = document1.getElementsByTagNameNS( ChangeRecorderXML.CHANGES_NAMESPACE, "updated" ); - - Assert.assertEquals( "Correct number of updates", elements0.getLength(), elements1.getLength() ); - - for ( int index = 0; index < elements0.getLength(); ++index ) - { - final Element element0 = (Element) elements0.item( index ); - final Element element1 = (Element) elements1.item( index ); - - Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId" ) ); - Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "groupId" ) ); - Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion" ) ); - Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion" ) ); + recorder.recordChange(DefaultChangeRecord.builder() + .withKind(ChangeRecord.ChangeKind.DEPENDENCY) + .withGroupId("org.codehaus") + .withArtifactId("example0") + .withOldVersion("0.0.1") + .withNewVersion("0.0.2") + .build()); + + recorder.recordChange(DefaultChangeRecord.builder() + .withKind(ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT) + .withGroupId("org.codehaus") + .withArtifactId("example1") + .withOldVersion("1.0.0") + .withNewVersion("2.0.0") + .build()); + + recorder.writeReport(path1); + + final Document document0 = parseXML(path0); + final Document document1 = parseXML(path1); + + final NodeList elements0 = document0.getElementsByTagNameNS(ChangeRecorderXML.CHANGES_NAMESPACE, "updated"); + final NodeList elements1 = document1.getElementsByTagNameNS(ChangeRecorderXML.CHANGES_NAMESPACE, "updated"); + + Assert.assertEquals("Correct number of updates", elements0.getLength(), elements1.getLength()); + + for (int index = 0; index < elements0.getLength(); ++index) { + final Element element0 = (Element) elements0.item(index); + final Element element1 = (Element) elements1.item(index); + + Assert.assertEquals( + element0.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId"), + element1.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "artifactId")); + Assert.assertEquals( + element0.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "groupId"), + element1.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "groupId")); + Assert.assertEquals( + element0.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion"), + element1.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "oldVersion")); + Assert.assertEquals( + element0.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion"), + element1.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "newVersion")); // FIXME - looks like assertions not working - Assert.assertEquals( element0.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "kind" ), - element1.getAttributeNS( ChangeRecorderXML.CHANGES_NAMESPACE, "kind" ) ); + Assert.assertEquals( + element0.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "kind"), + element1.getAttributeNS(ChangeRecorderXML.CHANGES_NAMESPACE, "kind")); } } @Test - public void emptyResultShouldNotGenerateReports() throws Exception - { - Path path = Files.createTempDirectory( "ChangeRecorderTest" ).resolve( "ChangeRecorderTest.xml" ); + public void emptyResultShouldNotGenerateReports() throws Exception { + Path path = Files.createTempDirectory("ChangeRecorderTest").resolve("ChangeRecorderTest.xml"); ChangeRecorder recorder = new ChangeRecorderXML(); - recorder.writeReport( path ); - - Assert.assertFalse( "File should not be created", Files.isRegularFile( path ) ); + recorder.writeReport(path); + Assert.assertFalse("File should not be created", Files.isRegularFile(path)); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java index 5ae699c20c..efe6787692 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/rewriting/ModifiedPomXMLEventReaderTest.java @@ -44,10 +44,8 @@ * * @author Andrzej Jarmoniuk */ - -@RunWith( MockitoJUnitRunner.class ) -public class ModifiedPomXMLEventReaderTest extends AbstractMojoTestCase -{ +@RunWith(MockitoJUnitRunner.class) +public class ModifiedPomXMLEventReaderTest extends AbstractMojoTestCase { private static final String[] STR = {"xyz", "0123456789abcdef"}; private static final String REPLACEMENT = "abcdef"; @@ -66,73 +64,64 @@ public class ModifiedPomXMLEventReaderTest extends AbstractMojoTestCase private ModifiedPomXMLEventReader pomXMLEventReader; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - when( location.getCharacterOffset() ) - .thenReturn( STR[0].length() ) - .thenReturn( STR[0].length() + STR[1].length() ); + when(location.getCharacterOffset()).thenReturn(STR[0].length()).thenReturn(STR[0].length() + STR[1].length()); - when( xmlEvent.isCharacters() ).thenReturn( true ); - when( xmlEvent.getLocation() ).thenReturn( location ); + when(xmlEvent.isCharacters()).thenReturn(true); + when(xmlEvent.getLocation()).thenReturn(location); - when( xmlEventReader.hasNext() ) - .thenReturn( true ).thenReturn( true ) // str[0] - .thenReturn( true ).thenReturn( true ) // str[1] - .thenReturn( false ); // ∅ - when( xmlEventReader.nextEvent() ) - .thenReturn( xmlEvent ) - .thenReturn( xmlEvent ); - when( xmlEventReader.peek() ) - .thenReturn( xmlEvent ); + when(xmlEventReader.hasNext()) + .thenReturn(true) + .thenReturn(true) // str[0] + .thenReturn(true) + .thenReturn(true) // str[1] + .thenReturn(false); // ∅ + when(xmlEventReader.nextEvent()).thenReturn(xmlEvent).thenReturn(xmlEvent); + when(xmlEventReader.peek()).thenReturn(xmlEvent); - when( xmlInputFactory.createXMLEventReader( any( StringReader.class ) ) ) - .thenReturn( xmlEventReader ); + when(xmlInputFactory.createXMLEventReader(any(StringReader.class))).thenReturn(xmlEventReader); pomXMLEventReader = - new ModifiedPomXMLEventReader( new StringBuilder( STR[0] ).append( STR[1] ), xmlInputFactory, "" ); + new ModifiedPomXMLEventReader(new StringBuilder(STR[0]).append(STR[1]), xmlInputFactory, ""); } @Test - public void testReplace() throws XMLStreamException, IllegalAccessException - { - assertThat( pomXMLEventReader.hasNext(), is( true ) ); - assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + public void testReplace() throws XMLStreamException, IllegalAccessException { + assertThat(pomXMLEventReader.hasNext(), is(true)); + assertThat(pomXMLEventReader.nextEvent(), is(xmlEvent)); - assertThat( pomXMLEventReader.hasNext(), is( true ) ); - assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + assertThat(pomXMLEventReader.hasNext(), is(true)); + assertThat(pomXMLEventReader.nextEvent(), is(xmlEvent)); - pomXMLEventReader.replace( REPLACEMENT ); - assertThat( pomXMLEventReader.asStringBuilder().toString(), is( STR[0] + REPLACEMENT ) ); + pomXMLEventReader.replace(REPLACEMENT); + assertThat(pomXMLEventReader.asStringBuilder().toString(), is(STR[0] + REPLACEMENT)); - pomXMLEventReader.mark( 0 ); - assertThat( pomXMLEventReader.getMarkVerbatim( 0 ), is( REPLACEMENT ) ); + pomXMLEventReader.mark(0); + assertThat(pomXMLEventReader.getMarkVerbatim(0), is(REPLACEMENT)); // more dangerous test since this touches the implementation - assertThat( getVariableValueFromObject( pomXMLEventReader, "lastEnd" ), - is( ( STR[0] + REPLACEMENT ).length() ) ); + assertThat(getVariableValueFromObject(pomXMLEventReader, "lastEnd"), is((STR[0] + REPLACEMENT).length())); } @Test - public void testReplaceMark() throws XMLStreamException, IllegalAccessException - { - assertThat( pomXMLEventReader.hasNext(), is( true ) ); - assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + public void testReplaceMark() throws XMLStreamException, IllegalAccessException { + assertThat(pomXMLEventReader.hasNext(), is(true)); + assertThat(pomXMLEventReader.nextEvent(), is(xmlEvent)); - assertThat( pomXMLEventReader.hasNext(), is( true ) ); - assertThat( pomXMLEventReader.nextEvent(), is( xmlEvent ) ); + assertThat(pomXMLEventReader.hasNext(), is(true)); + assertThat(pomXMLEventReader.nextEvent(), is(xmlEvent)); - pomXMLEventReader.mark( 0 ); + pomXMLEventReader.mark(0); - pomXMLEventReader.replaceMark( 0, REPLACEMENT ); - assertThat( pomXMLEventReader.asStringBuilder().toString(), is( STR[0] + REPLACEMENT ) ); + pomXMLEventReader.replaceMark(0, REPLACEMENT); + assertThat(pomXMLEventReader.asStringBuilder().toString(), is(STR[0] + REPLACEMENT)); - pomXMLEventReader.mark( 0 ); - assertThat( pomXMLEventReader.getMarkVerbatim( 0 ), is( REPLACEMENT ) ); + pomXMLEventReader.mark(0); + assertThat(pomXMLEventReader.getMarkVerbatim(0), is(REPLACEMENT)); // more dangerous test since this touches the implementation - assertThat( getVariableValueFromObject( pomXMLEventReader, "lastEnd" ), - is( ( STR[0] + REPLACEMENT ).length() ) ); + assertThat(getVariableValueFromObject(pomXMLEventReader, "lastEnd"), is((STR[0] + REPLACEMENT).length())); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java index fb8a37a3b3..01143daa4f 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/ModifiedPomXMLEventReaderUtils.java @@ -29,33 +29,26 @@ * * @author Andrzej Jarmoniuk */ -public class ModifiedPomXMLEventReaderUtils -{ - public static

    Matcher

    matches( String pattern ) - { - return new TypeSafeMatcher

    () - { +public class ModifiedPomXMLEventReaderUtils { + public static

    Matcher

    matches(String pattern) { + return new TypeSafeMatcher

    () { @Override - public void describeTo( Description description ) - { - description.appendText( pattern ); + public void describeTo(Description description) { + description.appendText(pattern); } @Override - protected void describeMismatchSafely( P pom, Description description ) - { - description.appendText( asString( pom ) ); + protected void describeMismatchSafely(P pom, Description description) { + description.appendText(asString(pom)); } @Override - protected boolean matchesSafely( P pom ) - { - return pattern.matches( asString( pom ) ); + protected boolean matchesSafely(P pom) { + return pattern.matches(asString(pom)); } - private String asString( P pom ) - { - return pom.asStringBuilder().toString().replaceAll( "\\s", "" ); + private String asString(P pom) { + return pom.asStringBuilder().toString().replaceAll("\\s", ""); } }; } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java index 4f68d71089..5fd8c98413 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/PropertiesVersionsFileReaderTest.java @@ -28,32 +28,28 @@ import org.junit.Assert; import org.junit.Test; -public class PropertiesVersionsFileReaderTest -{ +public class PropertiesVersionsFileReaderTest { private static final String TEST_PROPERTIES_FILE = - "src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties"; + "src/test/resources/org/codehaus/mojo/versions/utils/testPropertiesVersionsFile.properties"; @Test - public void testRead() throws IOException - { - PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader( TEST_PROPERTIES_FILE ); + public void testRead() throws IOException { + PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader(TEST_PROPERTIES_FILE); reader.read(); int numberOfPropertiesConfig = 3; - Assert.assertTrue( equalsCvsUnordered( "booking-api.version,booking-lib.version,be-air-impl.version", - reader.getProperties() ) ); - Assert.assertEquals( numberOfPropertiesConfig, reader.getPropertiesConfig().length ); + Assert.assertTrue(equalsCvsUnordered( + "booking-api.version,booking-lib.version,be-air-impl.version", reader.getProperties())); + Assert.assertEquals(numberOfPropertiesConfig, reader.getPropertiesConfig().length); } - private boolean equalsCvsUnordered( String csvExpected, String csvActual ) - { - if ( StringUtils.isEmpty( csvExpected ) ) - { + private boolean equalsCvsUnordered(String csvExpected, String csvActual) { + if (StringUtils.isEmpty(csvExpected)) { return false; } - Set listExpected = new HashSet<>( Arrays.asList( csvExpected.split( "," ) ) ); - Set listActual = new HashSet<>( Arrays.asList( csvActual.split( "," ) ) ); - return listExpected.equals( listActual ); + Set listExpected = new HashSet<>(Arrays.asList(csvExpected.split(","))); + Set listActual = new HashSet<>(Arrays.asList(csvActual.split(","))); + return listExpected.equals(listActual); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java index 4170e2dc7e..7d22804b35 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/SegmentUtilsTest.java @@ -32,39 +32,27 @@ /** * Unit tests for {@link SegmentUtils} */ -public class SegmentUtilsTest -{ +public class SegmentUtilsTest { @Test - public void testIncremental() - { - assertThat( determineUnchangedSegment( false, false, false, null ), - is( of( INCREMENTAL ) ) ); - assertThat( determineUnchangedSegment( true, false, false, null ), - is( of( INCREMENTAL ) ) ); - assertThat( determineUnchangedSegment( true, true, false, null ), - is( of( INCREMENTAL ) ) ); + public void testIncremental() { + assertThat(determineUnchangedSegment(false, false, false, null), is(of(INCREMENTAL))); + assertThat(determineUnchangedSegment(true, false, false, null), is(of(INCREMENTAL))); + assertThat(determineUnchangedSegment(true, true, false, null), is(of(INCREMENTAL))); } @Test - public void testMinor() - { - assertThat( determineUnchangedSegment( false, false, true, null ), - is( of( MINOR ) ) ); - assertThat( determineUnchangedSegment( true, false, true, null ), - is( of( MINOR ) ) ); + public void testMinor() { + assertThat(determineUnchangedSegment(false, false, true, null), is(of(MINOR))); + assertThat(determineUnchangedSegment(true, false, true, null), is(of(MINOR))); } @Test - public void testMajor() - { - assertThat( determineUnchangedSegment( false, true, true, null ), - is( of( MAJOR ) ) ); + public void testMajor() { + assertThat(determineUnchangedSegment(false, true, true, null), is(of(MAJOR))); } @Test - public void testEmpty() - { - assertThat( determineUnchangedSegment( true, true, true, null ), - is( empty() ) ); + public void testEmpty() { + assertThat(determineUnchangedSegment(true, true, true, null), is(empty())); } } diff --git a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java index 699644eeca..c23e057580 100644 --- a/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java +++ b/versions-common/src/test/java/org/codehaus/mojo/versions/utils/VersionStub.java @@ -24,53 +24,43 @@ /** * Stubs the {@link org.eclipse.aether.version.Version} */ -public class VersionStub implements Version -{ +public class VersionStub implements Version { private final String version; /** * Creates a new instance with the given version string * @param version version to be set */ - public VersionStub( String version ) - { + public VersionStub(String version) { assert version != null; this.version = version; } @Override - public String toString() - { + public String toString() { return version; } @Override - public int compareTo( Version o ) - { - return o != null - ? version.compareTo( o.toString() ) - : 1; + public int compareTo(Version o) { + return o != null ? version.compareTo(o.toString()) : 1; } @Override - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( !( o instanceof Version ) ) - { + if (!(o instanceof Version)) { return false; } - return version.equals( o.toString() ); + return version.equals(o.toString()); } @Override - public int hashCode() - { + public int hashCode() { return version.hashCode(); } } diff --git a/versions-enforcer/pom.xml b/versions-enforcer/pom.xml index 376f23b5f9..e90199247d 100644 --- a/versions-enforcer/pom.xml +++ b/versions-enforcer/pom.xml @@ -1,186 +1,184 @@ - - - versions - org.codehaus.mojo.versions - 2.14.0-SNAPSHOT - - 4.0.0 - - versions-enforcer - - Versions Enforcer - Enforcer rules using Versions Maven Plugin - - - ${maven-enforcer-plugin.version} - - - - - - org.codehaus.mojo.versions - versions-common - ${project.version} - - - - org.codehaus.mojo.versions - versions-test - ${project.version} - test - - - - org.apache.maven.enforcer - enforcer-api - provided - - - - org.apache.maven - maven-core - ${mavenVersion} - provided - - - - org.junit.jupiter - junit-jupiter - test - - - - org.junit.vintage - junit-vintage-engine - test - - - org.hamcrest - hamcrest-core - - - - - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - test - - - - org.mockito - mockito-inline - test - - - - org.hamcrest - hamcrest - test - - - - org.slf4j - slf4j-simple - test - - - - - - - - org.eclipse.sisu - sisu-maven-plugin - - - org.apache.maven.plugins - maven-invoker-plugin - - src/it - ${project.build.directory}/it - ${project.build.directory}/local-repo - src/it/settings.xml - true - true - - 1 - - */pom.xml - - verify - - ${repository.proxy.url} - - -Xmx256m - - - - - - - - - run-its - - verify - - - - org.codehaus.mojo - mrm-maven-plugin - - - - start - stop - - - - - repository.proxy.url - - - src/it-repo - - - ${project.build.directory}/local-repo - - - - - - - org.apache.maven.plugins - maven-invoker-plugin - - - integration-test - - install - integration-test - verify - - - false - true - - - - - - - - - - \ No newline at end of file + run-its + + verify + + + + org.codehaus.mojo + mrm-maven-plugin + + repository.proxy.url + + + src/it-repo + + + ${project.build.directory}/local-repo + + + + + + + + start + stop + + + + + + org.apache.maven.plugins + maven-invoker-plugin + + + integration-test + + install + integration-test + verify + + + false + true + + + + + + + + + + diff --git a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java index 2895596b70..4956a2fd50 100644 --- a/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java +++ b/versions-enforcer/src/main/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdates.java @@ -62,8 +62,7 @@ import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractDependenciesFromPlugins; import static org.codehaus.mojo.versions.utils.MavenProjectUtils.extractPluginDependenciesFromPluginsInPluginManagement; -public class MaxDependencyUpdates implements EnforcerRule2 -{ +public class MaxDependencyUpdates implements EnforcerRule2 { /** * Maximum allowed number of updates. * @@ -145,7 +144,7 @@ public class MaxDependencyUpdates implements EnforcerRule2 * * @since 2.14.0 */ - protected List dependencyIncludes = singletonList( WILDCARD ); + protected List dependencyIncludes = singletonList(WILDCARD); /** * List of dependency exclusion patterns. @@ -165,7 +164,7 @@ public class MaxDependencyUpdates implements EnforcerRule2 * * @since 2.14.0 */ - protected List dependencyManagementIncludes = singletonList( WILDCARD ); + protected List dependencyManagementIncludes = singletonList(WILDCARD); /** * List of dependency management exclusion patterns. @@ -185,7 +184,7 @@ public class MaxDependencyUpdates implements EnforcerRule2 * * @since 2.14.0 */ - protected List pluginDependencyIncludes = singletonList( WILDCARD ); + protected List pluginDependencyIncludes = singletonList(WILDCARD); /** * List of plugin dependency exclusion patterns. @@ -205,7 +204,7 @@ public class MaxDependencyUpdates implements EnforcerRule2 * * @since 2.14.0 */ - protected List pluginManagementDependencyIncludes = singletonList( WILDCARD ); + protected List pluginManagementDependencyIncludes = singletonList(WILDCARD); /** * List of plugin dependency management exclusion patterns. @@ -249,15 +248,11 @@ public class MaxDependencyUpdates implements EnforcerRule2 * @param ruleHelper EnforcerRuleHelper object * @return maven project */ - private static MavenProject getMavenProject( EnforcerRuleHelper ruleHelper ) - { - try - { - return (MavenProject) ruleHelper.evaluate( "${project}" ); - } - catch ( ExpressionEvaluationException e ) - { - throw new RuntimeException( "Cannot evaluate project metadata", e ); + private static MavenProject getMavenProject(EnforcerRuleHelper ruleHelper) { + try { + return (MavenProject) ruleHelper.evaluate("${project}"); + } catch (ExpressionEvaluationException e) { + throw new RuntimeException("Cannot evaluate project metadata", e); } } @@ -266,136 +261,114 @@ private static MavenProject getMavenProject( EnforcerRuleHelper ruleHelper ) * @param ruleHelper EnforcerRuleHelper object * @return VersionsHelper object */ - @SuppressWarnings( "unchecked" ) - private static VersionsHelper createVersionsHelper( EnforcerRuleHelper ruleHelper, - String serverId, - String rulesUri, - RuleSet ruleSet ) - { - try - { + @SuppressWarnings("unchecked") + private static VersionsHelper createVersionsHelper( + EnforcerRuleHelper ruleHelper, String serverId, String rulesUri, RuleSet ruleSet) { + try { return new DefaultVersionsHelper.Builder() - .withRepositorySystem( ruleHelper.getComponent( RepositorySystem.class ) ) - .withAetherRepositorySystem( ruleHelper.getComponent( org.eclipse.aether.RepositorySystem.class ) ) - .withWagonMap( ruleHelper.getComponentMap( Wagon.class.getName() ) - .entrySet() - .parallelStream() - .filter( e -> e.getValue() instanceof Wagon ) - .collect( HashMap::new, - ( m, e ) -> m.put( e.getKey(), (Wagon) e.getValue() ), - HashMap::putAll ) ) - .withServerId( serverId ) - .withRulesUri( rulesUri ) - .withRuleSet( ruleSet ) - .withIgnoredVersions( null ) - .withLog( ruleHelper.getLog() ) - .withMavenSession( (MavenSession) ruleHelper.evaluate( "${session}" ) ) - .withMojoExecution( (MojoExecution) ruleHelper.evaluate( "${mojoExecution}" ) ) + .withRepositorySystem(ruleHelper.getComponent(RepositorySystem.class)) + .withAetherRepositorySystem(ruleHelper.getComponent(org.eclipse.aether.RepositorySystem.class)) + .withWagonMap(ruleHelper.getComponentMap(Wagon.class.getName()).entrySet().parallelStream() + .filter(e -> e.getValue() instanceof Wagon) + .collect(HashMap::new, (m, e) -> m.put(e.getKey(), (Wagon) e.getValue()), HashMap::putAll)) + .withServerId(serverId) + .withRulesUri(rulesUri) + .withRuleSet(ruleSet) + .withIgnoredVersions(null) + .withLog(ruleHelper.getLog()) + .withMavenSession((MavenSession) ruleHelper.evaluate("${session}")) + .withMojoExecution((MojoExecution) ruleHelper.evaluate("${mojoExecution}")) .build(); - } - catch ( ExpressionEvaluationException e ) - { - throw new RuntimeException( "Cannot evaluate project metadata", e ); - } - catch ( ComponentLookupException | MojoExecutionException e ) - { - throw new RuntimeException( "Cannot resolve dependency", e ); + } catch (ExpressionEvaluationException e) { + throw new RuntimeException("Cannot evaluate project metadata", e); + } catch (ComponentLookupException | MojoExecutionException e) { + throw new RuntimeException("Cannot resolve dependency", e); } } + @Override - public boolean isCacheable() - { + public boolean isCacheable() { return false; } @Override - public boolean isResultValid( EnforcerRule enforcerRule ) - { + public boolean isResultValid(EnforcerRule enforcerRule) { return false; } @Override - public String getCacheId() - { + public String getCacheId() { return "Does not matter as not cacheable"; } @Override - public void execute( EnforcerRuleHelper ruleHelper ) throws EnforcerRuleException - { - VersionsHelper versionsHelper = createVersionsHelper( ruleHelper, serverId != null ? serverId : "serverId", - rulesUri, ruleSet ); - MavenProject project = getMavenProject( ruleHelper ); - Set dependencies = new TreeSet<>( DependencyComparator.INSTANCE ); - if ( processDependencyManagement ) - { - try - { - dependencies.addAll( filterDependencies( extractDependenciesFromDependencyManagement( project, - processDependencyManagementTransitive, ruleHelper.getLog() ), - dependencyManagementIncludes, dependencyManagementExcludes, "Dependency Management", - ruleHelper.getLog() ) ); - } - catch ( VersionRetrievalException e ) - { - throw new EnforcerRuleException( e.getMessage() ); + public void execute(EnforcerRuleHelper ruleHelper) throws EnforcerRuleException { + VersionsHelper versionsHelper = + createVersionsHelper(ruleHelper, serverId != null ? serverId : "serverId", rulesUri, ruleSet); + MavenProject project = getMavenProject(ruleHelper); + Set dependencies = new TreeSet<>(DependencyComparator.INSTANCE); + if (processDependencyManagement) { + try { + dependencies.addAll(filterDependencies( + extractDependenciesFromDependencyManagement( + project, processDependencyManagementTransitive, ruleHelper.getLog()), + dependencyManagementIncludes, + dependencyManagementExcludes, + "Dependency Management", + ruleHelper.getLog())); + } catch (VersionRetrievalException e) { + throw new EnforcerRuleException(e.getMessage()); } } - if ( processPluginDependencies ) - { - dependencies.addAll( filterDependencies( extractDependenciesFromPlugins( project ), - pluginDependencyIncludes, pluginDependencyExcludes, - "Plugin Dependencies", ruleHelper.getLog() ) ); + if (processPluginDependencies) { + dependencies.addAll(filterDependencies( + extractDependenciesFromPlugins(project), + pluginDependencyIncludes, + pluginDependencyExcludes, + "Plugin Dependencies", + ruleHelper.getLog())); } - if ( processPluginDependenciesInPluginManagement ) - { - dependencies.addAll( filterDependencies( - extractPluginDependenciesFromPluginsInPluginManagement( project ), - pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, - "Plugin Management Dependencies", ruleHelper.getLog() ) ); + if (processPluginDependenciesInPluginManagement) { + dependencies.addAll(filterDependencies( + extractPluginDependenciesFromPluginsInPluginManagement(project), + pluginManagementDependencyIncludes, + pluginManagementDependencyExcludes, + "Plugin Management Dependencies", + ruleHelper.getLog())); } - if ( processDependencies ) - { - dependencies.addAll( filterDependencies( project.getDependencies(), - dependencyIncludes, dependencyExcludes, "Dependencies", ruleHelper.getLog() ) ); + if (processDependencies) { + dependencies.addAll(filterDependencies( + project.getDependencies(), + dependencyIncludes, + dependencyExcludes, + "Dependencies", + ruleHelper.getLog())); } - try - { + try { Optional ignoredSegment = ignoreSubIncrementalUpdates - ? of( SUBINCREMENTAL ) - : ignoreIncrementalUpdates - ? of( INCREMENTAL ) - : ignoreMinorUpdates - ? of( MINOR ) - : empty(); - List upgradable = versionsHelper - .lookupDependenciesUpdates( dependencies, false ) - .values() - .parallelStream() - .filter( v -> - v.getVersions( v.restrictionForIgnoreScope( ignoredSegment ), true ).length > 0 - ) - .collect( Collectors.toList() ); - if ( upgradable.size() > maxUpdates ) - { - throw new EnforcerRuleException( "More than " + maxUpdates + " upgradable artifacts detected: " - + upgradable.stream().map( av -> av.getArtifact() + " -> [" - + Arrays.stream( av.getVersions() ) - .map( ArtifactVersion::toString ) - .collect( Collectors.joining( ", " ) ) - + "]" ) - .collect( Collectors.joining( ", " ) ) ); + ? of(SUBINCREMENTAL) + : ignoreIncrementalUpdates ? of(INCREMENTAL) : ignoreMinorUpdates ? of(MINOR) : empty(); + List upgradable = + versionsHelper.lookupDependenciesUpdates(dependencies, false).values().parallelStream() + .filter(v -> v.getVersions(v.restrictionForIgnoreScope(ignoredSegment), true).length > 0) + .collect(Collectors.toList()); + if (upgradable.size() > maxUpdates) { + throw new EnforcerRuleException("More than " + maxUpdates + " upgradable artifacts detected: " + + upgradable.stream() + .map(av -> av.getArtifact() + " -> [" + + Arrays.stream(av.getVersions()) + .map(ArtifactVersion::toString) + .collect(Collectors.joining(", ")) + + "]") + .collect(Collectors.joining(", "))); } - } - catch ( VersionRetrievalException e ) - { - throw new RuntimeException( e.getMessage(), e ); + } catch (VersionRetrievalException e) { + throw new RuntimeException(e.getMessage(), e); } } @Override - public EnforcerLevel getLevel() - { + public EnforcerLevel getLevel() { // all reported items should be treated as errors return EnforcerLevel.ERROR; } diff --git a/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java index 62e029e813..09ad456716 100644 --- a/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java +++ b/versions-enforcer/src/test/java/org/apache/maven/plugins/enforcer/MaxDependencyUpdatesTest.java @@ -44,237 +44,226 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class MaxDependencyUpdatesTest -{ - private static EnforcerRuleHelper mockRuleHelper( MavenProject mavenProject, - org.eclipse.aether.RepositorySystem aetherRepositorySystem ) - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mock( EnforcerRuleHelper.class ); - when( ruleHelper.evaluate( anyString() ) ) - .then( ( a ) -> "${project}".equals( a.getArgument( 0 ) ) +public class MaxDependencyUpdatesTest { + private static EnforcerRuleHelper mockRuleHelper( + MavenProject mavenProject, org.eclipse.aether.RepositorySystem aetherRepositorySystem) + throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mock(EnforcerRuleHelper.class); + when(ruleHelper.evaluate(anyString())) + .then((a) -> "${project}".equals(a.getArgument(0)) ? mavenProject - : "${session}".equals( a.getArgument( 0 ) ) - ? mockMavenSession() - : "${mojoExecution}".equals( a.getArgument( 0 ) ) - ? mock( MojoExecution.class ) - : null ); - when( ruleHelper.getComponent( ArgumentMatchers.>any() ) ) - .then( ( a ) -> a.getArgument( 0 ) == RepositorySystem.class + : "${session}".equals(a.getArgument(0)) + ? mockMavenSession() + : "${mojoExecution}".equals(a.getArgument(0)) ? mock(MojoExecution.class) : null); + when(ruleHelper.getComponent(ArgumentMatchers.>any())) + .then((a) -> a.getArgument(0) == RepositorySystem.class ? mockRepositorySystem() - : a.getArgument( 0 ) == org.eclipse.aether.RepositorySystem.class - ? aetherRepositorySystem - : null ); + : a.getArgument(0) == org.eclipse.aether.RepositorySystem.class + ? aetherRepositorySystem + : null); return ruleHelper; } @Test - public void testRuleFailsByMaxUpdatesExceeded() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( asList( - dependencyWith( "group", "artifactA", "1.0.0" ), - dependencyWith( "group", "artifactB", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0", "2.0.0" } ); - }} ) ); + public void testRuleFailsByMaxUpdatesExceeded() throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(asList( + dependencyWith("group", "artifactA", "1.0.0"), + dependencyWith("group", "artifactB", "1.0.0"))); + } + }, + mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0", "2.0.0"}); + } + })); - try - { - new MaxDependencyUpdates() - {{ - maxUpdates = 1; - }}.execute( ruleHelper ); + try { + new MaxDependencyUpdates() { + { + maxUpdates = 1; + } + }.execute(ruleHelper); - fail( "EnforcerRuleException should have been thrown" ); - } - catch ( EnforcerRuleException e ) - { - assertThat( e.getMessage(), containsString( "More than 1 upgradable artifacts detected" ) ); + fail("EnforcerRuleException should have been thrown"); + } catch (EnforcerRuleException e) { + assertThat(e.getMessage(), containsString("More than 1 upgradable artifacts detected")); } } @Test - public void testRulePassesByMaxUpdatesNotExceeded() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( singletonList( - dependencyWith( "group", "artifactA", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( singletonMap( "artifactA", new String[] { "1.0.0", "2.0.0" } ) ) ); + public void testRulePassesByMaxUpdatesNotExceeded() throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(singletonList(dependencyWith("group", "artifactA", "1.0.0"))); + } + }, + mockAetherRepositorySystem(singletonMap("artifactA", new String[] {"1.0.0", "2.0.0"}))); - try - { - new MaxDependencyUpdates() - {{ - maxUpdates = 1; - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + maxUpdates = 1; + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test public void testRulePassesByMaxUpdatesNotExceededDependencyIncludes() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( asList( - dependencyWith( "group", "artifactA", "1.0.0" ), - dependencyWith( "group", "artifactB", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - }} ) ); + throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(asList( + dependencyWith("group", "artifactA", "1.0.0"), + dependencyWith("group", "artifactB", "1.0.0"))); + } + }, + mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + } + })); - try - { - new MaxDependencyUpdates() - {{ - dependencyIncludes = singletonList( "group:artifactB" ); - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + dependencyIncludes = singletonList("group:artifactB"); + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test public void testRulePassesByMaxUpdatesNotExceededDependencyExcludes() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( asList( - dependencyWith( "group", "artifactA", "1.0.0" ), - dependencyWith( "group", "artifactB", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - }} ) ); + throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(asList( + dependencyWith("group", "artifactA", "1.0.0"), + dependencyWith("group", "artifactB", "1.0.0"))); + } + }, + mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + } + })); - try - { - new MaxDependencyUpdates() - {{ - dependencyExcludes = singletonList( "group:artifactA" ); - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + dependencyExcludes = singletonList("group:artifactA"); + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test public void testRulePassesByMaxUpdatesNotExceededDependencyIncludesExcludes() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( asList( - dependencyWith( "group", "artifactA", "1.0.0" ), - dependencyWith( "group", "artifactB", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - }} ) ); + throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(asList( + dependencyWith("group", "artifactA", "1.0.0"), + dependencyWith("group", "artifactB", "1.0.0"))); + } + }, + mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + } + })); - try - { - new MaxDependencyUpdates() - {{ - dependencyIncludes = singletonList( "group:*" ); - dependencyExcludes = singletonList( "group:artifactA" ); - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + dependencyIncludes = singletonList("group:*"); + dependencyExcludes = singletonList("group:artifactA"); + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test - public void testIgnoreSubIncrementalUpdates() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( singletonList( - dependencyWith( "group", "artifactA", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( singletonMap( "artifactA", - new String[] { "1.0.0", "1.0.0-1" } ) ) ); + public void testIgnoreSubIncrementalUpdates() throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(singletonList(dependencyWith("group", "artifactA", "1.0.0"))); + } + }, + mockAetherRepositorySystem(singletonMap("artifactA", new String[] {"1.0.0", "1.0.0-1"}))); - try - { - new MaxDependencyUpdates() - {{ - ignoreSubIncrementalUpdates = true; - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + ignoreSubIncrementalUpdates = true; + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test - public void testIgnoreIncrementalUpdates() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( singletonList( - dependencyWith( "group", "artifactA", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( singletonMap( "artifactA", - new String[] { "1.0.0", "1.0.0-1", "1.0.1" } ) ) ); + public void testIgnoreIncrementalUpdates() throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(singletonList(dependencyWith("group", "artifactA", "1.0.0"))); + } + }, + mockAetherRepositorySystem(singletonMap("artifactA", new String[] {"1.0.0", "1.0.0-1", "1.0.1"}))); - try - { - new MaxDependencyUpdates() - {{ - ignoreIncrementalUpdates = true; - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + ignoreIncrementalUpdates = true; + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } @Test - public void testIgnoreMinorUpdates() - throws ExpressionEvaluationException, ComponentLookupException - { - EnforcerRuleHelper ruleHelper = mockRuleHelper( new MavenProject() - {{ - setDependencies( asList( - dependencyWith( "group", "artifactA", "1.0.0" ) ) ); - }}, mockAetherRepositorySystem( singletonMap( "artifactA", - new String[] { "1.0.0", "1.0.0-1", "1.0.1", "1.1.0" } ) ) ); + public void testIgnoreMinorUpdates() throws ExpressionEvaluationException, ComponentLookupException { + EnforcerRuleHelper ruleHelper = mockRuleHelper( + new MavenProject() { + { + setDependencies(asList(dependencyWith("group", "artifactA", "1.0.0"))); + } + }, + mockAetherRepositorySystem( + singletonMap("artifactA", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0"}))); - try - { - new MaxDependencyUpdates() - {{ - ignoreMinorUpdates = true; - }}.execute( ruleHelper ); - } - catch ( EnforcerRuleException e ) - { - fail( "No EnforcerRuleException should have been thrown" ); + try { + new MaxDependencyUpdates() { + { + ignoreMinorUpdates = true; + } + }.execute(ruleHelper); + } catch (EnforcerRuleException e) { + fail("No EnforcerRuleException should have been thrown"); } } } diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 629e0eaa5a..b531444ddb 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -1,3 +1,4 @@ + 4.0.0 @@ -85,7 +86,6 @@ maven-common-artifact-filters - org.apache.maven.doxia @@ -255,14 +255,6 @@ org.codehaus.mojo mrm-maven-plugin - - - - start - stop - - - repository.proxy.url @@ -275,6 +267,14 @@ + + + + start + stop + + + org.apache.maven.plugins diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java index d183fbdb2d..ac9b15b083 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java @@ -17,11 +17,6 @@ * */ - -import static java.util.Collections.emptyMap; -import static org.codehaus.mojo.versions.utils.MavenProjectUtils.interpolateVersion; -import static org.codehaus.mojo.versions.utils.MiscUtils.filter; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -33,6 +28,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Dependency; @@ -49,11 +45,14 @@ import org.codehaus.mojo.versions.xml.DependencyUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; +import static java.util.Collections.emptyMap; +import static org.codehaus.mojo.versions.utils.MavenProjectUtils.interpolateVersion; +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; + /** * Generates a report of available updates for the dependencies of a project. */ -public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersionsReport -{ +public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersionsReport { private static final DependencyComparator DEPENDENCY_COMPARATOR = DependencyComparator.INSTANCE; @@ -62,7 +61,7 @@ public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersio * * @since 2.5 */ - @Parameter( property = "processDependencyManagement", defaultValue = "true" ) + @Parameter(property = "processDependencyManagement", defaultValue = "true") protected boolean processDependencyManagement; /** @@ -75,13 +74,13 @@ public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersio * * @since 2.5 Note: Currently in experimental state. */ - @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) + @Parameter(property = "processDependencyManagementTransitive", defaultValue = "true") protected boolean processDependencyManagementTransitive; /** * Report formats (html and/or xml). HTML by default. */ - @Parameter( property = "dependencyUpdatesReportFormats", defaultValue = "html" ) + @Parameter(property = "dependencyUpdatesReportFormats", defaultValue = "html") protected String[] formats = new String[] {"html"}; /** @@ -90,7 +89,7 @@ public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersio * * @since 2.12 */ - @Parameter( property = "onlyProjectDependencies", defaultValue = "false" ) + @Parameter(property = "onlyProjectDependencies", defaultValue = "false") protected boolean onlyProjectDependencies; /** @@ -98,31 +97,29 @@ public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersio * * @since 2.12 */ - @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + @Parameter(property = "onlyUpgradable", defaultValue = "false") protected boolean onlyUpgradable; - public AbstractDependencyUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + public AbstractDependencyUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} */ - public boolean isExternalReport() - { + public boolean isExternalReport() { return false; } /** * {@inheritDoc} */ - public boolean canGenerateReport() - { + public boolean canGenerateReport() { return true; } @@ -132,115 +129,93 @@ public boolean canGenerateReport() * @param locale the locale to generate the report for. * @param sink the report formatting tool */ - @SuppressWarnings( "deprecation" ) - protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException - { + @SuppressWarnings("deprecation") + protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { Set dependencies = getDependencies(); Set dependencyManagement; - if ( processDependencyManagement ) - { - dependencyManagement = getDependencyManagement( dependencies ); - handleOnlyProjectDependencies( dependencyManagement, dependencies ); - } - else - { + if (processDependencyManagement) { + dependencyManagement = getDependencyManagement(dependencies); + handleOnlyProjectDependencies(dependencyManagement, dependencies); + } else { dependencyManagement = Collections.emptySet(); } - try - { + try { Map dependencyUpdates = - getHelper().lookupDependenciesUpdates( dependencies, false ); + getHelper().lookupDependenciesUpdates(dependencies, false); - Map dependencyManagementUpdates = - processDependencyManagement ? getHelper().lookupDependenciesUpdates( dependencyManagement, false ) - : emptyMap(); + Map dependencyManagementUpdates = processDependencyManagement + ? getHelper().lookupDependenciesUpdates(dependencyManagement, false) + : emptyMap(); - if ( onlyUpgradable ) - { - dependencyUpdates = filter( dependencyUpdates, e -> e.getVersions().length > 0 ); - dependencyManagementUpdates = filter( dependencyManagementUpdates, e -> e.getVersions().length > 0 ); + if (onlyUpgradable) { + dependencyUpdates = filter(dependencyUpdates, e -> e.getVersions().length > 0); + dependencyManagementUpdates = filter(dependencyManagementUpdates, e -> e.getVersions().length > 0); } - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Dependency versions:" ); - dependencyUpdates.forEach( ( key, value ) -> getLog().debug( - key.toString() + ": " + Arrays.stream( value.getVersions() ) - .map( ArtifactVersion::toString ) - .collect( Collectors.joining( ", " ) ) ) ); - - getLog().debug( "Dependency management versions:" ); - dependencyManagementUpdates.forEach( ( key, value ) -> getLog().debug( - key.toString() + ": " + Arrays.stream( value.getVersions() ) - .map( ArtifactVersion::toString ) - .collect( Collectors.joining( ", " ) ) ) ); + if (getLog().isDebugEnabled()) { + getLog().debug("Dependency versions:"); + dependencyUpdates.forEach((key, value) -> getLog().debug(key.toString() + ": " + + Arrays.stream(value.getVersions()) + .map(ArtifactVersion::toString) + .collect(Collectors.joining(", ")))); + + getLog().debug("Dependency management versions:"); + dependencyManagementUpdates.forEach((key, value) -> getLog().debug(key.toString() + ": " + + Arrays.stream(value.getVersions()) + .map(ArtifactVersion::toString) + .collect(Collectors.joining(", ")))); } - DependencyUpdatesModel model = new DependencyUpdatesModel( dependencyUpdates, dependencyManagementUpdates ); + DependencyUpdatesModel model = new DependencyUpdatesModel(dependencyUpdates, dependencyManagementUpdates); - renderReport( locale, sink, model ); - } - catch ( VersionRetrievalException e ) - { - throw new RuntimeException( e ); + renderReport(locale, sink, model); + } catch (VersionRetrievalException e) { + throw new RuntimeException(e); } } - protected void handleDependencyManagementTransitive( MavenProject project, - Set dependencyManagementCollector ) - throws MavenReportException - { - if ( processDependencyManagementTransitive ) - { - if ( hasDependencyManagement( project ) ) - { - for ( Dependency dep : project.getDependencyManagement().getDependencies() ) - { - getLog().debug( - "Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + ":" - + dep.getType() + ":" + dep.getScope() ); + protected void handleDependencyManagementTransitive( + MavenProject project, Set dependencyManagementCollector) throws MavenReportException { + if (processDependencyManagementTransitive) { + if (hasDependencyManagement(project)) { + for (Dependency dep : project.getDependencyManagement().getDependencies()) { + getLog().debug("Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + dep.getVersion() + + ":" + dep.getType() + ":" + dep.getScope()); } - dependencyManagementCollector.addAll( project.getDependencyManagement().getDependencies() ); + dependencyManagementCollector.addAll( + project.getDependencyManagement().getDependencies()); } - } - else - { - if ( project.getOriginalModel().getDependencyManagement() != null - && project.getOriginalModel().getDependencyManagement().getDependencies() != null ) - { + } else { + if (project.getOriginalModel().getDependencyManagement() != null + && project.getOriginalModel().getDependencyManagement().getDependencies() != null) { // Using the original model to get the original dependencyManagement entries and // not the interpolated model. // TODO: I'm not 100% sure if this will work correctly in all cases. - for ( Dependency dep : project.getOriginalModel().getDependencyManagement().getDependencies() ) - { - dep = interpolateVersion( dep, project ); + for (Dependency dep : + project.getOriginalModel().getDependencyManagement().getDependencies()) { + dep = interpolateVersion(dep, project); - getLog().debug( "Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" - + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope() ); + getLog().debug("Original Dpmg: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" + + dep.getVersion() + ":" + dep.getType() + ":" + dep.getScope()); } dependencyManagementCollector.addAll( - project.getOriginalModel().getDependencyManagement().getDependencies() ); + project.getOriginalModel().getDependencyManagement().getDependencies()); } } } - private void handleOnlyProjectDependencies( Set dependencyManagement, - Set dependencies ) - { - if ( !onlyProjectDependencies ) - { + private void handleOnlyProjectDependencies(Set dependencyManagement, Set dependencies) { + if (!onlyProjectDependencies) { // Retains only dependencies not present in dependencyManagement - dependencies.removeIf( dep -> dependencyManagement.stream().anyMatch( dmDep -> match( dep, dmDep ) ) ); - } - else - { + dependencies.removeIf(dep -> dependencyManagement.stream().anyMatch(dmDep -> match(dep, dmDep))); + } else { // Retain only dependencies in dependencyManagement that are also present in dependencies - dependencyManagement.removeIf( dep -> dependencies.stream().noneMatch( dmDep -> match( dep, dmDep ) ) ); + dependencyManagement.removeIf(dep -> dependencies.stream().noneMatch(dmDep -> match(dep, dmDep))); } } @@ -252,10 +227,9 @@ private void handleOnlyProjectDependencies( Set dependencyManagement * @return a {@link Set} that can be additionally populated by {@link #populateDependencies(Set)}. * If not, an empty set is returned * */ - private Set getDependencies() - { - final Set dependenciesCollector = new TreeSet<>( DEPENDENCY_COMPARATOR ); - populateDependencies( dependenciesCollector ); + private Set getDependencies() { + final Set dependenciesCollector = new TreeSet<>(DEPENDENCY_COMPARATOR); + populateDependencies(dependenciesCollector); return dependenciesCollector; } @@ -267,7 +241,7 @@ private Set getDependencies() * @param dependenciesCollector, a Set, initialized with a DependencyComparator * comparator. * */ - protected abstract void populateDependencies( Set dependenciesCollector ); + protected abstract void populateDependencies(Set dependenciesCollector); /** * Constructs a final instance of a {@link Set} with a {@link DependencyComparator} comparator. @@ -277,10 +251,9 @@ private Set getDependencies() * @return a {@link Set} that can be additionally populated by * {@link #populateDependencyManagement(Set, Set)}. If not, an empty set is returned * */ - private Set getDependencyManagement( Set dependencies ) throws MavenReportException - { - final Set dependencyManagementCollector = new TreeSet<>( DEPENDENCY_COMPARATOR ); - populateDependencyManagement ( dependencyManagementCollector, dependencies ); + private Set getDependencyManagement(Set dependencies) throws MavenReportException { + final Set dependencyManagementCollector = new TreeSet<>(DEPENDENCY_COMPARATOR); + populateDependencyManagement(dependencyManagementCollector, dependencies); return dependencyManagementCollector; } @@ -295,37 +268,26 @@ private Set getDependencyManagement( Set dependencies ) * * @throws MavenReportException when things go wrong. * */ - protected abstract void populateDependencyManagement( Set dependencyManagementCollector, - Set dependencies ) - throws MavenReportException; - - private void renderReport( Locale locale, - Sink sink, - DependencyUpdatesModel model ) - throws MavenReportException - { - for ( String format : formats ) - { - if ( "html".equals( format ) ) - { - rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); + protected abstract void populateDependencyManagement( + Set dependencyManagementCollector, Set dependencies) throws MavenReportException; + + private void renderReport(Locale locale, Sink sink, DependencyUpdatesModel model) throws MavenReportException { + for (String format : formats) { + if ("html".equals(format)) { + rendererFactory + .createReportRenderer(getOutputName(), sink, locale, model) + .render(); + } else if ("xml".equals(format)) { + Path outputDir = Paths.get(getProject().getBuild().getDirectory()); + if (!Files.exists(outputDir)) { + try { + Files.createDirectories(outputDir); + } catch (IOException e) { + throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new DependencyUpdatesXmlReportRenderer( model, outputFile ).render(); + Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + new DependencyUpdatesXmlReportRenderer(model, outputFile).render(); } } } @@ -335,20 +297,18 @@ else if ( "xml".equals( format ) ) * * @return true if the two dependencies match */ - private boolean match( Dependency dep, Dependency dmDep ) - { - return dmDep.getGroupId().equals( dep.getGroupId() ) - && dmDep.getArtifactId().equals( dep.getArtifactId() ) - && ( dmDep.getScope() == null || dmDep.getScope().equals( dep.getScope() ) ) - && ( dmDep.getClassifier() == null || dmDep.getClassifier().equals( dep.getClassifier() ) ) - && ( dep.getVersion() == null || dmDep.getVersion() == null || dmDep.getVersion() - .equals( dep.getVersion() ) ); + private boolean match(Dependency dep, Dependency dmDep) { + return dmDep.getGroupId().equals(dep.getGroupId()) + && dmDep.getArtifactId().equals(dep.getArtifactId()) + && (dmDep.getScope() == null || dmDep.getScope().equals(dep.getScope())) + && (dmDep.getClassifier() == null || dmDep.getClassifier().equals(dep.getClassifier())) + && (dep.getVersion() == null + || dmDep.getVersion() == null + || dmDep.getVersion().equals(dep.getVersion())); } - protected boolean hasDependencyManagement( MavenProject project ) - { - if ( project == null ) - { + protected boolean hasDependencyManagement(MavenProject project) { + if (project == null) { return false; } return project.getDependencyManagement() != null @@ -358,8 +318,7 @@ protected boolean hasDependencyManagement( MavenProject project ) /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "dependency-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java index 36ed84d9f0..f96ec322cb 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java @@ -17,8 +17,6 @@ * */ -import static org.codehaus.mojo.versions.utils.MiscUtils.filter; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -27,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; + import org.apache.maven.doxia.sink.Sink; import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Parameter; @@ -42,20 +41,20 @@ import org.codehaus.mojo.versions.xml.PluginUpdatesXmlReportRenderer; import org.codehaus.plexus.i18n.I18N; +import static org.codehaus.mojo.versions.utils.MiscUtils.filter; + /** * Generates a report of available updates for the plugins of a project. */ - -public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsReport -{ +public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsReport { private static final PluginComparator PLUGIN_COMPARATOR = PluginComparator.INSTANCE; /** * Report formats (html and/or xml). HTML by default. */ - @Parameter( property = "pluginUpdatesReportFormats", defaultValue = "html" ) - private String[] formats = new String[] { "html" }; + @Parameter(property = "pluginUpdatesReportFormats", defaultValue = "html") + private String[] formats = new String[] {"html"}; /** * If true, only shows the subsection of the pluginManagement artifacts that @@ -63,7 +62,7 @@ public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsRe * * @since 2.12 */ - @Parameter( property = "onlyProjectPlugins", defaultValue = "false" ) + @Parameter(property = "onlyProjectPlugins", defaultValue = "false") protected boolean onlyProjectPlugins; /** @@ -71,44 +70,42 @@ public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsRe * * @since 2.12 */ - @Parameter( property = "onlyUpgradable", defaultValue = "false" ) + @Parameter(property = "onlyUpgradable", defaultValue = "false") protected boolean onlyUpgradable; - public AbstractPluginUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + public AbstractPluginUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} */ - public boolean isExternalReport() - { + public boolean isExternalReport() { return false; } /** * {@inheritDoc} */ - public boolean canGenerateReport() - { - return haveBuildPlugins( getProject() ) || haveBuildPluginManagementPlugins( getProject() ); + public boolean canGenerateReport() { + return haveBuildPlugins(getProject()) || haveBuildPluginManagementPlugins(getProject()); } - protected boolean haveBuildPluginManagementPlugins( MavenProject project ) - { - return project.getBuild() != null && project.getBuild().getPluginManagement() != null - && project.getBuild().getPluginManagement().getPlugins() != null && !project.getBuild() - .getPluginManagement().getPlugins().isEmpty(); + protected boolean haveBuildPluginManagementPlugins(MavenProject project) { + return project.getBuild() != null + && project.getBuild().getPluginManagement() != null + && project.getBuild().getPluginManagement().getPlugins() != null + && !project.getBuild().getPluginManagement().getPlugins().isEmpty(); } - protected boolean haveBuildPlugins( MavenProject project ) - { - return project.getBuild() != null && project.getBuild().getPlugins() != null + protected boolean haveBuildPlugins(MavenProject project) { + return project.getBuild() != null + && project.getBuild().getPlugins() != null && !project.getBuild().getPlugins().isEmpty(); } @@ -118,34 +115,29 @@ protected boolean haveBuildPlugins( MavenProject project ) * @param locale the locale to generate the report for. * @param sink the report formatting tool */ - protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException - { + protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { Set pluginManagement = getPluginManagement(); Set plugins = getPlugins(); - handleOnlyProjectPlugins( pluginManagement, plugins ); + handleOnlyProjectPlugins(pluginManagement, plugins); - try - { + try { Map pluginUpdates = - getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() ); + getHelper().lookupPluginsUpdates(plugins, getAllowSnapshots()); Map pluginManagementUpdates = - getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() ); + getHelper().lookupPluginsUpdates(pluginManagement, getAllowSnapshots()); - if ( onlyUpgradable ) - { - pluginUpdates = filter( pluginUpdates, p -> p.getVersions().length > 0 ); - pluginManagementUpdates = filter( pluginManagementUpdates, p -> p.getVersions().length > 0 ); + if (onlyUpgradable) { + pluginUpdates = filter(pluginUpdates, p -> p.getVersions().length > 0); + pluginManagementUpdates = filter(pluginManagementUpdates, p -> p.getVersions().length > 0); } - renderReport( locale, sink, new PluginUpdatesModel( pluginUpdates, pluginManagementUpdates ) ); - } - catch ( VersionRetrievalException e ) - { - throw new MavenReportException( e.getMessage(), e ); + renderReport(locale, sink, new PluginUpdatesModel(pluginUpdates, pluginManagementUpdates)); + } catch (VersionRetrievalException e) { + throw new MavenReportException(e.getMessage(), e); } } @@ -157,10 +149,9 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx * @return a {@link Set} that can be additionally populated by {@link #populatePluginManagement(Set)}}. * If not, an empty set is returned * */ - private Set getPluginManagement() - { - final Set pluginManagementCollector = new TreeSet<>( PLUGIN_COMPARATOR ); - populatePluginManagement( pluginManagementCollector ); + private Set getPluginManagement() { + final Set pluginManagementCollector = new TreeSet<>(PLUGIN_COMPARATOR); + populatePluginManagement(pluginManagementCollector); return pluginManagementCollector; } @@ -170,8 +161,7 @@ private Set getPluginManagement() * * @param pluginManagementCollector, a set initialized with a {@link PluginComparator} comparator. * */ - protected abstract void populatePluginManagement( Set pluginManagementCollector ); - + protected abstract void populatePluginManagement(Set pluginManagementCollector); /** * Constructs a final instance of a {@link Set} with a {@link PluginComparator} comparator. This set can be @@ -180,10 +170,9 @@ private Set getPluginManagement() * @return a {@link Set} that can be additionally populated by {@link #populatePlugins(Set)}. * If not, an empty set is returned * */ - private Set getPlugins() - { - final Set pluginsCollector = new TreeSet<>( PLUGIN_COMPARATOR ); - populatePlugins( pluginsCollector ); + private Set getPlugins() { + final Set pluginsCollector = new TreeSet<>(PLUGIN_COMPARATOR); + populatePlugins(pluginsCollector); return pluginsCollector; } @@ -193,52 +182,39 @@ private Set getPlugins() * *@param pluginsCollector, a set initialized with a {@link PluginComparator} comparator. * */ - protected abstract void populatePlugins( Set pluginsCollector ); - - private void renderReport( Locale locale, Sink sink, PluginUpdatesModel model ) - throws MavenReportException - { - for ( String format : formats ) - { - if ( "html".equals( format ) ) - { - rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); + protected abstract void populatePlugins(Set pluginsCollector); + + private void renderReport(Locale locale, Sink sink, PluginUpdatesModel model) throws MavenReportException { + for (String format : formats) { + if ("html".equals(format)) { + rendererFactory + .createReportRenderer(getOutputName(), sink, locale, model) + .render(); + } else if ("xml".equals(format)) { + Path outputDir = Paths.get(getProject().getBuild().getDirectory()); + if (!Files.exists(outputDir)) { + try { + Files.createDirectories(outputDir); + } catch (IOException e) { + throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new PluginUpdatesXmlReportRenderer( model, outputFile ).render(); + Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + new PluginUpdatesXmlReportRenderer(model, outputFile).render(); } } } - private void handleOnlyProjectPlugins( Set pluginManagement, Set plugins ) - { + private void handleOnlyProjectPlugins(Set pluginManagement, Set plugins) { - if ( !onlyProjectPlugins ) - { + if (!onlyProjectPlugins) { // Retains only plugins not present in pluginManagement - plugins.removeIf( plugin -> pluginManagement.stream() - .anyMatch( pmPlugin -> PLUGIN_COMPARATOR.compare( plugin, pmPlugin ) == 0 ) ); - } - else - { + plugins.removeIf(plugin -> + pluginManagement.stream().anyMatch(pmPlugin -> PLUGIN_COMPARATOR.compare(plugin, pmPlugin) == 0)); + } else { // Retain only plugins in pluginManagement that are also present in plugins pluginManagement.removeIf( - pmPlugin -> plugins.stream() - .noneMatch( plugin -> PLUGIN_COMPARATOR.compare( plugin, pmPlugin ) == 0 ) ); + pmPlugin -> plugins.stream().noneMatch(plugin -> PLUGIN_COMPARATOR.compare(plugin, pmPlugin) == 0)); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java index 0380369d03..e2ab84276a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java @@ -24,6 +24,7 @@ import java.util.Locale; import java.util.Map; import java.util.TreeMap; + import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; @@ -44,9 +45,7 @@ * Generates a report of available updates for properties of a project which are linked to the dependencies and/or * plugins of a project. */ -public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersionsReport -{ - +public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersionsReport { private static final PropertyComparator PROPERTIES_COMPARATOR = PropertyComparator.INSTANCE; @@ -63,7 +62,7 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions * * @since 1.0-beta-1 */ - @Parameter( property = "includeProperties" ) + @Parameter(property = "includeProperties") private String includeProperties = null; /** @@ -71,7 +70,7 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions * * @since 1.0-beta-1 */ - @Parameter( property = "excludeProperties" ) + @Parameter(property = "excludeProperties") private String excludeProperties = null; /** @@ -79,7 +78,7 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions * * @since 1.0-beta-1 */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) + @Parameter(property = "autoLinkItems", defaultValue = "true") private boolean autoLinkItems; /** @@ -87,7 +86,7 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions * * @since 2.14.0 */ - @Parameter( property = "includeParent", defaultValue = "true" ) + @Parameter(property = "includeParent", defaultValue = "true") private boolean includeParent = true; /** @@ -95,56 +94,46 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions * * @since 2.14.0 */ - @Parameter( property = "propertyUpdatesReportFormats", defaultValue = "html" ) + @Parameter(property = "propertyUpdatesReportFormats", defaultValue = "html") protected String[] formats = new String[] {"html"}; - public AbstractPropertyUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + public AbstractPropertyUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} */ - public boolean isExternalReport() - { + public boolean isExternalReport() { return false; } /** * {@inheritDoc} */ - public boolean canGenerateReport() - { + public boolean canGenerateReport() { return haveBuildProperties(); } - protected boolean haveBuildProperties() - { - return getProject().getProperties() != null && !getProject().getProperties().isEmpty(); + protected boolean haveBuildProperties() { + return getProject().getProperties() != null + && !getProject().getProperties().isEmpty(); } - protected void doGenerateReport( Locale locale, Sink sink ) - throws MavenReportException - { - try - { - final Map updateSet = new TreeMap<>( PROPERTIES_COMPARATOR ); - populateUpdateSet( updateSet ); - - renderReport( locale, - sink, - getPropertyUpdatesModel( updateSet ) ); - } - catch ( MojoExecutionException e ) - { - throw new MavenReportException( e.getMessage(), e ); - } + protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { + try { + final Map updateSet = new TreeMap<>(PROPERTIES_COMPARATOR); + populateUpdateSet(updateSet); + renderReport(locale, sink, getPropertyUpdatesModel(updateSet)); + } catch (MojoExecutionException e) { + throw new MavenReportException(e.getMessage(), e); + } } /** @@ -155,64 +144,51 @@ protected void doGenerateReport( Locale locale, Sink sink ) * @throws MavenReportException when things go wrong. * @throws MojoExecutionException if something goes wrong. * */ - protected abstract void populateUpdateSet( - Map propertyCollector ) + protected abstract void populateUpdateSet(Map propertyCollector) throws MojoExecutionException, MavenReportException; + private void renderReport(Locale locale, Sink sink, PropertyUpdatesModel propertyUpdatesModel) + throws MavenReportException { - private void renderReport( Locale locale, Sink sink, PropertyUpdatesModel propertyUpdatesModel ) - throws MavenReportException - { - - for ( String format : this.formats ) - { - if ( "html".equals( format ) ) - { - this.rendererFactory.createReportRenderer( getOutputName(), sink, locale, propertyUpdatesModel ) + for (String format : this.formats) { + if ("html".equals(format)) { + this.rendererFactory + .createReportRenderer(getOutputName(), sink, locale, propertyUpdatesModel) .render(); - } - else if ( "xml".equals( format ) ) - { - Path outputDir = Paths.get( getProject().getBuild().getDirectory() ); - if ( !Files.exists( outputDir ) ) - { - try - { - Files.createDirectories( outputDir ); - } - catch ( IOException e ) - { - throw new MavenReportException( "Could not create the output directory" ); + } else if ("xml".equals(format)) { + Path outputDir = Paths.get(getProject().getBuild().getDirectory()); + if (!Files.exists(outputDir)) { + try { + Files.createDirectories(outputDir); + } catch (IOException e) { + throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve( getOutputName() + ".xml" ); - new PropertyUpdatesXmlReportRenderer( propertyUpdatesModel, outputFile ).render(); + Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + new PropertyUpdatesXmlReportRenderer(propertyUpdatesModel, outputFile).render(); } } } - private PropertyUpdatesModel getPropertyUpdatesModel( Map updateSet ) - { - return new PropertyUpdatesModel( PROPERTIES_COMPARATOR, updateSet ); + private PropertyUpdatesModel getPropertyUpdatesModel(Map updateSet) { + return new PropertyUpdatesModel(PROPERTIES_COMPARATOR, updateSet); } - protected VersionPropertiesMapRequest getRequest( MavenProject project ) - { + protected VersionPropertiesMapRequest getRequest(MavenProject project) { return VersionPropertiesMapRequest.builder() - .withMavenProject( project ) - .withPropertyDefinitions( this.properties ) - .withIncludeProperties( this.includeProperties ) - .withExcludeProperties( this.excludeProperties ) - .withIncludeParent( this.includeParent ) - .withAutoLinkItems( this.autoLinkItems ) + .withMavenProject(project) + .withPropertyDefinitions(this.properties) + .withIncludeProperties(this.includeProperties) + .withExcludeProperties(this.excludeProperties) + .withIncludeParent(this.includeParent) + .withAutoLinkItems(this.autoLinkItems) .build(); } /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "property-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java index 2f442832aa..dd27032b9b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDependencyUpdaterMojo.java @@ -56,9 +56,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public abstract class AbstractVersionsDependencyUpdaterMojo - extends AbstractVersionsUpdaterMojo -{ +public abstract class AbstractVersionsDependencyUpdaterMojo extends AbstractVersionsUpdaterMojo { private static final String END_RANGE_CHARS = "])"; private static final String START_RANGE_CHARS = "[("; @@ -66,8 +64,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo /** * Pattern to match snapshot versions */ - protected static final Pattern SNAPSHOT_REGEX = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); - + protected static final Pattern SNAPSHOT_REGEX = Pattern.compile("^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$"); /** * A comma separated list of artifact patterns to include. Follows the pattern @@ -77,7 +74,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 1.0-beta-1 */ - @Parameter( property = "includes" ) + @Parameter(property = "includes") private String includesList = null; /** @@ -88,7 +85,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 1.0-beta-1 */ - @Parameter( property = "excludes" ) + @Parameter(property = "excludes") private String excludesList = null; /** @@ -114,7 +111,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "processDependencies", defaultValue = "true" ) + @Parameter(property = "processDependencies", defaultValue = "true") private boolean processDependencies = true; /** @@ -122,7 +119,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "processDependencyManagement", defaultValue = "true" ) + @Parameter(property = "processDependencyManagement", defaultValue = "true") private boolean processDependencyManagement = true; /** @@ -130,7 +127,7 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 2.3 */ - @Parameter( property = "processParent", defaultValue = "false" ) + @Parameter(property = "processParent", defaultValue = "false") private boolean processParent = false; /** @@ -152,16 +149,16 @@ public abstract class AbstractVersionsDependencyUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "excludeReactor", defaultValue = "true" ) + @Parameter(property = "excludeReactor", defaultValue = "true") private boolean excludeReactor = true; @Inject - protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + protected AbstractVersionsDependencyUpdaterMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -170,8 +167,7 @@ protected AbstractVersionsDependencyUpdaterMojo( RepositorySystem repositorySyst * @return returns true if the project/dependencies section of the pom should be processed. * @since 1.0-alpha-3 */ - public boolean isProcessingDependencies() - { + public boolean isProcessingDependencies() { return processDependencies; } @@ -181,8 +177,7 @@ public boolean isProcessingDependencies() * @return returns true if the project/dependencyManagement section of the pom should be processed. * @since 1.0-alpha-3 */ - public boolean isProcessingDependencyManagement() - { + public boolean isProcessingDependencyManagement() { return processDependencyManagement; } @@ -192,8 +187,7 @@ public boolean isProcessingDependencyManagement() * @return returns true if the project/parent section of the pom should be processed. * @since 2.3 */ - public boolean isProcessingParent() - { + public boolean isProcessingParent() { return processParent; } @@ -204,8 +198,7 @@ public boolean isProcessingParent() * should be excluded from processing. * @since 1.0-alpha-3 */ - public boolean isExcludeReactor() - { + public boolean isExcludeReactor() { return excludeReactor; } @@ -216,10 +209,9 @@ public boolean isExcludeReactor() * @return true if the version starts with '${' * @since 2.8 */ - protected boolean isHandledByProperty( Dependency dependency ) - { + protected boolean isHandledByProperty(Dependency dependency) { String version = dependency.getVersion(); - return version != null && version.startsWith( "${" ); + return version != null && version.startsWith("${"); } /** @@ -229,16 +221,12 @@ protected boolean isHandledByProperty( Dependency dependency ) * @return Artifact * @since 1.0-alpha-3 */ - protected Artifact findArtifact( Dependency dependency ) - { - if ( getProject().getDependencyArtifacts() == null ) - { + protected Artifact findArtifact(Dependency dependency) { + if (getProject().getDependencyArtifacts() == null) { return null; } - for ( Artifact artifact : getProject().getDependencyArtifacts() ) - { - if ( compare( artifact, dependency ) ) - { + for (Artifact artifact : getProject().getDependencyArtifacts()) { + if (compare(artifact, dependency)) { return artifact; } } @@ -253,84 +241,70 @@ protected Artifact findArtifact( Dependency dependency ) * @throws MojoExecutionException Mojo execution exception * @since 1.0-alpha-3 */ - protected Artifact toArtifact( Dependency dependency ) - throws MojoExecutionException - { - Artifact artifact = findArtifact( dependency ); - if ( artifact == null ) - { - return getHelper().createDependencyArtifact( dependency ); + protected Artifact toArtifact(Dependency dependency) throws MojoExecutionException { + Artifact artifact = findArtifact(dependency); + if (artifact == null) { + return getHelper().createDependencyArtifact(dependency); } return artifact; } - protected Artifact toArtifact( Parent model ) - throws MojoExecutionException - { - return this.toArtifact( DependencyBuilder.newBuilder() - .withGroupId( model.getGroupId() ) - .withArtifactId( model.getArtifactId() ) - .withVersion( model.getVersion() ) - .withType( "pom" ) - .withScope( Artifact.SCOPE_COMPILE ) - .build() ); + protected Artifact toArtifact(Parent model) throws MojoExecutionException { + return this.toArtifact(DependencyBuilder.newBuilder() + .withGroupId(model.getGroupId()) + .withArtifactId(model.getArtifactId()) + .withVersion(model.getVersion()) + .withType("pom") + .withScope(Artifact.SCOPE_COMPILE) + .build()); } /** * Returns the {@link Dependency} instance for the parent project * @return {@link Dependency} object for the parent */ - protected Dependency getParentDependency() - { + protected Dependency getParentDependency() { return DependencyBuilder.newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( getProject().getParent().getVersion() ) - .withType( "pom" ) + .withGroupId(getProject().getParent().getGroupId()) + .withArtifactId(getProject().getParent().getArtifactId()) + .withVersion(getProject().getParent().getVersion()) + .withType("pom") .build(); } - protected String toString( MavenProject project ) - { + protected String toString(MavenProject project) { StringBuilder buf = new StringBuilder(); - buf.append( project.getGroupId() ); - buf.append( ':' ); - buf.append( project.getArtifactId() ); + buf.append(project.getGroupId()); + buf.append(':'); + buf.append(project.getArtifactId()); - if ( project.getVersion() != null && project.getVersion().length() > 0 ) - { - buf.append( ":" ); - buf.append( project.getVersion() ); + if (project.getVersion() != null && project.getVersion().length() > 0) { + buf.append(":"); + buf.append(project.getVersion()); } return buf.toString(); } - protected String toString( Dependency d ) - { + protected String toString(Dependency d) { StringBuilder buf = new StringBuilder(); - buf.append( d.getGroupId() ); - buf.append( ':' ); - buf.append( d.getArtifactId() ); - if ( d.getType() != null && d.getType().length() > 0 ) - { - buf.append( ':' ); - buf.append( d.getType() ); - } - else - { - buf.append( ":jar" ); + buf.append(d.getGroupId()); + buf.append(':'); + buf.append(d.getArtifactId()); + if (d.getType() != null && d.getType().length() > 0) { + buf.append(':'); + buf.append(d.getType()); + } else { + buf.append(":jar"); } - if ( d.getClassifier() != null && d.getClassifier().length() > 0 ) - { - buf.append( ':' ); - buf.append( d.getClassifier() ); + if (d.getClassifier() != null && d.getClassifier().length() > 0) { + buf.append(':'); + buf.append(d.getClassifier()); } - if ( d.getVersion() != null && d.getVersion().length() > 0 ) - { - buf.append( ":" ); - buf.append( d.getVersion() ); + if (d.getVersion() != null && d.getVersion().length() > 0) { + buf.append(":"); + buf.append(d.getVersion()); } return buf.toString(); } @@ -342,10 +316,8 @@ protected String toString( Dependency d ) * @return true if the dependency is produced by the current reactor. * @since 1.0-alpha-3 */ - protected boolean isProducedByReactor( Dependency dependency ) - { - return reactorProjects.stream() - .anyMatch( reactorProject -> compare( reactorProject, dependency ) ); + protected boolean isProducedByReactor(Dependency dependency) { + return reactorProjects.stream().anyMatch(reactorProject -> compare(reactorProject, dependency)); } /** @@ -355,13 +327,11 @@ protected boolean isProducedByReactor( Dependency dependency ) * @param dep the dependency * @return true if project and dep refer to the same artifact */ - private boolean compare( MavenProject project, Dependency dep ) - { - if ( !StringUtils.equals( project.getGroupId(), dep.getGroupId() ) ) - { + private boolean compare(MavenProject project, Dependency dep) { + if (!StringUtils.equals(project.getGroupId(), dep.getGroupId())) { return false; } - return project.getArtifactId().equals( dep.getArtifactId() ); + return project.getArtifactId().equals(dep.getArtifactId()); } /** @@ -372,21 +342,17 @@ private boolean compare( MavenProject project, Dependency dep ) * @param dep Dependency * @return true if artifact and dep refer to the same artifact */ - private boolean compare( Artifact artifact, Dependency dep ) - { - if ( !StringUtils.equals( artifact.getGroupId(), dep.getGroupId() ) ) - { + private boolean compare(Artifact artifact, Dependency dep) { + if (!StringUtils.equals(artifact.getGroupId(), dep.getGroupId())) { return false; } - if ( !StringUtils.equals( artifact.getArtifactId(), dep.getArtifactId() ) ) - { + if (!StringUtils.equals(artifact.getArtifactId(), dep.getArtifactId())) { return false; } - if ( !StringUtils.equals( artifact.getType(), dep.getType() ) ) - { + if (!StringUtils.equals(artifact.getType(), dep.getType())) { return false; } - return StringUtils.equals( artifact.getClassifier(), dep.getClassifier() ); + return StringUtils.equals(artifact.getClassifier(), dep.getClassifier()); } /** @@ -395,22 +361,19 @@ private boolean compare( Artifact artifact, Dependency dep ) * @param artifact The artifact we want to check. * @return true if the artifact should be processed, false otherwise. */ - protected boolean isIncluded( Artifact artifact ) - { + protected boolean isIncluded(Artifact artifact) { boolean result = true; ArtifactFilter includesFilter = this.getIncludesArtifactFilter(); - if ( includesFilter != null ) - { - result = includesFilter.include( artifact ); + if (includesFilter != null) { + result = includesFilter.include(artifact); } ArtifactFilter excludesFilter = this.getExcludesArtifactFilter(); - if ( excludesFilter != null ) - { - result = result && excludesFilter.include( artifact ); + if (excludesFilter != null) { + result = result && excludesFilter.include(artifact); } return result; @@ -421,43 +384,32 @@ protected boolean isIncluded( Artifact artifact ) * * @return true if includes were specified, false otherwise. */ - protected boolean hasIncludes() - { + protected boolean hasIncludes() { return includes != null || includesList != null; } - private ArtifactFilter getIncludesArtifactFilter() - { - if ( includesFilter == null && ( includes != null || includesList != null ) ) - { + private ArtifactFilter getIncludesArtifactFilter() { + if (includesFilter == null && (includes != null || includesList != null)) { List patterns = new ArrayList<>(); - if ( this.includesList != null ) - { - patterns.addAll( separatePatterns( includesList ) ); - } - else if ( includes != null ) - { - patterns.addAll( Arrays.asList( includes ) ); + if (this.includesList != null) { + patterns.addAll(separatePatterns(includesList)); + } else if (includes != null) { + patterns.addAll(Arrays.asList(includes)); } - includesFilter = new PatternIncludesArtifactFilter( patterns ); + includesFilter = new PatternIncludesArtifactFilter(patterns); } return includesFilter; } - private ArtifactFilter getExcludesArtifactFilter() - { - if ( excludesFilter == null && ( excludes != null || excludesList != null ) ) - { + private ArtifactFilter getExcludesArtifactFilter() { + if (excludesFilter == null && (excludes != null || excludesList != null)) { List patterns = new ArrayList<>(); - if ( excludesList != null ) - { - patterns.addAll( separatePatterns( excludesList ) ); + if (excludesList != null) { + patterns.addAll(separatePatterns(excludesList)); + } else if (excludes != null) { + patterns.addAll(Arrays.asList(excludes)); } - else if ( excludes != null ) - { - patterns.addAll( Arrays.asList( excludes ) ); - } - excludesFilter = new PatternExcludesArtifactFilter( patterns ); + excludesFilter = new PatternExcludesArtifactFilter(patterns); } return excludesFilter; } @@ -469,62 +421,49 @@ else if ( excludes != null ) * @param includeString the string to parse * @return list of patterns */ - protected List separatePatterns( String includeString ) - { - if ( includeString == null ) - { + protected List separatePatterns(String includeString) { + if (includeString == null) { return Collections.emptyList(); } List patterns = new ArrayList<>(); - int indexOf = nextCommaIndex( includeString ); - while ( indexOf >= 0 ) - { - patterns.add( includeString.substring( 0, indexOf ) ); - includeString = includeString.substring( indexOf + 1 ); - indexOf = nextCommaIndex( includeString ); + int indexOf = nextCommaIndex(includeString); + while (indexOf >= 0) { + patterns.add(includeString.substring(0, indexOf)); + includeString = includeString.substring(indexOf + 1); + indexOf = nextCommaIndex(includeString); } - patterns.add( includeString ); + patterns.add(includeString); return patterns; } - private int nextCommaIndex( final String includeString ) - { + private int nextCommaIndex(final String includeString) { - int indexOfComma = includeString.indexOf( ',' ); - int nextRangeStartDelimiterIndex = findFirstChar( includeString, START_RANGE_CHARS ); - if ( nextRangeStartDelimiterIndex >= 0 ) - { - if ( !( indexOfComma >= 0 && indexOfComma < nextRangeStartDelimiterIndex ) ) - { - int nextStopDelimiterIndex = findFirstChar( includeString, END_RANGE_CHARS ); + int indexOfComma = includeString.indexOf(','); + int nextRangeStartDelimiterIndex = findFirstChar(includeString, START_RANGE_CHARS); + if (nextRangeStartDelimiterIndex >= 0) { + if (!(indexOfComma >= 0 && indexOfComma < nextRangeStartDelimiterIndex)) { + int nextStopDelimiterIndex = findFirstChar(includeString, END_RANGE_CHARS); // recursive call - int tmp = nextCommaIndex( includeString.substring( nextStopDelimiterIndex + 1 ) ); - indexOfComma = ( tmp >= 0 ) ? nextStopDelimiterIndex + 1 + tmp : -1; + int tmp = nextCommaIndex(includeString.substring(nextStopDelimiterIndex + 1)); + indexOfComma = (tmp >= 0) ? nextStopDelimiterIndex + 1 + tmp : -1; } } return indexOfComma; - } - private int findFirstChar( final String includeString, final String chars ) - { + private int findFirstChar(final String includeString, final String chars) { int nextRangeStartDelimiterIndex = -1; char[] delimiters = chars.toCharArray(); - for ( char delimiter : delimiters ) - { - int index = includeString.indexOf( delimiter ); - if ( index >= 0 && nextRangeStartDelimiterIndex >= 0 ) - { - nextRangeStartDelimiterIndex = Math.min( index, nextRangeStartDelimiterIndex ); - } - else - { - if ( index >= 0 ) - { + for (char delimiter : delimiters) { + int index = includeString.indexOf(delimiter); + if (index >= 0 && nextRangeStartDelimiterIndex >= 0) { + nextRangeStartDelimiterIndex = Math.min(index, nextRangeStartDelimiterIndex); + } else { + if (index >= 0) { nextRangeStartDelimiterIndex = index; } } @@ -543,45 +482,52 @@ private int findFirstChar( final String includeString, final String chars ) * @return {@code true} if an update has been made, {@code false} otherwise * @throws XMLStreamException thrown if updating the XML doesn't succeed */ - protected boolean updateDependencyVersion( ModifiedPomXMLEventReader pom, Dependency dep, - String newVersion, ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException - { + protected boolean updateDependencyVersion( + ModifiedPomXMLEventReader pom, Dependency dep, String newVersion, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException { boolean updated = false; - if ( isProcessingParent() + if (isProcessingParent() && getProject().getParent() != null - && DependencyComparator.INSTANCE.compare( dep, DependencyBuilder.newBuilder() - .withGroupId( getProject().getParentArtifact().getGroupId() ) - .withArtifactId( getProject().getParentArtifact().getArtifactId() ) - .withVersion( getProject().getParentArtifact().getVersion() ) - .build() ) == 0 - && PomHelper.setProjectParentVersion( pom, newVersion ) ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Made parent update from " + dep.getVersion() + " to " + newVersion ); + && DependencyComparator.INSTANCE.compare( + dep, + DependencyBuilder.newBuilder() + .withGroupId( + getProject().getParentArtifact().getGroupId()) + .withArtifactId( + getProject().getParentArtifact().getArtifactId()) + .withVersion( + getProject().getParentArtifact().getVersion()) + .build()) + == 0 + && PomHelper.setProjectParentVersion(pom, newVersion)) { + if (getLog().isDebugEnabled()) { + getLog().debug("Made parent update from " + dep.getVersion() + " to " + newVersion); } - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( changeKind ) - .withDependency( dep ) - .withNewVersion( newVersion ) - .build() ); + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(changeKind) + .withDependency(dep) + .withNewVersion(newVersion) + .build()); updated = true; } - if ( PomHelper.setDependencyVersion( pom, - dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - newVersion, getProject().getModel() ) ) - { - if ( getLog().isInfoEnabled() ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + newVersion ); + if (PomHelper.setDependencyVersion( + pom, + dep.getGroupId(), + dep.getArtifactId(), + dep.getVersion(), + newVersion, + getProject().getModel())) { + if (getLog().isInfoEnabled()) { + getLog().info("Updated " + toString(dep) + " to version " + newVersion); } - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( changeKind ) - .withDependency( dep ) - .withNewVersion( newVersion ) - .build() ); + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(changeKind) + .withDependency(dep) + .withNewVersion(newVersion) + .build()); updated = true; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java index 635732cb83..e59587f3e9 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsDisplayMojo.java @@ -40,10 +40,8 @@ * * @author Stephen Connolly */ -public abstract class AbstractVersionsDisplayMojo - extends AbstractVersionsUpdaterMojo -{ - static final String NL = System.getProperty( "line.separator" ); +public abstract class AbstractVersionsDisplayMojo extends AbstractVersionsUpdaterMojo { + static final String NL = System.getProperty("line.separator"); private static final int DEFAULT_OUTPUT_LINE_WIDTH = 80; @@ -52,7 +50,7 @@ public abstract class AbstractVersionsDisplayMojo * * @since 2.2 */ - @Parameter( property = "versions.outputFile" ) + @Parameter(property = "versions.outputFile") protected File outputFile; /** @@ -60,7 +58,7 @@ public abstract class AbstractVersionsDisplayMojo * * @since 2.2 */ - @Parameter( property = "versions.logOutput", defaultValue = "true" ) + @Parameter(property = "versions.logOutput", defaultValue = "true") protected boolean logOutput; /** @@ -68,7 +66,7 @@ public abstract class AbstractVersionsDisplayMojo * * @since 2.2 */ - @Parameter( property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}" ) + @Parameter(property = "outputEncoding", defaultValue = "${project.reporting.outputEncoding}") protected String outputEncoding; /** @@ -76,105 +74,81 @@ public abstract class AbstractVersionsDisplayMojo * * @since 2.10.0 */ - @Parameter( property = "versions.outputLineWidth", - defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "" ) + @Parameter( + property = "versions.outputLineWidth", + defaultValue = AbstractVersionsDisplayMojo.DEFAULT_OUTPUT_LINE_WIDTH + "") protected int outputLineWidth; private boolean outputFileError = false; @Inject - protected AbstractVersionsDisplayMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + protected AbstractVersionsDisplayMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } - @SuppressWarnings( "unchecked" ) - protected void logInit() - { - if ( outputFile != null && !outputFileError ) - { - if ( outputFile.isFile() ) - { + @SuppressWarnings("unchecked") + protected void logInit() { + if (outputFile != null && !outputFileError) { + if (outputFile.isFile()) { final String key = AbstractVersionsDisplayMojo.class.getName() + ".outputFile"; String outputFileName; - try - { + try { outputFileName = outputFile.getCanonicalPath(); - } - catch ( IOException e ) - { + } catch (IOException e) { outputFileName = outputFile.getAbsolutePath(); } - Set files = (Set) getPluginContext().get( key ); - if ( files == null ) - { + Set files = (Set) getPluginContext().get(key); + if (files == null) { files = new LinkedHashSet<>(); + } else { + files = new LinkedHashSet<>(files); } - else - { - files = new LinkedHashSet<>( files ); - } - if ( !files.contains( outputFileName ) ) - { - if ( !outputFile.delete() ) - { - getLog().error( "Cannot delete " + outputFile + " will append instead" ); + if (!files.contains(outputFileName)) { + if (!outputFile.delete()) { + getLog().error("Cannot delete " + outputFile + " will append instead"); } } - files.add( outputFileName ); - getPluginContext().put( key, files ); - } - else - { - if ( outputFile.exists() ) - { - getLog().error( "Cannot send output to " + outputFile + " as it exists but is not a file" ); + files.add(outputFileName); + getPluginContext().put(key, files); + } else { + if (outputFile.exists()) { + getLog().error("Cannot send output to " + outputFile + " as it exists but is not a file"); outputFileError = true; - } - else if ( !outputFile.getParentFile().isDirectory() ) - { - if ( !outputFile.getParentFile().mkdirs() ) - { + } else if (!outputFile.getParentFile().isDirectory()) { + if (!outputFile.getParentFile().mkdirs()) { outputFileError = true; } } } - if ( !outputFileError && StringUtils.isBlank( outputEncoding ) ) - { - outputEncoding = System.getProperty( "file.encoding" ); - getLog().warn( "File encoding has not been set, using platform encoding " + outputEncoding - + ", i.e. build is platform dependent!" ); + if (!outputFileError && StringUtils.isBlank(outputEncoding)) { + outputEncoding = System.getProperty("file.encoding"); + getLog().warn("File encoding has not been set, using platform encoding " + outputEncoding + + ", i.e. build is platform dependent!"); } } } - protected void logLine( boolean error, String line ) - { - if ( logOutput ) - { - if ( error ) - { - getLog().error( line ); - } - else - { - getLog().info( line ); + protected void logLine(boolean error, String line) { + if (logOutput) { + if (error) { + getLog().error(line); + } else { + getLog().info(line); } } - if ( outputFile != null && !outputFileError ) - { - try - { - Files.write( outputFile.toPath(), - ( error ? "> " + line + NL : line + NL ).getBytes( outputEncoding ), - StandardOpenOption.APPEND, StandardOpenOption.CREATE ); - } - catch ( IOException e ) - { - getLog().error( "Cannot send output to " + outputFile, e ); + if (outputFile != null && !outputFileError) { + try { + Files.write( + outputFile.toPath(), + (error ? "> " + line + NL : line + NL).getBytes(outputEncoding), + StandardOpenOption.APPEND, + StandardOpenOption.CREATE); + } catch (IOException e) { + getLog().error("Cannot send output to " + outputFile, e); outputFileError = true; } } @@ -183,9 +157,7 @@ protected void logLine( boolean error, String line ) /** * @return Offset of the configured output line width compared to the default with of 80. */ - protected int getOutputLineWidthOffset() - { + protected int getOutputLineWidthOffset() { return this.outputLineWidth - DEFAULT_OUTPUT_LINE_WIDTH; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index bf7d697965..18f815eca6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -48,9 +48,7 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -public abstract class AbstractVersionsReport - extends AbstractMavenReport -{ +public abstract class AbstractVersionsReport extends AbstractMavenReport { /** * Internationalization component. * @@ -65,7 +63,7 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-3 */ - @Parameter( property = "versions.skip" ) + @Parameter(property = "versions.skip") private boolean skip; /** @@ -78,7 +76,7 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-3 */ - @Parameter( property = "maven.version.rules.serverId", defaultValue = "serverId" ) + @Parameter(property = "maven.version.rules.serverId", defaultValue = "serverId") private String serverId; /** @@ -88,7 +86,7 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-3 */ - @Parameter( property = "maven.version.rules" ) + @Parameter(property = "maven.version.rules") private String rulesUri; /** @@ -98,7 +96,7 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-1 */ - @Parameter( property = "comparisonMethod" ) + @Parameter(property = "comparisonMethod") protected String comparisonMethod; /** @@ -106,7 +104,7 @@ public abstract class AbstractVersionsReport * * @since 1.0-alpha-3 */ - @Parameter( property = "allowSnapshots", defaultValue = "false" ) + @Parameter(property = "allowSnapshots", defaultValue = "false") protected boolean allowSnapshots; /** @@ -119,10 +117,10 @@ public abstract class AbstractVersionsReport * * @since 1.0-beta-1 */ - @Parameter( defaultValue = "${session}", required = true, readonly = true ) + @Parameter(defaultValue = "${session}", required = true, readonly = true) protected MavenSession session; - @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) + @Parameter(defaultValue = "${mojoExecution}", required = true, readonly = true) private MojoExecution mojoExecution; /** @@ -149,7 +147,7 @@ public abstract class AbstractVersionsReport *

    Currently, this parameter will override the defined {@link #ruleSet}

    * @since 2.13.0 */ - @Parameter( property = "maven.version.ignore" ) + @Parameter(property = "maven.version.ignore") protected Set ignoredVersions; /** @@ -168,11 +166,12 @@ public abstract class AbstractVersionsReport // --------------------- GETTER / SETTER METHODS --------------------- - protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { + protected AbstractVersionsReport( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { this.i18n = i18n; this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; @@ -180,29 +179,23 @@ protected AbstractVersionsReport( I18N i18n, RepositorySystem repositorySystem, this.rendererFactory = rendererFactory; } - public VersionsHelper getHelper() - throws MavenReportException - { - if ( helper == null ) - { - try - { + public VersionsHelper getHelper() throws MavenReportException { + if (helper == null) { + try { helper = new DefaultVersionsHelper.Builder() - .withRepositorySystem( repositorySystem ) - .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonMap( wagonMap ) - .withServerId( serverId ) - .withRulesUri( rulesUri ) - .withRuleSet( ruleSet ) - .withIgnoredVersions( ignoredVersions ) - .withLog( getLog() ) - .withMavenSession( session ) - .withMojoExecution( mojoExecution ) + .withRepositorySystem(repositorySystem) + .withAetherRepositorySystem(aetherRepositorySystem) + .withWagonMap(wagonMap) + .withServerId(serverId) + .withRulesUri(rulesUri) + .withRuleSet(ruleSet) + .withIgnoredVersions(ignoredVersions) + .withLog(getLog()) + .withMavenSession(session) + .withMojoExecution(mojoExecution) .build(); - } - catch ( MojoExecutionException e ) - { - throw new MavenReportException( e.getMessage(), e ); + } catch (MojoExecutionException e) { + throw new MavenReportException(e.getMessage(), e); } } return helper; @@ -211,18 +204,12 @@ public VersionsHelper getHelper() /** * {@inheritDoc} */ - protected void executeReport( Locale locale ) - throws MavenReportException - { - if ( !skip ) - { - try - { - doGenerateReport( locale, getSink() ); - } - catch ( MojoExecutionException e ) - { - throw new MavenReportException( e.getMessage(), e ); + protected void executeReport(Locale locale) throws MavenReportException { + if (!skip) { + try { + doGenerateReport(locale, getSink()); + } catch (MojoExecutionException e) { + throw new MavenReportException(e.getMessage(), e); } } } @@ -235,42 +222,36 @@ protected void executeReport( Locale locale ) * @throws MavenReportException when things go wrong. * @throws MojoExecutionException if something goes wrong. */ - protected abstract void doGenerateReport( Locale locale, Sink sink ) - throws MavenReportException, MojoExecutionException; + protected abstract void doGenerateReport(Locale locale, Sink sink) + throws MavenReportException, MojoExecutionException; @Override - protected MavenProject getProject() - { + protected MavenProject getProject() { return project; } @Override - protected String getOutputDirectory() - { - if ( !outputDirectory.isAbsolute() ) - { - outputDirectory = new File( project.getBasedir(), outputDirectory.getPath() ); + protected String getOutputDirectory() { + if (!outputDirectory.isAbsolute()) { + outputDirectory = new File(project.getBasedir(), outputDirectory.getPath()); } return outputDirectory.getAbsolutePath(); } @Override - protected Renderer getSiteRenderer() - { + protected Renderer getSiteRenderer() { return siteRenderer; } @Override - public String getDescription( Locale locale ) - { - return getText( locale, "report.description" ); + public String getDescription(Locale locale) { + return getText(locale, "report.description"); } @Override - public String getName( Locale locale ) - { - return getText( locale, "report.title" ); + public String getName(Locale locale) { + return getText(locale, "report.title"); } /** @@ -280,24 +261,19 @@ public String getName( Locale locale ) * @param key the message key. * @return the message. */ - public String getText( Locale locale, String key ) - { - return i18n.getString( getOutputName(), locale, key ); + public String getText(Locale locale, String key) { + return i18n.getString(getOutputName(), locale, key); } - public Boolean getAllowSnapshots() - { + public Boolean getAllowSnapshots() { return this.allowSnapshots; } - public String getComparisonMethod() - { + public String getComparisonMethod() { return comparisonMethod; } - public I18N getI18n() - { + public I18N getI18n() { return i18n; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java index b9b15b5cf6..caee51d729 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojo.java @@ -67,9 +67,7 @@ * * @author Stephen Connolly */ -public abstract class AbstractVersionsUpdaterMojo - extends AbstractMojo -{ +public abstract class AbstractVersionsUpdaterMojo extends AbstractMojo { // ------------------------------ FIELDS ------------------------------ @@ -78,7 +76,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-1 */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) protected MavenProject project; /** @@ -94,7 +92,7 @@ public abstract class AbstractVersionsUpdaterMojo /** * @since 1.0-alpha-1 */ - @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) + @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) protected List reactorProjects; /** @@ -102,7 +100,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "maven.version.rules.serverId", defaultValue = "serverId" ) + @Parameter(property = "maven.version.rules.serverId", defaultValue = "serverId") private String serverId; /** @@ -112,7 +110,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "maven.version.rules" ) + @Parameter(property = "maven.version.rules") private String rulesUri; /** @@ -120,7 +118,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-3 */ - @Parameter( property = "generateBackupPoms", defaultValue = "true" ) + @Parameter(property = "generateBackupPoms", defaultValue = "true") private boolean generateBackupPoms; /** @@ -128,7 +126,7 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-1 */ - @Parameter( property = "allowSnapshots", defaultValue = "false" ) + @Parameter(property = "allowSnapshots", defaultValue = "false") protected boolean allowSnapshots; /** @@ -141,10 +139,10 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 1.0-alpha-1 */ - @Parameter( defaultValue = "${session}", required = true, readonly = true ) + @Parameter(defaultValue = "${session}", required = true, readonly = true) protected MavenSession session; - @Parameter( defaultValue = "${mojoExecution}", required = true, readonly = true ) + @Parameter(defaultValue = "${mojoExecution}", required = true, readonly = true) private MojoExecution mojoExecution; /** @@ -152,15 +150,14 @@ public abstract class AbstractVersionsUpdaterMojo * * @since 2.11 */ - @Parameter( property = "changeRecorderFormat", defaultValue = "none" ) + @Parameter(property = "changeRecorderFormat", defaultValue = "none") private String changeRecorderFormat = "none"; /** * The output file used to record changes. * * @since 2.11 */ - @Parameter( property = "changeRecorderOutputFile", - defaultValue = "${project.build.directory}/versions-changes.xml" ) + @Parameter(property = "changeRecorderOutputFile", defaultValue = "${project.build.directory}/versions-changes.xml") private File changeRecorderOutputFile; /** @@ -192,7 +189,7 @@ public abstract class AbstractVersionsUpdaterMojo *

    Currently, this parameter will override the defined {@link #ruleSet}

    * @since 2.13.0 */ - @Parameter( property = "maven.version.ignore" ) + @Parameter(property = "maven.version.ignore") protected Set ignoredVersions; /** @@ -205,32 +202,30 @@ public abstract class AbstractVersionsUpdaterMojo // --------------------- GETTER / SETTER METHODS --------------------- @Inject - protected AbstractVersionsUpdaterMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { + protected AbstractVersionsUpdaterMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { this.repositorySystem = repositorySystem; this.aetherRepositorySystem = aetherRepositorySystem; this.wagonMap = wagonMap; this.changeRecorders = changeRecorders; } - public VersionsHelper getHelper() throws MojoExecutionException - { - if ( helper == null ) - { + public VersionsHelper getHelper() throws MojoExecutionException { + if (helper == null) { helper = new DefaultVersionsHelper.Builder() - .withRepositorySystem( repositorySystem ) - .withAetherRepositorySystem( aetherRepositorySystem ) - .withWagonMap( wagonMap ) - .withServerId( serverId ) - .withRulesUri( rulesUri ) - .withRuleSet( ruleSet ) - .withIgnoredVersions( ignoredVersions ) - .withLog( getLog() ) - .withMavenSession( session ) - .withMojoExecution( mojoExecution ) + .withRepositorySystem(repositorySystem) + .withAetherRepositorySystem(aetherRepositorySystem) + .withWagonMap(wagonMap) + .withServerId(serverId) + .withRulesUri(rulesUri) + .withRuleSet(ruleSet) + .withIgnoredVersions(ignoredVersions) + .withLog(getLog()) + .withMavenSession(session) + .withMojoExecution(mojoExecution) .build(); } return helper; @@ -242,8 +237,7 @@ public VersionsHelper getHelper() throws MojoExecutionException * @return Value for property 'project'. * @since 1.0-alpha-1 */ - public MavenProject getProject() - { + public MavenProject getProject() { return project; } @@ -253,13 +247,11 @@ public MavenProject getProject() * @param project Value to set for property 'project'. * @since 1.0-alpha-1 */ - public void setProject( MavenProject project ) - { + public void setProject(MavenProject project) { this.project = project; } - public String getVersion() - { + public String getVersion() { return getProject() == null ? null : getProject().getVersion(); } @@ -272,12 +264,10 @@ public String getVersion() * * @since 1.0-alpha-1 */ - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { validateInput(); File outFile = project.getFile(); - process( outFile ); + process(outFile); } // -------------------------- OTHER METHODS -------------------------- @@ -287,9 +277,7 @@ public void execute() * * @throws MojoExecutionException thrown if any of input parameters is invalid */ - protected void validateInput() throws MojoExecutionException - { - } + protected void validateInput() throws MojoExecutionException {} /** * Finds the latest version of the specified artifact that matches the version range. * @@ -303,14 +291,13 @@ protected void validateInput() throws MojoExecutionException * @throws MojoExecutionException if something goes wrong. * @since 1.0-alpha-1 */ - protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange, - Boolean allowingSnapshots, boolean usePluginRepositories ) - throws MojoExecutionException, VersionRetrievalException - { + protected ArtifactVersion findLatestVersion( + Artifact artifact, VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories) + throws MojoExecutionException, VersionRetrievalException { boolean includeSnapshots = allowingSnapshots != null ? allowingSnapshots : this.allowSnapshots; - final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, versionRange, - usePluginRepositories ); - return artifactVersions.getNewestVersion( versionRange, null, includeSnapshots, false ); + final ArtifactVersions artifactVersions = + getHelper().lookupArtifactVersions(artifact, versionRange, usePluginRepositories); + return artifactVersions.getNewestVersion(versionRange, null, includeSnapshots, false); } /** @@ -322,9 +309,8 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver * @return The value as defined in the pom or null if not defined. * @since 1.0-alpha-1 */ - protected String getPropertyValue( StringBuilder pom, String property ) - { - return project.getProperties().getProperty( property ); + protected String getPropertyValue(StringBuilder pom, String property) { + return project.getProperties().getProperty(property); } /** @@ -335,49 +321,34 @@ protected String getPropertyValue( StringBuilder pom, String property ) * @throws MojoFailureException If things go wrong. * @since 1.0-alpha-1 */ - protected void process( File outFile ) - throws MojoExecutionException, MojoFailureException - { - try - { - StringBuilder input = PomHelper.readXmlFile( outFile ); - ModifiedPomXMLEventReader newPom = newModifiedPomXER( input, outFile.getAbsolutePath() ); - - update( newPom ); - - if ( newPom.isModified() ) - { - if ( generateBackupPoms ) - { - File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" ); - if ( !backupFile.exists() ) - { - getLog().debug( "Backing up " + outFile + " to " + backupFile ); - FileUtils.copyFile( outFile, backupFile ); - } - else - { - getLog().debug( "Leaving existing backup " + backupFile + " unmodified" ); + protected void process(File outFile) throws MojoExecutionException, MojoFailureException { + try { + StringBuilder input = PomHelper.readXmlFile(outFile); + ModifiedPomXMLEventReader newPom = newModifiedPomXER(input, outFile.getAbsolutePath()); + + update(newPom); + + if (newPom.isModified()) { + if (generateBackupPoms) { + File backupFile = new File(outFile.getParentFile(), outFile.getName() + ".versionsBackup"); + if (!backupFile.exists()) { + getLog().debug("Backing up " + outFile + " to " + backupFile); + FileUtils.copyFile(outFile, backupFile); + } else { + getLog().debug("Leaving existing backup " + backupFile + " unmodified"); } + } else { + getLog().debug("Skipping generation of backup file"); } - else - { - getLog().debug( "Skipping generation of backup file" ); - } - writeFile( outFile, input ); + writeFile(outFile, input); } saveChangeRecorderResults(); + } catch (IOException | XMLStreamException e) { + getLog().error(e); + } catch (VersionRetrievalException e) { + throw new MojoExecutionException(e.getMessage(), e); } - catch ( IOException | XMLStreamException e ) - { - getLog().error( e ); - } - catch ( VersionRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - } /** @@ -387,18 +358,14 @@ protected void process( File outFile ) * @param path Path pointing to the source of the XML * @return The {@link org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader}. */ - protected final ModifiedPomXMLEventReader newModifiedPomXER( StringBuilder input, String path ) - { + protected final ModifiedPomXMLEventReader newModifiedPomXER(StringBuilder input, String path) { ModifiedPomXMLEventReader newPom = null; - try - { + try { XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); - newPom = new ModifiedPomXMLEventReader( input, inputFactory, path ); - } - catch ( XMLStreamException e ) - { - getLog().error( e ); + inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE); + newPom = new ModifiedPomXMLEventReader(input, inputFactory, path); + } catch (XMLStreamException e) { + getLog().error(e); } return newPom; } @@ -410,12 +377,9 @@ protected final ModifiedPomXMLEventReader newModifiedPomXER( StringBuilder input * @param input The contents of the file. * @throws IOException when things go wrong. */ - protected final void writeFile( File outFile, StringBuilder input ) - throws IOException - { - try ( Writer writer = WriterFactory.newXmlWriter( outFile ) ) - { - IOUtil.copy( input.toString(), writer ); + protected final void writeFile(File outFile, StringBuilder input) throws IOException { + try (Writer writer = WriterFactory.newXmlWriter(outFile)) { + IOUtil.copy(input.toString(), writer); } } @@ -429,8 +393,8 @@ protected final void writeFile( File outFile, StringBuilder input ) * @throws VersionRetrievalException if version retrieval goes wrong * @since 1.0-alpha-1 */ - protected abstract void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException; + protected abstract void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException; /** * @param artifact The artifact. @@ -445,9 +409,8 @@ protected abstract void update( ModifiedPomXMLEventReader pom ) * Returns true if the update should be applied. */ @Deprecated - protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion ) - { - return shouldApplyUpdate( artifact, currentVersion, updateVersion, false ); + protected boolean shouldApplyUpdate(Artifact artifact, String currentVersion, ArtifactVersion updateVersion) { + return shouldApplyUpdate(artifact, currentVersion, updateVersion, false); } /** @@ -460,37 +423,30 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * @return true if the update should be applied to the pom. * @since 2.9 */ - protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, - boolean forceUpdate ) - { - getLog().debug( "Proposal is to update from " + currentVersion + " to " + updateVersion ); - - if ( updateVersion == null ) - { - getLog().warn( "Not updating version: could not resolve any versions" ); + protected boolean shouldApplyUpdate( + Artifact artifact, String currentVersion, ArtifactVersion updateVersion, boolean forceUpdate) { + getLog().debug("Proposal is to update from " + currentVersion + " to " + updateVersion); + + if (updateVersion == null) { + getLog().warn("Not updating version: could not resolve any versions"); return false; } - if ( forceUpdate ) - { - getLog().info( "Force update enabled. LATEST or RELEASE versions will be overwritten with real version" ); + if (forceUpdate) { + getLog().info("Force update enabled. LATEST or RELEASE versions will be overwritten with real version"); return true; } - artifact.setVersion( updateVersion.toString() ); - try - { - getHelper().resolveArtifact( artifact, false ); - } - catch ( ArtifactResolutionException | MojoExecutionException e ) - { - getLog().warn( "Not updating version: could not resolve " + artifact, e ); + artifact.setVersion(updateVersion.toString()); + try { + getHelper().resolveArtifact(artifact, false); + } catch (ArtifactResolutionException | MojoExecutionException e) { + getLog().warn("Not updating version: could not resolve " + artifact, e); return false; } - if ( currentVersion.equals( updateVersion.toString() ) ) - { - getLog().info( "Current version of " + artifact + " is the latest." ); + if (currentVersion.equals(updateVersion.toString())) { + getLog().info("Current version of " + artifact + " is the latest."); return false; } return true; @@ -510,24 +466,28 @@ protected boolean shouldApplyUpdate( Artifact artifact, String currentVersion, A * @throws InvalidSegmentException thrown if {@code unchangedSegment} is invalid * @throws MojoExecutionException thrown if any other error occurs */ - protected ArtifactVersion updatePropertyToNewestVersion( ModifiedPomXMLEventReader pom, Property property, - PropertyVersions version, String currentVersion, - boolean allowDowngrade, - Optional unchangedSegment ) - throws XMLStreamException, InvalidVersionSpecificationException, - InvalidSegmentException, MojoExecutionException - { - ArtifactVersion winner = - version.getNewestVersion( currentVersion, property, this.allowSnapshots, this.reactorProjects, - this.getHelper(), allowDowngrade, unchangedSegment ); - - if ( winner == null || currentVersion.equals( winner.toString() ) ) - { - getLog().info( "Property ${" + property.getName() + "}: Leaving unchanged as " + currentVersion ); - } - else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.getName(), winner.toString() ) ) - { - getLog().info( "Updated ${" + property.getName() + "} from " + currentVersion + " to " + winner ); + protected ArtifactVersion updatePropertyToNewestVersion( + ModifiedPomXMLEventReader pom, + Property property, + PropertyVersions version, + String currentVersion, + boolean allowDowngrade, + Optional unchangedSegment) + throws XMLStreamException, InvalidVersionSpecificationException, InvalidSegmentException, + MojoExecutionException { + ArtifactVersion winner = version.getNewestVersion( + currentVersion, + property, + this.allowSnapshots, + this.reactorProjects, + this.getHelper(), + allowDowngrade, + unchangedSegment); + + if (winner == null || currentVersion.equals(winner.toString())) { + getLog().info("Property ${" + property.getName() + "}: Leaving unchanged as " + currentVersion); + } else if (PomHelper.setPropertyVersion(pom, version.getProfileId(), property.getName(), winner.toString())) { + getLog().info("Updated ${" + property.getName() + "} from " + currentVersion + " to " + winner); return winner; } @@ -540,13 +500,11 @@ else if ( PomHelper.setPropertyVersion( pom, version.getProfileId(), property.ge * @return The change recorder * @throws MojoExecutionException if something goes wrong. */ - protected ChangeRecorder getChangeRecorder() throws MojoExecutionException - { - ChangeRecorder changeRecorder = changeRecorders.get( changeRecorderFormat ); - if ( changeRecorder == null ) - { - throw new MojoExecutionException( "Only " + changeRecorders.keySet() - + " formats are supported for change recordings" ); + protected ChangeRecorder getChangeRecorder() throws MojoExecutionException { + ChangeRecorder changeRecorder = changeRecorders.get(changeRecorderFormat); + if (changeRecorder == null) { + throw new MojoExecutionException( + "Only " + changeRecorders.keySet() + " formats are supported for change recordings"); } return changeRecorder; } @@ -557,13 +515,12 @@ protected ChangeRecorder getChangeRecorder() throws MojoExecutionException * @throws IOException On I/O errors * @throws MojoExecutionException if something goes wrong. */ + protected void saveChangeRecorderResults() throws IOException, MojoExecutionException { - protected void saveChangeRecorderResults() throws IOException, MojoExecutionException - { - - this.getLog().debug( "writing change record to " + this.changeRecorderOutputFile ); - getChangeRecorder().writeReport( Optional.ofNullable( changeRecorderOutputFile ) - .map( File::toPath ) - .orElse( null ) ); + this.getLog().debug("writing change record to " + this.changeRecorderOutputFile); + getChangeRecorder() + .writeReport(Optional.ofNullable(changeRecorderOutputFile) + .map(File::toPath) + .orElse(null)); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java index b1bf396613..4e160c7d2d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CommitMojo.java @@ -36,34 +36,26 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "commit", threadSafe = true ) -public class CommitMojo - extends AbstractMojo -{ +@Mojo(name = "commit", threadSafe = true) +public class CommitMojo extends AbstractMojo { /** * The Maven Project. * * @since 1.0-alpha-1 */ - @Parameter( defaultValue = "${project}", required = true, readonly = true ) + @Parameter(defaultValue = "${project}", required = true, readonly = true) private MavenProject project; - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { File outFile = project.getFile(); - File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" ); + File backupFile = new File(outFile.getParentFile(), outFile.getName() + ".versionsBackup"); - if ( backupFile.exists() ) - { - getLog().info( "Accepting all changes to " + outFile ); - try - { - FileUtils.forceDelete( backupFile ); - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + if (backupFile.exists()) { + getLog().info("Accepting all changes to " + outFile); + try { + FileUtils.forceDelete(backupFile); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java index a531a5c131..13fb201ee2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/CompareDependenciesMojo.java @@ -63,10 +63,8 @@ * @author Paul Gier * @since 1.3 */ -@Mojo( name = "compare-dependencies", threadSafe = true ) -public class CompareDependenciesMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "compare-dependencies", threadSafe = true) +public class CompareDependenciesMojo extends AbstractVersionsDependencyUpdaterMojo { /** * The width to pad info messages. @@ -79,44 +77,44 @@ public class CompareDependenciesMojo * The groupId, artifactId, and version of the remote project (POM) to which we are comparing. This should be in the * form "groupId:artifactId:version" */ - @Parameter( property = "remotePom", required = true ) + @Parameter(property = "remotePom", required = true) protected String remotePom; /** * Ignore the list of remote dependencies and only compare the remote dependencyManagement */ - @Parameter( property = "ignoreRemoteDependencies", defaultValue = "false" ) + @Parameter(property = "ignoreRemoteDependencies", defaultValue = "false") protected boolean ignoreRemoteDependencies; /** * Ignore the remote dependency management and only check against the actual dependencies of the remote project */ - @Parameter( property = "ignoreRemoteDependencyManagement", defaultValue = "false" ) + @Parameter(property = "ignoreRemoteDependencyManagement", defaultValue = "false") protected boolean ignoreRemoteDependencyManagement; /** * Update dependency versions in the current POM. */ - @Parameter( property = "updateDependencies", defaultValue = "false" ) + @Parameter(property = "updateDependencies", defaultValue = "false") protected boolean updateDependencies; /** * Update dependency versions stored in properties */ - @Parameter( property = "updatePropertyVersions", defaultValue = "false" ) + @Parameter(property = "updatePropertyVersions", defaultValue = "false") protected boolean updatePropertyVersions; /** * Display the dependency version differences on the command line, but do not update the versions in the current * pom. If updateDependencies is set to "true" this will automatically be set to false. */ - @Parameter( property = "reportMode", defaultValue = "true" ) + @Parameter(property = "reportMode", defaultValue = "true") protected boolean reportMode; /** * If the output file is set, the diff report will be written to this file. */ - @Parameter( property = "reportOutputFile" ) + @Parameter(property = "reportOutputFile") protected File reportOutputFile; /** @@ -129,13 +127,13 @@ public class CompareDependenciesMojo // ------------------------------ METHODS -------------------------- @Inject - public CompareDependenciesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ProjectBuilder projectBuilder, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public CompareDependenciesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ProjectBuilder projectBuilder, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); this.projectBuilder = projectBuilder; } @@ -146,128 +144,101 @@ public CompareDependenciesMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - if ( this.ignoreRemoteDependencies && this.ignoreRemoteDependencyManagement ) - { - throw new MojoFailureException( " ignoreRemoteDependencies and ignoreRemoteDependencyManagement " - + "are both set to true. At least one of these needs to be false " ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + if (this.ignoreRemoteDependencies && this.ignoreRemoteDependencyManagement) { + throw new MojoFailureException(" ignoreRemoteDependencies and ignoreRemoteDependencyManagement " + + "are both set to true. At least one of these needs to be false "); } - if ( updateDependencies ) - { + if (updateDependencies) { reportMode = false; } - String[] remoteGAV = this.remotePom.split( ":" ); - if ( remoteGAV.length != 3 ) - { - throw new MojoFailureException( " Invalid format for remotePom: " + remotePom ); + String[] remoteGAV = this.remotePom.split(":"); + if (remoteGAV.length != 3) { + throw new MojoFailureException(" Invalid format for remotePom: " + remotePom); } MavenProject remoteMavenProject = null; - try - { - remoteMavenProject = getRemoteMavenProject( remoteGAV[0], remoteGAV[1], - remoteGAV[2] ); - } - catch ( ArtifactResolutionException | ProjectBuildingException e ) - { - throw new MojoFailureException( e.getMessage() ); + try { + remoteMavenProject = getRemoteMavenProject(remoteGAV[0], remoteGAV[1], remoteGAV[2]); + } catch (ArtifactResolutionException | ProjectBuildingException e) { + throw new MojoFailureException(e.getMessage()); } Map remoteDepsMap = new HashMap<>(); - if ( !ignoreRemoteDependencyManagement ) - { + if (!ignoreRemoteDependencyManagement) { List remoteProjectDepMgmtDeps = remoteMavenProject.getDependencyManagement() == null ? null : remoteMavenProject.getDependencyManagement().getDependencies(); - if ( remoteProjectDepMgmtDeps != null ) - { - remoteProjectDepMgmtDeps.forEach( dep -> remoteDepsMap.putIfAbsent( dep.getManagementKey(), dep ) ); + if (remoteProjectDepMgmtDeps != null) { + remoteProjectDepMgmtDeps.forEach(dep -> remoteDepsMap.putIfAbsent(dep.getManagementKey(), dep)); } } - if ( !ignoreRemoteDependencies && remoteMavenProject.getDependencies() != null ) - { - remoteMavenProject.getDependencies().forEach( dep -> - remoteDepsMap.putIfAbsent( dep.getManagementKey(), dep ) ); + if (!ignoreRemoteDependencies && remoteMavenProject.getDependencies() != null) { + remoteMavenProject.getDependencies().forEach(dep -> remoteDepsMap.putIfAbsent(dep.getManagementKey(), dep)); } List totalDiffs = new ArrayList<>(); List propertyDiffs = new ArrayList<>(); - if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() ) - { - totalDiffs.addAll( - compareVersions( pom, getProject().getDependencyManagement().getDependencies(), remoteDepsMap, - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ) ); + if (getProject().getDependencyManagement() != null && isProcessingDependencyManagement()) { + totalDiffs.addAll(compareVersions( + pom, + getProject().getDependencyManagement().getDependencies(), + remoteDepsMap, + ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT)); } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - totalDiffs.addAll( compareVersions( pom, getProject().getDependencies(), remoteDepsMap, - ChangeRecord.ChangeKind.DEPENDENCY ) ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + totalDiffs.addAll(compareVersions( + pom, getProject().getDependencies(), remoteDepsMap, ChangeRecord.ChangeKind.DEPENDENCY)); } - if ( updatePropertyVersions ) - { - Map versionProperties = - this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ).build() ); - propertyDiffs.addAll( updatePropertyVersions( pom, versionProperties, remoteDepsMap ) ); + if (updatePropertyVersions) { + Map versionProperties = this.getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .build()); + propertyDiffs.addAll(updatePropertyVersions(pom, versionProperties, remoteDepsMap)); } - if ( getProject().getParent() != null - && remoteMavenProject.getParent() != null - && isProcessingParent() ) - { + if (getProject().getParent() != null && remoteMavenProject.getParent() != null && isProcessingParent()) { Dependency parent = DependencyBuilder.newBuilder() - .withGroupId( remoteMavenProject.getParentArtifact().getGroupId() ) - .withArtifactId( remoteMavenProject.getParentArtifact().getArtifactId() ) - .withVersion( remoteMavenProject.getParentArtifact().getVersion() ) - .withType( remoteMavenProject.getParentArtifact().getType() ) - .withScope( remoteMavenProject.getParentArtifact().getScope() ) - .withClassifier( remoteMavenProject.getParentArtifact().getClassifier() ) + .withGroupId(remoteMavenProject.getParentArtifact().getGroupId()) + .withArtifactId(remoteMavenProject.getParentArtifact().getArtifactId()) + .withVersion(remoteMavenProject.getParentArtifact().getVersion()) + .withType(remoteMavenProject.getParentArtifact().getType()) + .withScope(remoteMavenProject.getParentArtifact().getScope()) + .withClassifier(remoteMavenProject.getParentArtifact().getClassifier()) .build(); - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Processing parent dependency: " + parent ); + if (getLog().isDebugEnabled()) { + getLog().debug("Processing parent dependency: " + parent); } - remoteDepsMap.putIfAbsent( parent.getManagementKey(), parent ); - totalDiffs.addAll( compareVersions( pom, singletonList( getParentDependency() ), remoteDepsMap, - ChangeRecord.ChangeKind.PARENT ) ); + remoteDepsMap.putIfAbsent(parent.getManagementKey(), parent); + totalDiffs.addAll(compareVersions( + pom, singletonList(getParentDependency()), remoteDepsMap, ChangeRecord.ChangeKind.PARENT)); } - if ( reportMode ) - { - getLog().info( "The following differences were found:" ); - if ( totalDiffs.size() == 0 ) - { - getLog().info( " none" ); - } - else - { - for ( String totalDiff : totalDiffs ) - { - getLog().info( " " + totalDiff ); + if (reportMode) { + getLog().info("The following differences were found:"); + if (totalDiffs.size() == 0) { + getLog().info(" none"); + } else { + for (String totalDiff : totalDiffs) { + getLog().info(" " + totalDiff); } } - getLog().info( "The following property differences were found:" ); - if ( propertyDiffs.size() == 0 ) - { - getLog().info( " none" ); - } - else - { - for ( String propertyDiff : propertyDiffs ) - { - getLog().info( " " + propertyDiff ); + getLog().info("The following property differences were found:"); + if (propertyDiffs.size() == 0) { + getLog().info(" none"); + } else { + for (String propertyDiff : propertyDiffs) { + getLog().info(" " + propertyDiff); } } } - if ( reportOutputFile != null ) - { - writeReportFile( totalDiffs, propertyDiffs ); + if (reportOutputFile != null) { + writeReportFile(totalDiffs, propertyDiffs); } - } /** @@ -280,26 +251,23 @@ && isProcessingParent() ) * @throws MojoExecutionException thrown if the artifact for the dependency could not be constructed * @throws ProjectBuildingException thrown if the {@link MavenProject} instance could not be constructed */ - private MavenProject getRemoteMavenProject( String groupId, String artifactId, String version ) - throws MojoExecutionException, ArtifactResolutionException, ProjectBuildingException - { - Artifact remoteArtifact = toArtifact( DependencyBuilder.newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ) - .build() ); - ProjectBuildingResult result = - projectBuilder.build( remoteArtifact, true, - PomHelper.createProjectBuilderRequest( session, - r -> r.setProcessPlugins( false ), - r -> r.setRemoteRepositories( session.getCurrentProject() - .getPluginArtifactRepositories() ) ) ); - if ( !result.getProblems().isEmpty() ) - { - getLog().warn( "Problems encountered during construction of the POM for " - + remoteArtifact.toString() ); - result.getProblems().forEach( p -> - getLog().warn( "\t" + p.getMessage() ) ); + private MavenProject getRemoteMavenProject(String groupId, String artifactId, String version) + throws MojoExecutionException, ArtifactResolutionException, ProjectBuildingException { + Artifact remoteArtifact = toArtifact(DependencyBuilder.newBuilder() + .withGroupId(groupId) + .withArtifactId(artifactId) + .withVersion(version) + .build()); + ProjectBuildingResult result = projectBuilder.build( + remoteArtifact, + true, + PomHelper.createProjectBuilderRequest( + session, + r -> r.setProcessPlugins(false), + r -> r.setRemoteRepositories(session.getCurrentProject().getPluginArtifactRepositories()))); + if (!result.getProblems().isEmpty()) { + getLog().warn("Problems encountered during construction of the POM for " + remoteArtifact.toString()); + result.getProblems().forEach(p -> getLog().warn("\t" + p.getMessage())); } return result.getProject(); } @@ -310,68 +278,59 @@ private MavenProject getRemoteMavenProject( String groupId, String artifactId, S * @throws XMLStreamException * @throws MojoExecutionException */ - private List compareVersions( ModifiedPomXMLEventReader pom, List dependencies, - Map remoteDependencies, - ChangeRecord.ChangeKind changeKind ) - throws MojoExecutionException, XMLStreamException - { + private List compareVersions( + ModifiedPomXMLEventReader pom, + List dependencies, + Map remoteDependencies, + ChangeRecord.ChangeKind changeKind) + throws MojoExecutionException, XMLStreamException { List updates = new ArrayList<>(); - for ( Dependency dep : dependencies ) - { - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { + for (Dependency dep : dependencies) { + Artifact artifact = this.toArtifact(dep); + if (!isIncluded(artifact)) { continue; } - Dependency remoteDep = remoteDependencies.get( dep.getManagementKey() ); - if ( remoteDep != null ) - { + Dependency remoteDep = remoteDependencies.get(dep.getManagementKey()); + if (remoteDep != null) { String remoteVersion = remoteDep.getVersion(); - if ( !dep.getVersion().equals( remoteVersion ) ) - { - StringBuilder buf = writeDependencyDiffMessage( dep, remoteVersion ); - updates.add( buf.toString() ); - if ( !reportMode ) - { - updateDependencyVersion( pom, dep, remoteVersion, changeKind ); + if (!dep.getVersion().equals(remoteVersion)) { + StringBuilder buf = writeDependencyDiffMessage(dep, remoteVersion); + updates.add(buf.toString()); + if (!reportMode) { + updateDependencyVersion(pom, dep, remoteVersion, changeKind); } - } - } } return updates; - } /** * Updates the properties holding a version if necessary. */ - private List updatePropertyVersions( ModifiedPomXMLEventReader pom, - Map versionProperties, - Map remoteDependencies ) - throws XMLStreamException - { + private List updatePropertyVersions( + ModifiedPomXMLEventReader pom, + Map versionProperties, + Map remoteDependencies) + throws XMLStreamException { List result = new ArrayList<>(); - for ( Map.Entry entry : versionProperties.entrySet() ) - { + for (Map.Entry entry : versionProperties.entrySet()) { Property property = entry.getKey(); PropertyVersions version = entry.getValue(); - String candidateVersion = computeCandidateVersion( remoteDependencies, property, version ); - if ( candidateVersion != null ) - { - String originalVersion = version.getAssociations()[0].getArtifact().getVersion(); // Yekes - if ( !candidateVersion.equals( originalVersion ) ) // Update needed + String candidateVersion = computeCandidateVersion(remoteDependencies, property, version); + if (candidateVersion != null) { + String originalVersion = + version.getAssociations()[0].getArtifact().getVersion(); // Yekes + if (!candidateVersion.equals(originalVersion)) // Update needed { - result.add( writeDiffMessage( property.getName(), originalVersion, candidateVersion ).toString() ); - if ( !reportMode - && PomHelper.setPropertyVersion( pom, null, property.getName(), candidateVersion ) ) - { - getLog().info( "Updated ${" + property.getName() + "} from " + originalVersion + " to " - + candidateVersion ); + result.add(writeDiffMessage(property.getName(), originalVersion, candidateVersion) + .toString()); + if (!reportMode && PomHelper.setPropertyVersion(pom, null, property.getName(), candidateVersion)) { + getLog().info("Updated ${" + property.getName() + "} from " + originalVersion + " to " + + candidateVersion); } } } @@ -391,28 +350,20 @@ private List updatePropertyVersions( ModifiedPomXMLEventReader pom, * @param propertyVersions the association * @return the candidate version or null if there isn't any */ - private String computeCandidateVersion( Map remoteDependencies, Property property, - PropertyVersions propertyVersions ) - { + private String computeCandidateVersion( + Map remoteDependencies, Property property, PropertyVersions propertyVersions) { String candidateVersion = null; - for ( ArtifactAssociation artifactAssociation : propertyVersions.getAssociations() ) - { - String id = generateId( artifactAssociation.getArtifact() ); - Dependency dependency = remoteDependencies.get( id ); - if ( dependency == null ) - { - getLog().info( "Not updating ${" + property.getName() + "}: no info for " + id ); + for (ArtifactAssociation artifactAssociation : propertyVersions.getAssociations()) { + String id = generateId(artifactAssociation.getArtifact()); + Dependency dependency = remoteDependencies.get(id); + if (dependency == null) { + getLog().info("Not updating ${" + property.getName() + "}: no info for " + id); return null; - } - else - { - if ( candidateVersion == null ) - { + } else { + if (candidateVersion == null) { candidateVersion = dependency.getVersion(); - } - else if ( !candidateVersion.equals( dependency.getVersion() ) ) - { - getLog().warn( "Could not update ${" + property.getName() + "}: version mismatch" ); + } else if (!candidateVersion.equals(dependency.getVersion())) { + getLog().warn("Could not update ${" + property.getName() + "}: version mismatch"); return null; } } @@ -420,48 +371,35 @@ else if ( !candidateVersion.equals( dependency.getVersion() ) ) return candidateVersion; } - private void writeReportFile( List dependenciesUpdate, List propertiesUpdate ) - throws MojoExecutionException - { - if ( !reportOutputFile.getParentFile().exists() ) - { + private void writeReportFile(List dependenciesUpdate, List propertiesUpdate) + throws MojoExecutionException { + if (!reportOutputFile.getParentFile().exists()) { reportOutputFile.getParentFile().mkdirs(); } - try ( FileWriter fw = new FileWriter( reportOutputFile ); // - PrintWriter pw = new PrintWriter( fw ) ) - { - pw.println( "The following differences were found:" ); + try (FileWriter fw = new FileWriter(reportOutputFile); // + PrintWriter pw = new PrintWriter(fw)) { + pw.println("The following differences were found:"); pw.println(); - if ( dependenciesUpdate.size() == 0 ) - { - pw.println( " none" ); - } - else - { - for ( String dependencyUpdate : dependenciesUpdate ) - { - pw.println( " " + dependencyUpdate ); + if (dependenciesUpdate.size() == 0) { + pw.println(" none"); + } else { + for (String dependencyUpdate : dependenciesUpdate) { + pw.println(" " + dependencyUpdate); } } pw.println(); - pw.println( "The following property differences were found:" ); + pw.println("The following property differences were found:"); pw.println(); - if ( propertiesUpdate.size() == 0 ) - { - pw.println( " none" ); - } - else - { - for ( String propertyUpdate : propertiesUpdate ) - { - pw.println( " " + propertyUpdate ); + if (propertiesUpdate.size() == 0) { + pw.println(" none"); + } else { + for (String propertyUpdate : propertiesUpdate) { + pw.println(" " + propertyUpdate); } } - } - catch ( IOException e ) - { - throw new MojoExecutionException( "Unable to write report file. ", e ); + } catch (IOException e) { + throw new MojoExecutionException("Unable to write report file. ", e); } } @@ -472,42 +410,39 @@ private void writeReportFile( List dependenciesUpdate, List prop * @param remoteVersion * @return The message */ - private StringBuilder writeDependencyDiffMessage( Dependency dep, String remoteVersion ) - { + private StringBuilder writeDependencyDiffMessage(Dependency dep, String remoteVersion) { String id = dep.getGroupId() + ":" + dep.getArtifactId(); - return writeDiffMessage( id, dep.getVersion(), remoteVersion ); + return writeDiffMessage(id, dep.getVersion(), remoteVersion); } - private StringBuilder writeDiffMessage( String id, String originalVersion, String targetVersion ) - { + private StringBuilder writeDiffMessage(String id, String originalVersion, String targetVersion) { StringBuilder buf = new StringBuilder(); - buf.append( id ); - buf.append( ' ' ); + buf.append(id); + buf.append(' '); int padding = INFO_PAD_SIZE - originalVersion.length() - targetVersion.length() - 4; - while ( buf.length() < padding ) - { - buf.append( '.' ); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - buf.append( originalVersion ); - buf.append( " -> " ); - buf.append( targetVersion ); + buf.append(' '); + buf.append(originalVersion); + buf.append(" -> "); + buf.append(targetVersion); return buf; } /** * Creates a key that is similar to what {@link Dependency#getManagementKey()} generates for a dependency. */ - private static String generateId( Artifact artifact ) - { + private static String generateId(Artifact artifact) { StringBuilder sb = new StringBuilder(); - sb.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" ) - .append( artifact.getType() ); - if ( artifact.getClassifier() != null ) - { - sb.append( ":" ).append( artifact.getClassifier() ); + sb.append(artifact.getGroupId()) + .append(":") + .append(artifact.getArtifactId()) + .append(":") + .append(artifact.getType()); + if (artifact.getClassifier() != null) { + sb.append(":").append(artifact.getClassifier()); } return sb.toString(); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java index 63b07f8513..d7736aa59d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesAggregateReportMojo.java @@ -17,10 +17,11 @@ * */ +import javax.inject.Inject; import java.util.Map; import java.util.Set; -import javax.inject.Inject; + import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -37,31 +38,31 @@ * * @since 2.14.0 */ -@Mojo( name = "dependency-updates-aggregate-report", - requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true, aggregator = true ) -public class DependencyUpdatesAggregateReportMojo extends AbstractDependencyUpdatesReportMojo -{ +@Mojo( + name = "dependency-updates-aggregate-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true, + aggregator = true) +public class DependencyUpdatesAggregateReportMojo extends AbstractDependencyUpdatesReportMojo { @Inject - protected DependencyUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected DependencyUpdatesAggregateReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} * */ @Override - protected void populateDependencies( Set dependenciesCollector ) - { - getLog().debug( String.format( "Collecting dependencies for project %s", - project.getName() ) ); - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - dependenciesCollector.addAll( project.getDependencies() ); + protected void populateDependencies(Set dependenciesCollector) { + getLog().debug(String.format("Collecting dependencies for project %s", project.getName())); + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + dependenciesCollector.addAll(project.getDependencies()); } } @@ -69,14 +70,11 @@ protected void populateDependencies( Set dependenciesCollector ) * {@inheritDoc} * */ @Override - protected void populateDependencyManagement( Set dependencyManagementCollector, - Set dependencies ) throws MavenReportException - { - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - getLog().debug( String.format( "Collecting managed dependencies for project %s", - project.getName() ) ); - handleDependencyManagementTransitive( project, dependencyManagementCollector ); + protected void populateDependencyManagement( + Set dependencyManagementCollector, Set dependencies) throws MavenReportException { + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + getLog().debug(String.format("Collecting managed dependencies for project %s", project.getName())); + handleDependencyManagementTransitive(project, dependencyManagementCollector); } } @@ -84,9 +82,7 @@ protected void populateDependencyManagement( Set dependencyManagemen * {@inheritDoc} */ @Override - public String getOutputName() - { + public String getOutputName() { return "dependency-updates-aggregate-report"; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index 711086ccb8..76e49a3669 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -19,9 +19,11 @@ * under the License. */ +import javax.inject.Inject; + import java.util.Map; import java.util.Set; -import javax.inject.Inject; + import org.apache.maven.model.Dependency; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -37,51 +39,47 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "dependency-updates-report", - requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class DependencyUpdatesReportMojo extends AbstractDependencyUpdatesReportMojo -{ +@Mojo(name = "dependency-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) +public class DependencyUpdatesReportMojo extends AbstractDependencyUpdatesReportMojo { @Inject - protected DependencyUpdatesReportMojo( I18N i18n, RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected DependencyUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} * */ @Override - protected void populateDependencies( Set dependenciesCollector ) - { - getLog().debug( String.format( "Collecting dependencies for project %s", - getProject().getName() ) ); - dependenciesCollector.addAll( getProject().getDependencies() ); + protected void populateDependencies(Set dependenciesCollector) { + getLog().debug(String.format( + "Collecting dependencies for project %s", getProject().getName())); + dependenciesCollector.addAll(getProject().getDependencies()); } /** * {@inheritDoc} * */ @Override - protected void populateDependencyManagement( Set dependencyManagementCollector, - Set dependencies ) throws MavenReportException - { - if ( hasDependencyManagement( getProject() ) ) - { - getLog().debug( String.format( "Collecting managed dependencies for project %s", - getProject().getName() ) ); - handleDependencyManagementTransitive( getProject(), dependencyManagementCollector ); + protected void populateDependencyManagement( + Set dependencyManagementCollector, Set dependencies) throws MavenReportException { + if (hasDependencyManagement(getProject())) { + getLog().debug(String.format( + "Collecting managed dependencies for project %s", + getProject().getName())); + handleDependencyManagementTransitive(getProject(), dependencyManagementCollector); } } /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "dependency-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java index 9f978b18aa..de698b1743 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojo.java @@ -66,10 +66,8 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "display-dependency-updates", threadSafe = true ) -public class DisplayDependencyUpdatesMojo - extends AbstractVersionsDisplayMojo -{ +@Mojo(name = "display-dependency-updates", threadSafe = true) +public class DisplayDependencyUpdatesMojo extends AbstractVersionsDisplayMojo { // ------------------------------ FIELDS ------------------------------ @@ -85,7 +83,7 @@ public class DisplayDependencyUpdatesMojo * * @since 1.2 */ - @Parameter( property = "processDependencyManagement", defaultValue = "true" ) + @Parameter(property = "processDependencyManagement", defaultValue = "true") private boolean processDependencyManagement; /** @@ -98,7 +96,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.11 */ - @Parameter( property = "processDependencyManagementTransitive", defaultValue = "true" ) + @Parameter(property = "processDependencyManagementTransitive", defaultValue = "true") private boolean processDependencyManagementTransitive; /** @@ -120,7 +118,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "dependencyManagementIncludes", defaultValue = WildcardMatcher.WILDCARD ) + @Parameter(property = "dependencyManagementIncludes", defaultValue = WildcardMatcher.WILDCARD) private List dependencyManagementIncludes; /** @@ -142,7 +140,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "dependencyManagementExcludes" ) + @Parameter(property = "dependencyManagementExcludes") private List dependencyManagementExcludes; /** @@ -150,7 +148,7 @@ public class DisplayDependencyUpdatesMojo * * @since 1.2 */ - @Parameter( property = "processDependencies", defaultValue = "true" ) + @Parameter(property = "processDependencies", defaultValue = "true") private boolean processDependencies; /** @@ -172,7 +170,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "dependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + @Parameter(property = "dependencyIncludes", defaultValue = WildcardMatcher.WILDCARD) private List dependencyIncludes; /** @@ -194,7 +192,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "dependencyExcludes" ) + @Parameter(property = "dependencyExcludes") private List dependencyExcludes; /** @@ -202,7 +200,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "processPluginDependencies", defaultValue = "true" ) + @Parameter(property = "processPluginDependencies", defaultValue = "true") private boolean processPluginDependencies; /** @@ -210,7 +208,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "processPluginDependenciesInPluginManagement", defaultValue = "true" ) + @Parameter(property = "processPluginDependenciesInPluginManagement", defaultValue = "true") private boolean processPluginDependenciesInPluginManagement; /** @@ -221,7 +219,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") private boolean allowMajorUpdates = true; /** @@ -232,7 +230,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") private boolean allowMinorUpdates = true; /** @@ -244,7 +242,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates = true; /** @@ -258,7 +256,7 @@ public class DisplayDependencyUpdatesMojo * @deprecated This will be removed with version 3.0.0 */ @Deprecated - @Parameter( property = "allowAnyUpdates", defaultValue = "true" ) + @Parameter(property = "allowAnyUpdates", defaultValue = "true") private boolean allowAnyUpdates = true; /** @@ -266,7 +264,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.1 */ - @Parameter( property = "verbose", defaultValue = "false" ) + @Parameter(property = "verbose", defaultValue = "false") private boolean verbose; /** @@ -284,7 +282,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "pluginDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + @Parameter(property = "pluginDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD) private List pluginDependencyIncludes; /** @@ -302,13 +300,13 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "pluginDependencyExcludes" ) + @Parameter(property = "pluginDependencyExcludes") private List pluginDependencyExcludes; /** *

    Only take these artifacts into consideration:
    * Comma-separated list of {@code groupId:[artifactId[:version]]} patterns

    - + * * The wildcard "*" can be used as the only, first, last or both characters in each token. * The version token does support version ranges. *

    @@ -319,7 +317,7 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "pluginManagementDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD ) + @Parameter(property = "pluginManagementDependencyIncludes", defaultValue = WildcardMatcher.WILDCARD) private List pluginManagementDependencyIncludes; /** @@ -337,72 +335,62 @@ public class DisplayDependencyUpdatesMojo * * @since 2.12.0 */ - @Parameter( property = "pluginManagementDependencyExcludes" ) + @Parameter(property = "pluginManagementDependencyExcludes") private List pluginManagementDependencyExcludes; // --------------------- GETTER / SETTER METHODS --------------------- @Inject - public DisplayDependencyUpdatesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public DisplayDependencyUpdatesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } // open for tests - protected static boolean dependenciesMatch( Dependency dependency, Dependency managedDependency ) - { - if ( !managedDependency.getGroupId().equals( dependency.getGroupId() ) ) - { + protected static boolean dependenciesMatch(Dependency dependency, Dependency managedDependency) { + if (!managedDependency.getGroupId().equals(dependency.getGroupId())) { return false; } - if ( !managedDependency.getArtifactId().equals( dependency.getArtifactId() ) ) - { + if (!managedDependency.getArtifactId().equals(dependency.getArtifactId())) { return false; } - if ( managedDependency.getScope() == null - || Objects.equals( managedDependency.getScope(), dependency.getScope() ) ) - { + if (managedDependency.getScope() == null + || Objects.equals(managedDependency.getScope(), dependency.getScope())) { return false; } - if ( managedDependency.getClassifier() == null - || Objects.equals( managedDependency.getClassifier(), dependency.getClassifier() ) ) - { + if (managedDependency.getClassifier() == null + || Objects.equals(managedDependency.getClassifier(), dependency.getClassifier())) { return false; } return dependency.getVersion() == null - || managedDependency.getVersion() == null - || Objects.equals( managedDependency.getVersion(), dependency.getVersion() ); + || managedDependency.getVersion() == null + || Objects.equals(managedDependency.getVersion(), dependency.getVersion()); } - public boolean isProcessingDependencyManagement() - { + public boolean isProcessingDependencyManagement() { return processDependencyManagement; } - public boolean isProcessingDependencies() - { + public boolean isProcessingDependencies() { return processDependencies; } - public boolean isProcessingPluginDependencies() - { + public boolean isProcessingPluginDependencies() { return processPluginDependencies; } - public boolean isProcessPluginDependenciesInDependencyManagement() - { + public boolean isProcessPluginDependenciesInDependencyManagement() { return processPluginDependenciesInPluginManagement; } - public boolean isVerbose() - { + public boolean isVerbose() { return verbose; } @@ -417,73 +405,85 @@ public boolean isVerbose() * @since 1.0-alpha-1 */ @Override - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { logInit(); validateInput(); Set dependencyManagement = emptySet(); - try - { - if ( isProcessingDependencyManagement() ) - { - dependencyManagement = filterDependencies( extractDependenciesFromDependencyManagement( getProject(), - processDependencyManagementTransitive, getLog() ), - dependencyManagementIncludes, dependencyManagementExcludes, "Dependecy Management", - getLog() ); - - logUpdates( getHelper().lookupDependenciesUpdates( dependencyManagement, - false ), "Dependency Management" ); + try { + if (isProcessingDependencyManagement()) { + dependencyManagement = filterDependencies( + extractDependenciesFromDependencyManagement( + getProject(), processDependencyManagementTransitive, getLog()), + dependencyManagementIncludes, + dependencyManagementExcludes, + "Dependecy Management", + getLog()); + + logUpdates(getHelper().lookupDependenciesUpdates(dependencyManagement, false), "Dependency Management"); } - if ( isProcessingDependencies() ) - { + if (isProcessingDependencies()) { Set finalDependencyManagement = dependencyManagement; - logUpdates( getHelper().lookupDependenciesUpdates( - filterDependencies( getProject().getDependencies() - .parallelStream() - .filter( dep -> finalDependencyManagement.parallelStream() - .noneMatch( depMan -> dependenciesMatch( dep, depMan ) ) ) - .collect( () -> new TreeSet<>( DependencyComparator.INSTANCE ), Set::add, Set::addAll ), - dependencyIncludes, dependencyExcludes, "Dependencies", getLog() ), - false ), - "Dependencies" ); + logUpdates( + getHelper() + .lookupDependenciesUpdates( + filterDependencies( + getProject().getDependencies().parallelStream() + .filter(dep -> finalDependencyManagement.parallelStream() + .noneMatch(depMan -> dependenciesMatch(dep, depMan))) + .collect( + () -> new TreeSet<>(DependencyComparator.INSTANCE), + Set::add, + Set::addAll), + dependencyIncludes, + dependencyExcludes, + "Dependencies", + getLog()), + false), + "Dependencies"); } - if ( isProcessPluginDependenciesInDependencyManagement() ) - { - logUpdates( getHelper().lookupDependenciesUpdates( filterDependencies( - extractPluginDependenciesFromPluginsInPluginManagement( getProject() ), - pluginManagementDependencyIncludes, pluginManagementDependencyExcludes, - "Plugin Management Dependencies", getLog() ), false ), - "pluginManagement of plugins" ); + if (isProcessPluginDependenciesInDependencyManagement()) { + logUpdates( + getHelper() + .lookupDependenciesUpdates( + filterDependencies( + extractPluginDependenciesFromPluginsInPluginManagement(getProject()), + pluginManagementDependencyIncludes, + pluginManagementDependencyExcludes, + "Plugin Management Dependencies", + getLog()), + false), + "pluginManagement of plugins"); } - if ( isProcessingPluginDependencies() ) - { - logUpdates( getHelper().lookupDependenciesUpdates( filterDependencies( - extractDependenciesFromPlugins( getProject() ), - pluginDependencyIncludes, pluginDependencyExcludes, "Plugin Dependencies", - getLog() ), false ), - "Plugin Dependencies" ); + if (isProcessingPluginDependencies()) { + logUpdates( + getHelper() + .lookupDependenciesUpdates( + filterDependencies( + extractDependenciesFromPlugins(getProject()), + pluginDependencyIncludes, + pluginDependencyExcludes, + "Plugin Dependencies", + getLog()), + false), + "Plugin Dependencies"); } - } - catch ( VersionRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (VersionRetrievalException e) { + throw new MojoExecutionException(e.getMessage(), e); } } @Override - protected void validateInput() throws MojoExecutionException - { - validateGAVList( dependencyIncludes, 6, "dependencyIncludes" ); - validateGAVList( dependencyExcludes, 6, "dependencyExcludes" ); - validateGAVList( dependencyManagementIncludes, 6, "dependencyManagementIncludes" ); - validateGAVList( dependencyManagementIncludes, 6, "dependencyManagementExcludes" ); - validateGAVList( pluginDependencyIncludes, 3, "pluginDependencyIncludes" ); - validateGAVList( pluginDependencyExcludes, 3, "pluginDependencyExcludes" ); - validateGAVList( pluginManagementDependencyIncludes, 3, "pluginManagementDependencyIncludes" ); - validateGAVList( pluginManagementDependencyExcludes, 3, "pluginManagementDependencyExcludes" ); + protected void validateInput() throws MojoExecutionException { + validateGAVList(dependencyIncludes, 6, "dependencyIncludes"); + validateGAVList(dependencyExcludes, 6, "dependencyExcludes"); + validateGAVList(dependencyManagementIncludes, 6, "dependencyManagementIncludes"); + validateGAVList(dependencyManagementIncludes, 6, "dependencyManagementExcludes"); + validateGAVList(pluginDependencyIncludes, 3, "pluginDependencyIncludes"); + validateGAVList(pluginDependencyExcludes, 3, "pluginDependencyExcludes"); + validateGAVList(pluginManagementDependencyIncludes, 3, "pluginManagementDependencyIncludes"); + validateGAVList(pluginManagementDependencyExcludes, 3, "pluginManagementDependencyExcludes"); } /** @@ -493,105 +493,83 @@ protected void validateInput() throws MojoExecutionException * @param argumentName argument name to indicate in the exception * @throws MojoExecutionException if the argument is invalid */ - static void validateGAVList( List gavList, int numSections, String argumentName ) - throws MojoExecutionException - { - if ( gavList != null && gavList.stream().anyMatch( gav -> countMatches( gav, ":" ) >= numSections ) ) - { - throw new MojoExecutionException( argumentName + " should not contain more than 6 segments" ); + static void validateGAVList(List gavList, int numSections, String argumentName) + throws MojoExecutionException { + if (gavList != null && gavList.stream().anyMatch(gav -> countMatches(gav, ":") >= numSections)) { + throw new MojoExecutionException(argumentName + " should not contain more than 6 segments"); } } - private Optional calculateUpdateScope() - { + private Optional calculateUpdateScope() { return allowAnyUpdates - ? empty() - : of( SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ) - .map( s -> Segment.of( s.value() + 1 ) ) - .orElse( MAJOR ) ); + ? empty() + : of(SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()) + .map(s -> Segment.of(s.value() + 1)) + .orElse(MAJOR)); } - private void logUpdates( Map updates, String section ) - { + private void logUpdates(Map updates, String section) { List withUpdates = new ArrayList<>(); List usingCurrent = new ArrayList<>(); - for ( ArtifactVersions versions : updates.values() ) - { - String left = " " + ArtifactUtils.versionlessKey( versions.getArtifact() ) + " "; + for (ArtifactVersions versions : updates.values()) { + String left = " " + ArtifactUtils.versionlessKey(versions.getArtifact()) + " "; final String current; ArtifactVersion latest; - if ( versions.isCurrentVersionDefined() ) - { + if (versions.isCurrentVersionDefined()) { current = versions.getCurrentVersion().toString(); - latest = versions.getNewestUpdate( calculateUpdateScope(), allowSnapshots ); - } - else - { + latest = versions.getNewestUpdate(calculateUpdateScope(), allowSnapshots); + } else { ArtifactVersion newestVersion = - versions.getNewestVersion( versions.getArtifact().getVersionRange(), allowSnapshots ); + versions.getNewestVersion(versions.getArtifact().getVersionRange(), allowSnapshots); current = versions.getArtifact().getVersionRange().toString(); - latest = newestVersion == null ? null - : versions.getNewestUpdate( newestVersion, calculateUpdateScope(), allowSnapshots ); - if ( latest != null - && ArtifactVersions.isVersionInRange( latest, versions.getArtifact().getVersionRange() ) ) - { + latest = newestVersion == null + ? null + : versions.getNewestUpdate(newestVersion, calculateUpdateScope(), allowSnapshots); + if (latest != null + && ArtifactVersions.isVersionInRange( + latest, versions.getArtifact().getVersionRange())) { latest = null; } } - String right = " " + ( latest == null ? current : current + " -> " + latest ); + String right = " " + (latest == null ? current : current + " -> " + latest); List t = latest == null ? usingCurrent : withUpdates; - if ( right.length() + left.length() + 3 > INFO_PAD_SIZE + getOutputLineWidthOffset() ) - { - t.add( left + "..." ); - t.add( StringUtils.leftPad( right, INFO_PAD_SIZE + getOutputLineWidthOffset() ) ); + if (right.length() + left.length() + 3 > INFO_PAD_SIZE + getOutputLineWidthOffset()) { + t.add(left + "..."); + t.add(StringUtils.leftPad(right, INFO_PAD_SIZE + getOutputLineWidthOffset())); - } - else - { - t.add( StringUtils.rightPad( left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), "." ) - + right ); + } else { + t.add(StringUtils.rightPad(left, INFO_PAD_SIZE + getOutputLineWidthOffset() - right.length(), ".") + + right); } } - if ( isVerbose() ) - { - if ( usingCurrent.isEmpty() ) - { - if ( !withUpdates.isEmpty() ) - { - logLine( false, "No dependencies in " + section + " are using the newest version." ); - logLine( false, "" ); + if (isVerbose()) { + if (usingCurrent.isEmpty()) { + if (!withUpdates.isEmpty()) { + logLine(false, "No dependencies in " + section + " are using the newest version."); + logLine(false, ""); } - } - else - { - logLine( false, "The following dependencies in " + section + " are using the newest version:" ); - for ( String s : usingCurrent ) - { - logLine( false, s ); + } else { + logLine(false, "The following dependencies in " + section + " are using the newest version:"); + for (String s : usingCurrent) { + logLine(false, s); } - logLine( false, "" ); + logLine(false, ""); } } - - if ( withUpdates.isEmpty() ) - { - if ( !usingCurrent.isEmpty() ) - { - logLine( false, "No dependencies in " + section + " have newer versions." ); - logLine( false, "" ); + if (withUpdates.isEmpty()) { + if (!usingCurrent.isEmpty()) { + logLine(false, "No dependencies in " + section + " have newer versions."); + logLine(false, ""); } - } - else - { - logLine( false, "The following dependencies in " + section + " have newer versions:" ); - for ( String withUpdate : withUpdates ) - { - logLine( false, withUpdate ); + } else { + logLine(false, "The following dependencies in " + section + " have newer versions:"); + for (String withUpdate : withUpdates) { + logLine(false, withUpdate); } - logLine( false, "" ); + logLine(false, ""); } } @@ -601,9 +579,7 @@ private void logUpdates( Map updates, String secti * @since 1.0-alpha-1 */ @Override - protected void update( ModifiedPomXMLEventReader pom ) - { + protected void update(ModifiedPomXMLEventReader pom) { // do nothing } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java index a65d58faa2..af8ee80e31 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayParentUpdatesMojo.java @@ -43,36 +43,30 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "display-parent-updates", threadSafe = true ) -public class DisplayParentUpdatesMojo - extends AbstractVersionsDisplayMojo -{ +@Mojo(name = "display-parent-updates", threadSafe = true) +public class DisplayParentUpdatesMojo extends AbstractVersionsDisplayMojo { public static final int MESSAGE_LENGTH = 68; @Inject - public DisplayParentUpdatesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public DisplayParentUpdatesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } @Override - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { logInit(); - if ( getProject().getParent() == null ) - { - logLine( false, "Project does not have a parent." ); + if (getProject().getParent() == null) { + logLine(false, "Project does not have a parent."); return; } - if ( reactorProjects.contains( getProject().getParent() ) ) - { - logLine( false, "Parent project is part of the reactor." ); + if (reactorProjects.contains(getProject().getParent())) { + logLine(false, "Parent project is part of the reactor."); return; } @@ -80,75 +74,65 @@ public void execute() String version = currentVersion; VersionRange versionRange; - try - { - versionRange = VersionRange.createFromVersionSpec( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( "Invalid version range specification: " + version, e ); + try { + versionRange = VersionRange.createFromVersionSpec(version); + } catch (InvalidVersionSpecificationException e) { + throw new MojoExecutionException("Invalid version range specification: " + version, e); } - Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( version ) - .withType( "pom" ) - .build() ); + Artifact artifact = getHelper() + .createDependencyArtifact(DependencyBuilder.newBuilder() + .withGroupId(getProject().getParent().getGroupId()) + .withArtifactId(getProject().getParent().getArtifactId()) + .withVersion(version) + .withType("pom") + .build()); ArtifactVersion artifactVersion; - try - { - artifactVersion = findLatestVersion( artifact, versionRange, null, false ); - } - catch ( VersionRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + try { + artifactVersion = findLatestVersion(artifact, versionRange, null, false); + } catch (VersionRetrievalException e) { + throw new MojoExecutionException(e.getMessage(), e); } - if ( artifactVersion == null || currentVersion.equals( artifactVersion.toString() ) ) - { - logLine( false, "The parent project is the latest version:" ); - StringBuilder buf = new StringBuilder( MESSAGE_LENGTH ); - buf.append( " " ); - buf.append( getProject().getParent().getGroupId() ); - buf.append( ':' ); - buf.append( getProject().getParent().getArtifactId() ); - buf.append( ' ' ); + if (artifactVersion == null || currentVersion.equals(artifactVersion.toString())) { + logLine(false, "The parent project is the latest version:"); + StringBuilder buf = new StringBuilder(MESSAGE_LENGTH); + buf.append(" "); + buf.append(getProject().getParent().getGroupId()); + buf.append(':'); + buf.append(getProject().getParent().getArtifactId()); + buf.append(' '); int padding = MESSAGE_LENGTH - currentVersion.length(); - while ( buf.length() < padding ) - { - buf.append( '.' ); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - buf.append( currentVersion ); - logLine( false, buf.toString() ); - } - else - { - logLine( false, "The parent project has a newer version:" ); - StringBuilder buf = new StringBuilder( MESSAGE_LENGTH ); - buf.append( " " ); - buf.append( getProject().getParent().getGroupId() ); - buf.append( ':' ); - buf.append( getProject().getParent().getArtifactId() ); - buf.append( ' ' ); - int padding = MESSAGE_LENGTH - currentVersion.length() - - artifactVersion.toString().length() - " -> ".length(); - while ( buf.length() < padding ) - { - buf.append( '.' ); + buf.append(' '); + buf.append(currentVersion); + logLine(false, buf.toString()); + } else { + logLine(false, "The parent project has a newer version:"); + StringBuilder buf = new StringBuilder(MESSAGE_LENGTH); + buf.append(" "); + buf.append(getProject().getParent().getGroupId()); + buf.append(':'); + buf.append(getProject().getParent().getArtifactId()); + buf.append(' '); + int padding = MESSAGE_LENGTH + - currentVersion.length() + - artifactVersion.toString().length() + - " -> ".length(); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - buf.append( currentVersion ); - buf.append( " -> " ); - buf.append( artifactVersion ); - logLine( false, buf.toString() ); + buf.append(' '); + buf.append(currentVersion); + buf.append(" -> "); + buf.append(artifactVersion); + logLine(false, buf.toString()); } } @Override - protected void update( ModifiedPomXMLEventReader pom ) - { - } + protected void update(ModifiedPomXMLEventReader pom) {} } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java index 0b9c84508b..8f7724d7b6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPluginUpdatesMojo.java @@ -93,10 +93,8 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "display-plugin-updates", threadSafe = true ) -public class DisplayPluginUpdatesMojo - extends AbstractVersionsDisplayMojo -{ +@Mojo(name = "display-plugin-updates", threadSafe = true) +public class DisplayPluginUpdatesMojo extends AbstractVersionsDisplayMojo { // ------------------------------ FIELDS ------------------------------ @@ -120,6 +118,7 @@ public class DisplayPluginUpdatesMojo * @since 1.0-alpha-1 */ private static final String FROM_SUPER_POM = "(from super-pom) "; + public static final String DEFAULT_MVN_VERSION = "3.2.5"; /** @@ -149,17 +148,17 @@ public class DisplayPluginUpdatesMojo // --------------------- GETTER / SETTER METHODS --------------------- @Inject - @SuppressWarnings( "checkstyle:ParameterNumber" ) - public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - ProjectBuilder projectBuilder, - Map wagonMap, - LifecycleExecutor lifecycleExecutor, - ModelInterpolator modelInterpolator, - RuntimeInformation runtimeInformation, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + @SuppressWarnings("checkstyle:ParameterNumber") + public DisplayPluginUpdatesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + ProjectBuilder projectBuilder, + Map wagonMap, + LifecycleExecutor lifecycleExecutor, + ModelInterpolator modelInterpolator, + RuntimeInformation runtimeInformation, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); this.projectBuilder = projectBuilder; this.lifecycleExecutor = lifecycleExecutor; this.modelInterpolator = modelInterpolator; @@ -172,82 +171,65 @@ public DisplayPluginUpdatesMojo( RepositorySystem repositorySystem, * @return Returns the pluginManagement section of the super-pom. * @throws MojoExecutionException when things go wrong. */ - private Map getSuperPomPluginManagement() - throws MojoExecutionException - { + private Map getSuperPomPluginManagement() throws MojoExecutionException { // we need to provide a copy with the version blanked out so that inferring from super-pom // works as for 2.x as 3.x fills in the version on us! - Map result = lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( getProject() - .getPackaging() ) - .stream() - .collect( LinkedHashMap::new, - ( m, p ) -> m.put( p.getKey(), p.getVersion() ), - Map::putAll ); - - URL superPom = getClass().getClassLoader().getResource( "org/apache/maven/model/pom-4.0.0.xml" ); - if ( superPom != null ) - { - try - { - try ( Reader reader = ReaderFactory.newXmlReader( superPom ) ) - { - StringBuilder buf = new StringBuilder( IOUtil.toString( reader ) ); - ModifiedPomXMLEventReader pom = newModifiedPomXER( buf, superPom.toString() ); - - Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" + Map result = + lifecycleExecutor + .getPluginsBoundByDefaultToAllLifecycles(getProject().getPackaging()) + .stream() + .collect(LinkedHashMap::new, (m, p) -> m.put(p.getKey(), p.getVersion()), Map::putAll); + + URL superPom = getClass().getClassLoader().getResource("org/apache/maven/model/pom-4.0.0.xml"); + if (superPom != null) { + try { + try (Reader reader = ReaderFactory.newXmlReader(superPom)) { + StringBuilder buf = new StringBuilder(IOUtil.toString(reader)); + ModifiedPomXMLEventReader pom = newModifiedPomXER(buf, superPom.toString()); + + Pattern pathRegex = Pattern.compile("/project(/profiles/profile)?" + "((/build(/pluginManagement)?)|(/reporting))" - + "/plugins/plugin" ); + + "/plugins/plugin"); Stack pathStack = new Stack<>(); StackState curState = null; - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartDocument() ) - { - curState = new StackState( "" ); + if (event.isStartDocument()) { + curState = new StackState(""); pathStack.clear(); - } - else if ( event.isStartElement() ) - { - String elementName = event.asStartElement().getName().getLocalPart(); - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { + } else if (event.isStartElement()) { + String elementName = + event.asStartElement().getName().getLocalPart(); + if (curState != null + && pathRegex.matcher(curState.path).matches()) { + if ("groupId".equals(elementName)) { curState.groupId = pom.getElementText().trim(); continue; - } - else if ( "artifactId".equals( elementName ) ) - { + } else if ("artifactId".equals(elementName)) { curState.artifactId = pom.getElementText().trim(); continue; - } - else if ( "version".equals( elementName ) ) - { + } else if ("version".equals(elementName)) { curState.version = pom.getElementText().trim(); continue; } } - pathStack.push( curState ); - curState = new StackState( curState.path + "/" + elementName ); - } - else if ( event.isEndElement() ) - { - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) - { - if ( curState.artifactId != null ) - { + pathStack.push(curState); + curState = new StackState(curState.path + "/" + elementName); + } else if (event.isEndElement()) { + if (curState != null + && pathRegex.matcher(curState.path).matches()) { + if (curState.artifactId != null) { Plugin plugin = new Plugin(); - plugin.setArtifactId( curState.artifactId ); - plugin.setGroupId( curState.groupId == null - ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID - : curState.groupId ); - plugin.setVersion( curState.version ); - if ( !result.containsKey( plugin.getKey() ) ) - { - result.put( plugin.getKey(), plugin.getVersion() ); + plugin.setArtifactId(curState.artifactId); + plugin.setGroupId( + curState.groupId == null + ? PomHelper.APACHE_MAVEN_PLUGINS_GROUPID + : curState.groupId); + plugin.setVersion(curState.version); + if (!result.containsKey(plugin.getKey())) { + result.put(plugin.getKey(), plugin.getVersion()); } } } @@ -255,9 +237,7 @@ else if ( event.isEndElement() ) } } } - } - catch ( IOException | XMLStreamException e ) - { + } catch (IOException | XMLStreamException e) { // ignore } } @@ -272,50 +252,36 @@ else if ( event.isEndElement() ) * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ - private Map getPluginManagement( Model model ) - { + private Map getPluginManagement(Model model) { // we want only those parts of pluginManagement that are defined in this project Map pluginManagement = new HashMap<>(); - try - { - for ( Plugin plugin : model.getBuild().getPluginManagement().getPlugins() ) - { + try { + for (Plugin plugin : model.getBuild().getPluginManagement().getPlugins()) { String coord = plugin.getKey(); String version = plugin.getVersion(); - if ( version != null ) - { - pluginManagement.put( coord, version ); + if (version != null) { + pluginManagement.put(coord, version); } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no plugins here } - try - { - for ( Profile profile : model.getProfiles() ) - { - try - { - for ( Plugin plugin : profile.getBuild().getPluginManagement().getPlugins() ) - { + try { + for (Profile profile : model.getProfiles()) { + try { + for (Plugin plugin : + profile.getBuild().getPluginManagement().getPlugins()) { String coord = plugin.getKey(); String version = plugin.getVersion(); - if ( version != null ) - { - pluginManagement.put( coord, version ); + if (version != null) { + pluginManagement.put(coord, version); } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no plugins here } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no profiles here } @@ -332,29 +298,23 @@ private Map getPluginManagement( Model model ) * @see AbstractVersionsUpdaterMojo#execute() * @since 1.0-alpha-1 */ - @SuppressWarnings( "checkstyle:MethodLength" ) - public void execute() - throws MojoExecutionException, MojoFailureException - { + @SuppressWarnings("checkstyle:MethodLength") + public void execute() throws MojoExecutionException, MojoFailureException { logInit(); Set pluginsWithVersionsSpecified; - try - { + try { MavenProject project1 = getProject(); - pluginsWithVersionsSpecified = - findPluginsWithVersionsSpecified( PomHelper.readXmlFile( project1.getFile() ), - getSafeProjectPathInfo( project1 ) ); - } - catch ( XMLStreamException | IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + pluginsWithVersionsSpecified = findPluginsWithVersionsSpecified( + PomHelper.readXmlFile(project1.getFile()), getSafeProjectPathInfo(project1)); + } catch (XMLStreamException | IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } Map superPomPluginManagement = getSuperPomPluginManagement(); - getLog().debug( "superPom plugins = " + superPomPluginManagement ); + getLog().debug("superPom plugins = " + superPomPluginManagement); - List parents = getParentProjects( getProject() ); - Map parentPlugins = getParentsPlugins( parents ); + List parents = getParentProjects(getProject()); + Map parentPlugins = getParentsPlugins(parents); // TODO remove, not used any more (found while extracting getParentsPlugins method and // renaming parentPluginManagement to parentPlugins) // NOTICE: getProjectPlugins() takes profiles while getParentPlugins does not @@ -362,132 +322,117 @@ public void execute() Map parentBuildPlugins = new HashMap<>(); Map parentReportPlugins = new HashMap<>(); - Set plugins = getProjectPlugins( superPomPluginManagement, parentPlugins, parentBuildPlugins, - parentReportPlugins, pluginsWithVersionsSpecified ); + Set plugins = getProjectPlugins( + superPomPluginManagement, + parentPlugins, + parentBuildPlugins, + parentReportPlugins, + pluginsWithVersionsSpecified); List pluginUpdates = new ArrayList<>(); List pluginLockdowns = new ArrayList<>(); - ArtifactVersion curMavenVersion = new DefaultArtifactVersion( runtimeInformation.getMavenVersion() ); - ArtifactVersion specMavenVersion = MinimalMavenBuildVersionFinder.find( getProject(), DEFAULT_MVN_VERSION, - getLog() ); + ArtifactVersion curMavenVersion = new DefaultArtifactVersion(runtimeInformation.getMavenVersion()); + ArtifactVersion specMavenVersion = + MinimalMavenBuildVersionFinder.find(getProject(), DEFAULT_MVN_VERSION, getLog()); ArtifactVersion minMavenVersion = null; boolean superPomDrivingMinVersion = false; // if Maven prerequisite upgraded to a version, Map - Map> mavenUpgrades = new TreeMap<>( new MavenVersionComparator() ); + Map> mavenUpgrades = new TreeMap<>(new MavenVersionComparator()); - for ( Plugin plugin : plugins ) - { + for (Plugin plugin : plugins) { String groupId = plugin.getGroupId(); String artifactId = plugin.getArtifactId(); String version = plugin.getVersion(); - String coords = ArtifactUtils.versionlessKey( groupId, artifactId ); + String coords = ArtifactUtils.versionlessKey(groupId, artifactId); - if ( version == null ) - { - version = parentPlugins.get( coords ); + if (version == null) { + version = parentPlugins.get(coords); } - boolean versionSpecifiedInCurrentPom = pluginsWithVersionsSpecified.contains( coords ); - if ( !versionSpecifiedInCurrentPom && parentPlugins.containsKey( coords ) ) - { - getLog().debug( "Skip " + coords + ", version " + version + " is defined in parent POM." ); + boolean versionSpecifiedInCurrentPom = pluginsWithVersionsSpecified.contains(coords); + if (!versionSpecifiedInCurrentPom && parentPlugins.containsKey(coords)) { + getLog().debug("Skip " + coords + ", version " + version + " is defined in parent POM."); continue; } - getLog().debug( "Checking " + coords + " for updates newer than " + version ); + getLog().debug("Checking " + coords + " for updates newer than " + version); String effectiveVersion = version; - Artifact artifactRange = getHelper().createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), - version ); + Artifact artifactRange = + getHelper().createPluginArtifact(plugin.getGroupId(), plugin.getArtifactId(), version); ArtifactVersion artifactVersion = null; - try - { + try { // now we want to find the newest versions and check their Maven version prerequisite - ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifactRange, true ); - ArtifactVersion[] newerVersions = artifactVersions.getVersions( this.allowSnapshots ); + ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions(artifactRange, true); + ArtifactVersion[] newerVersions = artifactVersions.getVersions(this.allowSnapshots); ArtifactVersion minRequires = null; - for ( int j = newerVersions.length - 1; j >= 0; j-- ) - { - try - { + for (int j = newerVersions.length - 1; j >= 0; j--) { + try { ArtifactVersion pluginRequires = getPrerequisitesMavenVersion( - getPluginProject( groupId, artifactId, newerVersions[j].toString() ) ); - if ( artifactVersion == null && compare( specMavenVersion, pluginRequires ) >= 0 ) - { + getPluginProject(groupId, artifactId, newerVersions[j].toString())); + if (artifactVersion == null && compare(specMavenVersion, pluginRequires) >= 0) { // ok, newer version compatible with current specMavenVersion artifactVersion = newerVersions[j]; } - if ( effectiveVersion == null && compare( curMavenVersion, pluginRequires ) >= 0 ) - { + if (effectiveVersion == null && compare(curMavenVersion, pluginRequires) >= 0) { // version was unspecified, current version of maven thinks it should use this effectiveVersion = newerVersions[j].toString(); } - if ( artifactVersion != null && effectiveVersion != null ) - { + if (artifactVersion != null && effectiveVersion != null) { // no need to look at any older versions: latest compatible found break; } // newer version not compatible with current specMavenVersion: track opportunity if Maven spec // upgrade - if ( minRequires == null || compare( minRequires, pluginRequires ) > 0 ) - { + if (minRequires == null || compare(minRequires, pluginRequires) > 0) { Map upgradePlugins = - mavenUpgrades.computeIfAbsent( pluginRequires, k -> new LinkedHashMap<>() ); + mavenUpgrades.computeIfAbsent(pluginRequires, k -> new LinkedHashMap<>()); - String upgradePluginKey = compactKey( groupId, artifactId ); - if ( !upgradePlugins.containsKey( upgradePluginKey ) ) - { + String upgradePluginKey = compactKey(groupId, artifactId); + if (!upgradePlugins.containsKey(upgradePluginKey)) { String newer = newerVersions[j].toString(); - if ( newer.equals( effectiveVersion ) ) - { + if (newer.equals(effectiveVersion)) { // plugin version configured that require a Maven version higher than spec - upgradePlugins.put( upgradePluginKey, - pad( upgradePluginKey, - INFO_PAD_SIZE + getOutputLineWidthOffset(), newer ) ); - } - else - { + upgradePlugins.put( + upgradePluginKey, + pad(upgradePluginKey, INFO_PAD_SIZE + getOutputLineWidthOffset(), newer)); + } else { // plugin that can be upgraded - upgradePlugins.put( upgradePluginKey, pad( upgradePluginKey, INFO_PAD_SIZE - + getOutputLineWidthOffset(), - effectiveVersion, " -> ", newer ) ); + upgradePlugins.put( + upgradePluginKey, + pad( + upgradePluginKey, + INFO_PAD_SIZE + getOutputLineWidthOffset(), + effectiveVersion, + " -> ", + newer)); } } minRequires = pluginRequires; } - } - catch ( ArtifactResolutionException | ProjectBuildingException e ) - { + } catch (ArtifactResolutionException | ProjectBuildingException e) { // ignore bad version } } - if ( effectiveVersion != null ) - { - try - { - ArtifactVersion requires = getPrerequisitesMavenVersion( - getPluginProject( groupId, artifactId, effectiveVersion ) ); - if ( minMavenVersion == null || compare( minMavenVersion, requires ) < 0 ) - { + if (effectiveVersion != null) { + try { + ArtifactVersion requires = + getPrerequisitesMavenVersion(getPluginProject(groupId, artifactId, effectiveVersion)); + if (minMavenVersion == null || compare(minMavenVersion, requires) < 0) { minMavenVersion = requires; } - } - catch ( ArtifactResolutionException | ProjectBuildingException e ) - { + } catch (ArtifactResolutionException | ProjectBuildingException e) { // ignore bad version } } - } - catch ( VersionRetrievalException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (VersionRetrievalException e) { + throw new MojoExecutionException(e.getMessage(), e); } String newVersion; - if ( version == null && versionSpecifiedInCurrentPom ) - { + if (version == null && versionSpecifiedInCurrentPom) { // Hack ALERT! // // All this should be re-written in a less "pom is xml" way... but it'll @@ -498,165 +443,139 @@ public void execute() version = artifactVersion != null ? artifactVersion.toString() : null; } - getLog().debug( "[" + coords + "].version=" + version ); - getLog().debug( "[" + coords + "].artifactVersion=" + artifactVersion ); - getLog().debug( "[" + coords + "].effectiveVersion=" + effectiveVersion ); - getLog().debug( "[" + coords + "].specified=" + versionSpecifiedInCurrentPom ); - if ( version == null || !versionSpecifiedInCurrentPom ) - { - version = superPomPluginManagement.get( coords ); - getLog().debug( "[" + coords + "].superPom.version=" + version ); - - newVersion = artifactVersion != null ? artifactVersion.toString() - : ( version != null ? version - : ( effectiveVersion != null ? effectiveVersion : "(unknown)" ) ); - if ( version != null ) - { + getLog().debug("[" + coords + "].version=" + version); + getLog().debug("[" + coords + "].artifactVersion=" + artifactVersion); + getLog().debug("[" + coords + "].effectiveVersion=" + effectiveVersion); + getLog().debug("[" + coords + "].specified=" + versionSpecifiedInCurrentPom); + if (version == null || !versionSpecifiedInCurrentPom) { + version = superPomPluginManagement.get(coords); + getLog().debug("[" + coords + "].superPom.version=" + version); + + newVersion = artifactVersion != null + ? artifactVersion.toString() + : (version != null ? version : (effectiveVersion != null ? effectiveVersion : "(unknown)")); + if (version != null) { superPomDrivingMinVersion = true; } - pluginLockdowns.add( pad( compactKey( groupId, artifactId ), WARN_PAD_SIZE + getOutputLineWidthOffset(), - superPomDrivingMinVersion ? FROM_SUPER_POM : "", newVersion ) ); - } - else if ( artifactVersion != null ) - { + pluginLockdowns.add(pad( + compactKey(groupId, artifactId), + WARN_PAD_SIZE + getOutputLineWidthOffset(), + superPomDrivingMinVersion ? FROM_SUPER_POM : "", + newVersion)); + } else if (artifactVersion != null) { newVersion = artifactVersion.toString(); - } - else - { + } else { newVersion = null; } - if ( version != null && artifactVersion != null && newVersion != null && effectiveVersion != null - && - new DefaultArtifactVersion( effectiveVersion ).compareTo( new DefaultArtifactVersion( newVersion ) ) - < 0 ) - { - pluginUpdates.add( pad( compactKey( groupId, artifactId ), INFO_PAD_SIZE + getOutputLineWidthOffset(), - effectiveVersion, " -> ", newVersion ) ); + if (version != null + && artifactVersion != null + && newVersion != null + && effectiveVersion != null + && new DefaultArtifactVersion(effectiveVersion).compareTo(new DefaultArtifactVersion(newVersion)) + < 0) { + pluginUpdates.add(pad( + compactKey(groupId, artifactId), + INFO_PAD_SIZE + getOutputLineWidthOffset(), + effectiveVersion, + " -> ", + newVersion)); } } // info on each plugin gathered: now it's time to display the result! // - logLine( false, "" ); + logLine(false, ""); // updates keeping currently defined Maven version minimum - if ( pluginUpdates.isEmpty() ) - { - logLine( false, "All plugins with a version specified are using the latest versions." ); - } - else - { - logLine( false, "The following plugin updates are available:" ); - for ( String update : new TreeSet<>( pluginUpdates ) ) - { - logLine( false, update ); + if (pluginUpdates.isEmpty()) { + logLine(false, "All plugins with a version specified are using the latest versions."); + } else { + logLine(false, "The following plugin updates are available:"); + for (String update : new TreeSet<>(pluginUpdates)) { + logLine(false, update); } } - logLine( false, "" ); + logLine(false, ""); // has every plugin a specified version? - if ( pluginLockdowns.isEmpty() ) - { - logLine( false, "All plugins have a version specified." ); - } - else - { - getLog().warn( "The following plugins do not have their version specified:" ); - for ( String lockdown : new TreeSet<>( pluginLockdowns ) ) - { - getLog().warn( lockdown ); + if (pluginLockdowns.isEmpty()) { + logLine(false, "All plugins have a version specified."); + } else { + getLog().warn("The following plugins do not have their version specified:"); + for (String lockdown : new TreeSet<>(pluginLockdowns)) { + getLog().warn(lockdown); } } - logLine( false, "" ); + logLine(false, ""); // information on minimum Maven version - boolean noMavenMinVersion = MinimalMavenBuildVersionFinder.find( getProject(), null, getLog() ) == null; - if ( noMavenMinVersion ) - { - getLog().warn( "Project does not define minimum Maven version required for build, default is: " - + DEFAULT_MVN_VERSION ); + boolean noMavenMinVersion = MinimalMavenBuildVersionFinder.find(getProject(), null, getLog()) == null; + if (noMavenMinVersion) { + getLog().warn("Project does not define minimum Maven version required for build, default is: " + + DEFAULT_MVN_VERSION); + } else { + logLine(false, "Project requires minimum Maven version for build of: " + specMavenVersion); } - else - { - logLine( false, "Project requires minimum Maven version for build of: " + specMavenVersion ); + logLine(false, "Plugins require minimum Maven version of: " + minMavenVersion); + if (superPomDrivingMinVersion) { + logLine(false, "Note: the super-pom from Maven " + curMavenVersion + " defines some of the plugin"); + logLine(false, " versions and may be influencing the plugins required minimum Maven"); + logLine(false, " version."); } - logLine( false, "Plugins require minimum Maven version of: " + minMavenVersion ); - if ( superPomDrivingMinVersion ) - { - logLine( false, "Note: the super-pom from Maven " + curMavenVersion + " defines some of the plugin" ); - logLine( false, " versions and may be influencing the plugins required minimum Maven" ); - logLine( false, " version." ); - } - logLine( false, "" ); - - if ( isMavenPluginProject() ) - { - if ( noMavenMinVersion ) - { - getLog().warn( "Project (which is a Maven plugin) does not define required minimum version of Maven." ); - getLog().warn( "Update the pom.xml to contain" ); - getLog().warn( " " ); - getLog().warn( " " ); - getLog().warn( " " ); - getLog().warn( "To build this plugin you need at least Maven " + minMavenVersion ); - getLog().warn( "A Maven Enforcer rule can be used to enforce this if you have not already set one up" ); - getLog().warn( "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html" ); - } - else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion ) < 0 ) - { - getLog().warn( "Project (which is a Maven plugin) targets Maven " + specMavenVersion + " or newer" ); - getLog().warn( "but requires Maven " + minMavenVersion + " or newer to build." ); - getLog().warn( "This may or may not be a problem. A Maven Enforcer rule can help " ); - getLog().warn( "enforce that the correct version of Maven is used to build this plugin." ); - getLog().warn( "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html" ); - } - else - { - logLine( false, "No plugins require a newer version of Maven than specified by the pom." ); - } - } - else - { - if ( noMavenMinVersion ) - { - logLine( true, "Project does not define required minimum version of Maven." ); - logLine( true, "Update the pom.xml to contain maven-enforcer-plugin to" ); - logLine( true, "force the Maven version which is needed to build this project." ); - logLine( true, "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html" ); - logLine( true, "Using the minimum version of Maven: " + minMavenVersion ); - } - else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion ) < 0 ) - { - logLine( true, "Project requires an incorrect minimum version of Maven." ); - logLine( true, "Update the pom.xml to contain maven-enforcer-plugin to" ); - logLine( true, "force the Maven version which is needed to build this project." ); - logLine( true, "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html" ); - logLine( true, "Using the minimum version of Maven: " + specMavenVersion ); + logLine(false, ""); + + if (isMavenPluginProject()) { + if (noMavenMinVersion) { + getLog().warn("Project (which is a Maven plugin) does not define required minimum version of Maven."); + getLog().warn("Update the pom.xml to contain"); + getLog().warn(" "); + getLog().warn(" "); + getLog().warn(" "); + getLog().warn("To build this plugin you need at least Maven " + minMavenVersion); + getLog().warn("A Maven Enforcer rule can be used to enforce this if you have not already set one up"); + getLog().warn("See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html"); + } else if (minMavenVersion != null && compare(specMavenVersion, minMavenVersion) < 0) { + getLog().warn("Project (which is a Maven plugin) targets Maven " + specMavenVersion + " or newer"); + getLog().warn("but requires Maven " + minMavenVersion + " or newer to build."); + getLog().warn("This may or may not be a problem. A Maven Enforcer rule can help "); + getLog().warn("enforce that the correct version of Maven is used to build this plugin."); + getLog().warn("See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html"); + } else { + logLine(false, "No plugins require a newer version of Maven than specified by the pom."); } - else - { - logLine( false, "No plugins require a newer version of Maven than specified by the pom." ); + } else { + if (noMavenMinVersion) { + logLine(true, "Project does not define required minimum version of Maven."); + logLine(true, "Update the pom.xml to contain maven-enforcer-plugin to"); + logLine(true, "force the Maven version which is needed to build this project."); + logLine(true, "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html"); + logLine(true, "Using the minimum version of Maven: " + minMavenVersion); + } else if (minMavenVersion != null && compare(specMavenVersion, minMavenVersion) < 0) { + logLine(true, "Project requires an incorrect minimum version of Maven."); + logLine(true, "Update the pom.xml to contain maven-enforcer-plugin to"); + logLine(true, "force the Maven version which is needed to build this project."); + logLine(true, "See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html"); + logLine(true, "Using the minimum version of Maven: " + specMavenVersion); + } else { + logLine(false, "No plugins require a newer version of Maven than specified by the pom."); } } // updates if minimum Maven version is changed - for ( Map.Entry> mavenUpgrade : mavenUpgrades.entrySet() ) - { + for (Map.Entry> mavenUpgrade : mavenUpgrades.entrySet()) { ArtifactVersion mavenUpgradeVersion = mavenUpgrade.getKey(); Map upgradePlugins = mavenUpgrade.getValue(); - if ( upgradePlugins.isEmpty() || compare( specMavenVersion, mavenUpgradeVersion ) >= 0 ) - { + if (upgradePlugins.isEmpty() || compare(specMavenVersion, mavenUpgradeVersion) >= 0) { continue; } - logLine( false, "" ); - logLine( false, "Require Maven " + mavenUpgradeVersion + " to use the following plugin updates:" ); - for ( Map.Entry entry : upgradePlugins.entrySet() ) - { - logLine( false, entry.getValue() ); + logLine(false, ""); + logLine(false, "Require Maven " + mavenUpgradeVersion + " to use the following plugin updates:"); + for (Map.Entry entry : upgradePlugins.entrySet()) { + logLine(false, entry.getValue()); } } - logLine( false, "" ); + logLine(false, ""); } /** @@ -670,151 +589,126 @@ else if ( minMavenVersion != null && compare( specMavenVersion, minMavenVersion * @throws MojoExecutionException thrown if the artifact for the plugin could not be constructed * @throws ProjectBuildingException thrown if the {@link MavenProject} instance could not be constructed */ - private MavenProject getPluginProject( String groupId, String artifactId, String version ) - throws MojoExecutionException, ProjectBuildingException, ArtifactResolutionException - { - Artifact probe = getHelper().createDependencyArtifact( DependencyBuilder.newBuilder() - .withGroupId( groupId ) - .withArtifactId( artifactId ) - .withVersion( version ) - .withType( "pom" ) - .withScope( Artifact.SCOPE_RUNTIME ) - .build() ); - getHelper().resolveArtifact( probe, true ); - ProjectBuildingResult result = - projectBuilder.build( probe, true, - PomHelper.createProjectBuilderRequest( session, - r -> r.setProcessPlugins( false ), - r -> r.setRemoteRepositories( session.getCurrentProject() - .getPluginArtifactRepositories() ) ) ); - if ( !result.getProblems().isEmpty() ) - { - getLog().warn( "Problems encountered during construction of the plugin POM for " - + probe.toString() ); - result.getProblems().forEach( p -> - getLog().warn( "\t" + p.getMessage() ) ); + private MavenProject getPluginProject(String groupId, String artifactId, String version) + throws MojoExecutionException, ProjectBuildingException, ArtifactResolutionException { + Artifact probe = getHelper() + .createDependencyArtifact(DependencyBuilder.newBuilder() + .withGroupId(groupId) + .withArtifactId(artifactId) + .withVersion(version) + .withType("pom") + .withScope(Artifact.SCOPE_RUNTIME) + .build()); + getHelper().resolveArtifact(probe, true); + ProjectBuildingResult result = projectBuilder.build( + probe, + true, + PomHelper.createProjectBuilderRequest( + session, + r -> r.setProcessPlugins(false), + r -> r.setRemoteRepositories(session.getCurrentProject().getPluginArtifactRepositories()))); + if (!result.getProblems().isEmpty()) { + getLog().warn("Problems encountered during construction of the plugin POM for " + probe.toString()); + result.getProblems().forEach(p -> getLog().warn("\t" + p.getMessage())); } return result.getProject(); } - private static String pad( String start, int len, String... ends ) - { - StringBuilder buf = new StringBuilder( len ); - buf.append( " " ); - buf.append( start ); + private static String pad(String start, int len, String... ends) { + StringBuilder buf = new StringBuilder(len); + buf.append(" "); + buf.append(start); int padding = len; - for ( String end : ends ) - { + for (String end : ends) { padding -= end.length(); } - buf.append( ' ' ); - while ( buf.length() < padding ) - { - buf.append( '.' ); + buf.append(' '); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - for ( String end : ends ) - { - buf.append( end ); + buf.append(' '); + for (String end : ends) { + buf.append(end); } return buf.toString(); } - private Map getParentsPlugins( List parents ) - throws MojoExecutionException - { + private Map getParentsPlugins(List parents) throws MojoExecutionException { Map parentPlugins = new HashMap<>(); - for ( MavenProject parentProject : parents ) - { - getLog().debug( "Processing parent: " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() - + ":" + parentProject.getVersion() + " -> " + parentProject.getFile() ); + for (MavenProject parentProject : parents) { + getLog().debug("Processing parent: " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() + + ":" + parentProject.getVersion() + " -> " + parentProject.getFile()); StringWriter writer = new StringWriter(); boolean havePom = false; Model interpolatedModel; Model originalModel = parentProject.getOriginalModel(); - if ( originalModel == null ) - { - getLog().warn( "project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" + if (originalModel == null) { + getLog().warn("project.getOriginalModel()==null for " + parentProject.getGroupId() + ":" + parentProject.getArtifactId() + ":" + parentProject.getVersion() - + " is null, substituting project.getModel()" ); + + " is null, substituting project.getModel()"); originalModel = parentProject.getModel(); } - try - { - new MavenXpp3Writer().write( writer, originalModel ); + try { + new MavenXpp3Writer().write(writer, originalModel); writer.close(); havePom = true; - } - catch ( IOException e ) - { + } catch (IOException e) { // ignore } ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); - modelBuildingRequest.setUserProperties( getProject().getProperties() ); - interpolatedModel = modelInterpolator.interpolateModel( originalModel, null, - modelBuildingRequest, - new IgnoringModelProblemCollector() ); - if ( havePom ) - { - try - { - Set withVersionSpecified = - findPluginsWithVersionsSpecified( new StringBuilder( writer.toString() ), - getSafeProjectPathInfo( parentProject ) ); - - Map map = getPluginManagement( interpolatedModel ); - map.keySet().retainAll( withVersionSpecified ); - parentPlugins.putAll( map ); - - map = getBuildPlugins( interpolatedModel, true ); - map.keySet().retainAll( withVersionSpecified ); - parentPlugins.putAll( map ); - - map = getReportPlugins( interpolatedModel, true ); - map.keySet().retainAll( withVersionSpecified ); - parentPlugins.putAll( map ); - } - catch ( XMLStreamException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + modelBuildingRequest.setUserProperties(getProject().getProperties()); + interpolatedModel = modelInterpolator.interpolateModel( + originalModel, null, modelBuildingRequest, new IgnoringModelProblemCollector()); + if (havePom) { + try { + Set withVersionSpecified = findPluginsWithVersionsSpecified( + new StringBuilder(writer.toString()), getSafeProjectPathInfo(parentProject)); + + Map map = getPluginManagement(interpolatedModel); + map.keySet().retainAll(withVersionSpecified); + parentPlugins.putAll(map); + + map = getBuildPlugins(interpolatedModel, true); + map.keySet().retainAll(withVersionSpecified); + parentPlugins.putAll(map); + + map = getReportPlugins(interpolatedModel, true); + map.keySet().retainAll(withVersionSpecified); + parentPlugins.putAll(map); + } catch (XMLStreamException e) { + throw new MojoExecutionException(e.getMessage(), e); } - } - else - { - parentPlugins.putAll( getPluginManagement( interpolatedModel ) ); - parentPlugins.putAll( getBuildPlugins( interpolatedModel, true ) ); - parentPlugins.putAll( getReportPlugins( interpolatedModel, true ) ); + } else { + parentPlugins.putAll(getPluginManagement(interpolatedModel)); + parentPlugins.putAll(getBuildPlugins(interpolatedModel, true)); + parentPlugins.putAll(getReportPlugins(interpolatedModel, true)); } } return parentPlugins; } - private String getSafeProjectPathInfo( MavenProject project ) - { - return ofNullable( project.getFile() ) - .map( File::getAbsolutePath ) + private String getSafeProjectPathInfo(MavenProject project) { + return ofNullable(project.getFile()) + .map(File::getAbsolutePath) // path is used only as information in error message, // we can fallback to project artifact info here - .orElse( project.toString() ); + .orElse(project.toString()); } - private boolean isMavenPluginProject() - { - return "maven-plugin".equals( getProject().getPackaging() ); + private boolean isMavenPluginProject() { + return "maven-plugin".equals(getProject().getPackaging()); } - private String compactKey( String groupId, String artifactId ) - { - return PomHelper.APACHE_MAVEN_PLUGINS_GROUPID.equals( groupId ) + private String compactKey(String groupId, String artifactId) { + return PomHelper.APACHE_MAVEN_PLUGINS_GROUPID.equals(groupId) // a core plugin... group id is not needed ? artifactId : groupId + ":" + artifactId; } - private static final class StackState - { + private static final class StackState { private final String path; private String groupId; @@ -823,13 +717,11 @@ private static final class StackState private String version; - StackState( String path ) - { + StackState(String path) { this.path = path; } - public String toString() - { + public String toString() { return path + "[groupId=" + groupId + ", artifactId=" + artifactId + ", version=" + version + "]"; } } @@ -841,61 +733,45 @@ public String toString() * @param path Path that points to the source of the XML * @return a set of Strings which correspond to the plugin coordinates where there is a version specified. */ - private Set findPluginsWithVersionsSpecified( StringBuilder pomContents, String path ) - throws XMLStreamException - { + private Set findPluginsWithVersionsSpecified(StringBuilder pomContents, String path) + throws XMLStreamException { Set result = new HashSet<>(); - ModifiedPomXMLEventReader pom = newModifiedPomXER( pomContents, path ); + ModifiedPomXMLEventReader pom = newModifiedPomXER(pomContents, path); - Pattern pathRegex = Pattern.compile( "/project(/profiles/profile)?" - + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin" ); + Pattern pathRegex = Pattern.compile( + "/project(/profiles/profile)?" + "((/build(/pluginManagement)?)|(/reporting))" + "/plugins/plugin"); Stack pathStack = new Stack<>(); StackState curState = null; - while ( pom.hasNext() ) - { + while (pom.hasNext()) { XMLEvent event = pom.nextEvent(); - if ( event.isStartDocument() ) - { - curState = new StackState( "" ); + if (event.isStartDocument()) { + curState = new StackState(""); pathStack.clear(); - } - else if ( event.isStartElement() ) - { + } else if (event.isStartElement()) { String elementName = event.asStartElement().getName().getLocalPart(); - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) - { - if ( "groupId".equals( elementName ) ) - { + if (curState != null && pathRegex.matcher(curState.path).matches()) { + if ("groupId".equals(elementName)) { curState.groupId = pom.getElementText().trim(); continue; - } - else if ( "artifactId".equals( elementName ) ) - { + } else if ("artifactId".equals(elementName)) { curState.artifactId = pom.getElementText().trim(); continue; - } - else if ( "version".equals( elementName ) ) - { + } else if ("version".equals(elementName)) { curState.version = pom.getElementText().trim(); continue; } } - pathStack.push( curState ); - curState = new StackState( curState.path + "/" + elementName ); - } - else if ( event.isEndElement() ) - { - if ( curState != null && pathRegex.matcher( curState.path ).matches() ) - { - if ( curState.artifactId != null && curState.version != null ) - { - if ( curState.groupId == null ) - { + pathStack.push(curState); + curState = new StackState(curState.path + "/" + elementName); + } else if (event.isEndElement()) { + if (curState != null && pathRegex.matcher(curState.path).matches()) { + if (curState.artifactId != null && curState.version != null) { + if (curState.groupId == null) { curState.groupId = PomHelper.APACHE_MAVEN_PLUGINS_GROUPID; } - result.add( curState.groupId + ":" + curState.artifactId ); + result.add(curState.groupId + ":" + curState.artifactId); } } curState = pathStack.pop(); @@ -903,7 +779,6 @@ else if ( event.isEndElement() ) } return result; - } // -------------------------- OTHER METHODS -------------------------- @@ -916,12 +791,11 @@ else if ( event.isEndElement() ) * @param pluginProject the plugin for which to retrieve the minimum Maven version which is required * @return The minimally required Maven version (never {@code null}) */ - private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject ) - { - return ofNullable( pluginProject.getPrerequisites() ) - .map( Prerequisites::getMaven ) - .map( DefaultArtifactVersion::new ) - .orElse( new DefaultArtifactVersion( DEFAULT_MVN_VERSION ) ); + private ArtifactVersion getPrerequisitesMavenVersion(MavenProject pluginProject) { + return ofNullable(pluginProject.getPrerequisites()) + .map(Prerequisites::getMaven) + .map(DefaultArtifactVersion::new) + .orElse(new DefaultArtifactVersion(DEFAULT_MVN_VERSION)); } /** @@ -932,15 +806,13 @@ private ArtifactVersion getPrerequisitesMavenVersion( MavenProject pluginProject * child projects. * @return map of plugin name x version */ - private Map getPluginsFromBuild( BuildBase build, boolean onlyIncludeInherited ) - { - return ofNullable( build ) - .flatMap( b -> ofNullable( b.getPlugins() ) - .map( plugins -> plugins.stream() - .filter( plugin -> plugin.getVersion() != null ) - .filter( plugin -> !onlyIncludeInherited || getPluginInherited( plugin ) ) - .collect( toMap( Plugin::getKey, Plugin::getVersion ) ) ) ) - .orElse( emptyMap() ); + private Map getPluginsFromBuild(BuildBase build, boolean onlyIncludeInherited) { + return ofNullable(build) + .flatMap(b -> ofNullable(b.getPlugins()).map(plugins -> plugins.stream() + .filter(plugin -> plugin.getVersion() != null) + .filter(plugin -> !onlyIncludeInherited || getPluginInherited(plugin)) + .collect(toMap(Plugin::getKey, Plugin::getVersion)))) + .orElse(emptyMap()); } /** @@ -952,14 +824,11 @@ private Map getPluginsFromBuild( BuildBase build, boolean onlyIn * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ - private Map getBuildPlugins( Model model, boolean onlyIncludeInherited ) - { - Map buildPlugins = - new HashMap<>( getPluginsFromBuild( model.getBuild(), onlyIncludeInherited ) ); - ofNullable( model.getProfiles() ) - .ifPresent( profiles -> profiles.stream() - .map( profile -> getPluginsFromBuild( profile.getBuild(), onlyIncludeInherited ) ) - .forEach( buildPlugins::putAll ) ); + private Map getBuildPlugins(Model model, boolean onlyIncludeInherited) { + Map buildPlugins = new HashMap<>(getPluginsFromBuild(model.getBuild(), onlyIncludeInherited)); + ofNullable(model.getProfiles()).ifPresent(profiles -> profiles.stream() + .map(profile -> getPluginsFromBuild(profile.getBuild(), onlyIncludeInherited)) + .forEach(buildPlugins::putAll)); return buildPlugins; } @@ -970,10 +839,12 @@ private Map getBuildPlugins( Model model, boolean onlyIncludeInh * @return the Inherited of the {@link Plugin} or {@link ReportPlugin} * @since 1.0-alpha-1 */ - private static boolean getPluginInherited( Object plugin ) - { - return "true".equalsIgnoreCase( plugin instanceof ReportPlugin ? ( (ReportPlugin) plugin ).getInherited() - : ( (Plugin) plugin ).getInherited() ); + private static boolean getPluginInherited(Object plugin) { + return "true" + .equalsIgnoreCase( + plugin instanceof ReportPlugin + ? ((ReportPlugin) plugin).getInherited() + : ((Plugin) plugin).getInherited()); } /** @@ -984,16 +855,11 @@ private static boolean getPluginInherited( Object plugin ) * @throws org.apache.maven.plugin.MojoExecutionException if things go wrong. * @since 1.0-alpha-1 */ - private Map getLifecyclePlugins( MavenProject project ) - throws MojoExecutionException - { - return getBoundPlugins( project ) - .parallelStream() - .filter( Objects::nonNull ) - .filter( p -> p.getKey() != null ) - .collect( HashMap::new, - ( m, p ) -> m.put( p.getKey(), p ), - Map::putAll ); + private Map getLifecyclePlugins(MavenProject project) throws MojoExecutionException { + return getBoundPlugins(project).parallelStream() + .filter(Objects::nonNull) + .filter(p -> p.getKey() != null) + .collect(HashMap::new, (m, p) -> m.put(p.getKey(), p), Map::putAll); } /** @@ -1005,18 +871,17 @@ private Map getLifecyclePlugins( MavenProject project ) */ // pilfered this from enforcer-rules // TODO coordinate with Brian Fox to remove the duplicate code - private Set getBoundPlugins( MavenProject project ) - { + private Set getBoundPlugins(MavenProject project) { // we need to provide a copy with the version blanked out so that inferring from super-pom // works as for 2.x as 3.x fills in the version on us! - return lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles( project.getPackaging() ) - .parallelStream() - .map( p -> new Plugin() - {{ - setGroupId( p.getGroupId() ); - setArtifactId( p.getArtifactId() ); - }} ) - .collect( toSet() ); + return lifecycleExecutor.getPluginsBoundByDefaultToAllLifecycles(project.getPackaging()).parallelStream() + .map(p -> new Plugin() { + { + setGroupId(p.getGroupId()); + setArtifactId(p.getArtifactId()); + } + }) + .collect(toSet()); } /** @@ -1027,19 +892,16 @@ private Set getBoundPlugins( MavenProject project ) * @throws org.apache.maven.plugin.MojoExecutionException if the super-pom could not be created. * @since 1.0-alpha-1 */ - private List getParentProjects( MavenProject project ) - throws MojoExecutionException - { + private List getParentProjects(MavenProject project) throws MojoExecutionException { List parents = new ArrayList<>(); - while ( project.getParent() != null ) - { + while (project.getParent() != null) { project = project.getParent(); - parents.add( 0, project ); + parents.add(0, project); } return parents; } - /** + /** * Returns the set of all plugins used by the project. * * @param superPomPluginManagement the super pom's pluginManagement plugins. @@ -1050,177 +912,144 @@ private List getParentProjects( MavenProject project ) * @return the set of plugins used by the project. * @throws org.apache.maven.plugin.MojoExecutionException if things go wrong. */ - @SuppressWarnings( "checkstyle:MethodLength" ) - private Set getProjectPlugins( Map superPomPluginManagement, - Map parentPluginManagement, - Map parentBuildPlugins, - Map parentReportPlugins, - Set pluginsWithVersionsSpecified ) - throws MojoExecutionException - { + @SuppressWarnings("checkstyle:MethodLength") + private Set getProjectPlugins( + Map superPomPluginManagement, + Map parentPluginManagement, + Map parentBuildPlugins, + Map parentReportPlugins, + Set pluginsWithVersionsSpecified) + throws MojoExecutionException { Map plugins = new HashMap<>(); - getLog().debug( "Building list of project plugins..." ); + getLog().debug("Building list of project plugins..."); - if ( getLog().isDebugEnabled() ) - { + if (getLog().isDebugEnabled()) { StringWriter origModel = new StringWriter(); - try - { - origModel.write( "Original model:\n" ); - getProject().writeOriginalModel( origModel ); - getLog().debug( origModel.toString() ); - } - catch ( IOException e ) - { + try { + origModel.write("Original model:\n"); + getProject().writeOriginalModel(origModel); + getLog().debug(origModel.toString()); + } catch (IOException e) { // ignore } } - debugVersionMap( "super-pom version map", superPomPluginManagement ); - debugVersionMap( "parent version map", parentPluginManagement ); + debugVersionMap("super-pom version map", superPomPluginManagement); + debugVersionMap("parent version map", parentPluginManagement); - Map excludePluginManagement = new HashMap<>( superPomPluginManagement ); - excludePluginManagement.putAll( parentPluginManagement ); + Map excludePluginManagement = new HashMap<>(superPomPluginManagement); + excludePluginManagement.putAll(parentPluginManagement); - debugVersionMap( "aggregate version map", excludePluginManagement ); + debugVersionMap("aggregate version map", excludePluginManagement); - excludePluginManagement.keySet().removeAll( pluginsWithVersionsSpecified ); + excludePluginManagement.keySet().removeAll(pluginsWithVersionsSpecified); - debugVersionMap( "final aggregate version map", excludePluginManagement ); + debugVersionMap("final aggregate version map", excludePluginManagement); ModelBuildingRequest modelBuildingRequest = new DefaultModelBuildingRequest(); - modelBuildingRequest.setUserProperties( getProject().getProperties() ); - Model originalModel = - modelInterpolator.interpolateModel( getProject().getOriginalModel(), getProject().getBasedir(), - modelBuildingRequest, new IgnoringModelProblemCollector() ); - - try - { - addProjectPlugins( plugins, originalModel.getBuild().getPluginManagement().getPlugins(), - excludePluginManagement ); - } - catch ( NullPointerException e ) - { + modelBuildingRequest.setUserProperties(getProject().getProperties()); + Model originalModel = modelInterpolator.interpolateModel( + getProject().getOriginalModel(), + getProject().getBasedir(), + modelBuildingRequest, + new IgnoringModelProblemCollector()); + + try { + addProjectPlugins( + plugins, originalModel.getBuild().getPluginManagement().getPlugins(), excludePluginManagement); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding local pluginManagement", plugins ); + debugPluginMap("after adding local pluginManagement", plugins); - try - { - List lifecyclePlugins = new ArrayList<>( getLifecyclePlugins( getProject() ).values() ); - for ( Iterator i = lifecyclePlugins.iterator(); i.hasNext(); ) - { + try { + List lifecyclePlugins = + new ArrayList<>(getLifecyclePlugins(getProject()).values()); + for (Iterator i = lifecyclePlugins.iterator(); i.hasNext(); ) { Plugin lifecyclePlugin = i.next(); - if ( lifecyclePlugin.getVersion() != null ) - { + if (lifecyclePlugin.getVersion() != null) { // version comes from lifecycle, therefore cannot modify i.remove(); - } - else - { + } else { // lifecycle leaves version open - String parentVersion = parentPluginManagement.get( lifecyclePlugin.getKey() ); - if ( parentVersion != null ) - { + String parentVersion = parentPluginManagement.get(lifecyclePlugin.getKey()); + if (parentVersion != null) { // parent controls version i.remove(); } } } - addProjectPlugins( plugins, lifecyclePlugins, parentPluginManagement ); + addProjectPlugins(plugins, lifecyclePlugins, parentPluginManagement); - debugPluginMap( "after adding lifecycle plugins", plugins ); - } - catch ( NullPointerException e ) - { + debugPluginMap("after adding lifecycle plugins", plugins); + } catch (NullPointerException e) { // using maven 3.x or newer } - try - { - List buildPlugins = new ArrayList<>( originalModel.getBuild().getPlugins() ); - for ( Iterator i = buildPlugins.iterator(); i.hasNext(); ) - { + try { + List buildPlugins = new ArrayList<>(originalModel.getBuild().getPlugins()); + for (Iterator i = buildPlugins.iterator(); i.hasNext(); ) { Plugin buildPlugin = i.next(); - if ( buildPlugin.getVersion() == null ) - { - String parentVersion = parentPluginManagement.get( buildPlugin.getKey() ); - if ( parentVersion != null ) - { + if (buildPlugin.getVersion() == null) { + String parentVersion = parentPluginManagement.get(buildPlugin.getKey()); + if (parentVersion != null) { // parent controls version i.remove(); } } } - addProjectPlugins( plugins, buildPlugins, parentBuildPlugins ); - } - catch ( NullPointerException e ) - { + addProjectPlugins(plugins, buildPlugins, parentBuildPlugins); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding build plugins", plugins ); + debugPluginMap("after adding build plugins", plugins); - try - { - List reportPlugins = new ArrayList<>( originalModel.getReporting().getPlugins() ); - for ( Iterator i = reportPlugins.iterator(); i.hasNext(); ) - { + try { + List reportPlugins = + new ArrayList<>(originalModel.getReporting().getPlugins()); + for (Iterator i = reportPlugins.iterator(); i.hasNext(); ) { ReportPlugin reportPlugin = i.next(); - if ( reportPlugin.getVersion() == null ) - { - String parentVersion = parentPluginManagement.get( reportPlugin.getKey() ); - if ( parentVersion != null ) - { + if (reportPlugin.getVersion() == null) { + String parentVersion = parentPluginManagement.get(reportPlugin.getKey()); + if (parentVersion != null) { // parent controls version i.remove(); } } } - addProjectPlugins( plugins, toPlugins( reportPlugins ), parentReportPlugins ); - } - catch ( NullPointerException e ) - { + addProjectPlugins(plugins, toPlugins(reportPlugins), parentReportPlugins); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding reporting plugins", plugins ); - - for ( Profile profile : originalModel.getProfiles() ) - { - try - { - addProjectPlugins( plugins, profile.getBuild().getPluginManagement().getPlugins(), - excludePluginManagement ); - } - catch ( NullPointerException e ) - { + debugPluginMap("after adding reporting plugins", plugins); + + for (Profile profile : originalModel.getProfiles()) { + try { + addProjectPlugins( + plugins, profile.getBuild().getPluginManagement().getPlugins(), excludePluginManagement); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding build pluginManagement for profile " + profile.getId(), plugins ); + debugPluginMap("after adding build pluginManagement for profile " + profile.getId(), plugins); - try - { - addProjectPlugins( plugins, profile.getBuild().getPlugins(), parentBuildPlugins ); - } - catch ( NullPointerException e ) - { + try { + addProjectPlugins(plugins, profile.getBuild().getPlugins(), parentBuildPlugins); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding build plugins for profile " + profile.getId(), plugins ); + debugPluginMap("after adding build plugins for profile " + profile.getId(), plugins); - try - { - addProjectPlugins( plugins, toPlugins( profile.getReporting().getPlugins() ), parentReportPlugins ); - } - catch ( NullPointerException e ) - { + try { + addProjectPlugins(plugins, toPlugins(profile.getReporting().getPlugins()), parentReportPlugins); + } catch (NullPointerException e) { // guess there are no plugins here } - debugPluginMap( "after adding reporting plugins for profile " + profile.getId(), plugins ); + debugPluginMap("after adding reporting plugins for profile " + profile.getId(), plugins); } - Set result = new TreeSet<>( PluginComparator.INSTANCE ); - result.addAll( plugins.values() ); + Set result = new TreeSet<>(PluginComparator.INSTANCE); + result.addAll(plugins.values()); return result; } @@ -1232,34 +1061,27 @@ private Set getProjectPlugins( Map superPomPluginManagem * @param parentDefinitions The parent plugin definitions. * @since 1.0-alpha-1 */ - private void addProjectPlugins( Map plugins, Collection projectPlugins, - Map parentDefinitions ) - { - for ( Plugin plugin : projectPlugins ) - { + private void addProjectPlugins( + Map plugins, Collection projectPlugins, Map parentDefinitions) { + for (Plugin plugin : projectPlugins) { String coord = plugin.getKey(); String version = plugin.getVersion(); - String parentVersion = parentDefinitions.get( coord ); - if ( version == null - && ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null ) - && parentVersion != null ) - { + String parentVersion = parentDefinitions.get(coord); + if (version == null + && (!plugins.containsKey(coord) || plugins.get(coord).getVersion() == null) + && parentVersion != null) { Plugin parentPlugin = new Plugin(); - parentPlugin.setGroupId( plugin.getGroupId() ); - parentPlugin.setArtifactId( plugin.getArtifactId() ); - parentPlugin.setVersion( parentVersion ); - plugins.put( coord, parentPlugin ); - } - else if ( parentVersion == null || !parentVersion.equals( version ) ) - { - if ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null ) - { - plugins.put( coord, plugin ); + parentPlugin.setGroupId(plugin.getGroupId()); + parentPlugin.setArtifactId(plugin.getArtifactId()); + parentPlugin.setVersion(parentVersion); + plugins.put(coord, parentPlugin); + } else if (parentVersion == null || !parentVersion.equals(version)) { + if (!plugins.containsKey(coord) || plugins.get(coord).getVersion() == null) { + plugins.put(coord, plugin); } } - if ( !plugins.containsKey( coord ) ) - { - plugins.put( coord, plugin ); + if (!plugins.containsKey(coord)) { + plugins.put(coord, plugin); } } } @@ -1272,21 +1094,18 @@ else if ( parentVersion == null || !parentVersion.equals( version ) ) * values * being {@link Plugin} or {@link ReportPlugin}. */ - private void debugPluginMap( String description, Map plugins ) - { - if ( getLog().isDebugEnabled() ) - { - Set sorted = new TreeSet<>( PluginComparator.INSTANCE ); - sorted.addAll( plugins.values() ); - StringBuilder buf = new StringBuilder( description ); - for ( Plugin plugin : sorted ) - { - buf.append( "\n " ); - buf.append( plugin.getKey() ); - buf.append( ":" ); - buf.append( plugin.getVersion() ); + private void debugPluginMap(String description, Map plugins) { + if (getLog().isDebugEnabled()) { + Set sorted = new TreeSet<>(PluginComparator.INSTANCE); + sorted.addAll(plugins.values()); + StringBuilder buf = new StringBuilder(description); + for (Plugin plugin : sorted) { + buf.append("\n "); + buf.append(plugin.getKey()); + buf.append(":"); + buf.append(plugin.getVersion()); } - getLog().debug( buf.toString() ); + getLog().debug(buf.toString()); } } @@ -1298,37 +1117,31 @@ private void debugPluginMap( String description, Map plugins ) * values * being {@link String} plugin version. */ - private void debugVersionMap( String description, Map pluginVersions ) - { - if ( getLog().isDebugEnabled() ) - { - StringBuilder buf = new StringBuilder( description ); - for ( Map.Entry pluginVersion : pluginVersions.entrySet() ) - { - buf.append( "\n " ); - buf.append( pluginVersion.getKey() ); - buf.append( ":" ); - buf.append( pluginVersion.getValue() ); + private void debugVersionMap(String description, Map pluginVersions) { + if (getLog().isDebugEnabled()) { + StringBuilder buf = new StringBuilder(description); + for (Map.Entry pluginVersion : pluginVersions.entrySet()) { + buf.append("\n "); + buf.append(pluginVersion.getKey()); + buf.append(":"); + buf.append(pluginVersion.getValue()); } - getLog().debug( buf.toString() ); + getLog().debug(buf.toString()); } } - private static Plugin toPlugin( ReportPlugin reportPlugin ) - { + private static Plugin toPlugin(ReportPlugin reportPlugin) { Plugin plugin = new Plugin(); - plugin.setGroupId( reportPlugin.getGroupId() ); - plugin.setArtifactId( reportPlugin.getArtifactId() ); - plugin.setVersion( reportPlugin.getVersion() ); + plugin.setGroupId(reportPlugin.getGroupId()); + plugin.setArtifactId(reportPlugin.getArtifactId()); + plugin.setVersion(reportPlugin.getVersion()); return plugin; } - private static List toPlugins( List reportPlugins ) - { - List result = new ArrayList<>( reportPlugins.size() ); - for ( ReportPlugin reportPlugin : reportPlugins ) - { - result.add( toPlugin( reportPlugin ) ); + private static List toPlugins(List reportPlugins) { + List result = new ArrayList<>(reportPlugins.size()); + for (ReportPlugin reportPlugin : reportPlugins) { + result.add(toPlugin(reportPlugin)); } return result; } @@ -1342,49 +1155,34 @@ private static List toPlugins( List reportPlugins ) * @return The map of effective plugin versions keyed by coordinates. * @since 1.0-alpha-1 */ - private Map getReportPlugins( Model model, boolean onlyIncludeInherited ) - { + private Map getReportPlugins(Model model, boolean onlyIncludeInherited) { Map reportPlugins = new HashMap<>(); - try - { - for ( ReportPlugin plugin : model.getReporting().getPlugins() ) - { + try { + for (ReportPlugin plugin : model.getReporting().getPlugins()) { String coord = plugin.getKey(); String version = plugin.getVersion(); - if ( version != null && ( !onlyIncludeInherited || getPluginInherited( plugin ) ) ) - { - reportPlugins.put( coord, version ); + if (version != null && (!onlyIncludeInherited || getPluginInherited(plugin))) { + reportPlugins.put(coord, version); } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no plugins here } - try - { - for ( Profile profile : model.getProfiles() ) - { - try - { - for ( ReportPlugin plugin : profile.getReporting().getPlugins() ) - { + try { + for (Profile profile : model.getProfiles()) { + try { + for (ReportPlugin plugin : profile.getReporting().getPlugins()) { String coord = plugin.getKey(); String version = plugin.getVersion(); - if ( version != null && ( !onlyIncludeInherited || getPluginInherited( plugin ) ) ) - { - reportPlugins.put( coord, version ); + if (version != null && (!onlyIncludeInherited || getPluginInherited(plugin))) { + reportPlugins.put(coord, version); } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no plugins here } } - } - catch ( NullPointerException e ) - { + } catch (NullPointerException e) { // guess there are no profiles here } return reportPlugins; @@ -1395,24 +1193,19 @@ private Map getReportPlugins( Model model, boolean onlyIncludeIn * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - { + protected void update(ModifiedPomXMLEventReader pom) { // do nothing } - private static int compare( ArtifactVersion a, ArtifactVersion b ) - { - return a.compareTo( b ); + private static int compare(ArtifactVersion a, ArtifactVersion b) { + return a.compareTo(b); } - private static class IgnoringModelProblemCollector implements ModelProblemCollector - { + private static class IgnoringModelProblemCollector implements ModelProblemCollector { @Override - public void add( ModelProblemCollectorRequest req ) - { + public void add(ModelProblemCollectorRequest req) { // ignore } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java index dcf7be6ff9..ba5a0061e8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojo.java @@ -50,10 +50,8 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "display-property-updates", threadSafe = true ) -public class DisplayPropertyUpdatesMojo - extends AbstractVersionsDisplayMojo -{ +@Mojo(name = "display-property-updates", threadSafe = true) +public class DisplayPropertyUpdatesMojo extends AbstractVersionsDisplayMojo { /** * The width to pad info messages. @@ -77,7 +75,7 @@ public class DisplayPropertyUpdatesMojo * * @since 1.0-alpha-1 */ - @Parameter( property = "includeProperties" ) + @Parameter(property = "includeProperties") private String includeProperties = null; /** @@ -86,7 +84,7 @@ public class DisplayPropertyUpdatesMojo * @parameter property="excludeProperties" * @since 1.0-alpha-1 */ - @Parameter( property = "excludeProperties" ) + @Parameter(property = "excludeProperties") private String excludeProperties = null; /** @@ -94,7 +92,7 @@ public class DisplayPropertyUpdatesMojo * * @since 1.0-alpha-2 */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) + @Parameter(property = "autoLinkItems", defaultValue = "true") private boolean autoLinkItems; /** @@ -102,7 +100,7 @@ public class DisplayPropertyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") private boolean allowMajorUpdates; /** @@ -112,7 +110,7 @@ public class DisplayPropertyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") private boolean allowMinorUpdates; /** @@ -123,7 +121,7 @@ public class DisplayPropertyUpdatesMojo * * @since 2.5 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates; /** @@ -131,7 +129,7 @@ public class DisplayPropertyUpdatesMojo * * @since 2.14.0 */ - @Parameter( property = "includeParent", defaultValue = "false" ) + @Parameter(property = "includeParent", defaultValue = "false") protected boolean includeParent = true; // -------------------------- STATIC METHODS -------------------------- @@ -139,122 +137,109 @@ public class DisplayPropertyUpdatesMojo // -------------------------- OTHER METHODS -------------------------- @Inject - public DisplayPropertyUpdatesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public DisplayPropertyUpdatesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { logInit(); List current = new ArrayList<>(); List updates = new ArrayList<>(); - Map propertyVersions = - this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( properties ) - .withIncludeProperties( includeProperties ) - .withExcludeProperties( excludeProperties ) - .withIncludeParent( includeParent ) - .withAutoLinkItems( autoLinkItems ) - .build() ); - for ( Map.Entry entry : propertyVersions.entrySet() ) - { + Map propertyVersions = this.getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .withPropertyDefinitions(properties) + .withIncludeProperties(includeProperties) + .withExcludeProperties(excludeProperties) + .withIncludeParent(includeParent) + .withAutoLinkItems(autoLinkItems) + .build()); + for (Map.Entry entry : propertyVersions.entrySet()) { Property property = entry.getKey(); PropertyVersions version = entry.getValue(); - final String currentVersion = getProject().getProperties().getProperty( property.getName() ); - if ( currentVersion == null ) - { + final String currentVersion = getProject().getProperties().getProperty(property.getName()); + if (currentVersion == null) { continue; } - Optional unchangedSegment = - SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ); - try - { - ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots, - this.reactorProjects, this.getHelper(), false, unchangedSegment ); - if ( winner != null && !currentVersion.equals( winner.toString() ) ) - { + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); + try { + ArtifactVersion winner = version.getNewestVersion( + currentVersion, + property, + this.allowSnapshots, + this.reactorProjects, + this.getHelper(), + false, + unchangedSegment); + if (winner != null && !currentVersion.equals(winner.toString())) { StringBuilder buf = new StringBuilder(); - buf.append( "${" ); - buf.append( property.getName() ); - buf.append( "} " ); + buf.append("${"); + buf.append(property.getName()); + buf.append("} "); final String newVersion = winner.toString(); - int padding = - INFO_PAD_SIZE - currentVersion.length() - newVersion.length() - 4 - + getOutputLineWidthOffset(); - while ( buf.length() < padding ) - { - buf.append( '.' ); + int padding = INFO_PAD_SIZE + - currentVersion.length() + - newVersion.length() + - 4 + + getOutputLineWidthOffset(); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - buf.append( currentVersion ); - buf.append( " -> " ); - buf.append( newVersion ); - updates.add( buf.toString() ); - } - else - { + buf.append(' '); + buf.append(currentVersion); + buf.append(" -> "); + buf.append(newVersion); + updates.add(buf.toString()); + } else { StringBuilder buf = new StringBuilder(); - buf.append( "${" ); - buf.append( property.getName() ); - buf.append( "} " ); + buf.append("${"); + buf.append(property.getName()); + buf.append("} "); int padding = INFO_PAD_SIZE - currentVersion.length() + getOutputLineWidthOffset(); - while ( buf.length() < padding ) - { - buf.append( '.' ); + while (buf.length() < padding) { + buf.append('.'); } - buf.append( ' ' ); - buf.append( currentVersion ); - current.add( buf.toString() ); + buf.append(' '); + buf.append(currentVersion); + current.add(buf.toString()); } - } - catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), - property.getVersion(), e.getMessage() ) ); + } catch (InvalidSegmentException | InvalidVersionSpecificationException e) { + getLog().warn(String.format( + "Skipping the processing of %s:%s due to: %s", + property.getName(), property.getVersion(), e.getMessage())); } } - logLine( false, "" ); - if ( !current.isEmpty() ) - { - logLine( false, "The following version properties are referencing the newest available version:" ); - for ( String s : new TreeSet<>( current ) ) - { - logLine( false, " " + s ); + logLine(false, ""); + if (!current.isEmpty()) { + logLine(false, "The following version properties are referencing the newest available version:"); + for (String s : new TreeSet<>(current)) { + logLine(false, " " + s); } } - if ( updates.isEmpty() && current.isEmpty() ) - { - logLine( false, "This project does not have any properties associated with versions." ); - } - else if ( updates.isEmpty() ) - { - logLine( false, "All version properties are referencing the newest version available." ); + if (updates.isEmpty() && current.isEmpty()) { + logLine(false, "This project does not have any properties associated with versions."); + } else if (updates.isEmpty()) { + logLine(false, "All version properties are referencing the newest version available."); } - if ( !updates.isEmpty() ) - { - logLine( false, "The following version property updates are available:" ); - for ( String update : new TreeSet<>( updates ) ) - { - logLine( false, " " + update ); + if (!updates.isEmpty()) { + logLine(false, "The following version property updates are available:"); + for (String update : new TreeSet<>(updates)) { + logLine(false, " " + update); } } - logLine( false, "" ); + logLine(false, ""); } @Override - protected void update( ModifiedPomXMLEventReader pom ) - { - } + protected void update(ModifiedPomXMLEventReader pom) {} } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java index 28de4ba3f5..2bdb0f298d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ForceReleasesMojo.java @@ -53,27 +53,25 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "force-releases", threadSafe = true ) -public class ForceReleasesMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "force-releases", threadSafe = true) +public class ForceReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { /** * Whether to fail if a SNAPSHOT could not be replaced * * @since 2.14.0 */ - @Parameter( property = "failIfNotReplaced", defaultValue = "false" ) + @Parameter(property = "failIfNotReplaced", defaultValue = "false") protected boolean failIfNotReplaced; // ------------------------------ METHODS -------------------------- @Inject - public ForceReleasesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public ForceReleasesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -83,91 +81,67 @@ public ForceReleasesMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useReleases( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useReleases( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useReleases( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + private void useReleases( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - Matcher versionMatcher = SNAPSHOT_REGEX.matcher( dep.getVersion() ); - if ( versionMatcher.matches() ) - { - String releaseVersion = versionMatcher.group( 1 ); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { + Matcher versionMatcher = SNAPSHOT_REGEX.matcher(dep.getVersion()); + if (versionMatcher.matches()) { + String releaseVersion = versionMatcher.group(1); + Artifact artifact = this.toArtifact(dep); + if (!isIncluded(artifact)) { continue; } - getLog().debug( "Looking for a release of " + toString( dep ) ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - if ( versions.containsVersion( releaseVersion ) ) - { - updateDependencyVersion( pom, dep, releaseVersion, changeKind ); - } - else - { - ArtifactVersion newestRelease = versions.getNewestVersion( (VersionRange) null, null, - false, true ); - if ( newestRelease == null ) - { - getLog().info( "No release of " + toString( dep ) + " to force." ); - if ( failIfNotReplaced ) - { - throw new MojoExecutionException( "No matching release of " + toString( dep ) - + " found for update." ); + getLog().debug("Looking for a release of " + toString(dep)); + ArtifactVersions versions = getHelper().lookupArtifactVersions(artifact, false); + if (versions.containsVersion(releaseVersion)) { + updateDependencyVersion(pom, dep, releaseVersion, changeKind); + } else { + ArtifactVersion newestRelease = versions.getNewestVersion((VersionRange) null, null, false, true); + if (newestRelease == null) { + getLog().info("No release of " + toString(dep) + " to force."); + if (failIfNotReplaced) { + throw new MojoExecutionException( + "No matching release of " + toString(dep) + " found for update."); } - } - else - { - updateDependencyVersion( pom, dep, newestRelease.toString(), changeKind ); + } else { + updateDependencyVersion(pom, dep, newestRelease.toString(), changeKind); } } } } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java index 9b57fc8914..4cb287f3ab 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/LockSnapshotsMojo.java @@ -52,27 +52,25 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "lock-snapshots", threadSafe = true ) -public class LockSnapshotsMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "lock-snapshots", threadSafe = true) +public class LockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { // ------------------------------ FIELDS ------------------------------ /** * Pattern to match a timestamped snapshot version. For example 1.0-20090128.202731-1 */ - private static final Pattern TIMESTAMPED_SNAPSHOT_REGEX = Pattern.compile( "-" + Artifact.SNAPSHOT_VERSION ); + private static final Pattern TIMESTAMPED_SNAPSHOT_REGEX = Pattern.compile("-" + Artifact.SNAPSHOT_VERSION); // ------------------------------ METHODS -------------------------- @Inject - public LockSnapshotsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public LockSnapshotsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -82,102 +80,84 @@ public LockSnapshotsMojo( RepositorySystem repositorySystem, * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - lockSnapshots( pom, dependencyManagement.getDependencies() ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + lockSnapshots(pom, dependencyManagement.getDependencies()); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - lockSnapshots( pom, getProject().getDependencies() ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + lockSnapshots(pom, getProject().getDependencies()); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - lockParentSnapshot( pom, getProject().getParent() ); + if (getProject().getParent() != null && isProcessingParent()) { + lockParentSnapshot(pom, getProject().getParent()); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void lockSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException - { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + private void lockSnapshots(ModifiedPomXMLEventReader pom, Collection dependencies) + throws XMLStreamException, MojoExecutionException { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - if ( !isIncluded( this.toArtifact( dep ) ) ) - { + if (!isIncluded(this.toArtifact(dep))) { continue; } String version = dep.getVersion(); - Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( version ); - if ( versionMatcher.find() && versionMatcher.end() == version.length() ) - { - String lockedVersion = resolveSnapshotVersion( dep ); - if ( !version.equals( lockedVersion ) ) - { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), version, - lockedVersion, getProject().getModel() ) ) - { - getLog().info( "Locked " + toString( dep ) + " to version " + lockedVersion ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher(version); + if (versionMatcher.find() && versionMatcher.end() == version.length()) { + String lockedVersion = resolveSnapshotVersion(dep); + if (!version.equals(lockedVersion)) { + if (PomHelper.setDependencyVersion( + pom, + dep.getGroupId(), + dep.getArtifactId(), + version, + lockedVersion, + getProject().getModel())) { + getLog().info("Locked " + toString(dep) + " to version " + lockedVersion); } } } } } - private void lockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, MojoExecutionException - { - if ( parent == null ) - { - getLog().info( "Project does not have a parent" ); + private void lockParentSnapshot(ModifiedPomXMLEventReader pom, MavenProject parent) + throws XMLStreamException, MojoExecutionException { + if (parent == null) { + getLog().info("Project does not have a parent"); return; } - if ( reactorProjects.contains( parent ) ) - { - getLog().info( "Project's parent is part of the reactor" ); + if (reactorProjects.contains(parent)) { + getLog().info("Project's parent is part of the reactor"); return; } Artifact parentArtifact = parent.getArtifact(); String parentVersion = parentArtifact.getVersion(); - Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( parentVersion ); - if ( versionMatcher.find() && versionMatcher.end() == parentVersion.length() ) - { - String lockedParentVersion = resolveSnapshotVersion( parentArtifact ); - if ( !parentVersion.equals( lockedParentVersion ) ) - { - if ( PomHelper.setProjectParentVersion( pom, lockedParentVersion ) ) - { - getLog().info( "Locked parent " + parentArtifact + " to version " - + lockedParentVersion ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher(parentVersion); + if (versionMatcher.find() && versionMatcher.end() == parentVersion.length()) { + String lockedParentVersion = resolveSnapshotVersion(parentArtifact); + if (!parentVersion.equals(lockedParentVersion)) { + if (PomHelper.setProjectParentVersion(pom, lockedParentVersion)) { + getLog().info("Locked parent " + parentArtifact + " to version " + lockedParentVersion); } } } @@ -189,23 +169,22 @@ private void lockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject par * @param artifact * @return The timestamp version if exists, otherwise the original snapshot artifact version is returned. */ - private String resolveSnapshotVersion( Artifact artifact ) - { - getLog().debug( "Resolving snapshot version for artifact: " + artifact ); + private String resolveSnapshotVersion(Artifact artifact) { + getLog().debug("Resolving snapshot version for artifact: " + artifact); String lockedVersion = artifact.getVersion(); - try - { - aetherRepositorySystem.resolveArtifact( session.getRepositorySession(), - new ArtifactRequest( RepositoryUtils.toArtifact( artifact ), - getProject().getRemoteProjectRepositories(), getClass().getName() ) ); + try { + aetherRepositorySystem.resolveArtifact( + session.getRepositorySession(), + new ArtifactRequest( + RepositoryUtils.toArtifact(artifact), + getProject().getRemoteProjectRepositories(), + getClass().getName())); lockedVersion = artifact.getVersion(); - } - catch ( Exception e ) - { - getLog().error( e ); + } catch (Exception e) { + getLog().error(e); } return lockedVersion; } @@ -216,27 +195,24 @@ private String resolveSnapshotVersion( Artifact artifact ) * @param dep * @return The timestamp version if exists, otherwise the original snapshot dependency version is returned. */ - private String resolveSnapshotVersion( Dependency dep ) - { - getLog().debug( "Resolving snapshot version for dependency: " + dep ); + private String resolveSnapshotVersion(Dependency dep) { + getLog().debug("Resolving snapshot version for dependency: " + dep); String lockedVersion = dep.getVersion(); - try - { - Artifact depArtifact = getHelper().createDependencyArtifact( dep ); - aetherRepositorySystem.resolveArtifact( session.getRepositorySession(), - new ArtifactRequest( RepositoryUtils.toArtifact( depArtifact ), + try { + Artifact depArtifact = getHelper().createDependencyArtifact(dep); + aetherRepositorySystem.resolveArtifact( + session.getRepositorySession(), + new ArtifactRequest( + RepositoryUtils.toArtifact(depArtifact), getProject().getRemoteProjectRepositories(), - getClass().getName() ) ); + getClass().getName())); lockedVersion = depArtifact.getVersion(); - } - catch ( Exception e ) - { - getLog().error( e ); + } catch (Exception e) { + getLog().error(e); } return lockedVersion; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java index 4f606ab0a7..818ad30d71 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinder.java @@ -18,129 +18,106 @@ * * @see Require Maven Version Rule */ -class MinimalMavenBuildVersionFinder -{ +class MinimalMavenBuildVersionFinder { - private MinimalMavenBuildVersionFinder() - { + private MinimalMavenBuildVersionFinder() { // not supposed to be created, static methods only } - static ArtifactVersion find( MavenProject mavenProject, String defaultVersion, Log log ) - { - ArtifactVersion version = getEnforcerMavenVersion( mavenProject, log ); - if ( version == null && defaultVersion != null ) - { - version = new DefaultArtifactVersion( defaultVersion ); + static ArtifactVersion find(MavenProject mavenProject, String defaultVersion, Log log) { + ArtifactVersion version = getEnforcerMavenVersion(mavenProject, log); + if (version == null && defaultVersion != null) { + version = new DefaultArtifactVersion(defaultVersion); } return version; } - private static ArtifactVersion getEnforcerMavenVersion( MavenProject mavenProject, Log log ) - { + private static ArtifactVersion getEnforcerMavenVersion(MavenProject mavenProject, Log log) { List buildPlugins = mavenProject.getBuildPlugins(); - if ( null == buildPlugins ) - { - log.debug( "MinimalMavenBuildVersionFinder: No build plugins found" ); + if (null == buildPlugins) { + log.debug("MinimalMavenBuildVersionFinder: No build plugins found"); return null; } - Plugin mavenEnforcerPlugin = getMavenEnforcerPlugin( buildPlugins ); - if ( null == mavenEnforcerPlugin ) - { - log.debug( "MinimalMavenBuildVersionFinder: No maven-enforcer-plugin used" ); + Plugin mavenEnforcerPlugin = getMavenEnforcerPlugin(buildPlugins); + if (null == mavenEnforcerPlugin) { + log.debug("MinimalMavenBuildVersionFinder: No maven-enforcer-plugin used"); return null; } List pluginExecutions = mavenEnforcerPlugin.getExecutions(); - if ( null == pluginExecutions ) - { - log.debug( "MinimalMavenBuildVersionFinder: No executions of maven-enforcer-plugin found" ); + if (null == pluginExecutions) { + log.debug("MinimalMavenBuildVersionFinder: No executions of maven-enforcer-plugin found"); return null; } - List pluginExecutionsWithEnforceGoal = getPluginExecutionsWithEnforceGoal( pluginExecutions ); - if ( pluginExecutionsWithEnforceGoal.isEmpty() ) - { - log.debug( "MinimalMavenBuildVersionFinder: No 'enforce' execution of maven-enforcer-plugin found" ); + List pluginExecutionsWithEnforceGoal = getPluginExecutionsWithEnforceGoal(pluginExecutions); + if (pluginExecutionsWithEnforceGoal.isEmpty()) { + log.debug("MinimalMavenBuildVersionFinder: No 'enforce' execution of maven-enforcer-plugin found"); return null; } - Xpp3Dom requireMavenVersionTag = getRequireMavenVersionTag( pluginExecutionsWithEnforceGoal ); - if ( null == requireMavenVersionTag ) - { - log.debug( "MinimalMavenBuildVersionFinder: " - + "No 'requireMavenVersion' rule of maven-enforcer-plugin found" ); + Xpp3Dom requireMavenVersionTag = getRequireMavenVersionTag(pluginExecutionsWithEnforceGoal); + if (null == requireMavenVersionTag) { + log.debug("MinimalMavenBuildVersionFinder: " + + "No 'requireMavenVersion' rule of maven-enforcer-plugin found"); return null; } - Xpp3Dom versionTag = requireMavenVersionTag.getChild( "version" ); - if ( null == versionTag ) - { - log.debug( "MinimalMavenBuildVersionFinder: " - + "No version specified in 'requireMavenVersion' rule of maven-enforcer-plugin" ); + Xpp3Dom versionTag = requireMavenVersionTag.getChild("version"); + if (null == versionTag) { + log.debug("MinimalMavenBuildVersionFinder: " + + "No version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); return null; } String versionTagValue = versionTag.getValue(); - if ( null == versionTagValue || "".equals( versionTagValue ) ) - { - log.debug( "MinimalMavenBuildVersionFinder: " - + "Empty version specified in 'requireMavenVersion' rule of maven-enforcer-plugin" ); + if (null == versionTagValue || "".equals(versionTagValue)) { + log.debug("MinimalMavenBuildVersionFinder: " + + "Empty version specified in 'requireMavenVersion' rule of maven-enforcer-plugin"); return null; } - ArtifactVersion minimumVersion = getMinimumVersionFromRange( versionTagValue ); - log.debug( "Calculated minimum version " + minimumVersion + " from version parameter value '" + versionTagValue - + "'" ); + ArtifactVersion minimumVersion = getMinimumVersionFromRange(versionTagValue); + log.debug("Calculated minimum version " + minimumVersion + " from version parameter value '" + versionTagValue + + "'"); return minimumVersion; } - private static Plugin getMavenEnforcerPlugin( List buildPlugins ) - { - for ( Plugin plugin : buildPlugins ) - { - if ( "maven-enforcer-plugin".equals( plugin.getArtifactId() ) && "org.apache.maven.plugins".equals( - plugin.getGroupId() ) ) - { + private static Plugin getMavenEnforcerPlugin(List buildPlugins) { + for (Plugin plugin : buildPlugins) { + if ("maven-enforcer-plugin".equals(plugin.getArtifactId()) + && "org.apache.maven.plugins".equals(plugin.getGroupId())) { return plugin; } } return null; } - private static List getPluginExecutionsWithEnforceGoal( List executions ) - { + private static List getPluginExecutionsWithEnforceGoal(List executions) { List pluginExecutions = new ArrayList<>(); - for ( PluginExecution pluginExecution : executions ) - { + for (PluginExecution pluginExecution : executions) { List goals = pluginExecution.getGoals(); - if ( goals != null && goals.contains( "enforce" ) ) - { - pluginExecutions.add( pluginExecution ); + if (goals != null && goals.contains("enforce")) { + pluginExecutions.add(pluginExecution); } } return pluginExecutions; } - private static Xpp3Dom getRequireMavenVersionTag( List executions ) - { - for ( PluginExecution pluginExecution : executions ) - { + private static Xpp3Dom getRequireMavenVersionTag(List executions) { + for (PluginExecution pluginExecution : executions) { Xpp3Dom configurationTag = (Xpp3Dom) pluginExecution.getConfiguration(); - if ( null == configurationTag ) - { + if (null == configurationTag) { continue; } - Xpp3Dom rulesTag = configurationTag.getChild( "rules" ); - if ( null == rulesTag ) - { + Xpp3Dom rulesTag = configurationTag.getChild("rules"); + if (null == rulesTag) { continue; } - Xpp3Dom requireMavenVersionTag = rulesTag.getChild( "requireMavenVersion" ); - if ( null == requireMavenVersionTag ) - { + Xpp3Dom requireMavenVersionTag = rulesTag.getChild("requireMavenVersion"); + if (null == requireMavenVersionTag) { continue; } @@ -153,100 +130,81 @@ private static Xpp3Dom getRequireMavenVersionTag( List executio * The below method implements the specification found at * https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html */ - static ArtifactVersion getMinimumVersionFromRange( String versionRange ) - { + static ArtifactVersion getMinimumVersionFromRange(String versionRange) { int openIndicesCount = 0; int closeIndicesCount = 0; - for ( int i = 0; i < versionRange.length(); i++ ) - { - char character = versionRange.charAt( i ); + for (int i = 0; i < versionRange.length(); i++) { + char character = versionRange.charAt(i); - if ( '(' == character || '[' == character ) - { + if ('(' == character || '[' == character) { openIndicesCount++; - } - else if ( ')' == character || ']' == character ) - { + } else if (')' == character || ']' == character) { closeIndicesCount++; } } - if ( openIndicesCount != closeIndicesCount ) - { + if (openIndicesCount != closeIndicesCount) { return null; } - if ( openIndicesCount == 0 ) - { - return new DefaultArtifactVersion( versionRange ); + if (openIndicesCount == 0) { + return new DefaultArtifactVersion(versionRange); } - if ( !( ( versionRange.charAt( 0 ) == '[' || versionRange.charAt( 0 ) == '(' ) && ( - versionRange.charAt( versionRange.length() - 1 ) == ']' - || versionRange.charAt( versionRange.length() - 1 ) == ')' ) ) ) - { + if (!((versionRange.charAt(0) == '[' || versionRange.charAt(0) == '(') + && (versionRange.charAt(versionRange.length() - 1) == ']' + || versionRange.charAt(versionRange.length() - 1) == ')'))) { return null; } - if ( openIndicesCount != 1 ) - { + if (openIndicesCount != 1) { return null; } - String innerString = versionRange.substring( 1, versionRange.length() - 1 ); + String innerString = versionRange.substring(1, versionRange.length() - 1); - int commaIndex = innerString.indexOf( ',' ); + int commaIndex = innerString.indexOf(','); - if ( commaIndex == -1 ) - { - if ( versionRange.charAt( 0 ) == '[' && versionRange.charAt( versionRange.length() - 1 ) == ']' ) - { - return new DefaultArtifactVersion( innerString ); - } - else - { + if (commaIndex == -1) { + if (versionRange.charAt(0) == '[' && versionRange.charAt(versionRange.length() - 1) == ']') { + return new DefaultArtifactVersion(innerString); + } else { return null; } } - if ( commaIndex == 0 ) - { + if (commaIndex == 0) { return null; } - if ( commaIndex == innerString.length() - 1 ) - { - String minimumVersion = innerString.substring( 0, innerString.length() - 1 ); + if (commaIndex == innerString.length() - 1) { + String minimumVersion = innerString.substring(0, innerString.length() - 1); - if ( versionRange.charAt( 0 ) == '[' && versionRange.charAt( versionRange.length() - 1 ) == ')' ) - { - return new DefaultArtifactVersion( minimumVersion ); + if (versionRange.charAt(0) == '[' && versionRange.charAt(versionRange.length() - 1) == ')') { + return new DefaultArtifactVersion(minimumVersion); } - if ( versionRange.charAt( 0 ) == '(' && versionRange.charAt( versionRange.length() - 1 ) == ')' ) - { + if (versionRange.charAt(0) == '(' && versionRange.charAt(versionRange.length() - 1) == ')') { // this is actually wrong - the Maven version should be higher than this, // the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this - return new DefaultArtifactVersion( minimumVersion ); + return new DefaultArtifactVersion(minimumVersion); } return null; } - String minimumVersion = innerString.substring( 0, commaIndex ); + String minimumVersion = innerString.substring(0, commaIndex); - if ( versionRange.charAt( 0 ) == '[' ) - { - return new DefaultArtifactVersion( minimumVersion ); + if (versionRange.charAt(0) == '[') { + return new DefaultArtifactVersion(minimumVersion); } - if ( versionRange.charAt( 0 ) == '(' ) - { + if (versionRange.charAt(0) == '(') { // this is actually wrong - the Maven version should be higher than this, // the Maven version cannot be equal to this, but the Maven Enforcer plugin should capture this - return new DefaultArtifactVersion( minimumVersion ); + return new DefaultArtifactVersion(minimumVersion); } return null; diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index 61097221ee..fcef804c21 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -46,45 +46,39 @@ * @author Andrzej Jarmoniuk * @since 2.13.0 */ -@Mojo( name = "parent-updates-report", - requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true ) -public class ParentUpdatesReportMojo extends AbstractVersionsReport -{ - @Parameter( defaultValue = "${reactorProjects}", required = true, readonly = true ) +@Mojo(name = "parent-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) +public class ParentUpdatesReportMojo extends AbstractVersionsReport { + @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) protected List reactorProjects; @Inject - protected ParentUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected ParentUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} */ - public boolean isExternalReport() - { + public boolean isExternalReport() { return false; } /** * {@inheritDoc} */ - public boolean canGenerateReport() - { - if ( getProject().getParent() == null ) - { - getLog().warn( "Project does not have a parent." ); + public boolean canGenerateReport() { + if (getProject().getParent() == null) { + getLog().warn("Project does not have a parent."); return false; } - if ( reactorProjects.contains( getProject().getParent() ) ) - { - getLog().warn( "Parent project is part of the reactor." ); + if (reactorProjects.contains(getProject().getParent())) { + getLog().warn("Parent project is part of the reactor."); return false; } @@ -97,36 +91,44 @@ public boolean canGenerateReport() * @param locale the locale to generate the report for. * @param sink the report formatting tool */ - @SuppressWarnings( "deprecation" ) - protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportException - { - try - { - ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( project.getParentArtifact(), - false ); - artifactVersions.setIncludeSnapshots( allowSnapshots ); - rendererFactory.createReportRenderer( getOutputName(), sink, locale, - new ParentUpdatesModel( DependencyBuilder.newBuilder() - .withGroupId( artifactVersions.getGroupId() ) - .withArtifactId( artifactVersions.getArtifactId() ) - .withVersion( artifactVersions.getArtifact().getVersion() ) - .withScope( artifactVersions.getArtifact().getScope() ) - .withType( artifactVersions.getArtifact().getType() ) - .withClassifier( artifactVersions.getArtifact().getClassifier() ) - .build(), artifactVersions ) ) + @SuppressWarnings("deprecation") + protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { + try { + ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions(project.getParentArtifact(), false); + artifactVersions.setIncludeSnapshots(allowSnapshots); + rendererFactory + .createReportRenderer( + getOutputName(), + sink, + locale, + new ParentUpdatesModel( + DependencyBuilder.newBuilder() + .withGroupId(artifactVersions.getGroupId()) + .withArtifactId(artifactVersions.getArtifactId()) + .withVersion(artifactVersions + .getArtifact() + .getVersion()) + .withScope(artifactVersions + .getArtifact() + .getScope()) + .withType(artifactVersions + .getArtifact() + .getType()) + .withClassifier(artifactVersions + .getArtifact() + .getClassifier()) + .build(), + artifactVersions)) .render(); - } - catch ( VersionRetrievalException e ) - { - throw new MavenReportException( e.getMessage(), e ); + } catch (VersionRetrievalException e) { + throw new MavenReportException(e.getMessage(), e); } } /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "parent-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java index f9305383b5..f11468c4b8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java @@ -17,10 +17,11 @@ * */ +import javax.inject.Inject; import java.util.Map; import java.util.Set; -import javax.inject.Inject; + import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -36,28 +37,29 @@ * * @since 2.14.0 */ -@Mojo( name = "plugin-updates-aggregate-report", requiresDependencyResolution = ResolutionScope.RUNTIME, - threadSafe = true, aggregator = true ) -public class PluginUpdatesAggregateReportMojo extends AbstractPluginUpdatesReportMojo -{ +@Mojo( + name = "plugin-updates-aggregate-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true, + aggregator = true) +public class PluginUpdatesAggregateReportMojo extends AbstractPluginUpdatesReportMojo { @Inject - protected PluginUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected PluginUpdatesAggregateReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } @Override - protected void populatePluginManagement( Set pluginManagementCollector ) - { - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - if ( haveBuildPluginManagementPlugins( project ) ) - { - pluginManagementCollector.addAll( project.getBuild().getPluginManagement().getPlugins() ); + protected void populatePluginManagement(Set pluginManagementCollector) { + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + if (haveBuildPluginManagementPlugins(project)) { + pluginManagementCollector.addAll( + project.getBuild().getPluginManagement().getPlugins()); } } } @@ -66,13 +68,10 @@ protected void populatePluginManagement( Set pluginManagementCollector ) * {@inheritDoc} * */ @Override - protected void populatePlugins( Set pluginsCollector ) - { - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - if ( haveBuildPluginManagementPlugins( project ) ) - { - pluginsCollector.addAll( project.getBuild().getPlugins() ); + protected void populatePlugins(Set pluginsCollector) { + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + if (haveBuildPluginManagementPlugins(project)) { + pluginsCollector.addAll(project.getBuild().getPlugins()); } } } @@ -80,9 +79,7 @@ protected void populatePlugins( Set pluginsCollector ) /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "plugin-updates-aggregate-report"; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 8eec073c5b..f1cf564aa0 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -19,9 +19,11 @@ * under the License. */ +import javax.inject.Inject; + import java.util.Map; import java.util.Set; -import javax.inject.Inject; + import org.apache.maven.model.Plugin; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -36,30 +38,27 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "plugin-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, - threadSafe = true ) -public class PluginUpdatesReportMojo extends AbstractPluginUpdatesReportMojo -{ +@Mojo(name = "plugin-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) +public class PluginUpdatesReportMojo extends AbstractPluginUpdatesReportMojo { @Inject - protected PluginUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected PluginUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} * */ @Override - protected void populatePluginManagement( Set pluginManagementCollector ) - { - if ( haveBuildPluginManagementPlugins( getProject() ) ) - { - pluginManagementCollector.addAll( getProject().getBuild().getPluginManagement().getPlugins() ); + protected void populatePluginManagement(Set pluginManagementCollector) { + if (haveBuildPluginManagementPlugins(getProject())) { + pluginManagementCollector.addAll( + getProject().getBuild().getPluginManagement().getPlugins()); } } @@ -67,19 +66,16 @@ protected void populatePluginManagement( Set pluginManagementCollector ) * {@inheritDoc} * */ @Override - protected void populatePlugins( Set pluginsCollector ) - { - if ( haveBuildPlugins( getProject() ) ) - { - pluginsCollector.addAll( getProject().getBuild().getPlugins() ); + protected void populatePlugins(Set pluginsCollector) { + if (haveBuildPlugins(getProject())) { + pluginsCollector.addAll(getProject().getBuild().getPlugins()); } } /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "plugin-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java index fdb022f74e..7230ecf9bc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java @@ -17,9 +17,10 @@ * */ +import javax.inject.Inject; import java.util.Map; -import javax.inject.Inject; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -40,31 +41,32 @@ * * @since 2.14.0 */ -@Mojo( name = "property-updates-aggregate-report", requiresDependencyResolution = ResolutionScope.RUNTIME, - threadSafe = true, aggregator = true ) -public class PropertyUpdatesAggregateReportMojo extends AbstractPropertyUpdatesReportMojo -{ +@Mojo( + name = "property-updates-aggregate-report", + requiresDependencyResolution = ResolutionScope.RUNTIME, + threadSafe = true, + aggregator = true) +public class PropertyUpdatesAggregateReportMojo extends AbstractPropertyUpdatesReportMojo { @Inject - protected PropertyUpdatesAggregateReportMojo( I18N i18n, RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected PropertyUpdatesAggregateReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} * */ @Override - protected void populateUpdateSet( Map propertyCollector ) - throws MojoExecutionException, MavenReportException - { + protected void populateUpdateSet(Map propertyCollector) + throws MojoExecutionException, MavenReportException { VersionsHelper helper = getHelper(); - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - propertyCollector.putAll( helper.getVersionPropertiesMap( getRequest( project ) ) ); + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + propertyCollector.putAll(helper.getVersionPropertiesMap(getRequest(project))); } } @@ -72,12 +74,9 @@ protected void populateUpdateSet( Map propertyCollec * {@inheritDoc} * */ @Override - protected boolean haveBuildProperties() - { - for ( MavenProject project : AggregateReportUtils.getProjectsToProcess( getProject() ) ) - { - if ( project.getProperties() != null && !project.getProperties().isEmpty() ) - { + protected boolean haveBuildProperties() { + for (MavenProject project : AggregateReportUtils.getProjectsToProcess(getProject())) { + if (project.getProperties() != null && !project.getProperties().isEmpty()) { return true; } } @@ -88,8 +87,7 @@ protected boolean haveBuildProperties() /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "property-updates-aggregate-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 8b6abe85be..715616d4fe 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -19,8 +19,10 @@ * under the License. */ -import java.util.Map; import javax.inject.Inject; + +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; @@ -39,35 +41,31 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "property-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, - threadSafe = true ) -public class PropertyUpdatesReportMojo extends AbstractPropertyUpdatesReportMojo -{ +@Mojo(name = "property-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) +public class PropertyUpdatesReportMojo extends AbstractPropertyUpdatesReportMojo { @Inject - protected PropertyUpdatesReportMojo( I18N i18n, - RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - ReportRendererFactory rendererFactory ) - { - super( i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory ); + protected PropertyUpdatesReportMojo( + I18N i18n, + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + ReportRendererFactory rendererFactory) { + super(i18n, repositorySystem, aetherRepositorySystem, wagonMap, rendererFactory); } /** * {@inheritDoc} */ @Override - protected void populateUpdateSet( Map propertyCollector ) - throws MojoExecutionException, MavenReportException - { - propertyCollector.putAll( getHelper().getVersionPropertiesMap( getRequest( getProject() ) ) ); + protected void populateUpdateSet(Map propertyCollector) + throws MojoExecutionException, MavenReportException { + propertyCollector.putAll(getHelper().getVersionPropertiesMap(getRequest(getProject()))); } /** * {@inheritDoc} */ - public String getOutputName() - { + public String getOutputName() { return "property-updates-report"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java index f6278cdc66..04b043f376 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java @@ -57,16 +57,14 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "resolve-ranges", threadSafe = true ) -public class ResolveRangesMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "resolve-ranges", threadSafe = true) +public class ResolveRangesMojo extends AbstractVersionsDependencyUpdaterMojo { /** * Whether to process the properties section of the project. * * @since 1.3 */ - @Parameter( property = "processProperties", defaultValue = "true" ) + @Parameter(property = "processProperties", defaultValue = "true") private boolean processProperties; /** @@ -75,7 +73,7 @@ public class ResolveRangesMojo * @parameter property="includeProperties" * @since 1.3 */ - @Parameter( property = "includeProperties" ) + @Parameter(property = "includeProperties") private String includeProperties = null; /** @@ -83,7 +81,7 @@ public class ResolveRangesMojo * * @since 1.3 */ - @Parameter( property = "excludeProperties" ) + @Parameter(property = "excludeProperties") private String excludeProperties = null; /** @@ -91,7 +89,7 @@ public class ResolveRangesMojo * * @since 2.5 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") private boolean allowMajorUpdates; /** @@ -101,7 +99,7 @@ public class ResolveRangesMojo * * @since 2.5 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") private boolean allowMinorUpdates; /** @@ -112,7 +110,7 @@ public class ResolveRangesMojo * * @since 2.5 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates; // ------------------------------ FIELDS ------------------------------ @@ -120,17 +118,17 @@ public class ResolveRangesMojo /** * Pattern to match a version range. For example 1.0-20090128.202731-1 */ - private final Pattern matchRangeRegex = Pattern.compile( "," ); + private final Pattern matchRangeRegex = Pattern.compile(","); // ------------------------------ METHODS -------------------------- @Inject - public ResolveRangesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public ResolveRangesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -140,157 +138,128 @@ public ResolveRangesMojo( RepositorySystem repositorySystem, * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { // Note we have to get the dependencies from the model because the dependencies in the // project may have already had their range resolved [MNG-4138] - if ( hasDependencyManagement() && hasDependenciesInDependencyManagement() - && isProcessingDependencyManagement() ) - { - getLog().debug( "processing dependencyManagement of " + getProject().getId() ); - resolveRanges( pom, getProject().getModel().getDependencyManagement().getDependencies() ); + if (hasDependencyManagement() + && hasDependenciesInDependencyManagement() + && isProcessingDependencyManagement()) { + getLog().debug("processing dependencyManagement of " + getProject().getId()); + resolveRanges(pom, getProject().getModel().getDependencyManagement().getDependencies()); } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - getLog().debug( "processing dependencies of " + getProject().getId() ); - resolveRanges( pom, getProject().getModel().getDependencies() ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + getLog().debug("processing dependencies of " + getProject().getId()); + resolveRanges(pom, getProject().getModel().getDependencies()); } - if ( hasParent() && isProcessingParent() ) - { - getLog().debug( "processing parent " + getProject().getId() ); - resolveRangesInParent( pom ); + if (hasParent() && isProcessingParent()) { + getLog().debug("processing parent " + getProject().getId()); + resolveRangesInParent(pom); } - if ( processProperties ) - { - getLog().debug( "processing properties of " + getProject().getId() ); - resolvePropertyRanges( pom ); + if (processProperties) { + getLog().debug("processing properties of " + getProject().getId()); + resolvePropertyRanges(pom); } } - private boolean hasParent() - { + private boolean hasParent() { return getProject().getModel().getParent() != null; } - private boolean hasDependenciesInDependencyManagement() - { + private boolean hasDependenciesInDependencyManagement() { return getProject().getModel().getDependencyManagement().getDependencies() != null; } - private boolean hasDependencyManagement() - { + private boolean hasDependencyManagement() { return getProject().getModel().getDependencyManagement() != null; } - private void resolveRangesInParent( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, VersionRetrievalException, XMLStreamException - { - Matcher versionMatcher = matchRangeRegex.matcher( getProject().getModel().getParent().getVersion() ); + private void resolveRangesInParent(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, VersionRetrievalException, XMLStreamException { + Matcher versionMatcher = + matchRangeRegex.matcher(getProject().getModel().getParent().getVersion()); - if ( versionMatcher.find() ) - { - Artifact artifact = this.toArtifact( getProject().getModel().getParent() ); + if (versionMatcher.find()) { + Artifact artifact = this.toArtifact(getProject().getModel().getParent()); - if ( artifact != null && isIncluded( artifact ) ) - { - getLog().debug( "Resolving version range for parent: " + artifact ); + if (artifact != null && isIncluded(artifact)) { + getLog().debug("Resolving version range for parent: " + artifact); String artifactVersion = artifact.getVersion(); - if ( artifactVersion == null ) - { + if (artifactVersion == null) { ArtifactVersion latestVersion = - findLatestVersion( artifact, artifact.getVersionRange(), allowSnapshots, false ); + findLatestVersion(artifact, artifact.getVersionRange(), allowSnapshots, false); - if ( latestVersion != null ) - { + if (latestVersion != null) { artifactVersion = latestVersion.toString(); - } - else - { - getLog().warn( "Not updating version " + artifact + " : could not resolve any versions" ); + } else { + getLog().warn("Not updating version " + artifact + " : could not resolve any versions"); } } - if ( artifactVersion != null ) - { - if ( PomHelper.setProjectParentVersion( pom, artifactVersion ) ) - { - getLog().debug( "Version set to " + artifactVersion + " for parent: " + artifact ); - } - else - { - getLog().warn( "Could not find the version tag for parent " + artifact + " in project " - + getProject().getId() + " so unable to set version to " + artifactVersion ); + if (artifactVersion != null) { + if (PomHelper.setProjectParentVersion(pom, artifactVersion)) { + getLog().debug("Version set to " + artifactVersion + " for parent: " + artifact); + } else { + getLog().warn("Could not find the version tag for parent " + artifact + " in project " + + getProject().getId() + " so unable to set version to " + artifactVersion); } } } } - } - private void resolveRanges( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { + private void resolveRanges(ModifiedPomXMLEventReader pom, Collection dependencies) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { continue; } - if ( StringUtils.isBlank( dep.getVersion() ) ) - { + if (StringUtils.isBlank(dep.getVersion())) { throw new MojoExecutionException( - "Found invalid managed dependency " + toString( dep ) + " without a version" ); + "Found invalid managed dependency " + toString(dep) + " without a version"); } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - Matcher versionMatcher = matchRangeRegex.matcher( dep.getVersion() ); + Matcher versionMatcher = matchRangeRegex.matcher(dep.getVersion()); - if ( versionMatcher.find() ) - { - Artifact artifact = this.toArtifact( dep ); + if (versionMatcher.find()) { + Artifact artifact = this.toArtifact(dep); - if ( artifact != null && isIncluded( artifact ) ) - { - getLog().debug( "Resolving version range for dependency: " + artifact ); + if (artifact != null && isIncluded(artifact)) { + getLog().debug("Resolving version range for dependency: " + artifact); String artifactVersion = artifact.getVersion(); - if ( artifactVersion == null ) - { + if (artifactVersion == null) { ArtifactVersion latestVersion = - findLatestVersion( artifact, artifact.getVersionRange(), allowSnapshots, false ); + findLatestVersion(artifact, artifact.getVersionRange(), allowSnapshots, false); - if ( latestVersion != null ) - { + if (latestVersion != null) { artifactVersion = latestVersion.toString(); - } - else - { - getLog().warn( "Not updating version " + artifact + " : could not resolve any versions" ); + } else { + getLog().warn("Not updating version " + artifact + " : could not resolve any versions"); } } - if ( artifactVersion != null ) - { - if ( PomHelper.setDependencyVersion( pom, artifact.getGroupId(), artifact.getArtifactId(), - dep.getVersion(), artifactVersion, - getProject().getModel() ) ) - { - getLog().debug( "Version set to " + artifactVersion + " for dependency: " + artifact ); - } - else - { - getLog().debug( "Could not find the version tag for dependency " + artifact + " in project " - + getProject().getId() + " so unable to set version to " - + artifactVersion ); + if (artifactVersion != null) { + if (PomHelper.setDependencyVersion( + pom, + artifact.getGroupId(), + artifact.getArtifactId(), + dep.getVersion(), + artifactVersion, + getProject().getModel())) { + getLog().debug("Version set to " + artifactVersion + " for dependency: " + artifact); + } else { + getLog().debug("Could not find the version tag for dependency " + artifact + " in project " + + getProject().getId() + " so unable to set version to " + + artifactVersion); } } } @@ -298,42 +267,37 @@ private void resolveRanges( ModifiedPomXMLEventReader pom, Collection propertyVersions = - this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withIncludeProperties( includeProperties ) - .withExcludeProperties( excludeProperties ) - .build() ); - for ( Map.Entry entry : propertyVersions.entrySet() ) - { + private void resolvePropertyRanges(ModifiedPomXMLEventReader pom) + throws XMLStreamException, MojoExecutionException { + + Map propertyVersions = this.getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .withIncludeProperties(includeProperties) + .withExcludeProperties(excludeProperties) + .build()); + for (Map.Entry entry : propertyVersions.entrySet()) { Property property = entry.getKey(); PropertyVersions version = entry.getValue(); - final String currentVersion = getProject().getProperties().getProperty( property.getName() ); - if ( currentVersion == null || !matchRangeRegex.matcher( currentVersion ).find() ) - { + final String currentVersion = getProject().getProperties().getProperty(property.getName()); + if (currentVersion == null + || !matchRangeRegex.matcher(currentVersion).find()) { continue; } - property.setVersion( currentVersion ); - - Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, - allowMinorUpdates, allowIncrementalUpdates, getLog() ); - // TODO: Check if we could add allowDowngrade ? - try - { - updatePropertyToNewestVersion( pom, property, version, currentVersion, false, unchangedSegment ); - } - catch ( InvalidSegmentException | InvalidVersionSpecificationException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), - property.getVersion(), e.getMessage() ) ); + property.setVersion(currentVersion); + + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); + // TODO: Check if we could add allowDowngrade ? + try { + updatePropertyToNewestVersion(pom, property, version, currentVersion, false, unchangedSegment); + } catch (InvalidSegmentException | InvalidVersionSpecificationException e) { + getLog().warn(String.format( + "Skipping the processing of %s:%s due to: %s", + property.getName(), property.getVersion(), e.getMessage())); } } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java index 1f232613b7..ebb64f171c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/RevertMojo.java @@ -45,15 +45,14 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "revert", threadSafe = true ) -public class RevertMojo extends AbstractMojo -{ +@Mojo(name = "revert", threadSafe = true) +public class RevertMojo extends AbstractMojo { /** * The {@link MavenSession} instance * * @since 2.14.0 */ - @Parameter( defaultValue = "${session}", required = true, readonly = true ) + @Parameter(defaultValue = "${session}", required = true, readonly = true) private MavenSession session; /** @@ -63,7 +62,7 @@ public class RevertMojo extends AbstractMojo * * @since 2.13.0 */ - @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) + @Parameter(property = "processFromLocalAggregationRoot", defaultValue = "true") private boolean processFromLocalAggregationRoot; /** @@ -74,46 +73,41 @@ public class RevertMojo extends AbstractMojo protected final ProjectBuilder projectBuilder; @Inject - protected RevertMojo( ProjectBuilder projectBuilder ) - { + protected RevertMojo(ProjectBuilder projectBuilder) { this.projectBuilder = projectBuilder; } - public void execute() throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { final MavenProject projectToProcess = !processFromLocalAggregationRoot - ? PomHelper.getLocalRoot( projectBuilder, session, getLog() ) + ? PomHelper.getLocalRoot(projectBuilder, session, getLog()) : session.getCurrentProject(); - getLog().info( "Local aggregation root: " + projectToProcess.getBasedir() ); - Set reactor = PomHelper.getAllChildModules( projectToProcess, getLog() ); - reactor.add( "." ); + getLog().info("Local aggregation root: " + projectToProcess.getBasedir()); + Set reactor = PomHelper.getAllChildModules(projectToProcess, getLog()); + reactor.add("."); - reactor.forEach( entry -> - { - Path pomFile = projectToProcess.getBasedir().toPath().resolve( entry ).resolve( "pom.xml" ).normalize(); - getLog().debug( "Processing:" + pomFile ); - Path backupFile = Paths.get( pomFile + ".versionsBackup" ); - if ( Files.exists( backupFile ) ) - { - getLog().info( "Restoring " + pomFile + " from " + backupFile ); - try - { - Files.copy( backupFile, pomFile, REPLACE_EXISTING ); - try - { - Files.delete( backupFile ); + reactor.forEach(entry -> { + Path pomFile = projectToProcess + .getBasedir() + .toPath() + .resolve(entry) + .resolve("pom.xml") + .normalize(); + getLog().debug("Processing:" + pomFile); + Path backupFile = Paths.get(pomFile + ".versionsBackup"); + if (Files.exists(backupFile)) { + getLog().info("Restoring " + pomFile + " from " + backupFile); + try { + Files.copy(backupFile, pomFile, REPLACE_EXISTING); + try { + Files.delete(backupFile); + } catch (IOException e) { + getLog().warn("Error deleting " + backupFile); } - catch ( IOException e ) - { - getLog().warn( "Error deleting " + backupFile ); - } - } - catch ( IOException e ) - { - getLog().warn( "Error copying " + backupFile + " onto " + pomFile ); + } catch (IOException e) { + getLog().warn("Error copying " + backupFile + " onto " + pomFile); } } - } ); + }); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java index 1bdceacb0b..44035838b9 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -74,9 +74,8 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "set", aggregator = true, threadSafe = true ) -public class SetMojo extends AbstractVersionsUpdaterMojo -{ +@Mojo(name = "set", aggregator = true, threadSafe = true) +public class SetMojo extends AbstractVersionsUpdaterMojo { private static final String SNAPSHOT = "-SNAPSHOT"; @@ -85,7 +84,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.0-beta-1 */ - @Parameter( property = "newVersion" ) + @Parameter(property = "newVersion") private String newVersion; /** @@ -98,7 +97,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.2 */ - @Parameter( property = "groupId", defaultValue = "${project.groupId}" ) + @Parameter(property = "groupId", defaultValue = "${project.groupId}") private String groupId; /** @@ -111,7 +110,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.2 */ - @Parameter( property = "artifactId", defaultValue = "${project.artifactId}" ) + @Parameter(property = "artifactId", defaultValue = "${project.artifactId}") private String artifactId; /** @@ -124,7 +123,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.2 */ - @Parameter( property = "oldVersion", defaultValue = "${project.version}" ) + @Parameter(property = "oldVersion", defaultValue = "${project.version}") private String oldVersion; /** @@ -132,7 +131,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.3 */ - @Parameter( property = "updateMatchingVersions", defaultValue = "true" ) + @Parameter(property = "updateMatchingVersions", defaultValue = "true") private boolean updateMatchingVersions; /** @@ -140,7 +139,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.3 */ - @Parameter( property = "processParent", defaultValue = "true" ) + @Parameter(property = "processParent", defaultValue = "true") private boolean processParent; /** @@ -148,7 +147,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.3 */ - @Parameter( property = "processProject", defaultValue = "true" ) + @Parameter(property = "processProject", defaultValue = "true") private boolean processProject; /** @@ -156,7 +155,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.3 */ - @Parameter( property = "processDependencies", defaultValue = "true" ) + @Parameter(property = "processDependencies", defaultValue = "true") private boolean processDependencies; /** @@ -164,7 +163,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 1.3 */ - @Parameter( property = "processPlugins", defaultValue = "true" ) + @Parameter(property = "processPlugins", defaultValue = "true") private boolean processPlugins; /** @@ -177,7 +176,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.10 */ - @Parameter( property = "removeSnapshot", defaultValue = "false" ) + @Parameter(property = "removeSnapshot", defaultValue = "false") private boolean removeSnapshot; /** @@ -187,7 +186,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.10 */ - @Parameter( property = "nextSnapshot", defaultValue = "false" ) + @Parameter(property = "nextSnapshot", defaultValue = "false") protected boolean nextSnapshot; /** @@ -199,7 +198,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.12 */ - @Parameter( property = "nextSnapshotIndexToIncrement" ) + @Parameter(property = "nextSnapshotIndexToIncrement") protected Integer nextSnapshotIndexToIncrement; /** @@ -207,7 +206,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.5 */ - @Parameter( property = "processAllModules", defaultValue = "false" ) + @Parameter(property = "processAllModules", defaultValue = "false") private boolean processAllModules; /** @@ -217,7 +216,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.9 */ - @Parameter( property = "processFromLocalAggregationRoot", defaultValue = "true" ) + @Parameter(property = "processFromLocalAggregationRoot", defaultValue = "true") private boolean processFromLocalAggregationRoot; /** @@ -226,7 +225,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * @since 2.10 * @deprecated please use {@link #updateBuildOutputTimestampPolicy} instead */ - @Parameter( property = "updateBuildOutputTimestamp", defaultValue = "true" ) + @Parameter(property = "updateBuildOutputTimestamp", defaultValue = "true") private boolean updateBuildOutputTimestamp; /** @@ -236,7 +235,7 @@ public class SetMojo extends AbstractVersionsUpdaterMojo * * @since 2.12 */ - @Parameter( property = "updateBuildOutputTimestampPolicy", defaultValue = "onchange" ) + @Parameter(property = "updateBuildOutputTimestampPolicy", defaultValue = "onchange") private String updateBuildOutputTimestampPolicy; /** @@ -252,23 +251,21 @@ public class SetMojo extends AbstractVersionsUpdaterMojo protected final ProjectBuilder projectBuilder; @Inject - public SetMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - ProjectBuilder projectBuilder, - Map wagonMap, - Map changeRecorders, - Prompter prompter ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public SetMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + ProjectBuilder projectBuilder, + Map wagonMap, + Map changeRecorders, + Prompter prompter) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); this.projectBuilder = projectBuilder; this.prompter = prompter; } - private synchronized void addChange( String groupId, String artifactId, String oldVersion, String newVersion ) - { - if ( !newVersion.equals( oldVersion ) ) - { - sourceChanges.add( new DefaultVersionChange( groupId, artifactId, oldVersion, newVersion ) ); + private synchronized void addChange(String groupId, String artifactId, String oldVersion, String newVersion) { + if (!newVersion.equals(oldVersion)) { + sourceChanges.add(new DefaultVersionChange(groupId, artifactId, oldVersion, newVersion)); } } @@ -278,131 +275,114 @@ private synchronized void addChange( String groupId, String artifactId, String o * @throws org.apache.maven.plugin.MojoExecutionException when things go wrong. * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. */ - public void execute() throws MojoExecutionException, MojoFailureException - { - if ( getProject().getOriginalModel().getVersion() == null ) - { - throw new MojoExecutionException( "Project version is inherited from parent." ); + public void execute() throws MojoExecutionException, MojoFailureException { + if (getProject().getOriginalModel().getVersion() == null) { + throw new MojoExecutionException("Project version is inherited from parent."); } - if ( removeSnapshot && !nextSnapshot ) - { + if (removeSnapshot && !nextSnapshot) { String version = getVersion(); - if ( version.endsWith( SNAPSHOT ) ) - { - String release = version.substring( 0, version.indexOf( SNAPSHOT ) ); + if (version.endsWith(SNAPSHOT)) { + String release = version.substring(0, version.indexOf(SNAPSHOT)); newVersion = release; - getLog().info( "SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion ); + getLog().info("SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion); } } - if ( !nextSnapshot && nextSnapshotIndexToIncrement != null ) - { - throw new MojoExecutionException( "nextSnapshotIndexToIncrement is not valid when nextSnapshot is false" ); + if (!nextSnapshot && nextSnapshotIndexToIncrement != null) { + throw new MojoExecutionException("nextSnapshotIndexToIncrement is not valid when nextSnapshot is false"); } - if ( !removeSnapshot && nextSnapshot ) - { + if (!removeSnapshot && nextSnapshot) { String version = getVersion(); - newVersion = getIncrementedVersion( version, nextSnapshotIndexToIncrement ); - getLog().info( "SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion ); + newVersion = getIncrementedVersion(version, nextSnapshotIndexToIncrement); + getLog().info("SNAPSHOT found. BEFORE " + version + " --> AFTER: " + newVersion); } - if ( isEmpty( newVersion ) ) - { - if ( removeSnapshot ) - { - getLog().info( "removeSnapshot enabled whilst the version is not a snapshot: nothing to do." ); + if (isEmpty(newVersion)) { + if (removeSnapshot) { + getLog().info("removeSnapshot enabled whilst the version is not a snapshot: nothing to do."); return; } - if ( session.getSettings().isInteractiveMode() ) - { - try - { - newVersion = prompter.prompt( "Enter the new version to set", - getProject().getOriginalModel().getVersion() ); + if (session.getSettings().isInteractiveMode()) { + try { + newVersion = prompter.prompt( + "Enter the new version to set", + getProject().getOriginalModel().getVersion()); + } catch (PrompterException e) { + throw new MojoExecutionException(e.getMessage(), e); } - catch ( PrompterException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - } - else - { - throw new MojoExecutionException( "You must specify the new version, either by using the newVersion " - + "property (that is -DnewVersion=... on the command line) " - + "or run in interactive mode" ); + } else { + throw new MojoExecutionException("You must specify the new version, either by using the newVersion " + + "property (that is -DnewVersion=... on the command line) " + + "or run in interactive mode"); } } - if ( !"onchange".equals( updateBuildOutputTimestampPolicy ) && !"always".equals( - updateBuildOutputTimestampPolicy ) && !"never".equals( updateBuildOutputTimestampPolicy ) ) - { + if (!"onchange".equals(updateBuildOutputTimestampPolicy) + && !"always".equals(updateBuildOutputTimestampPolicy) + && !"never".equals(updateBuildOutputTimestampPolicy)) { throw new MojoExecutionException( - "updateBuildOutputTimestampPolicy should be one of: " + "\"onchange\", \"always\", \"never\"." ); + "updateBuildOutputTimestampPolicy should be one of: " + "\"onchange\", \"always\", \"never\"."); } - try - { + try { final MavenProject project = processFromLocalAggregationRoot - ? PomHelper.getLocalRoot( projectBuilder, session, getLog() ) + ? PomHelper.getLocalRoot(projectBuilder, session, getLog()) : getProject(); - getLog().info( "Local aggregation root: " + project.getBasedir() ); - Map reactorModels = PomHelper.getReactorModels( project, getLog() ); - final SortedMap reactor = - new TreeMap<>( new ReactorDepthComparator( reactorModels ) ); - reactor.putAll( reactorModels ); + getLog().info("Local aggregation root: " + project.getBasedir()); + Map reactorModels = PomHelper.getReactorModels(project, getLog()); + final SortedMap reactor = new TreeMap<>(new ReactorDepthComparator(reactorModels)); + reactor.putAll(reactorModels); // set of files to update final Set files = new LinkedHashSet<>(); - getLog().info( - "Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); + getLog().info("Processing change of " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + + newVersion); Pattern groupIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( groupId, "*" ), true ) ); + Pattern.compile(RegexUtils.convertWildcardsToRegex(fixNullOrEmpty(groupId, "*"), true)); Pattern artifactIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( artifactId, "*" ), true ) ); + Pattern.compile(RegexUtils.convertWildcardsToRegex(fixNullOrEmpty(artifactId, "*"), true)); Pattern oldVersionIdRegex = - Pattern.compile( RegexUtils.convertWildcardsToRegex( fixNullOrEmpty( oldVersion, "*" ), true ) ); - - for ( Model m : reactor.values() ) - { - final String mGroupId = PomHelper.getGroupId( m ); - final String mArtifactId = PomHelper.getArtifactId( m ); - final String mVersion = PomHelper.getVersion( m ); - if ( ( processAllModules - || groupIdRegex.matcher( mGroupId ).matches() - && artifactIdRegex.matcher( mArtifactId ).matches() ) - && oldVersionIdRegex.matcher( mVersion ).matches() - && !newVersion.equals( mVersion ) ) - { - applyChange( project, reactor, files, mGroupId, m.getArtifactId(), - StringUtils.isBlank( oldVersion ) || "*".equals( oldVersion ) ? "" : mVersion ); + Pattern.compile(RegexUtils.convertWildcardsToRegex(fixNullOrEmpty(oldVersion, "*"), true)); + + for (Model m : reactor.values()) { + final String mGroupId = PomHelper.getGroupId(m); + final String mArtifactId = PomHelper.getArtifactId(m); + final String mVersion = PomHelper.getVersion(m); + if ((processAllModules + || groupIdRegex.matcher(mGroupId).matches() + && artifactIdRegex.matcher(mArtifactId).matches()) + && oldVersionIdRegex.matcher(mVersion).matches() + && !newVersion.equals(mVersion)) { + applyChange( + project, + reactor, + files, + mGroupId, + m.getArtifactId(), + StringUtils.isBlank(oldVersion) || "*".equals(oldVersion) ? "" : mVersion); } } - if ( "always".equals( updateBuildOutputTimestampPolicy ) ) - { + if ("always".equals(updateBuildOutputTimestampPolicy)) { reactor.values().parallelStream() - .map( m -> PomHelper.getModelEntry( reactor, PomHelper.getGroupId( m ), - PomHelper.getArtifactId( m ) ) ) - .filter( Objects::nonNull ) - .map( Map.Entry::getKey ) - .map( f -> getModuleProjectFile( project, f ) ) - .forEach( files::add ); + .map(m -> PomHelper.getModelEntry(reactor, PomHelper.getGroupId(m), PomHelper.getArtifactId(m))) + .filter(Objects::nonNull) + .map(Map.Entry::getKey) + .map(f -> getModuleProjectFile(project, f)) + .forEach(files::add); } // now process all the updates - for ( File file : files ) - { - process( file ); + for (File file : files) { + process(file); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } @@ -415,149 +395,133 @@ public void execute() throws MojoExecutionException, MojoFailureException * @return version with the incremented index specified by nextSnapshotIndexToIncrement or last index * @throws MojoExecutionException thrown if the input parameters are invalid */ - protected String getIncrementedVersion( String version, Integer nextSnapshotIndexToIncrement ) - throws MojoExecutionException - { + protected String getIncrementedVersion(String version, Integer nextSnapshotIndexToIncrement) + throws MojoExecutionException { String versionWithoutSnapshot = - version.endsWith( SNAPSHOT ) ? version.substring( 0, version.indexOf( SNAPSHOT ) ) : version; - List numbers = new LinkedList<>( Arrays.asList( versionWithoutSnapshot.split( "\\." ) ) ); + version.endsWith(SNAPSHOT) ? version.substring(0, version.indexOf(SNAPSHOT)) : version; + List numbers = new LinkedList<>(Arrays.asList(versionWithoutSnapshot.split("\\."))); - if ( nextSnapshotIndexToIncrement == null ) - { + if (nextSnapshotIndexToIncrement == null) { nextSnapshotIndexToIncrement = numbers.size(); - } - else if ( nextSnapshotIndexToIncrement < 1 ) - { - throw new MojoExecutionException( "nextSnapshotIndexToIncrement cannot be less than 1" ); - } - else if ( nextSnapshotIndexToIncrement > numbers.size() ) - { + } else if (nextSnapshotIndexToIncrement < 1) { + throw new MojoExecutionException("nextSnapshotIndexToIncrement cannot be less than 1"); + } else if (nextSnapshotIndexToIncrement > numbers.size()) { throw new MojoExecutionException( - "nextSnapshotIndexToIncrement cannot be greater than the last version index" ); + "nextSnapshotIndexToIncrement cannot be greater than the last version index"); } - int snapshotVersionToIncrement = Integer.parseInt( numbers.remove( nextSnapshotIndexToIncrement - 1 ) ); - numbers.add( nextSnapshotIndexToIncrement - 1, String.valueOf( snapshotVersionToIncrement + 1 ) ); + int snapshotVersionToIncrement = Integer.parseInt(numbers.remove(nextSnapshotIndexToIncrement - 1)); + numbers.add(nextSnapshotIndexToIncrement - 1, String.valueOf(snapshotVersionToIncrement + 1)); - return StringUtils.join( numbers.toArray( new String[0] ), "." ) + "-SNAPSHOT"; + return StringUtils.join(numbers.toArray(new String[0]), ".") + "-SNAPSHOT"; } - private static String fixNullOrEmpty( String value, String defaultValue ) - { - return StringUtils.isBlank( value ) ? defaultValue : value; + private static String fixNullOrEmpty(String value, String defaultValue) { + return StringUtils.isBlank(value) ? defaultValue : value; } - private void applyChange( MavenProject project, SortedMap reactor, Set files, String groupId, - String artifactId, String oldVersion ) - { + private void applyChange( + MavenProject project, + SortedMap reactor, + Set files, + String groupId, + String artifactId, + String oldVersion) { - getLog().debug( "Applying change " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion ); + getLog().debug("Applying change " + groupId + ":" + artifactId + ":" + oldVersion + " -> " + newVersion); // this is a triggering change - addChange( groupId, artifactId, oldVersion, newVersion ); + addChange(groupId, artifactId, oldVersion, newVersion); // now fake out the triggering change - Map.Entry current = PomHelper.getModelEntry( reactor, groupId, artifactId ); - if ( current != null ) - { - current.getValue().setVersion( newVersion ); - files.add( getModuleProjectFile( project, current.getKey() ) ); + Map.Entry current = PomHelper.getModelEntry(reactor, groupId, artifactId); + if (current != null) { + current.getValue().setVersion(newVersion); + files.add(getModuleProjectFile(project, current.getKey())); } - for ( Map.Entry sourceEntry : reactor.entrySet() ) - { + for (Map.Entry sourceEntry : reactor.entrySet()) { final String sourcePath = sourceEntry.getKey(); final Model sourceModel = sourceEntry.getValue(); - getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" - : "Processing " + sourcePath + " as a parent." ); + getLog().debug( + sourcePath.length() == 0 + ? "Processing root module as parent" + : "Processing " + sourcePath + " as a parent."); - final String sourceGroupId = PomHelper.getGroupId( sourceModel ); - if ( sourceGroupId == null ) - { - getLog().warn( "Module " + sourcePath + " is missing a groupId." ); + final String sourceGroupId = PomHelper.getGroupId(sourceModel); + if (sourceGroupId == null) { + getLog().warn("Module " + sourcePath + " is missing a groupId."); continue; } - final String sourceArtifactId = PomHelper.getArtifactId( sourceModel ); - if ( sourceArtifactId == null ) - { - getLog().warn( "Module " + sourcePath + " is missing an artifactId." ); + final String sourceArtifactId = PomHelper.getArtifactId(sourceModel); + if (sourceArtifactId == null) { + getLog().warn("Module " + sourcePath + " is missing an artifactId."); continue; } - final String sourceVersion = PomHelper.getVersion( sourceModel ); - if ( sourceVersion == null ) - { - getLog().warn( "Module " + sourcePath + " is missing a version." ); + final String sourceVersion = PomHelper.getVersion(sourceModel); + if (sourceVersion == null) { + getLog().warn("Module " + sourcePath + " is missing a version."); continue; } - files.add( getModuleProjectFile( project, sourcePath ) ); + files.add(getModuleProjectFile(project, sourcePath)); - getLog().debug( - "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + " as their parent" ); + getLog().debug("Looking for modules which use " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + " as their parent"); - for ( Map.Entry stringModelEntry : processAllModules ? reactor.entrySet() - : PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) - { + for (Map.Entry stringModelEntry : processAllModules + ? reactor.entrySet() + : PomHelper.getChildModels(reactor, sourceGroupId, sourceArtifactId) + .entrySet()) { final Model targetModel = stringModelEntry.getValue(); final Parent parent = targetModel.getParent(); - getLog().debug( "Module: " + stringModelEntry.getKey() ); - if ( parent != null && sourceVersion.equals( parent.getVersion() ) ) - { - getLog().debug( - " parent already is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + ":" + sourceVersion ); + getLog().debug("Module: " + stringModelEntry.getKey()); + if (parent != null && sourceVersion.equals(parent.getVersion())) { + getLog().debug(" parent already is " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + ":" + sourceVersion); + } else { + getLog().debug(" parent is " + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + + ":" + (parent == null ? "" : parent.getVersion())); + getLog().debug(" will become " + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + + ":" + sourceVersion); } - else - { - getLog().debug( - " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + ( - parent == null ? "" : parent.getVersion() ) ); - getLog().debug( - " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); - } - final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); - if ( ( updateMatchingVersions || !targetExplicit ) // - && ( parent != null && StringUtils.equals( parent.getVersion(), - PomHelper.getVersion( targetModel ) ) ) ) - { - getLog().debug( - " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" - + PomHelper.getVersion( - targetModel ) ); - getLog().debug( - " will become " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) - + ":" + sourceVersion ); - addChange( PomHelper.getGroupId( targetModel ), PomHelper.getArtifactId( targetModel ), - PomHelper.getVersion( targetModel ), sourceVersion ); - targetModel.setVersion( sourceVersion ); - } - else - { - getLog().debug( - " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" - + PomHelper.getVersion( - targetModel ) ); + final boolean targetExplicit = PomHelper.isExplicitVersion(targetModel); + if ((updateMatchingVersions || !targetExplicit) // + && (parent != null + && StringUtils.equals(parent.getVersion(), PomHelper.getVersion(targetModel)))) { + getLog().debug(" module is " + + ArtifactUtils.versionlessKey( + PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel)) + + ":" + + PomHelper.getVersion(targetModel)); + getLog().debug(" will become " + + ArtifactUtils.versionlessKey( + PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel)) + + ":" + sourceVersion); + addChange( + PomHelper.getGroupId(targetModel), + PomHelper.getArtifactId(targetModel), + PomHelper.getVersion(targetModel), + sourceVersion); + targetModel.setVersion(sourceVersion); + } else { + getLog().debug(" module is " + + ArtifactUtils.versionlessKey( + PomHelper.getGroupId(targetModel), PomHelper.getArtifactId(targetModel)) + + ":" + + PomHelper.getVersion(targetModel)); } } } } - private static File getModuleProjectFile( MavenProject project, String relativePath ) - { - final File moduleDir = new File( project.getBasedir(), relativePath ); + private static File getModuleProjectFile(MavenProject project, String relativePath) { + final File moduleDir = new File(project.getBasedir(), relativePath); final File projectBaseDir = project.getBasedir(); - if ( projectBaseDir.equals( moduleDir ) ) - { + if (projectBaseDir.equals(moduleDir)) { return project.getFile(); - } - else if ( moduleDir.isDirectory() ) - { - return new File( moduleDir, "pom.xml" ); + } else if (moduleDir.isDirectory()) { + return new File(moduleDir, "pom.xml"); } // i don't think this should ever happen... but just in case // the module references the file-name @@ -572,74 +536,58 @@ else if ( moduleDir.isDirectory() ) * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. * @throws javax.xml.stream.XMLStreamException when things go wrong. */ - protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - ContextualLog log = new DelegatingContextualLog( getLog() ); - try - { - Model model = PomHelper.getRawModel( pom ); - log.setContext( "Processing " + PomHelper.getGroupId( model ) + ":" + PomHelper.getArtifactId( model ) ); + protected synchronized void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + ContextualLog log = new DelegatingContextualLog(getLog()); + try { + Model model = PomHelper.getRawModel(pom); + log.setContext("Processing " + PomHelper.getGroupId(model) + ":" + PomHelper.getArtifactId(model)); VersionChangerFactory versionChangerFactory = new VersionChangerFactory(); - versionChangerFactory.setPom( pom ); - versionChangerFactory.setLog( log ); - versionChangerFactory.setModel( model ); + versionChangerFactory.setPom(pom); + versionChangerFactory.setLog(log); + versionChangerFactory.setModel(model); - VersionChanger changer = - versionChangerFactory.newVersionChanger( processParent, processProject, processDependencies, - processPlugins ); + VersionChanger changer = versionChangerFactory.newVersionChanger( + processParent, processProject, processDependencies, processPlugins); - for ( DefaultVersionChange versionChange : sourceChanges ) - { - changer.apply( versionChange ); + for (DefaultVersionChange versionChange : sourceChanges) { + changer.apply(versionChange); } - if ( updateBuildOutputTimestamp && !"never".equals( updateBuildOutputTimestampPolicy ) ) - { - if ( "always".equals( updateBuildOutputTimestampPolicy ) || !sourceChanges.isEmpty() ) - { + if (updateBuildOutputTimestamp && !"never".equals(updateBuildOutputTimestampPolicy)) { + if ("always".equals(updateBuildOutputTimestampPolicy) || !sourceChanges.isEmpty()) { // also update project.build.outputTimestamp - updateBuildOutputTimestamp( pom, model ); + updateBuildOutputTimestamp(pom, model); } } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } log.clearContext(); } - private void updateBuildOutputTimestamp( ModifiedPomXMLEventReader pom, Model model ) throws XMLStreamException - { - String buildOutputTimestamp = model.getProperties().getProperty( "project.build.outputTimestamp" ); + private void updateBuildOutputTimestamp(ModifiedPomXMLEventReader pom, Model model) throws XMLStreamException { + String buildOutputTimestamp = model.getProperties().getProperty("project.build.outputTimestamp"); - if ( buildOutputTimestamp == null || isEmpty( buildOutputTimestamp ) ) - { + if (buildOutputTimestamp == null || isEmpty(buildOutputTimestamp)) { // no Reproducible Builds output timestamp defined return; } - if ( StringUtils.isNumeric( buildOutputTimestamp ) ) - { + if (StringUtils.isNumeric(buildOutputTimestamp)) { // int representing seconds since the epoch, like SOURCE_DATE_EPOCH - buildOutputTimestamp = String.valueOf( System.currentTimeMillis() / 1000 ); - } - else if ( buildOutputTimestamp.length() <= 1 ) - { + buildOutputTimestamp = String.valueOf(System.currentTimeMillis() / 1000); + } else if (buildOutputTimestamp.length() <= 1) { // value length == 1 means disable Reproducible Builds return; - } - else - { + } else { // ISO-8601 - DateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss'Z'" ); - df.setTimeZone( TimeZone.getTimeZone( "UTC" ) ); - buildOutputTimestamp = df.format( new Date() ); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + buildOutputTimestamp = df.format(new Date()); } - PomHelper.setPropertyVersion( pom, null, "project.build.outputTimestamp", buildOutputTimestamp ); + PomHelper.setPropertyVersion(pom, null, "project.build.outputTimestamp", buildOutputTimestamp); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java index 427cca501d..2bb6d7fc9a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java @@ -52,10 +52,8 @@ * @author Karl Heinz Marbaise * @since 2.5 */ -@Mojo( name = "set-property", threadSafe = true ) -public class SetPropertyMojo - extends AbstractVersionsUpdaterMojo -{ +@Mojo(name = "set-property", threadSafe = true) +public class SetPropertyMojo extends AbstractVersionsUpdaterMojo { // ------------------------------ FIELDS ------------------------------ @@ -63,19 +61,19 @@ public class SetPropertyMojo * A property to update. * You can also specify multiple property names separated by "," which are all set to the same new version. */ - @Parameter( property = "property" ) + @Parameter(property = "property") private String property = null; /** * The new version to set the property. */ - @Parameter( property = "newVersion" ) + @Parameter(property = "newVersion") private String newVersion = null; /** * Whether properties linking versions should be auto-detected or not. */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) + @Parameter(property = "autoLinkItems", defaultValue = "true") private boolean autoLinkItems; /** @@ -84,17 +82,16 @@ public class SetPropertyMojo * * @since 2.9 */ - - @Parameter( property = "propertiesVersionsFile" ) + @Parameter(property = "propertiesVersionsFile") private String propertiesVersionsFile; @Inject - public SetPropertyMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public SetPropertyMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -104,87 +101,69 @@ public SetPropertyMojo( RepositorySystem repositorySystem, * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { Property[] propertiesConfig; String properties; - if ( !isEmpty( propertiesVersionsFile ) ) - { + if (!isEmpty(propertiesVersionsFile)) { logWrongConfigWarning(); - getLog().debug( "Reading properties and versions to update from file: " + propertiesVersionsFile ); - PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader( propertiesVersionsFile ); - try - { + getLog().debug("Reading properties and versions to update from file: " + propertiesVersionsFile); + PropertiesVersionsFileReader reader = new PropertiesVersionsFileReader(propertiesVersionsFile); + try { reader.read(); - } - catch ( IOException e ) - { - getLog().error( "Unable to read property file " + propertiesVersionsFile - + ". re-run with -X option for more details." ); - getLog().debug( "Error while reading property file " + propertiesVersionsFile, e ); - throw new MojoFailureException( "Unable to read property file " + propertiesVersionsFile ); + } catch (IOException e) { + getLog().error("Unable to read property file " + propertiesVersionsFile + + ". re-run with -X option for more details."); + getLog().debug("Error while reading property file " + propertiesVersionsFile, e); + throw new MojoFailureException("Unable to read property file " + propertiesVersionsFile); } propertiesConfig = reader.getPropertiesConfig(); properties = reader.getProperties(); - } - else if ( !isEmpty( property ) ) - { - getLog().debug( "Reading properties and versions to update from property and newVersion " ); - propertiesConfig = Arrays.stream( split( property, "," ) ).map( - prp -> - { - Property propertyConfig = new Property( prp ); - propertyConfig.setVersion( newVersion ); + } else if (!isEmpty(property)) { + getLog().debug("Reading properties and versions to update from property and newVersion "); + propertiesConfig = Arrays.stream(split(property, ",")) + .map(prp -> { + Property propertyConfig = new Property(prp); + propertyConfig.setVersion(newVersion); return propertyConfig; - } ) - .toArray( Property[]::new ); + }) + .toArray(Property[]::new); properties = property; + } else { + throw new MojoExecutionException("Please provide either 'property' or 'propertiesVersionsFile' parameter."); } - else - { - throw new MojoExecutionException( - "Please provide either 'property' or 'propertiesVersionsFile' parameter." ); - } - update( pom, propertiesConfig, properties ); + update(pom, propertiesConfig, properties); } - private void update( ModifiedPomXMLEventReader pom, Property[] propertiesConfig, String properties ) - throws MojoExecutionException, XMLStreamException - { - Map propertyVersions = - this.getHelper().getVersionPropertiesMap( VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( propertiesConfig ) - .withIncludeProperties( properties ) - .withAutoLinkItems( autoLinkItems ) - .build() ); - for ( Map.Entry entry : propertyVersions.entrySet() ) - { + private void update(ModifiedPomXMLEventReader pom, Property[] propertiesConfig, String properties) + throws MojoExecutionException, XMLStreamException { + Map propertyVersions = this.getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .withPropertyDefinitions(propertiesConfig) + .withIncludeProperties(properties) + .withAutoLinkItems(autoLinkItems) + .build()); + for (Map.Entry entry : propertyVersions.entrySet()) { Property currentProperty = entry.getKey(); PropertyVersions version = entry.getValue(); String newVersionGiven = currentProperty.getVersion(); - final String currentVersion = getProject().getProperties().getProperty( currentProperty.getName() ); - if ( currentVersion == null ) - { + final String currentVersion = getProject().getProperties().getProperty(currentProperty.getName()); + if (currentVersion == null) { continue; } - PomHelper.setPropertyVersion( pom, version.getProfileId(), currentProperty.getName(), - defaultString( newVersionGiven ) ); + PomHelper.setPropertyVersion( + pom, version.getProfileId(), currentProperty.getName(), defaultString(newVersionGiven)); } } - private void logWrongConfigWarning() - { - if ( !isEmpty( property ) ) - { - getLog().warn( "-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used" ); + private void logWrongConfigWarning() { + if (!isEmpty(property)) { + getLog().warn("-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used"); } - if ( !isEmpty( newVersion ) ) - { - getLog().warn( "-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used" ); + if (!isEmpty(newVersion)) { + getLog().warn("-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used"); } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java index 5940640bec..bb1e3b13f2 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/SetScmTagMojo.java @@ -28,16 +28,15 @@ * @author Anton Johansson * @since 2.5 */ -@Mojo( name = "set-scm-tag", aggregator = true, threadSafe = true ) -public class SetScmTagMojo extends AbstractVersionsUpdaterMojo -{ +@Mojo(name = "set-scm-tag", aggregator = true, threadSafe = true) +public class SetScmTagMojo extends AbstractVersionsUpdaterMojo { /** * The new SCM tag to set. * * @since 2.5 */ - @Parameter( property = "newTag" ) + @Parameter(property = "newTag") private String newTag; /** @@ -45,7 +44,7 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo * * @since 2.12.0 */ - @Parameter( property = "connection" ) + @Parameter(property = "connection") private String connection; /** @@ -53,7 +52,7 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo * * @since 2.12.0 */ - @Parameter( property = "developerConnection" ) + @Parameter(property = "developerConnection") private String developerConnection; /** @@ -61,16 +60,16 @@ public class SetScmTagMojo extends AbstractVersionsUpdaterMojo * * @since 2.12.0 */ - @Parameter( property = "url" ) + @Parameter(property = "url") private String url; @Inject - public SetScmTagMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public SetScmTagMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -80,78 +79,64 @@ public SetScmTagMojo( RepositorySystem repositorySystem, * @throws org.apache.maven.plugin.MojoFailureException when things go wrong. */ @Override - public void execute() throws MojoExecutionException, MojoFailureException - { - if ( isAllBlank( newTag, connection, developerConnection, url ) ) - { + public void execute() throws MojoExecutionException, MojoFailureException { + if (isAllBlank(newTag, connection, developerConnection, url)) { throw new MojoFailureException( - "One of: \"newTag\", \"connection\", \"developerConnection\", \"url\" should be provided." ); + "One of: \"newTag\", \"connection\", \"developerConnection\", \"url\" should be provided."); } super.execute(); } @Override - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - try - { - Scm scm = PomHelper.getRawModel( pom ).getScm(); - if ( scm == null ) - { - throw new MojoFailureException( "No was present" ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + try { + Scm scm = PomHelper.getRawModel(pom).getScm(); + if (scm == null) { + throw new MojoFailureException("No was present"); } List failures = new ArrayList<>(); - if ( !isBlank( newTag ) ) - { - getLog().info( "Updating tag: " + ( scm != null && scm.getTag() != null - ? scm.getTag() : "(empty)" ) + " -> " + newTag ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "tag", newTag ) ) - { - failures.add( "tag: " + newTag ); + if (!isBlank(newTag)) { + getLog().info("Updating tag: " + (scm != null && scm.getTag() != null ? scm.getTag() : "(empty)") + + " -> " + newTag); + if (!PomHelper.setElementValue(pom, "/project/scm", "tag", newTag)) { + failures.add("tag: " + newTag); } } - if ( !isBlank( connection ) ) - { - getLog().info( "Updating connection: " + ( scm != null && scm.getConnection() != null - ? scm.getConnection() : "(empty)" ) + " -> " + connection ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "connection", connection ) ) - { - failures.add( "connection: " + connection ); + if (!isBlank(connection)) { + getLog().info("Updating connection: " + + (scm != null && scm.getConnection() != null ? scm.getConnection() : "(empty)") + " -> " + + connection); + if (!PomHelper.setElementValue(pom, "/project/scm", "connection", connection)) { + failures.add("connection: " + connection); } } - if ( !isBlank( developerConnection ) ) - { - getLog().info( "Updating developerConnection: " - + ( scm != null && scm.getDeveloperConnection() != null - ? scm.getDeveloperConnection() : "(empty)" ) + " -> " - + developerConnection ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "developerConnection", - developerConnection ) ) - { - failures.add( "developerConnection: " + developerConnection ); + if (!isBlank(developerConnection)) { + getLog().info("Updating developerConnection: " + + (scm != null && scm.getDeveloperConnection() != null + ? scm.getDeveloperConnection() + : "(empty)") + + " -> " + + developerConnection); + if (!PomHelper.setElementValue(pom, "/project/scm", "developerConnection", developerConnection)) { + failures.add("developerConnection: " + developerConnection); } } - if ( !isBlank( url ) ) - { - getLog().info( "Updating url: " + ( scm != null && scm.getUrl() != null - ? scm.getUrl() : "(empty)" ) + " -> " + url ); - if ( !PomHelper.setElementValue( pom, "/project/scm", "url", url ) ) - { - failures.add( "url: " + url ); + if (!isBlank(url)) { + getLog().info("Updating url: " + (scm != null && scm.getUrl() != null ? scm.getUrl() : "(empty)") + + " -> " + url); + if (!PomHelper.setElementValue(pom, "/project/scm", "url", url)) { + failures.add("url: " + url); } } - if ( !failures.isEmpty() ) - { - throw new MojoFailureException( "Could not update one or more SCM elements: " + String.join( ", ", - failures ) + ". Please make sure they are present in the original POM. " ); + if (!failures.isEmpty()) { + throw new MojoFailureException("Could not update one or more SCM elements: " + + String.join(", ", failures) + ". Please make sure they are present in the original POM. "); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java index b490d1400c..7276940a2c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UnlockSnapshotsMojo.java @@ -52,26 +52,25 @@ * @author Paul Gier * @since 1.0-alpha-3 */ -@Mojo( name = "unlock-snapshots", threadSafe = true ) -public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "unlock-snapshots", threadSafe = true) +public class UnlockSnapshotsMojo extends AbstractVersionsDependencyUpdaterMojo { // ------------------------------ FIELDS ------------------------------ /** * Pattern to match a timestamped snapshot version. For example 1.0-20090128.202731-1 */ - private static final Pattern TIMESTAMPED_SNAPSHOT_REGEX = Pattern.compile( "-(\\d{8}\\.\\d{6})-(\\d+)$" ); + private static final Pattern TIMESTAMPED_SNAPSHOT_REGEX = Pattern.compile("-(\\d{8}\\.\\d{6})-(\\d+)$"); // ------------------------------ METHODS -------------------------- @Inject - public UnlockSnapshotsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UnlockSnapshotsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -81,112 +80,97 @@ public UnlockSnapshotsMojo( RepositorySystem repositorySystem, * @throws XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - try - { - if ( isProcessingDependencyManagement() ) - { - DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - unlockSnapshots( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + try { + if (isProcessingDependencyManagement()) { + DependencyManagement dependencyManagement = + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + unlockSnapshots( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); + } } - } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - unlockSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); - } - if ( getProject().getParent() != null && isProcessingParent() ) - { - unlockParentSnapshot( pom, getProject().getParent() ); - } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + unlockSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); + } + if (getProject().getParent() != null && isProcessingParent()) { + unlockParentSnapshot(pom, getProject().getParent()); + } + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void unlockSnapshots( ModifiedPomXMLEventReader pom, List dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException - { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + private void unlockSnapshots( + ModifiedPomXMLEventReader pom, List dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - if ( !isIncluded( this.toArtifact( dep ) ) ) - { + if (!isIncluded(this.toArtifact(dep))) { continue; } String version = dep.getVersion(); - Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( version ); - if ( versionMatcher.find() && versionMatcher.end() == version.length() ) - { - String unlockedVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - unlockedVersion, getProject().getModel() ) ) - { - - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( changeKind ) - .withDependency( dep ) - .withNewVersion( unlockedVersion ) - .build() ); - getLog().info( "Unlocked " + toString( dep ) + " to version " + unlockedVersion ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher(version); + if (versionMatcher.find() && versionMatcher.end() == version.length()) { + String unlockedVersion = versionMatcher.replaceFirst("-SNAPSHOT"); + if (PomHelper.setDependencyVersion( + pom, + dep.getGroupId(), + dep.getArtifactId(), + dep.getVersion(), + unlockedVersion, + getProject().getModel())) { + + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(changeKind) + .withDependency(dep) + .withNewVersion(unlockedVersion) + .build()); + getLog().info("Unlocked " + toString(dep) + " to version " + unlockedVersion); } } } } - private void unlockParentSnapshot( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, MojoExecutionException - { - if ( parent == null ) - { - getLog().info( "Project does not have a parent" ); + private void unlockParentSnapshot(ModifiedPomXMLEventReader pom, MavenProject parent) + throws XMLStreamException, MojoExecutionException { + if (parent == null) { + getLog().info("Project does not have a parent"); return; } - if ( reactorProjects.contains( parent ) ) - { - getLog().info( "Project's parent is part of the reactor" ); + if (reactorProjects.contains(parent)) { + getLog().info("Project's parent is part of the reactor"); return; } Artifact parentArtifact = parent.getArtifact(); String parentVersion = parentArtifact.getVersion(); - Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher( parentVersion ); - if ( versionMatcher.find() && versionMatcher.end() == parentVersion.length() ) - { - String unlockedParentVersion = versionMatcher.replaceFirst( "-SNAPSHOT" ); - if ( PomHelper.setProjectParentVersion( pom, unlockedParentVersion ) ) - { - getLog().info( "Unlocked parent " + parentArtifact + " to version " - + unlockedParentVersion ); - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( ChangeRecord.ChangeKind.PARENT ) - .withArtifact( parentArtifact ) - .withNewVersion( unlockedParentVersion ) - .build() ); + Matcher versionMatcher = TIMESTAMPED_SNAPSHOT_REGEX.matcher(parentVersion); + if (versionMatcher.find() && versionMatcher.end() == parentVersion.length()) { + String unlockedParentVersion = versionMatcher.replaceFirst("-SNAPSHOT"); + if (PomHelper.setProjectParentVersion(pom, unlockedParentVersion)) { + getLog().info("Unlocked parent " + parentArtifact + " to version " + unlockedParentVersion); + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(ChangeRecord.ChangeKind.PARENT) + .withArtifact(parentArtifact) + .withNewVersion(unlockedParentVersion) + .build()); } } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java index 6a0bc41362..11fda20899 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateChildModulesMojo.java @@ -47,11 +47,8 @@ * @author Stephen Connolly * @since 1.0-alpha-2 */ -@Mojo( name = "update-child-modules", aggregator = true, - threadSafe = true ) -public class UpdateChildModulesMojo - extends AbstractVersionsUpdaterMojo -{ +@Mojo(name = "update-child-modules", aggregator = true, threadSafe = true) +public class UpdateChildModulesMojo extends AbstractVersionsUpdaterMojo { /** * The groupId that we are updating. Guarded by this. */ @@ -68,12 +65,12 @@ public class UpdateChildModulesMojo private transient String sourceVersion = null; @Inject - public UpdateChildModulesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UpdateChildModulesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -82,81 +79,67 @@ public UpdateChildModulesMojo( RepositorySystem repositorySystem, * @throws MojoExecutionException when things go wrong. * @throws MojoFailureException when things go wrong. */ - public void execute() - throws MojoExecutionException, MojoFailureException - { + public void execute() throws MojoExecutionException, MojoFailureException { boolean didSomething = false; - try - { - final Map reactor = PomHelper.getReactorModels( getProject(), getLog() ); - List order = new ArrayList<>( reactor.keySet() ); - order.sort( - ( o1, o2 ) -> - { - Model m1 = reactor.get( o1 ); - Model m2 = reactor.get( o2 ); - int d1 = PomHelper.getReactorParentCount( reactor, m1 ); - int d2 = PomHelper.getReactorParentCount( reactor, m2 ); - if ( d1 < d2 ) - { - return -1; - } - else if ( d1 > d2 ) - { - return 1; - } - return 0; - } ); - - for ( String sourcePath : order ) - { - Model sourceModel = reactor.get( sourcePath ); - - getLog().debug( sourcePath.length() == 0 ? "Processing root module as parent" - : "Processing " + sourcePath + " as a parent." ); - - synchronized ( this ) - { - sourceGroupId = PomHelper.getGroupId( sourceModel ); - if ( sourceGroupId == null ) - { - getLog().warn( "Module " + sourcePath + " is missing a groupId." ); + try { + final Map reactor = PomHelper.getReactorModels(getProject(), getLog()); + List order = new ArrayList<>(reactor.keySet()); + order.sort((o1, o2) -> { + Model m1 = reactor.get(o1); + Model m2 = reactor.get(o2); + int d1 = PomHelper.getReactorParentCount(reactor, m1); + int d2 = PomHelper.getReactorParentCount(reactor, m2); + if (d1 < d2) { + return -1; + } else if (d1 > d2) { + return 1; + } + return 0; + }); + + for (String sourcePath : order) { + Model sourceModel = reactor.get(sourcePath); + + getLog().debug( + sourcePath.length() == 0 + ? "Processing root module as parent" + : "Processing " + sourcePath + " as a parent."); + + synchronized (this) { + sourceGroupId = PomHelper.getGroupId(sourceModel); + if (sourceGroupId == null) { + getLog().warn("Module " + sourcePath + " is missing a groupId."); continue; } - sourceArtifactId = PomHelper.getArtifactId( sourceModel ); - if ( sourceArtifactId == null ) - { - getLog().warn( "Module " + sourcePath + " is missing an artifactId." ); + sourceArtifactId = PomHelper.getArtifactId(sourceModel); + if (sourceArtifactId == null) { + getLog().warn("Module " + sourcePath + " is missing an artifactId."); continue; } - sourceVersion = PomHelper.getVersion( sourceModel ); - if ( sourceVersion == null ) - { - getLog().warn( "Module " + sourcePath + " is missing a version." ); + sourceVersion = PomHelper.getVersion(sourceModel); + if (sourceVersion == null) { + getLog().warn("Module " + sourcePath + " is missing a version."); continue; } - getLog().debug( "Looking for modules which use " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + " as their parent to update it to " + sourceVersion ); + getLog().debug("Looking for modules which use " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + + " as their parent to update it to " + sourceVersion); - for ( Map.Entry target : PomHelper.getChildModels( reactor, sourceGroupId, - sourceArtifactId ).entrySet() ) - { + for (Map.Entry target : PomHelper.getChildModels( + reactor, sourceGroupId, sourceArtifactId) + .entrySet()) { String targetPath = target.getKey(); - File moduleDir = new File( getProject().getBasedir(), targetPath ); + File moduleDir = new File(getProject().getBasedir(), targetPath); File moduleProjectFile; - if ( moduleDir.isDirectory() ) - { - moduleProjectFile = new File( moduleDir, "pom.xml" ); - } - else - { + if (moduleDir.isDirectory()) { + moduleProjectFile = new File(moduleDir, "pom.xml"); + } else { // i don't think this should ever happen... but just in case // the module references the file-name moduleProjectFile = moduleDir; @@ -164,36 +147,30 @@ else if ( d1 > d2 ) Model targetModel = target.getValue(); final Parent parent = targetModel.getParent(); - if ( sourceVersion.equals( parent.getVersion() ) ) - { - getLog().debug( "Module: " + targetPath + " parent is " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); - } - else - { - getLog().info( "Module: " + targetPath ); - getLog().info( " parent was " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + parent.getVersion() ); - getLog().info( " updated to " - + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); - process( moduleProjectFile ); + if (sourceVersion.equals(parent.getVersion())) { + getLog().debug("Module: " + targetPath + " parent is " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + ":" + + sourceVersion); + } else { + getLog().info("Module: " + targetPath); + getLog().info(" parent was " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + ":" + + parent.getVersion()); + getLog().info(" updated to " + + ArtifactUtils.versionlessKey(sourceGroupId, sourceArtifactId) + ":" + + sourceVersion); + process(moduleProjectFile); didSomething = true; } } } } + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); - } - if ( !didSomething ) - { - getLog().info( "All child modules are up to date." ); + if (!didSomething) { + getLog().info("All child modules are up to date."); } } @@ -205,15 +182,12 @@ else if ( d1 > d2 ) * @throws MojoFailureException when things go wrong. * @throws XMLStreamException when things go wrong. */ - protected synchronized void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - getLog().debug( "Updating parent to " + sourceVersion ); - - if ( PomHelper.setProjectParentVersion( pom, sourceVersion ) ) - { - getLog().debug( "Made an update to " + sourceVersion ); + protected synchronized void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + getLog().debug("Updating parent to " + sourceVersion); + + if (PomHelper.setProjectParentVersion(pom, sourceVersion)) { + getLog().debug("Made an update to " + sourceVersion); } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java index 0841f9e865..3ede5832ac 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdateParentMojo.java @@ -59,9 +59,8 @@ * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-parent", threadSafe = true ) -public class UpdateParentMojo extends AbstractVersionsUpdaterMojo -{ +@Mojo(name = "update-parent", threadSafe = true) +public class UpdateParentMojo extends AbstractVersionsUpdaterMojo { // ------------------------------ FIELDS ------------------------------ @@ -74,7 +73,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * the parent artifact will be updated.

    * @since 1.0-alpha-1 */ - @Parameter( property = "parentVersion" ) + @Parameter(property = "parentVersion") protected String parentVersion = null; /** @@ -82,7 +81,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.9 */ - @Parameter( property = "forceUpdate", defaultValue = "false" ) + @Parameter(property = "forceUpdate", defaultValue = "false") protected boolean forceUpdate = false; /** @@ -91,7 +90,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.13.0 */ - @Parameter( property = "skipResolution", defaultValue = "false" ) + @Parameter(property = "skipResolution", defaultValue = "false") protected boolean skipResolution = false; /** @@ -101,8 +100,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.12.0 */ - @Parameter( property = "allowDowngrade", - defaultValue = "false" ) + @Parameter(property = "allowDowngrade", defaultValue = "false") protected boolean allowDowngrade; /** @@ -110,7 +108,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.13.0 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") protected boolean allowMajorUpdates = true; /** @@ -120,7 +118,7 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.13.0 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") protected boolean allowMinorUpdates = true; /** @@ -131,18 +129,18 @@ public class UpdateParentMojo extends AbstractVersionsUpdaterMojo * * @since 2.13.0 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") protected boolean allowIncrementalUpdates = true; // -------------------------- OTHER METHODS -------------------------- @Inject - public UpdateParentMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UpdateParentMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -153,116 +151,94 @@ public UpdateParentMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - if ( getProject().getParent() == null ) - { - getLog().info( "Project does not have a parent" ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + if (getProject().getParent() == null) { + getLog().info("Project does not have a parent"); return; } - if ( reactorProjects.contains( getProject().getParent() ) ) - { - getLog().info( "Project's parent is part of the reactor" ); + if (reactorProjects.contains(getProject().getParent())) { + getLog().info("Project's parent is part of the reactor"); return; } - if ( skipResolution && isBlank( parentVersion ) ) - { - throw new MojoExecutionException( "skipResolution is only valid if parentVersion is set" ); + if (skipResolution && isBlank(parentVersion)) { + throw new MojoExecutionException("skipResolution is only valid if parentVersion is set"); } - String initialVersion = parentVersion == null - ? getProject().getParent().getVersion() - : parentVersion; - try - { - ArtifactVersion artifactVersion = skipResolution - ? new DefaultArtifactVersion( parentVersion ) - : resolveTargetVersion( initialVersion ); - if ( artifactVersion != null ) - { - getLog().info( "Updating parent from " + getProject().getParent().getVersion() - + " to " + artifactVersion ); - - if ( PomHelper.setProjectParentVersion( pom, artifactVersion.toString() ) ) - { - if ( getLog().isDebugEnabled() ) - { - getLog().debug( "Made an update from " + getProject().getParent().getVersion() - + " to " + artifactVersion ); + String initialVersion = parentVersion == null ? getProject().getParent().getVersion() : parentVersion; + try { + ArtifactVersion artifactVersion = + skipResolution ? new DefaultArtifactVersion(parentVersion) : resolveTargetVersion(initialVersion); + if (artifactVersion != null) { + getLog().info("Updating parent from " + getProject().getParent().getVersion() + " to " + + artifactVersion); + + if (PomHelper.setProjectParentVersion(pom, artifactVersion.toString())) { + if (getLog().isDebugEnabled()) { + getLog().debug("Made an update from " + + getProject().getParent().getVersion() + " to " + artifactVersion); } - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( ChangeRecord.ChangeKind.PARENT ) - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withOldVersion( getProject().getParent().getVersion() ) - .withNewVersion( artifactVersion.toString() ) - .build() ); + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(ChangeRecord.ChangeKind.PARENT) + .withGroupId(getProject().getParent().getGroupId()) + .withArtifactId(getProject().getParent().getArtifactId()) + .withOldVersion(getProject().getParent().getVersion()) + .withNewVersion(artifactVersion.toString()) + .build()); } } - } - catch ( InvalidVersionSpecificationException e ) - { - throw new MojoExecutionException( "Invalid version range specification: " + initialVersion, e ); - } - catch ( InvalidSegmentException e ) - { - throw new MojoExecutionException( "Invalid segment specification for version " + initialVersion, e ); + } catch (InvalidVersionSpecificationException e) { + throw new MojoExecutionException("Invalid version range specification: " + initialVersion, e); + } catch (InvalidSegmentException e) { + throw new MojoExecutionException("Invalid segment specification for version " + initialVersion, e); } } - protected ArtifactVersion resolveTargetVersion( String initialVersion ) + protected ArtifactVersion resolveTargetVersion(String initialVersion) throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, - InvalidSegmentException - { - Artifact artifact = getHelper().createDependencyArtifact( DependencyBuilder - .newBuilder() - .withGroupId( getProject().getParent().getGroupId() ) - .withArtifactId( getProject().getParent().getArtifactId() ) - .withVersion( initialVersion ) - .withType( "pom" ) - .build() ); - - VersionRange targetVersionRange = VersionRange.createFromVersionSpec( initialVersion ); - if ( targetVersionRange.getRecommendedVersion() != null ) - { + InvalidSegmentException { + Artifact artifact = getHelper() + .createDependencyArtifact(DependencyBuilder.newBuilder() + .withGroupId(getProject().getParent().getGroupId()) + .withArtifactId(getProject().getParent().getArtifactId()) + .withVersion(initialVersion) + .withType("pom") + .build()); + + VersionRange targetVersionRange = VersionRange.createFromVersionSpec(initialVersion); + if (targetVersionRange.getRecommendedVersion() != null) { targetVersionRange = targetVersionRange.restrict( - VersionRange.createFromVersionSpec( "[" + targetVersionRange.getRecommendedVersion() + ",)" ) ); + VersionRange.createFromVersionSpec("[" + targetVersionRange.getRecommendedVersion() + ",)")); } - final ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, - allowMinorUpdates, allowIncrementalUpdates, getLog() ); + final ArtifactVersions versions = getHelper().lookupArtifactVersions(artifact, false); + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); // currentVersion (set to parentVersion here) is not included in the version range for searching upgrades // unless we set allowDowngrade to true - for ( ArtifactVersion candidate : reverse( versions.getNewerVersions( initialVersion, unchangedSegment, - allowSnapshots, !isBlank( parentVersion ) || allowDowngrade ) ) ) - { - if ( allowDowngrade + for (ArtifactVersion candidate : reverse(versions.getNewerVersions( + initialVersion, unchangedSegment, allowSnapshots, !isBlank(parentVersion) || allowDowngrade))) { + if (allowDowngrade || targetVersionRange == null - || ArtifactVersions.isVersionInRange( candidate, targetVersionRange ) ) - { - if ( shouldApplyUpdate( artifact, getProject().getParent().getVersion(), candidate, forceUpdate ) ) - { + || ArtifactVersions.isVersionInRange(candidate, targetVersionRange)) { + if (shouldApplyUpdate(artifact, getProject().getParent().getVersion(), candidate, forceUpdate)) { return candidate; - } - else - { - getLog().debug( "Update not applied. Exiting." ); + } else { + getLog().debug("Update not applied. Exiting."); return null; } } } - getLog().info( "No versions found" ); + getLog().info("No versions found"); return null; } - private static Iterable reverse( T[] array ) - { - return Arrays.stream( array ).sorted( Collections.reverseOrder() ).collect( Collectors.toList() ); + private static Iterable reverse(T[] array) { + return Arrays.stream(array).sorted(Collections.reverseOrder()).collect(Collectors.toList()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java index a91837629b..12da4e4fbb 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojo.java @@ -19,6 +19,11 @@ * under the License. */ +import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; + +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -30,19 +35,14 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; -import java.util.Map; - /** * Sets properties to the latest versions of specific artifacts. * * @author Stephen Connolly * @since 1.0-alpha-1 */ -@Mojo( name = "update-properties", threadSafe = true ) -public class UpdatePropertiesMojo extends UpdatePropertiesMojoBase -{ +@Mojo(name = "update-properties", threadSafe = true) +public class UpdatePropertiesMojo extends UpdatePropertiesMojoBase { /** * Any restrictions that apply to specific properties. * @@ -56,7 +56,7 @@ public class UpdatePropertiesMojo extends UpdatePropertiesMojoBase * * @since 1.0-alpha-1 */ - @Parameter( property = "includeProperties" ) + @Parameter(property = "includeProperties") private String includeProperties = null; /** @@ -64,16 +64,16 @@ public class UpdatePropertiesMojo extends UpdatePropertiesMojoBase * * @since 1.0-alpha-1 */ - @Parameter( property = "excludeProperties" ) + @Parameter(property = "excludeProperties") private String excludeProperties = null; @Inject - public UpdatePropertiesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UpdatePropertiesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -84,18 +84,18 @@ public UpdatePropertiesMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - update( pom, getHelper().getVersionPropertiesMap( - VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( properties ) - .withIncludeProperties( includeProperties ) - .withExcludeProperties( excludeProperties ) - .withAutoLinkItems( autoLinkItems ) - .withIncludeParent( includeParent ) - .build() ) ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + update( + pom, + getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .withPropertyDefinitions(properties) + .withIncludeProperties(includeProperties) + .withExcludeProperties(excludeProperties) + .withAutoLinkItems(autoLinkItems) + .withIncludeParent(includeParent) + .build())); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java index 8baa1eda0b..40f1d87aaf 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertiesMojoBase.java @@ -18,6 +18,11 @@ * under the License. */ +import javax.xml.stream.XMLStreamException; + +import java.util.Map; +import java.util.Optional; + import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.plugin.MojoExecutionException; @@ -34,24 +39,19 @@ import org.codehaus.mojo.versions.recording.DefaultChangeRecord; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.xml.stream.XMLStreamException; -import java.util.Map; -import java.util.Optional; - import static org.codehaus.mojo.versions.utils.SegmentUtils.determineUnchangedSegment; /** * Common base class for {@link UpdatePropertiesMojo} * and {@link UpdatePropertyMojo} */ -public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependencyUpdaterMojo -{ +public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependencyUpdaterMojo { /** * Whether properties linking versions should be auto-detected or not. * * @since 1.0-alpha-2 */ - @Parameter( property = "autoLinkItems", defaultValue = "true" ) + @Parameter(property = "autoLinkItems", defaultValue = "true") protected boolean autoLinkItems; /** @@ -61,7 +61,7 @@ public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependenc * * @since 3.0.0 */ - @Parameter( property = "allowDowngrade", defaultValue = "false" ) + @Parameter(property = "allowDowngrade", defaultValue = "false") protected boolean allowDowngrade; /** @@ -69,7 +69,7 @@ public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependenc * * @since 2.4 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") protected boolean allowMajorUpdates; /** @@ -79,7 +79,7 @@ public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependenc * * @since 2.4 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") protected boolean allowMinorUpdates; /** @@ -90,7 +90,7 @@ public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependenc * * @since 2.4 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") protected boolean allowIncrementalUpdates; /** @@ -100,80 +100,66 @@ public abstract class UpdatePropertiesMojoBase extends AbstractVersionsDependenc * * @since 2.14.0 */ - - @Parameter( property = "includeParent", defaultValue = "true" ) + @Parameter(property = "includeParent", defaultValue = "true") protected boolean includeParent = true; - public UpdatePropertiesMojoBase( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UpdatePropertiesMojoBase( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } - protected void update( ModifiedPomXMLEventReader pom, Map propertyVersions ) - throws XMLStreamException - { - for ( Map.Entry entry : propertyVersions.entrySet() ) - { + protected void update(ModifiedPomXMLEventReader pom, Map propertyVersions) + throws XMLStreamException { + for (Map.Entry entry : propertyVersions.entrySet()) { Property property = entry.getKey(); PropertyVersions version = entry.getValue(); - final String currentVersion = getProject().getProperties().getProperty( property.getName() ); - if ( currentVersion == null ) - { + final String currentVersion = getProject().getProperties().getProperty(property.getName()); + if (currentVersion == null) { continue; } boolean canUpdateProperty = true; - for ( ArtifactAssociation association : version.getAssociations() ) - { - if ( !( isIncluded( association.getArtifact() ) ) ) - { - getLog().info( - "Not updating the property ${" + property.getName() + "} because it is used by artifact " - + association.getArtifact().toString() - + " and that artifact is not included in the list of " - + " allowed artifacts to be updated." ); + for (ArtifactAssociation association : version.getAssociations()) { + if (!(isIncluded(association.getArtifact()))) { + getLog().info("Not updating the property ${" + property.getName() + + "} because it is used by artifact " + + association.getArtifact().toString() + + " and that artifact is not included in the list of " + + " allowed artifacts to be updated."); canUpdateProperty = false; break; } } - if ( canUpdateProperty ) - { - Optional unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ); - try - { - ArtifactVersion targetVersion = - updatePropertyToNewestVersion( pom, property, version, currentVersion, - allowDowngrade, unchangedSegment ); - - if ( targetVersion != null ) - { - for ( final ArtifactAssociation association : version.getAssociations() ) - { - if ( ( isIncluded( association.getArtifact() ) ) ) - { - getChangeRecorder().recordChange( DefaultChangeRecord.builder() - .withKind( - ChangeRecord.ChangeKind.PROPERTY ) - .withArtifact( association.getArtifact() ) - .withOldVersion( currentVersion ) - .withNewVersion( targetVersion.toString() ) - .build() ); + if (canUpdateProperty) { + Optional unchangedSegment = determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); + try { + ArtifactVersion targetVersion = updatePropertyToNewestVersion( + pom, property, version, currentVersion, allowDowngrade, unchangedSegment); + + if (targetVersion != null) { + for (final ArtifactAssociation association : version.getAssociations()) { + if ((isIncluded(association.getArtifact()))) { + getChangeRecorder() + .recordChange(DefaultChangeRecord.builder() + .withKind(ChangeRecord.ChangeKind.PROPERTY) + .withArtifact(association.getArtifact()) + .withOldVersion(currentVersion) + .withNewVersion(targetVersion.toString()) + .build()); } } } - } - catch ( InvalidSegmentException | InvalidVersionSpecificationException | MojoExecutionException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s due to: %s", property.getName(), - property.getVersion(), e.getMessage() ) ); + } catch (InvalidSegmentException | InvalidVersionSpecificationException | MojoExecutionException e) { + getLog().warn(String.format( + "Skipping the processing of %s:%s due to: %s", + property.getName(), property.getVersion(), e.getMessage())); } } - } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java index 2fc55cf48e..a541fbf139 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UpdatePropertyMojo.java @@ -19,6 +19,11 @@ * under the License. */ +import javax.inject.Inject; +import javax.xml.stream.XMLStreamException; + +import java.util.Map; + import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; @@ -30,25 +35,20 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecorder; import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader; -import javax.inject.Inject; -import javax.xml.stream.XMLStreamException; -import java.util.Map; - /** * Sets a property to the latest version in a given range of associated artifacts. * * @author Eric Pabst * @since 1.3 */ -@Mojo( name = "update-property", threadSafe = true ) -public class UpdatePropertyMojo extends UpdatePropertiesMojoBase -{ +@Mojo(name = "update-property", threadSafe = true) +public class UpdatePropertyMojo extends UpdatePropertiesMojoBase { /** * A property to update. * * @since 1.3 */ - @Parameter( property = "property" ) + @Parameter(property = "property") protected String property = null; /** @@ -67,16 +67,16 @@ public class UpdatePropertyMojo extends UpdatePropertiesMojoBase * * @since 1.3 */ - @Parameter( property = "newVersion" ) + @Parameter(property = "newVersion") private String newVersion = null; @Inject - public UpdatePropertyMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UpdatePropertyMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -87,20 +87,23 @@ public UpdatePropertyMojo( RepositorySystem repositorySystem, * @see AbstractVersionsUpdaterMojo#update(ModifiedPomXMLEventReader) * @since 1.0-alpha-1 */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException - { - update( pom, getHelper().getVersionPropertiesMap( - VersionsHelper.VersionPropertiesMapRequest.builder() - .withMavenProject( getProject() ) - .withPropertyDefinitions( new Property[] { new Property( property ) - {{ - setVersion( newVersion ); - }} } ) - .withIncludeProperties( property ) - .withAutoLinkItems( autoLinkItems ) - .withIncludeParent( includeParent ) - .build() ) ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException { + update( + pom, + getHelper() + .getVersionPropertiesMap(VersionsHelper.VersionPropertiesMapRequest.builder() + .withMavenProject(getProject()) + .withPropertyDefinitions(new Property[] { + new Property(property) { + { + setVersion(newVersion); + } + } + }) + .withIncludeProperties(property) + .withAutoLinkItems(autoLinkItems) + .withIncludeParent(includeParent) + .build())); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java index 1972443640..70c06daf60 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseDepVersionMojo.java @@ -52,117 +52,96 @@ * @author Dan Arcari * @since 2.3 */ -@Mojo( name = "use-dep-version", threadSafe = true ) -public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "use-dep-version", threadSafe = true) +public class UseDepVersionMojo extends AbstractVersionsDependencyUpdaterMojo { /** * The exact version to be applied for the included dependencies */ - @Parameter( property = "depVersion", - required = true ) + @Parameter(property = "depVersion", required = true) protected String depVersion; /** * If set to true, will use whatever version is supplied without attempting to validate that such a version is * obtainable from the repository chain. */ - @Parameter( property = "forceVersion", - defaultValue = "false" ) + @Parameter(property = "forceVersion", defaultValue = "false") protected boolean forceVersion; @Inject - public UseDepVersionMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseDepVersionMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } @Override - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { - if ( depVersion == null || depVersion.equals( "" ) ) - { + if (depVersion == null || depVersion.equals("")) { throw new IllegalArgumentException( - "depVersion must be supplied with use-specific-version, and cannot be blank." ); + "depVersion must be supplied with use-specific-version, and cannot be blank."); } - if ( !forceVersion && !hasIncludes() ) - { + if (!forceVersion && !hasIncludes()) { throw new IllegalArgumentException( - "The use-specific-version goal is intended to be used with a single artifact. " - + "Please specify a value for the 'includes' parameter, " - + "or use -DforceVersion=true to override this check." ); + "The use-specific-version goal is intended to be used with a single artifact. " + + "Please specify a value for the 'includes' parameter, " + + "or use -DforceVersion=true to override this check."); } - try - { - if ( isProcessingDependencyManagement() ) - { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useDepVersion( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useDepVersion( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useDepVersion( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useDepVersion(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useDepVersion( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useDepVersion(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useDepVersion( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws MojoExecutionException, XMLStreamException, VersionRetrievalException - { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + private void useDepVersion( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws MojoExecutionException, XMLStreamException, VersionRetrievalException { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - Artifact artifact = this.toArtifact( dep ); + Artifact artifact = this.toArtifact(dep); - if ( isIncluded( artifact ) ) - { - if ( !forceVersion ) - { - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); + if (isIncluded(artifact)) { + if (!forceVersion) { + ArtifactVersions versions = getHelper().lookupArtifactVersions(artifact, false); - if ( !versions.containsVersion( depVersion ) ) - { - throw new MojoExecutionException( - String.format( "Version %s is not available for artifact %s:%s", - depVersion, artifact.getGroupId(), artifact.getArtifactId() ) ); + if (!versions.containsVersion(depVersion)) { + throw new MojoExecutionException(String.format( + "Version %s is not available for artifact %s:%s", + depVersion, artifact.getGroupId(), artifact.getArtifactId())); } } - updateDependencyVersion( pom, dep, depVersion, changeKind ); + updateDependencyVersion(pom, dep, depVersion, changeKind); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java index 5202196bc5..44c5d57c7a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestReleasesMojo.java @@ -62,10 +62,8 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-latest-releases", threadSafe = true ) -public class UseLatestReleasesMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-latest-releases", threadSafe = true) +public class UseLatestReleasesMojo extends UseLatestVersionsMojoBase { // ------------------------------ FIELDS ------------------------------ @@ -74,7 +72,7 @@ public class UseLatestReleasesMojo * * @since 1.2 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") protected boolean allowMajorUpdates = true; /** @@ -84,7 +82,7 @@ public class UseLatestReleasesMojo * * @since 1.2 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") protected boolean allowMinorUpdates = true; /** @@ -95,18 +93,18 @@ public class UseLatestReleasesMojo * * @since 1.2 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") protected boolean allowIncrementalUpdates = true; // ------------------------------ METHODS -------------------------- @Inject - public UseLatestReleasesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseLatestReleasesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -116,60 +114,50 @@ public UseLatestReleasesMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useLatestReleases( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useLatestReleases( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useLatestReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useLatestReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useLatestReleases( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useLatestReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, - allowMinorUpdates, allowIncrementalUpdates, getLog() ); - - useLatestVersions( pom, dependencies, - ( dep, versions ) -> - { - try - { - return getLastFiltered( versions.getNewerVersions( dep.getVersion(), unchangedSegment, - false, false ), dep ); - } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", - dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + private void useLatestReleases( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); + + useLatestVersions( + pom, + dependencies, + (dep, versions) -> { + try { + return getLastFiltered( + versions.getNewerVersions(dep.getVersion(), unchangedSegment, false, false), dep); + } catch (InvalidSegmentException e) { + getLog().warn(String.format( + "Skipping the processing of %s:%s:%s due to: %s", + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage())); } return empty(); }, - changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + changeKind, + dep -> !SNAPSHOT_REGEX.matcher(dep.getVersion()).matches()); } /** @@ -180,18 +168,20 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection getLastFiltered( ArtifactVersion[] newer, Dependency dependency ) - { - return Arrays.stream( newer ) - .filter( version -> - { - Artifact artefactWithNewVersion = - new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), - VersionRange.createFromVersion( version.toString() ), dependency.getScope(), - dependency.getType(), null, new DefaultArtifactHandler(), false ); - return isIncluded( artefactWithNewVersion ); - } ) - .reduce( ( v1, v2 ) -> v2 ); + private Optional getLastFiltered(ArtifactVersion[] newer, Dependency dependency) { + return Arrays.stream(newer) + .filter(version -> { + Artifact artefactWithNewVersion = new DefaultArtifact( + dependency.getGroupId(), + dependency.getArtifactId(), + VersionRange.createFromVersion(version.toString()), + dependency.getScope(), + dependency.getType(), + null, + new DefaultArtifactHandler(), + false); + return isIncluded(artefactWithNewVersion); + }) + .reduce((v1, v2) -> v2); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java index f1f86dfa82..4f7b38636c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestSnapshotsMojo.java @@ -55,17 +55,15 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "use-latest-snapshots", threadSafe = true ) -public class UseLatestSnapshotsMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-latest-snapshots", threadSafe = true) +public class UseLatestSnapshotsMojo extends UseLatestVersionsMojoBase { /** * Whether to allow the major version number to be changed. * * @since 1.0-beta-1 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "false" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "false") protected boolean allowMajorUpdates; /** @@ -74,7 +72,7 @@ public class UseLatestSnapshotsMojo *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.0-beta-1 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "false" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "false") protected boolean allowMinorUpdates; /** @@ -84,18 +82,18 @@ public class UseLatestSnapshotsMojo * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.0-beta-1 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") protected boolean allowIncrementalUpdates; // ------------------------------ METHODS -------------------------- @Inject - public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseLatestSnapshotsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -105,60 +103,49 @@ public UseLatestSnapshotsMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useLatestSnapshots( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useLatestSnapshots( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useLatestSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useLatestSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useLatestSnapshots( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useLatestSnapshots(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, - allowMinorUpdates, allowIncrementalUpdates, getLog() ); + private void useLatestSnapshots( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); - useLatestVersions( pom, dependencies, - ( dep, versions ) -> - { - try - { - return Arrays.stream( versions.getNewerVersions( dep.getVersion(), unchangedSegment, - true, false ) ) - .filter( v -> SNAPSHOT_REGEX.matcher( v.toString() ).matches() ) - .max( Comparator.naturalOrder() ); - } - catch ( InvalidSegmentException e ) - { - getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); + useLatestVersions( + pom, + dependencies, + (dep, versions) -> { + try { + return Arrays.stream(versions.getNewerVersions(dep.getVersion(), unchangedSegment, true, false)) + .filter(v -> + SNAPSHOT_REGEX.matcher(v.toString()).matches()) + .max(Comparator.naturalOrder()); + } catch (InvalidSegmentException e) { + getLog().info("Ignoring " + toString(dep) + " as the version number is too short"); return empty(); } }, - changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + changeKind, + dep -> !SNAPSHOT_REGEX.matcher(dep.getVersion()).matches()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java index 8021f2fb38..a600a98ce7 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java @@ -53,16 +53,14 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-latest-versions", threadSafe = true ) -public class UseLatestVersionsMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-latest-versions", threadSafe = true) +public class UseLatestVersionsMojo extends UseLatestVersionsMojoBase { /** * Whether to allow the major version number to be changed. * * @since 1.2 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "true") private boolean allowMajorUpdates = true; /** @@ -71,7 +69,7 @@ public class UseLatestVersionsMojo *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.2 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "true" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "true") private boolean allowMinorUpdates = true; /** @@ -81,7 +79,7 @@ public class UseLatestVersionsMojo * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.2 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates = true; /** @@ -91,27 +89,24 @@ public class UseLatestVersionsMojo * * @since 2.12.0 */ - @Parameter( property = "allowDowngrade", - defaultValue = "false" ) + @Parameter(property = "allowDowngrade", defaultValue = "false") private boolean allowDowngrade; // ------------------------------ METHODS -------------------------- @Inject - public UseLatestVersionsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseLatestVersionsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } @Override - public void execute() throws MojoExecutionException, MojoFailureException - { - if ( allowDowngrade && allowSnapshots ) - { - throw new MojoExecutionException( "allowDowngrade is only valid with allowSnapshots equal to false" ); + public void execute() throws MojoExecutionException, MojoFailureException { + if (allowDowngrade && allowSnapshots) { + throw new MojoExecutionException("allowDowngrade is only valid with allowSnapshots equal to false"); } super.execute(); } @@ -123,58 +118,48 @@ public void execute() throws MojoExecutionException, MojoFailureException * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useLatestVersions( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useLatestVersions( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useLatestVersions( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useLatestVersions(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useLatestVersions( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useLatestVersions(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, - allowMinorUpdates, allowIncrementalUpdates, getLog() ); + private void useLatestVersions( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); - useLatestVersions( pom, dependencies, - ( dep, versions ) -> - { - try - { - return versions.getNewestVersion( dep.getVersion(), unchangedSegment, allowSnapshots, - allowDowngrade ); - } - catch ( InvalidSegmentException e ) - { - getLog().warn( String.format( "Skipping the processing of %s:%s:%s due to: %s", - dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage() ) ); + useLatestVersions( + pom, + dependencies, + (dep, versions) -> { + try { + return versions.getNewestVersion( + dep.getVersion(), unchangedSegment, allowSnapshots, allowDowngrade); + } catch (InvalidSegmentException e) { + getLog().warn(String.format( + "Skipping the processing of %s:%s:%s due to: %s", + dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), e.getMessage())); } return empty(); - }, changeKind ); + }, + changeKind); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java index 1b76bd9e0c..41c7692001 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojoBase.java @@ -45,15 +45,13 @@ * Common base class for {@link UseLatestVersionsMojo} * and {@link UseLatestReleasesMojo} */ -public abstract class UseLatestVersionsMojoBase - extends AbstractVersionsDependencyUpdaterMojo -{ - public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); +public abstract class UseLatestVersionsMojoBase extends AbstractVersionsDependencyUpdaterMojo { + public UseLatestVersionsMojoBase( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -71,50 +69,43 @@ public UseLatestVersionsMojoBase( RepositorySystem repositorySystem, * @throws VersionRetrievalException thrown if an artifact versions cannot be retrieved */ @SafeVarargs - protected final void useLatestVersions( ModifiedPomXMLEventReader pom, - Collection dependencies, - BiFunction> - newestVersionProducer, - ChangeRecord.ChangeKind changeKind, - Predicate... filters ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - for ( Dependency dep : dependencies ) - { - if ( !Arrays.stream( filters ) - .map( f -> f.test( dep ) ) - .reduce( Boolean::logicalAnd ) - .orElse( true ) ) - { + protected final void useLatestVersions( + ModifiedPomXMLEventReader pom, + Collection dependencies, + BiFunction> newestVersionProducer, + ChangeRecord.ChangeKind changeKind, + Predicate... filters) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + for (Dependency dep : dependencies) { + if (!Arrays.stream(filters) + .map(f -> f.test(dep)) + .reduce(Boolean::logicalAnd) + .orElse(true)) { continue; } - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } - Artifact artifact = toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { + Artifact artifact = toArtifact(dep); + if (!isIncluded(artifact)) { continue; } - ArtifactVersion selectedVersion = new DefaultArtifactVersion( dep.getVersion() ); - getLog().debug( "Selected version:" + selectedVersion ); - getLog().debug( "Looking for newer versions of " + toString( dep ) ); - ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false ); - Optional newestVer = newestVersionProducer.apply( dep, versions ); - if ( newestVer.isPresent() ) - { - updateDependencyVersion( pom, dep, newestVer.get().toString(), changeKind ); + ArtifactVersion selectedVersion = new DefaultArtifactVersion(dep.getVersion()); + getLog().debug("Selected version:" + selectedVersion); + getLog().debug("Looking for newer versions of " + toString(dep)); + ArtifactVersions versions = getHelper().lookupArtifactVersions(artifact, false); + Optional newestVer = newestVersionProducer.apply(dep, versions); + if (newestVer.isPresent()) { + updateDependencyVersion(pom, dep, newestVer.get().toString(), changeKind); } } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java index 70e86055e1..ca5bb9b027 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextReleasesMojo.java @@ -49,27 +49,25 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-next-releases", threadSafe = true ) -public class UseNextReleasesMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-next-releases", threadSafe = true) +public class UseNextReleasesMojo extends UseLatestVersionsMojoBase { // ------------------------------ FIELDS ------------------------------ /** * Pattern to match a snapshot version. */ - private static final Pattern MATCH_SNAPSHOT_REGEX = Pattern.compile( "^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$" ); + private static final Pattern MATCH_SNAPSHOT_REGEX = Pattern.compile("^(.+)-((SNAPSHOT)|(\\d{8}\\.\\d{6}-\\d+))$"); // ------------------------------ METHODS -------------------------- @Inject - public UseNextReleasesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseNextReleasesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -79,45 +77,38 @@ public UseNextReleasesMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useNextReleases( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useNextReleases( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useNextReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useNextReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useNextReleases( pom, singletonList( getParentDependency() ), ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useNextReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useNextReleases( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - useLatestVersions( pom, dependencies, - ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), false )[0] ), - changeKind, - dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + private void useNextReleases( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + useLatestVersions( + pom, + dependencies, + (dep, versions) -> of(versions.getNewerVersions(dep.getVersion(), false)[0]), + changeKind, + dep -> !SNAPSHOT_REGEX.matcher(dep.getVersion()).matches()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java index 7d5483afa1..12378ad8ca 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextSnapshotsMojo.java @@ -54,17 +54,15 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -@Mojo( name = "use-next-snapshots", threadSafe = true ) -public class UseNextSnapshotsMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-next-snapshots", threadSafe = true) +public class UseNextSnapshotsMojo extends UseLatestVersionsMojoBase { /** * Whether to allow the major version number to be changed. * * @since 1.0-beta-1 */ - @Parameter( property = "allowMajorUpdates", defaultValue = "false" ) + @Parameter(property = "allowMajorUpdates", defaultValue = "false") private boolean allowMajorUpdates; /** @@ -73,7 +71,7 @@ public class UseNextSnapshotsMojo *

    Note: {@code false} also implies {@linkplain #allowMajorUpdates} {@code false}

    * @since 1.0-beta-1 */ - @Parameter( property = "allowMinorUpdates", defaultValue = "false" ) + @Parameter(property = "allowMinorUpdates", defaultValue = "false") private boolean allowMinorUpdates; /** @@ -83,18 +81,18 @@ public class UseNextSnapshotsMojo * and {@linkplain #allowMinorUpdates} {@code false}

    * @since 1.0-beta-1 */ - @Parameter( property = "allowIncrementalUpdates", defaultValue = "true" ) + @Parameter(property = "allowIncrementalUpdates", defaultValue = "true") private boolean allowIncrementalUpdates; // ------------------------------ METHODS -------------------------- @Inject - public UseNextSnapshotsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseNextSnapshotsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); // the below is necessary for UseLatestVersionsMojoBase.useLatestVersions to select snapshots allowSnapshots = true; } @@ -106,57 +104,47 @@ public UseNextSnapshotsMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useNextSnapshots( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useNextSnapshots( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useNextSnapshots( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useNextSnapshots(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useNextSnapshots( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useNextSnapshots(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useNextSnapshots( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - Optional - unchangedSegment = SegmentUtils.determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, - allowIncrementalUpdates, getLog() ); + private void useNextSnapshots( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + Optional unchangedSegment = SegmentUtils.determineUnchangedSegment( + allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates, getLog()); - useLatestVersions( pom, dependencies, - ( dep, versions ) -> - { - try - { - return Arrays.stream( versions.getNewerVersions( dep.getVersion(), unchangedSegment, - true, false ) ) - .filter( v -> SNAPSHOT_REGEX.matcher( v.toString() ).matches() ) + useLatestVersions( + pom, + dependencies, + (dep, versions) -> { + try { + return Arrays.stream(versions.getNewerVersions(dep.getVersion(), unchangedSegment, true, false)) + .filter(v -> + SNAPSHOT_REGEX.matcher(v.toString()).matches()) .findFirst(); - } - catch ( InvalidSegmentException e ) - { - getLog().info( "Ignoring " + toString( dep ) + " as the version number is too short" ); + } catch (InvalidSegmentException e) { + getLog().info("Ignoring " + toString(dep) + " as the version number is too short"); return empty(); } - }, changeKind, dep -> !SNAPSHOT_REGEX.matcher( dep.getVersion() ).matches() ); + }, + changeKind, + dep -> !SNAPSHOT_REGEX.matcher(dep.getVersion()).matches()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java index 67abe9b090..7e3654f79b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseNextVersionsMojo.java @@ -48,20 +48,18 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-next-versions", threadSafe = true ) -public class UseNextVersionsMojo - extends UseLatestVersionsMojoBase -{ +@Mojo(name = "use-next-versions", threadSafe = true) +public class UseNextVersionsMojo extends UseLatestVersionsMojoBase { // ------------------------------ METHODS -------------------------- @Inject - public UseNextVersionsMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseNextVersionsMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -71,43 +69,35 @@ public UseNextVersionsMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useNextVersions( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useNextVersions( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useNextVersions( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useNextVersions(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useNextVersions( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useNextVersions(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useNextVersions( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - useLatestVersions( pom, dependencies, - ( dep, versions ) -> of( versions.getNewerVersions( dep.getVersion(), allowSnapshots )[0] ), - changeKind ); + private void useNextVersions( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + useLatestVersions( + pom, + dependencies, + (dep, versions) -> of(versions.getNewerVersions(dep.getVersion(), allowSnapshots)[0]), + changeKind); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java index 552dda2e82..3ea2f47113 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java @@ -47,20 +47,18 @@ * @author Stephen Connolly * @since 2.2 */ -@Mojo( name = "use-reactor", threadSafe = true ) -public class UseReactorMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "use-reactor", threadSafe = true) +public class UseReactorMojo extends AbstractVersionsDependencyUpdaterMojo { // ------------------------------ METHODS -------------------------- @Inject - public UseReactorMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseReactorMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -70,58 +68,49 @@ public UseReactorMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingParent() && getProject().hasParent() ) - { - useReactor( pom, getProject().getParent() ); + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingParent() && getProject().hasParent()) { + useReactor(pom, getProject().getParent()); } - if ( isProcessingDependencyManagement() ) - { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useReactor( pom, dependencyManagement.getDependencies() ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useReactor(pom, dependencyManagement.getDependencies()); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useReactor( pom, getProject().getDependencies() ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useReactor(pom, getProject().getDependencies()); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useReactor( ModifiedPomXMLEventReader pom, Collection dependencies ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { + private void useReactor(ModifiedPomXMLEventReader pom, Collection dependencies) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { - for ( Dependency dep : dependencies ) - { - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { + for (Dependency dep : dependencies) { + Artifact artifact = this.toArtifact(dep); + if (!isIncluded(artifact)) { continue; } - for ( MavenProject reactorProject : reactorProjects ) - { + for (MavenProject reactorProject : reactorProjects) { MavenProject project = reactorProject; - if ( StringUtils.equals( project.getGroupId(), dep.getGroupId() ) - && StringUtils.equals( project.getArtifactId(), dep.getArtifactId() ) - && !StringUtils.equals( project.getVersion(), dep.getVersion() ) ) - { - if ( PomHelper.setDependencyVersion( pom, dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), - project.getVersion(), getProject().getModel() ) ) - { - getLog().info( "Updated " + toString( dep ) + " to version " + project.getVersion() ); + if (StringUtils.equals(project.getGroupId(), dep.getGroupId()) + && StringUtils.equals(project.getArtifactId(), dep.getArtifactId()) + && !StringUtils.equals(project.getVersion(), dep.getVersion())) { + if (PomHelper.setDependencyVersion( + pom, + dep.getGroupId(), + dep.getArtifactId(), + dep.getVersion(), + project.getVersion(), + getProject().getModel())) { + getLog().info("Updated " + toString(dep) + " to version " + project.getVersion()); } break; } @@ -129,22 +118,16 @@ private void useReactor( ModifiedPomXMLEventReader pom, Collection d } } - private void useReactor( ModifiedPomXMLEventReader pom, MavenProject parent ) - throws XMLStreamException, VersionRetrievalException - { - for ( MavenProject project : reactorProjects ) - { - if ( StringUtils.equals( project.getGroupId(), parent.getGroupId() ) - && StringUtils.equals( project.getArtifactId(), parent.getArtifactId() ) - && !StringUtils.equals( project.getVersion(), parent.getVersion() ) ) - { - if ( PomHelper.setProjectParentVersion( pom, project.getVersion() ) ) - { - getLog().info( "Updated parent " + toString( parent ) + " to version " + project.getVersion() ); + private void useReactor(ModifiedPomXMLEventReader pom, MavenProject parent) + throws XMLStreamException, VersionRetrievalException { + for (MavenProject project : reactorProjects) { + if (StringUtils.equals(project.getGroupId(), parent.getGroupId()) + && StringUtils.equals(project.getArtifactId(), parent.getArtifactId()) + && !StringUtils.equals(project.getVersion(), parent.getVersion())) { + if (PomHelper.setProjectParentVersion(pom, project.getVersion())) { + getLog().info("Updated parent " + toString(parent) + " to version " + project.getVersion()); } } - } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java index 89ffbf8938..7bdda8be44 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseReleasesMojo.java @@ -54,10 +54,8 @@ * @author Stephen Connolly * @since 1.0-alpha-3 */ -@Mojo( name = "use-releases", threadSafe = true ) -public class UseReleasesMojo - extends AbstractVersionsDependencyUpdaterMojo -{ +@Mojo(name = "use-releases", threadSafe = true) +public class UseReleasesMojo extends AbstractVersionsDependencyUpdaterMojo { /** *

    When set to {@code true}, will use the highest found release version matching a string @@ -68,7 +66,7 @@ public class UseReleasesMojo * * @since 2.3 */ - @Parameter( property = "allowRangeMatching", defaultValue = "false" ) + @Parameter(property = "allowRangeMatching", defaultValue = "false") private boolean allowRangeMatching; /** @@ -76,18 +74,18 @@ public class UseReleasesMojo * * @since 2.3 */ - @Parameter( property = "failIfNotReplaced", defaultValue = "false" ) + @Parameter(property = "failIfNotReplaced", defaultValue = "false") protected boolean failIfNotReplaced; // ------------------------------ METHODS -------------------------- @Inject - public UseReleasesMojo( RepositorySystem repositorySystem, - org.eclipse.aether.RepositorySystem aetherRepositorySystem, - Map wagonMap, - Map changeRecorders ) - { - super( repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders ); + public UseReleasesMojo( + RepositorySystem repositorySystem, + org.eclipse.aether.RepositorySystem aetherRepositorySystem, + Map wagonMap, + Map changeRecorders) { + super(repositorySystem, aetherRepositorySystem, wagonMap, changeRecorders); } /** @@ -97,105 +95,86 @@ public UseReleasesMojo( RepositorySystem repositorySystem, * @throws javax.xml.stream.XMLStreamException when things go wrong with XML streaming * @see org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo#update(org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader) */ - protected void update( ModifiedPomXMLEventReader pom ) - throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException - { - try - { - if ( isProcessingDependencyManagement() ) - { + protected void update(ModifiedPomXMLEventReader pom) + throws MojoExecutionException, MojoFailureException, XMLStreamException, VersionRetrievalException { + try { + if (isProcessingDependencyManagement()) { DependencyManagement dependencyManagement = - PomHelper.getRawModel( getProject() ).getDependencyManagement(); - if ( dependencyManagement != null ) - { - useReleases( pom, dependencyManagement.getDependencies(), - ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT ); + PomHelper.getRawModel(getProject()).getDependencyManagement(); + if (dependencyManagement != null) { + useReleases( + pom, dependencyManagement.getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY_MANAGEMENT); } } - if ( getProject().getDependencies() != null && isProcessingDependencies() ) - { - useReleases( pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY ); + if (getProject().getDependencies() != null && isProcessingDependencies()) { + useReleases(pom, getProject().getDependencies(), ChangeRecord.ChangeKind.DEPENDENCY); } - if ( getProject().getParent() != null && isProcessingParent() ) - { - useReleases( pom, singletonList( getParentDependency() ), - ChangeRecord.ChangeKind.PARENT ); + if (getProject().getParent() != null && isProcessingParent()) { + useReleases(pom, singletonList(getParentDependency()), ChangeRecord.ChangeKind.PARENT); } - } - catch ( IOException e ) - { - throw new MojoExecutionException( e.getMessage(), e ); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage(), e); } } - private void useReleases( ModifiedPomXMLEventReader pom, Collection dependencies, - ChangeRecord.ChangeKind changeKind ) - throws XMLStreamException, MojoExecutionException, VersionRetrievalException - { - for ( Dependency dep : dependencies ) - { - if ( isExcludeReactor() && isProducedByReactor( dep ) ) - { - getLog().info( "Ignoring reactor dependency: " + toString( dep ) ); + private void useReleases( + ModifiedPomXMLEventReader pom, Collection dependencies, ChangeRecord.ChangeKind changeKind) + throws XMLStreamException, MojoExecutionException, VersionRetrievalException { + for (Dependency dep : dependencies) { + if (isExcludeReactor() && isProducedByReactor(dep)) { + getLog().info("Ignoring reactor dependency: " + toString(dep)); continue; } - if ( isHandledByProperty( dep ) ) - { - getLog().debug( "Ignoring dependency with property as version: " + toString( dep ) ); + if (isHandledByProperty(dep)) { + getLog().debug("Ignoring dependency with property as version: " + toString(dep)); continue; } String version = dep.getVersion(); - if ( version == null ) - { - getLog().info( "Ignoring dependency with no version: " + toString( dep ) ); + if (version == null) { + getLog().info("Ignoring dependency with no version: " + toString(dep)); continue; } - Matcher versionMatcher = SNAPSHOT_REGEX.matcher( version ); - if ( versionMatcher.matches() ) - { - String releaseVersion = versionMatcher.group( 1 ); - Artifact artifact = this.toArtifact( dep ); - if ( !isIncluded( artifact ) ) - { + Matcher versionMatcher = SNAPSHOT_REGEX.matcher(version); + if (versionMatcher.matches()) { + String releaseVersion = versionMatcher.group(1); + Artifact artifact = this.toArtifact(dep); + if (!isIncluded(artifact)) { continue; } - getLog().debug( "Looking for a release of " + toString( dep ) ); + getLog().debug("Looking for a release of " + toString(dep)); // Force releaseVersion version because org.apache.maven.artifact.metadata.MavenMetadataSource does not // retrieve release version if provided snapshot version. - artifact.setVersion( releaseVersion ); - Optional targetVersion = findReleaseVersion( pom, dep, version, releaseVersion, - getHelper().lookupArtifactVersions( artifact, false ) ); - if ( targetVersion.isPresent() ) - { - updateDependencyVersion( pom, dep, targetVersion.get(), changeKind ); - } - else - { - getLog().info( "No matching release of " + toString( dep ) + " to update." ); - if ( failIfNotReplaced ) - { - throw new MojoExecutionException( "No matching release of " + toString( dep ) - + " found for update" ); + artifact.setVersion(releaseVersion); + Optional targetVersion = findReleaseVersion( + pom, dep, version, releaseVersion, getHelper().lookupArtifactVersions(artifact, false)); + if (targetVersion.isPresent()) { + updateDependencyVersion(pom, dep, targetVersion.get(), changeKind); + } else { + getLog().info("No matching release of " + toString(dep) + " to update."); + if (failIfNotReplaced) { + throw new MojoExecutionException( + "No matching release of " + toString(dep) + " found for update"); } } } } } - private Optional findReleaseVersion( ModifiedPomXMLEventReader pom, Dependency dep, String version, - String releaseVersion, ArtifactVersions versions ) - { + private Optional findReleaseVersion( + ModifiedPomXMLEventReader pom, + Dependency dep, + String version, + String releaseVersion, + ArtifactVersions versions) { return !allowRangeMatching - ? versions.containsVersion( releaseVersion ) - ? Optional.of( releaseVersion ) - : Optional.empty() - : Arrays.stream( versions.getVersions( false ) ) - .sorted( ( v1, v2 ) -> -( v1.compareTo( v2 ) ) ) - .filter( v -> v.toString().startsWith( releaseVersion ) ) - .findFirst() - .map( ArtifactVersion::toString ); + ? versions.containsVersion(releaseVersion) ? Optional.of(releaseVersion) : Optional.empty() + : Arrays.stream(versions.getVersions(false)) + .sorted((v1, v2) -> -(v1.compareTo(v2))) + .filter(v -> v.toString().startsWith(releaseVersion)) + .findFirst() + .map(ArtifactVersion::toString); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 0b5117d9f3..632fec930a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -52,8 +52,7 @@ * @author Stephen Connolly * @since 1.0-beta-1 */ -public abstract class AbstractVersionsReportRenderer extends VersionsReportRendererBase implements ReportRenderer -{ +public abstract class AbstractVersionsReportRenderer extends VersionsReportRendererBase implements ReportRenderer { /** * Model of the object being rendered @@ -62,32 +61,29 @@ public abstract class AbstractVersionsReportRenderer extends VersionsReportRe */ protected T model; - protected final ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getReportNewestUpdate ); + protected final ArtifactVersionsCache newestUpdateCache = + new ArtifactVersionsCache(AbstractVersionDetails::getReportNewestUpdate); - protected final ArtifactVersionsCache allUpdatesCache - = new ArtifactVersionsCache( AbstractVersionDetails::getReportUpdates ); + protected final ArtifactVersionsCache allUpdatesCache = + new ArtifactVersionsCache(AbstractVersionDetails::getReportUpdates); - protected final SinkEventAttributes headerAttributes - = new SinkEventAttributeSet( SinkEventAttributes.WIDTH, "30%" ); + protected final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(SinkEventAttributes.WIDTH, "30%"); - protected AbstractVersionsReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, T model ) - { - super( sink, i18n, locale, bundleName ); + protected AbstractVersionsReportRenderer(I18N i18n, Sink sink, Locale locale, String bundleName, T model) { + super(sink, i18n, locale, bundleName); this.model = model; } /** * {@inheritDoc} */ - protected void renderBody() - { + protected void renderBody() { sink.section1(); sink.sectionTitle1(); - sink.text( getText( "report.overview.title" ) ); + sink.text(getText("report.overview.title")); sink.sectionTitle1_(); sink.paragraph(); - sink.text( getText( "report.overview.text" ) ); + sink.text(getText("report.overview.text")); sink.paragraph_(); renderOverview(); @@ -99,10 +95,10 @@ protected void renderBody() sink.section1(); sink.sectionTitle1(); - sink.text( getText( "report.detail.title" ) ); + sink.text(getText("report.detail.title")); sink.sectionTitle1_(); sink.paragraph(); - sink.text( getText( "report.detail.text" ) ); + sink.text(getText("report.detail.text")); sink.paragraph_(); renderDetails(); @@ -113,11 +109,10 @@ protected void renderBody() /** * Renders the "Overview" table */ - protected void renderOverview() - { + protected void renderOverview() { sink.table(); sink.tableRow(); - renderOverviewTableRow( computeOverviewStats() ); + renderOverviewTableRow(computeOverviewStats()); sink.tableRow_(); sink.table_(); } @@ -137,13 +132,12 @@ protected void renderOverview() * @param stats summary statistics object to render * @param concrete {@linkplain OverviewStats} class */ - protected void renderOverviewTableRow( Q stats ) - { - renderStatRow( "report.overview.numUpToDate", stats.getUpToDate(), true ); - renderStatRow( "report.overview.numNewerVersionAvailable", stats.getAny(), false ); - renderStatRow( "report.overview.numNewerIncrementalAvailable", stats.getIncremental(), false ); - renderStatRow( "report.overview.numNewerMinorAvailable", stats.getMinor(), false ); - renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor(), false ); + protected void renderOverviewTableRow(Q stats) { + renderStatRow("report.overview.numUpToDate", stats.getUpToDate(), true); + renderStatRow("report.overview.numNewerVersionAvailable", stats.getAny(), false); + renderStatRow("report.overview.numNewerIncrementalAvailable", stats.getIncremental(), false); + renderStatRow("report.overview.numNewerMinorAvailable", stats.getMinor(), false); + renderStatRow("report.overview.numNewerMajorAvailable", stats.getMajor(), false); } /** @@ -152,17 +146,16 @@ protected void renderOverviewTableRow( Q stats ) * @param statCount the number of artifacts with the given stat. * @param forceSuccessIcon if true, the success icon will be rendered regardless. */ - protected void renderStatRow( String textKey, int statCount, boolean forceSuccessIcon ) - { + protected void renderStatRow(String textKey, int statCount, boolean forceSuccessIcon) { sink.tableRow(); sink.tableCell(); - renderIcon( statCount == 0 || forceSuccessIcon ); + renderIcon(statCount == 0 || forceSuccessIcon); sink.tableCell_(); sink.tableCell(); - sink.text( getText( textKey ) ); + sink.text(getText(textKey)); sink.tableCell_(); sink.tableCell(); - sink.text( Integer.toString( statCount ) ); + sink.text(Integer.toString(statCount)); sink.tableCell_(); sink.tableRow_(); } @@ -171,14 +164,10 @@ protected void renderStatRow( String textKey, int statCount, boolean forceSucces * Renders the success or warning icon. * @param success if true, the success icon will be rendered, otherwise the warning icon will be rendered. */ - protected void renderIcon( boolean success ) - { - if ( success ) - { + protected void renderIcon(boolean success) { + if (success) { renderSuccessIcon(); - } - else - { + } else { renderWarningIcon(); } } @@ -195,59 +184,51 @@ protected void renderIcon( boolean success ) */ protected abstract void renderDetails(); - protected void renderSummaryTable( Map contents, boolean hasScope ) - { + protected void renderSummaryTable(Map contents, boolean hasScope) { sink.table(); sink.tableRow(); - renderSummaryTableHeader( hasScope, true ); + renderSummaryTableHeader(hasScope, true); sink.tableRow_(); - contents.forEach( ( artifact, artifactVersions ) -> - renderSummaryTableRow( artifact, artifactVersions, hasScope ) ); + contents.forEach((artifact, artifactVersions) -> renderSummaryTableRow(artifact, artifactVersions, hasScope)); sink.tableRow(); - renderSummaryTableHeader( hasScope, true ); + renderSummaryTableHeader(hasScope, true); sink.tableRow_(); sink.table_(); } - protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) - { - renderTableHeaderCells( "report.status", "report.groupId", "report.artifactId", - "report.currentVersion" ); - if ( hasScope ) - { - renderTableHeaderCells( "report.scope" ); + protected void renderSummaryTableHeader(boolean hasScope, boolean hasType) { + renderTableHeaderCells("report.status", "report.groupId", "report.artifactId", "report.currentVersion"); + if (hasScope) { + renderTableHeaderCells("report.scope"); } - if ( hasType ) - { - renderTableHeaderCells( "report.classifier", "report.type" ); + if (hasType) { + renderTableHeaderCells("report.classifier", "report.type"); } - renderTableHeaderCells( "report.latestSubIncremental", - "report.latestIncremental", "report.latestMinor", "report.latestMajor" ); + renderTableHeaderCells( + "report.latestSubIncremental", "report.latestIncremental", "report.latestMinor", "report.latestMajor"); } - protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, boolean includeScope ) - { - details.setCurrentVersion( artifact.getVersion() ); - ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + protected void renderSummaryTableRow(Dependency artifact, ArtifactVersions details, boolean includeScope) { + details.setCurrentVersion(artifact.getVersion()); + ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty()); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.tableRow(); sink.tableCell(); - renderIcon( upToDate ); + renderIcon(upToDate); sink.tableCell_(); - renderCells( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); - if ( includeScope ) - { - renderCell( artifact.getScope() ); + renderCells(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); + if (includeScope) { + renderCell(artifact.getScope()); } - renderCells( artifact.getClassifier(), artifact.getType() ); - renderNewestVersions( details ); + renderCells(artifact.getClassifier(), artifact.getType()); + renderNewestVersions(details); sink.tableRow_(); } @@ -256,35 +237,31 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions deta * Renders the newest versions for the given artifact. * @param details the artifact for which to render the newest versions. */ - protected void renderNewestVersions( AbstractVersionDetails details ) - { - renderBoldCell( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ); - renderBoldCell( newestUpdateCache.get( details, of( INCREMENTAL ) ) ); - renderBoldCell( newestUpdateCache.get( details, of( MINOR ) ) ); - renderBoldCell( newestUpdateCache.get( details, of( MAJOR ) ) ); + protected void renderNewestVersions(AbstractVersionDetails details) { + renderBoldCell(newestUpdateCache.get(details, of(SUBINCREMENTAL))); + renderBoldCell(newestUpdateCache.get(details, of(INCREMENTAL))); + renderBoldCell(newestUpdateCache.get(details, of(MINOR))); + renderBoldCell(newestUpdateCache.get(details, of(MAJOR))); } - protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope ) - { - ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + protected void renderDependencyDetailTable(Dependency artifact, ArtifactVersions details, boolean includeScope) { + ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty()); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - - renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); - renderTwoCellsRow( "report.groupId", artifact.getGroupId() ); - renderTwoCellsRow( "report.artifactId", artifact.getArtifactId() ); - renderTwoCellsRow( "report.currentVersion", artifact.getVersion() ); - if ( includeScope ) - { - renderTwoCellsRow( "report.scope", artifact.getScope() ); + sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + + renderTwoCellsRow("report.status", () -> renderStatus(details)); + renderTwoCellsRow("report.groupId", artifact.getGroupId()); + renderTwoCellsRow("report.artifactId", artifact.getArtifactId()); + renderTwoCellsRow("report.currentVersion", artifact.getVersion()); + if (includeScope) { + renderTwoCellsRow("report.scope", artifact.getScope()); } - renderTwoCellsRow( "report.classifier", artifact.getClassifier() ); - renderTwoCellsRow( "report.type", artifact.getType() ); - if ( !upToDate ) - { - renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); + renderTwoCellsRow("report.classifier", artifact.getClassifier()); + renderTwoCellsRow("report.type", artifact.getType()); + if (!upToDate) { + renderTwoCellsRow("report.updateVersions", () -> renderVersions(allUpdates, details)); } sink.tableRows_(); @@ -296,14 +273,13 @@ protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersion * @param textKey the key of the text to be rendered. * @param textValue the value of the text to be rendered. */ - protected void renderTwoCellsRow( String textKey, String textValue ) - { + protected void renderTwoCellsRow(String textKey, String textValue) { sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( textKey ) ); + sink.tableHeaderCell(headerAttributes); + sink.text(getText(textKey)); sink.tableHeaderCell_(); sink.tableCell(); - sink.text( textValue ); + sink.text(textValue); sink.tableCell_(); sink.tableRow_(); } @@ -313,11 +289,10 @@ protected void renderTwoCellsRow( String textKey, String textValue ) * @param textKey the key of the text to be rendered. * @param runnable the runnable to be executed to render the second cell content. */ - protected void renderTwoCellsRow( String textKey, Runnable runnable ) - { + protected void renderTwoCellsRow(String textKey, Runnable runnable) { sink.tableRow(); - sink.tableHeaderCell( headerAttributes ); - sink.text( getText( textKey ) ); + sink.tableHeaderCell(headerAttributes); + sink.text(getText(textKey)); sink.tableHeaderCell_(); sink.tableCell(); runnable.run(); @@ -329,37 +304,27 @@ protected void renderTwoCellsRow( String textKey, Runnable runnable ) * Renders the status of the given artifact. * @param details the artifact for which to render the status. */ - protected void renderStatus( AbstractVersionDetails details ) - { - if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) - { + protected void renderStatus(AbstractVersionDetails details) { + if (newestUpdateCache.get(details, of(SUBINCREMENTAL)) != null) { renderWarningIcon(); sink.nonBreakingSpace(); - sink.text( getText( "report.otherUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) - { + sink.text(getText("report.otherUpdatesAvailable")); + } else if (newestUpdateCache.get(details, of(INCREMENTAL)) != null) { renderWarningIcon(); sink.nonBreakingSpace(); - sink.text( getText( "report.incrementalUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) - { + sink.text(getText("report.incrementalUpdatesAvailable")); + } else if (newestUpdateCache.get(details, of(MINOR)) != null) { renderWarningIcon(); sink.nonBreakingSpace(); - sink.text( getText( "report.minorUpdatesAvailable" ) ); - } - else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) - { + sink.text(getText("report.minorUpdatesAvailable")); + } else if (newestUpdateCache.get(details, of(MAJOR)) != null) { renderWarningIcon(); sink.nonBreakingSpace(); - sink.text( getText( "report.majorUpdatesAvailable" ) ); - } - else - { + sink.text(getText("report.majorUpdatesAvailable")); + } else { renderSuccessIcon(); sink.nonBreakingSpace(); - sink.text( getText( "report.noUpdatesAvailable" ) ); + sink.text(getText("report.noUpdatesAvailable")); } } @@ -369,17 +334,13 @@ else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) * @param details the artifact or property for which to render the versions. * @return the list of restrictions for the spec versions range. */ - private List getArtifactVersionRange( AbstractVersionDetails details ) - { - try - { + private List getArtifactVersionRange(AbstractVersionDetails details) { + try { String spec = details.getCurrentVersion().toString(); - VersionRange range = VersionRange.createFromVersionSpec( spec ); + VersionRange range = VersionRange.createFromVersionSpec(spec); return range.getRestrictions(); - } - catch ( InvalidVersionSpecificationException ignored ) - { - ignored.printStackTrace( System.err ); + } catch (InvalidVersionSpecificationException ignored) { + ignored.printStackTrace(System.err); } return Collections.EMPTY_LIST; } @@ -389,50 +350,42 @@ private List getArtifactVersionRange( AbstractVersionDetails detail * @param allUpdates the list of all updates available. * @param details the versions details for the given artifact or property. */ - protected void renderVersions( ArtifactVersion[] allUpdates, AbstractVersionDetails details ) - { - List versionRange = getArtifactVersionRange( details ); + protected void renderVersions(ArtifactVersion[] allUpdates, AbstractVersionDetails details) { + List versionRange = getArtifactVersionRange(details); boolean someNotAllowed = false; - for ( int i = 0; i < allUpdates.length; i++ ) - { - if ( i > 0 ) - { + for (int i = 0; i < allUpdates.length; i++) { + if (i > 0) { sink.lineBreak(); } // if candidate version in range, display no star. ArtifactVersion candidate = allUpdates[i]; - boolean allowed = versionRange.stream().anyMatch( restriction -> - details.isVersionInRestriction( restriction, candidate ) ); - String label = getLabel( allUpdates[i], details ); - if ( !allowed ) - { - sink.text( "* " ); + boolean allowed = versionRange.stream() + .anyMatch(restriction -> details.isVersionInRestriction(restriction, candidate)); + String label = getLabel(allUpdates[i], details); + if (!allowed) { + sink.text("* "); someNotAllowed = true; } - if ( allowed && label != null ) - { + if (allowed && label != null) { safeBold(); } - sink.text( allUpdates[i].toString() ); - if ( label != null ) - { - if ( allowed ) - { + sink.text(allUpdates[i].toString()); + if (label != null) { + if (allowed) { safeBold_(); } sink.nonBreakingSpace(); safeItalic(); - sink.text( label ); + sink.text(label); safeItalic_(); } } - if ( someNotAllowed ) - { + if (someNotAllowed) { sink.lineBreak(); sink.lineBreak(); - sink.text( "* " ); + sink.text("* "); safeItalic(); - sink.text( getText( "report.excludedVersion" ) ); + sink.text(getText("report.excludedVersion")); safeItalic_(); } } @@ -443,30 +396,24 @@ protected void renderVersions( ArtifactVersion[] allUpdates, AbstractVersionDeta * @param details the artifact for which to render the versions. * @return a text label to describe if the given version is a major, minor, incremental or subincremental update. */ - protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) - { + protected String getLabel(ArtifactVersion version, AbstractVersionDetails details) { - if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.latestSubIncremental" ); + if (equals(version, newestUpdateCache.get(details, of(SUBINCREMENTAL)))) { + return getText("report.latestSubIncremental"); } - if ( equals( version, newestUpdateCache.get( details, of( INCREMENTAL ) ) ) ) - { - return getText( "report.latestIncremental" ); + if (equals(version, newestUpdateCache.get(details, of(INCREMENTAL)))) { + return getText("report.latestIncremental"); } - if ( equals( version, newestUpdateCache.get( details, of( MINOR ) ) ) ) - { - return getText( "report.latestMinor" ); + if (equals(version, newestUpdateCache.get(details, of(MINOR)))) { + return getText("report.latestMinor"); } - if ( equals( version, newestUpdateCache.get( details, of( MAJOR ) ) ) ) - { - return getText( "report.latestMajor" ); + if (equals(version, newestUpdateCache.get(details, of(MAJOR)))) { + return getText("report.latestMajor"); } return null; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index 8072e31192..4e81d32161 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -33,70 +33,60 @@ * @param type of the model * @since 1.0-beta-1 */ -public class DependencyUpdatesReportRenderer extends AbstractVersionsReportRenderer -{ - public DependencyUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, K model ) - { - super( i18n, sink, locale, bundleName, model ); +public class DependencyUpdatesReportRenderer + extends AbstractVersionsReportRenderer { + public DependencyUpdatesReportRenderer(I18N i18n, Sink sink, Locale locale, String bundleName, K model) { + super(i18n, sink, locale, bundleName, model); } /** * {@inheritDoc} */ @Override - protected void renderDetails() - { - model.getAllUpdates().forEach( this::renderDependencyDetail ); + protected void renderDetails() { + model.getAllUpdates().forEach(this::renderDependencyDetail); } @Override - protected void renderSummaryTable() - { - renderTable( "report.overview.dependency", model.getArtifactUpdates(), - "report.overview.noDependency" ); + protected void renderSummaryTable() { + renderTable("report.overview.dependency", model.getArtifactUpdates(), "report.overview.noDependency"); } @Override - protected void renderManagementSummaryTable() - { - renderTable( "report.overview.dependencyManagement", - model.getArtifactManagementUpdates(), "report.overview.noDependencyManagement" ); + protected void renderManagementSummaryTable() { + renderTable( + "report.overview.dependencyManagement", + model.getArtifactManagementUpdates(), + "report.overview.noDependencyManagement"); } - protected void renderTable( String titleKey, Map contents, String emptyKey ) - { + protected void renderTable(String titleKey, Map contents, String emptyKey) { sink.section2(); sink.sectionTitle2(); - sink.text( getText( titleKey ) ); + sink.text(getText(titleKey)); sink.sectionTitle2_(); - if ( contents.isEmpty() ) - { + if (contents.isEmpty()) { sink.paragraph(); - sink.text( getText( emptyKey ) ); + sink.text(getText(emptyKey)); sink.paragraph_(); - } - else - { - renderSummaryTable( contents, true ); + } else { + renderSummaryTable(contents, true); } sink.section2_(); } @Override - protected OverviewStats computeOverviewStats() - { - return OverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); + protected OverviewStats computeOverviewStats() { + return OverviewStats.fromUpdates(model.getAllUpdates().values(), newestUpdateCache); } - protected void renderDependencyDetail( Dependency artifact, ArtifactVersions details ) - { + protected void renderDependencyDetail(Dependency artifact, ArtifactVersions details) { sink.section2(); sink.sectionTitle2(); - sink.text( ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ) ); + sink.text(ArtifactUtils.versionlessKey(artifact.getGroupId(), artifact.getArtifactId())); sink.sectionTitle2_(); - renderDependencyDetailTable( artifact, details, true ); + renderDependencyDetailTable(artifact, details, true); sink.section2_(); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java index d822d67b3b..cb30cc74a8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java @@ -1,6 +1,5 @@ package org.codehaus.mojo.versions.reporting; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -40,8 +39,7 @@ * * @author Andrzej Jarmoniuk */ -public class OverviewStats -{ +public class OverviewStats { private int major; private int minor; @@ -64,90 +62,67 @@ public class OverviewStats * @param subclass of {@linkplain ArtifactVersions} * @return instance of the {@linkplain OverviewStats} */ - public static - T fromUpdates( Collection updates, ArtifactVersionsCache cache ) - { + public static T fromUpdates( + Collection updates, ArtifactVersionsCache cache) { OverviewStats stats = new OverviewStats(); - updates.forEach( details -> - { - if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) - { + updates.forEach(details -> { + if (getNewestUpdate(cache, details, of(SUBINCREMENTAL)) != null) { stats.incrementAny(); - } - else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(INCREMENTAL)) != null) { stats.incrementIncremental(); - } - else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(MINOR)) != null) { stats.incrementMinor(); - } - else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(MAJOR)) != null) { stats.incrementMajor(); - } - else - { + } else { stats.incrementUpToDate(); } - } ); + }); return (T) stats; } - protected static ArtifactVersion getNewestUpdate( ArtifactVersionsCache cache, - V details, - Optional segment ) - { - return cache != null ? cache.get( details, segment ) : details.getNewestUpdate( segment ); + protected static ArtifactVersion getNewestUpdate( + ArtifactVersionsCache cache, V details, Optional segment) { + return cache != null ? cache.get(details, segment) : details.getNewestUpdate(segment); } - public int getMajor() - { + public int getMajor() { return major; } - public void incrementMajor() - { + public void incrementMajor() { major++; } - public int getMinor() - { + public int getMinor() { return minor; } - public void incrementMinor() - { + public void incrementMinor() { minor++; } - public int getIncremental() - { + public int getIncremental() { return incremental; } - public void incrementIncremental() - { + public void incrementIncremental() { incremental++; } - public int getAny() - { + public int getAny() { return any; } - public void incrementAny() - { + public void incrementAny() { any++; } - public int getUpToDate() - { + public int getUpToDate() { return upToDate; } - public void incrementUpToDate() - { + public void incrementUpToDate() { upToDate++; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java index 63ea6fc969..003c23e468 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ParentUpdatesReportRenderer.java @@ -28,21 +28,15 @@ /** * @since 1.0-beta-1 */ -public class ParentUpdatesReportRenderer extends DependencyUpdatesReportRenderer -{ - public ParentUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, - ParentUpdatesModel model ) - { - super( i18n, sink, locale, bundleName, model ); +public class ParentUpdatesReportRenderer extends DependencyUpdatesReportRenderer { + public ParentUpdatesReportRenderer( + I18N i18n, Sink sink, Locale locale, String bundleName, ParentUpdatesModel model) { + super(i18n, sink, locale, bundleName, model); } @Override - protected void renderOverview() - { - } + protected void renderOverview() {} @Override - protected void renderManagementSummaryTable() - { - } + protected void renderManagementSummaryTable() {} } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 25494f7869..57186cb688 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -33,20 +33,17 @@ import static org.codehaus.mojo.versions.api.Segment.MINOR; import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; -public class PluginOverviewStats extends OverviewStats -{ +public class PluginOverviewStats extends OverviewStats { /** * Extension of the {@linkplain OverviewStats} adding dependency stats */ private int dependencies; - public int getDependencies() - { + public int getDependencies() { return dependencies; } - public void incrementDependencies() - { + public void incrementDependencies() { dependencies++; } @@ -61,37 +58,25 @@ public void incrementDependencies() * @param always equal to {@linkplain PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information */ - public static - T fromUpdates( Collection updates, ArtifactVersionsCache cache ) - { + public static T fromUpdates( + Collection updates, ArtifactVersionsCache cache) { PluginOverviewStats stats = new PluginOverviewStats(); - updates.forEach( details -> - { - if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) - { + updates.forEach(details -> { + if (getNewestUpdate(cache, details, of(SUBINCREMENTAL)) != null) { stats.incrementAny(); - } - else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(INCREMENTAL)) != null) { stats.incrementIncremental(); - } - else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(MINOR)) != null) { stats.incrementMinor(); - } - else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) - { + } else if (getNewestUpdate(cache, details, of(MAJOR)) != null) { stats.incrementMajor(); - } - else - { + } else { stats.incrementUpToDate(); } - if ( ( ( PluginUpdatesDetails ) details ).isDependencyUpdateAvailable() ) - { + if (((PluginUpdatesDetails) details).isDependencyUpdateAvailable()) { stats.incrementDependencies(); } - } ); + }); return (T) stats; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index bd0e3c2b24..bf5efe6164 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -37,80 +37,71 @@ /** * @since 1.0-beta-1 */ -public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer -{ +public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer { - public PluginUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, - PluginUpdatesModel model ) - { - super( i18n, sink, locale, bundleName, model ); + public PluginUpdatesReportRenderer( + I18N i18n, Sink sink, Locale locale, String bundleName, PluginUpdatesModel model) { + super(i18n, sink, locale, bundleName, model); } @Override - protected void renderSummaryTable() - { - renderTable( "report.overview.plugin", model.getArtifactUpdates(), - "report.overview.noPlugin" ); + protected void renderSummaryTable() { + renderTable("report.overview.plugin", model.getArtifactUpdates(), "report.overview.noPlugin"); } - protected void renderManagementSummaryTable() - { - renderTable( "report.overview.pluginManagement", model.getArtifactManagementUpdates(), - "report.overview.noPluginManagement" ); + protected void renderManagementSummaryTable() { + renderTable( + "report.overview.pluginManagement", + model.getArtifactManagementUpdates(), + "report.overview.noPluginManagement"); } /** * {@inheritDoc} */ @Override - protected void renderDetails() - { - model.getAllUpdates().forEach( this::renderPluginDetail ); + protected void renderDetails() { + model.getAllUpdates().forEach(this::renderPluginDetail); } - private void renderDependencyDetail( Dependency dependency, ArtifactVersions details ) - { + private void renderDependencyDetail(Dependency dependency, ArtifactVersions details) { sink.section3(); sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependency" ), - ArtifactUtils.versionlessKey( dependency.getGroupId(), dependency.getArtifactId() ) ) ); + sink.text(MessageFormat.format( + getText("report.pluginDependency"), + ArtifactUtils.versionlessKey(dependency.getGroupId(), dependency.getArtifactId()))); sink.sectionTitle3_(); - renderDependencyDetailTable( dependency, details, false ); + renderDependencyDetailTable(dependency, details, false); sink.section3_(); } - private void renderTable( String titleKey, Map contents, String emptyKey ) - { + private void renderTable(String titleKey, Map contents, String emptyKey) { sink.section2(); sink.sectionTitle2(); - sink.text( getText( titleKey ) ); + sink.text(getText(titleKey)); sink.sectionTitle2_(); - if ( contents.isEmpty() ) - { + if (contents.isEmpty()) { sink.paragraph(); - sink.text( getText( emptyKey ) ); + sink.text(getText(emptyKey)); sink.paragraph_(); - } - else - { - renderSummaryTable( contents ); + } else { + renderSummaryTable(contents); } sink.section2_(); } - protected void renderSummaryTable( Map contents ) - { + protected void renderSummaryTable(Map contents) { sink.table(); sink.tableRow(); - renderSummaryTableHeader( false, false ); + renderSummaryTableHeader(false, false); sink.tableRow_(); - contents.forEach( this::renderSummaryTableRow ); + contents.forEach(this::renderSummaryTableRow); sink.tableRow(); - renderSummaryTableHeader( false, false ); + renderSummaryTableHeader(false, false); sink.tableRow_(); sink.table_(); @@ -120,94 +111,88 @@ protected void renderSummaryTable( Map content * {@inheritDoc} */ @Override - protected PluginOverviewStats computeOverviewStats() - { - return PluginOverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); + protected PluginOverviewStats computeOverviewStats() { + return PluginOverviewStats.fromUpdates(model.getAllUpdates().values(), newestUpdateCache); } @Override - protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) - { - super.renderSummaryTableHeader( hasScope, hasType ); - renderTableHeaderCells( "report.dependencyStatus" ); + protected void renderSummaryTableHeader(boolean hasScope, boolean hasType) { + super.renderSummaryTableHeader(hasScope, hasType); + renderTableHeaderCells("report.dependencyStatus"); } @Override - protected void renderOverviewTableRow( T stats ) - { - super.renderOverviewTableRow( stats ); - super.renderStatRow( "report.overview.numNewerDependenciesAvailable", - ( (PluginOverviewStats) stats ).getDependencies(), false ); + protected void renderOverviewTableRow(T stats) { + super.renderOverviewTableRow(stats); + super.renderStatRow( + "report.overview.numNewerDependenciesAvailable", + ((PluginOverviewStats) stats).getDependencies(), + false); } - protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details ) - { + protected void renderSummaryTableRow(Dependency artifact, PluginUpdatesDetails details) { boolean upToDate = !details.isUpdateAvailable(); sink.tableRow(); sink.tableCell(); - renderIcon( upToDate ); + renderIcon(upToDate); sink.tableCell_(); - renderCells( artifact.getGroupId(), artifact.getArtifactId() ); - renderBoldCell( upToDate, artifact.getVersion() ); - renderNewestVersions( details ); + renderCells(artifact.getGroupId(), artifact.getArtifactId()); + renderBoldCell(upToDate, artifact.getVersion()); + renderNewestVersions(details); sink.tableCell(); - renderIcon( !details.isDependencyUpdateAvailable() ); + renderIcon(!details.isDependencyUpdateAvailable()); sink.tableCell_(); sink.tableRow_(); } - private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails details ) - { + private void renderPluginDetail(Dependency artifact, PluginUpdatesDetails details) { sink.section2(); sink.sectionTitle2(); - sink.text( MessageFormat.format( getText( "report.plugin" ), - ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); + sink.text(MessageFormat.format( + getText("report.plugin"), ArtifactUtils.versionlessKey(details.getGroupId(), details.getArtifactId()))); sink.sectionTitle2_(); - renderPluginDetailTable( details ); + renderPluginDetailTable(details); - if ( !details.getDependencyVersions().isEmpty() ) - { + if (!details.getDependencyVersions().isEmpty()) { sink.section3(); sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), - ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); + sink.text(MessageFormat.format( + getText("report.pluginDependencies"), + ArtifactUtils.versionlessKey(details.getGroupId(), details.getArtifactId()))); sink.sectionTitle3_(); - renderSummaryTable( details.getDependencyVersions(), false ); + renderSummaryTable(details.getDependencyVersions(), false); sink.section3_(); - details.getDependencyVersions().forEach( this::renderDependencyDetail ); + details.getDependencyVersions().forEach(this::renderDependencyDetail); } sink.section2_(); } - private void renderPluginDetailTable( PluginUpdatesDetails details ) - { + private void renderPluginDetailTable(PluginUpdatesDetails details) { // warning: using caches here might break plugin report - ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); + ArtifactVersion[] allUpdates = details.getAllUpdates(empty()); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - - renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); - renderTwoCellsRow( "report.groupId", details.getGroupId() ); - renderTwoCellsRow( "report.artifactId", details.getArtifactId() ); - renderTwoCellsRow( "report.currentVersion", details.getVersion() ); - if ( !upToDate ) - { - renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); + sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + + renderTwoCellsRow("report.status", () -> renderStatus(details)); + renderTwoCellsRow("report.groupId", details.getGroupId()); + renderTwoCellsRow("report.artifactId", details.getArtifactId()); + renderTwoCellsRow("report.currentVersion", details.getVersion()); + if (!upToDate) { + renderTwoCellsRow("report.updateVersions", () -> renderVersions(allUpdates, details)); } sink.tableRows_(); sink.table_(); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index 8b79da27b1..88f5ad05c4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -25,8 +25,8 @@ import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; -import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.ArtifactAssociation; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.reporting.model.PropertyUpdatesModel; import org.codehaus.plexus.i18n.I18N; @@ -36,110 +36,95 @@ /** * @since 1.0-beta-1 */ -public class PropertyUpdatesReportRenderer extends AbstractVersionsReportRenderer -{ - public PropertyUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, - PropertyUpdatesModel model ) - { - super( i18n, sink, locale, bundleName, model ); +public class PropertyUpdatesReportRenderer extends AbstractVersionsReportRenderer { + public PropertyUpdatesReportRenderer( + I18N i18n, Sink sink, Locale locale, String bundleName, PropertyUpdatesModel model) { + super(i18n, sink, locale, bundleName, model); } @Override - protected void renderManagementSummaryTable() - { - } + protected void renderManagementSummaryTable() {} @Override - protected void renderSummaryTable() - { - renderTable( "report.overview.property", model.getAllUpdates(), - "report.overview.noProperty" ); + protected void renderSummaryTable() { + renderTable("report.overview.property", model.getAllUpdates(), "report.overview.noProperty"); } /** * {@inheritDoc} */ @Override - protected void renderDetails() - { - model.getAllUpdates().forEach( this::renderPropertyDetail ); + protected void renderDetails() { + model.getAllUpdates().forEach(this::renderPropertyDetail); } - protected void renderTable( String titleKey, Map contents, String emptyKey ) - { + protected void renderTable(String titleKey, Map contents, String emptyKey) { sink.section2(); sink.sectionTitle2(); - sink.text( getText( titleKey ) ); + sink.text(getText(titleKey)); sink.sectionTitle2_(); - if ( contents.isEmpty() ) - { + if (contents.isEmpty()) { sink.paragraph(); - sink.text( getText( emptyKey ) ); + sink.text(getText(emptyKey)); sink.paragraph_(); - } - else - { - renderSummaryTable( contents ); + } else { + renderSummaryTable(contents); } sink.section2_(); } - protected void renderSummaryTable( Map contents ) - { + protected void renderSummaryTable(Map contents) { sink.table(); sink.tableRow(); - renderSummaryTableHeader( false, false ); + renderSummaryTableHeader(false, false); sink.tableRow_(); - contents.forEach( this::renderPropertySummaryTableRow ); + contents.forEach(this::renderPropertySummaryTableRow); sink.tableRow(); - renderSummaryTableHeader( false, false ); + renderSummaryTableHeader(false, false); sink.tableRow_(); sink.table_(); } - private void renderPropertySummaryTableRow( Property property, PropertyVersions details ) - { - ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + private void renderPropertySummaryTableRow(Property property, PropertyVersions details) { + ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty()); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.tableRow(); sink.tableCell(); - renderIcon( upToDate ); + renderIcon(upToDate); sink.tableCell_(); - renderCells( "${" + property.getName() + "}", details.getCurrentVersion() ); - renderNewestVersions( details ); + renderCells("${" + property.getName() + "}", details.getCurrentVersion()); + renderNewestVersions(details); sink.tableRow_(); } - protected void renderPropertyDetailTable( Property property, PropertyVersions details ) - { - ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + protected void renderPropertyDetailTable(Property property, PropertyVersions details) { + ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty()); boolean upToDate = allUpdates == null || allUpdates.length == 0; sink.table(); - sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); - - renderTwoCellsRow( "report.status", () -> renderStatus( details ) ); - renderTwoCellsRow( "report.property", "${" + property.getName() + "}" ); - renderTwoCellsRow( "report.associations", () -> renderAssociations( details ) ); - renderTwoCellsRow( "report.currentVersion", details.getCurrentVersion().toString() ); - if ( !upToDate ) - { - renderTwoCellsRow( "report.updateVersions", () -> renderVersions( allUpdates, details ) ); + sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + + renderTwoCellsRow("report.status", () -> renderStatus(details)); + renderTwoCellsRow("report.property", "${" + property.getName() + "}"); + renderTwoCellsRow("report.associations", () -> renderAssociations(details)); + renderTwoCellsRow("report.currentVersion", details.getCurrentVersion().toString()); + if (!upToDate) { + renderTwoCellsRow("report.updateVersions", () -> renderVersions(allUpdates, details)); } - renderTwoCellsRow( "report.versionRange", details.getCurrentVersion().toString() ); - renderTwoCellsRow( "report.autoLinkDependencies", property.isAutoLinkDependencies() ); - renderTwoCellsRow( "report.banSnapshots", property.isBanSnapshots() ); - renderTwoCellsRow( "report.searchReactor", property.isSearchReactor() ); - renderTwoCellsRow( "report.preferReactor", property.isPreferReactor() ); + renderTwoCellsRow("report.versionRange", details.getCurrentVersion().toString()); + renderTwoCellsRow("report.autoLinkDependencies", property.isAutoLinkDependencies()); + renderTwoCellsRow("report.banSnapshots", property.isBanSnapshots()); + renderTwoCellsRow("report.searchReactor", property.isSearchReactor()); + renderTwoCellsRow("report.preferReactor", property.isPreferReactor()); sink.tableRows_(); sink.table_(); @@ -150,46 +135,43 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions de * @param textKey the key of the text to be rendered in the header cell. * @param b a yes/no value to be rendered in the non-header cell. */ - private void renderTwoCellsRow( String textKey, boolean b ) - { - renderTwoCellsRow( textKey, getText( b ? "report.yes" : "report.no" ) ); + private void renderTwoCellsRow(String textKey, boolean b) { + renderTwoCellsRow(textKey, getText(b ? "report.yes" : "report.no")); } - private void renderAssociations( PropertyVersions details ) - { + private void renderAssociations(PropertyVersions details) { ArtifactAssociation[] associations = details.getAssociations(); - for ( int i = 0; i < associations.length; i++ ) - { - if ( i > 0 ) - { + for (int i = 0; i < associations.length; i++) { + if (i > 0) { sink.lineBreak(); } - sink.text( ArtifactUtils.versionlessKey( associations[i].getArtifact() ) ); + sink.text(ArtifactUtils.versionlessKey(associations[i].getArtifact())); } } @Override - protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) - { - renderTableHeaderCells( "report.status", "report.property", "report.currentVersion", - "report.latestSubIncremental", "report.latestIncremental", "report.latestMinor", - "report.latestMajor" ); + protected void renderSummaryTableHeader(boolean hasScope, boolean hasType) { + renderTableHeaderCells( + "report.status", + "report.property", + "report.currentVersion", + "report.latestSubIncremental", + "report.latestIncremental", + "report.latestMinor", + "report.latestMajor"); } @Override - protected OverviewStats computeOverviewStats() - { - return OverviewStats.fromUpdates( model.getAllUpdates().values(), newestUpdateCache ); + protected OverviewStats computeOverviewStats() { + return OverviewStats.fromUpdates(model.getAllUpdates().values(), newestUpdateCache); } - private void renderPropertyDetail( Property property, PropertyVersions details ) - { + private void renderPropertyDetail(Property property, PropertyVersions details) { sink.section2(); sink.sectionTitle2(); - sink.text( "${" + property.getName() + "}" ); + sink.text("${" + property.getName() + "}"); sink.sectionTitle2_(); - renderPropertyDetailTable( property, details ); + renderPropertyDetailTable(property, details); sink.section2_(); } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java index 1b977ecc5c..56dd9d33cc 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactory.java @@ -27,8 +27,7 @@ /** * Factory for report renderers */ -public interface ReportRendererFactory -{ +public interface ReportRendererFactory { /** * Creates a new {@linkplain ReportRenderer} instance for the given report renderer name. * @@ -41,6 +40,6 @@ public interface ReportRendererFactory * @return new report renderer * @throws IllegalArgumentException thrown if the report with the given name could not be found */ - T createReportRenderer( String reportName, Sink sink, Locale locale, U model ) + T createReportRenderer(String reportName, Sink sink, Locale locale, U model) throws IllegalArgumentException; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java index e66a1ad422..81af9c857d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/ReportRendererFactoryImpl.java @@ -38,8 +38,7 @@ */ @Named @Singleton -public class ReportRendererFactoryImpl implements ReportRendererFactory -{ +public class ReportRendererFactoryImpl implements ReportRendererFactory { public static final String DEPENDENCY_UPDATES_REPORT = "dependency-updates-report"; public static final String DEPENDENCY_UPDATES_AGGREGATE_REPORT = "dependency-updates-aggregate-report"; public static final String PLUGIN_UPDATES_REPORT = "plugin-updates-report"; @@ -50,8 +49,7 @@ public class ReportRendererFactoryImpl implements ReportRendererFactory private final I18N i18N; @Inject - public ReportRendererFactoryImpl( I18N i18N ) - { + public ReportRendererFactoryImpl(I18N i18N) { this.i18N = i18N; } @@ -59,31 +57,22 @@ public ReportRendererFactoryImpl( I18N i18N ) * {@inheritDoc} */ @Override - @SuppressWarnings( "unchecked" ) - public T createReportRenderer( String reportName, Sink sink, Locale locale, U model ) - throws IllegalArgumentException - { - if ( DEPENDENCY_UPDATES_REPORT.equals( reportName ) - || DEPENDENCY_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) - { - return (T) new DependencyUpdatesReportRenderer<>( i18N, sink, locale, reportName, - (DependencyUpdatesModel) model ); + @SuppressWarnings("unchecked") + public T createReportRenderer(String reportName, Sink sink, Locale locale, U model) + throws IllegalArgumentException { + if (DEPENDENCY_UPDATES_REPORT.equals(reportName) || DEPENDENCY_UPDATES_AGGREGATE_REPORT.equals(reportName)) { + return (T) new DependencyUpdatesReportRenderer<>( + i18N, sink, locale, reportName, (DependencyUpdatesModel) model); } - if ( PLUGIN_UPDATES_REPORT.equals( reportName ) || PLUGIN_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) - { - return (T) new PluginUpdatesReportRenderer( i18N, sink, locale, reportName, - (PluginUpdatesModel) model ); + if (PLUGIN_UPDATES_REPORT.equals(reportName) || PLUGIN_UPDATES_AGGREGATE_REPORT.equals(reportName)) { + return (T) new PluginUpdatesReportRenderer(i18N, sink, locale, reportName, (PluginUpdatesModel) model); } - if ( PROPERTY_UPDATES_REPORT.equals( reportName ) || PROPERTY_UPDATES_AGGREGATE_REPORT.equals( reportName ) ) - { - return (T) new PropertyUpdatesReportRenderer( i18N, sink, locale, reportName, - (PropertyUpdatesModel) model ); + if (PROPERTY_UPDATES_REPORT.equals(reportName) || PROPERTY_UPDATES_AGGREGATE_REPORT.equals(reportName)) { + return (T) new PropertyUpdatesReportRenderer(i18N, sink, locale, reportName, (PropertyUpdatesModel) model); } - if ( PARENT_UPDATES_REPORT.equals( reportName ) ) - { - return (T) new ParentUpdatesReportRenderer( i18N, sink, locale, reportName, - (ParentUpdatesModel) model ); + if (PARENT_UPDATES_REPORT.equals(reportName)) { + return (T) new ParentUpdatesReportRenderer(i18N, sink, locale, reportName, (ParentUpdatesModel) model); } - throw new IllegalArgumentException( "Invalid report name: " + reportName ); + throw new IllegalArgumentException("Invalid report name: " + reportName); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java index 82472b4eec..9719639752 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -1,6 +1,5 @@ package org.codehaus.mojo.versions.reporting; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -32,8 +31,7 @@ * Base class over AbstractVersionsReportRenderer providing base * utility methods */ -public abstract class VersionsReportRendererBase extends AbstractMavenReportRenderer -{ +public abstract class VersionsReportRendererBase extends AbstractMavenReportRenderer { /** * Internationalization component. * @@ -53,17 +51,15 @@ public abstract class VersionsReportRendererBase extends AbstractMavenReportRend */ protected String bundleName; - public VersionsReportRendererBase( Sink sink, I18N i18n, Locale locale, String bundleName ) - { - super( sink ); + public VersionsReportRendererBase(Sink sink, I18N i18n, Locale locale, String bundleName) { + super(sink); this.i18n = i18n; this.locale = locale; this.bundleName = bundleName; } - public String getTitle() - { - return getText( "report.title" ); + public String getTitle() { + return getText("report.title"); } /** @@ -72,73 +68,54 @@ public String getTitle() * @param key the message key. * @return the message. */ - public String getText( String key ) - { - return i18n.getString( bundleName, locale, key ); + public String getText(String key) { + return i18n.getString(bundleName, locale, key); } - protected void renderWarningIcon() - { - sink.figureGraphics( "images/icon_warning_sml.gif" ); + protected void renderWarningIcon() { + sink.figureGraphics("images/icon_warning_sml.gif"); } - protected void renderSuccessIcon() - { - sink.figureGraphics( "images/icon_success_sml.gif" ); + protected void renderSuccessIcon() { + sink.figureGraphics("images/icon_success_sml.gif"); } - protected boolean equals( ArtifactVersion v1, ArtifactVersion v2 ) - { - return v1 == v2 || ( v1 != null && v1.equals( v2 ) ) - || ( v1 != null && v2 != null && v1.toString().equals( v2.toString() ) ); + protected boolean equals(ArtifactVersion v1, ArtifactVersion v2) { + return v1 == v2 + || (v1 != null && v1.equals(v2)) + || (v1 != null && v2 != null && v1.toString().equals(v2.toString())); } - protected void safeBold() - { - try - { + protected void safeBold() { + try { sink.bold(); - } - catch ( NoSuchMethodError e ) - { + } catch (NoSuchMethodError e) { // ignore Maven 2.1.0 } } - @SuppressWarnings( "checkstyle:MethodName" ) - protected void safeBold_() - { - try - { + @SuppressWarnings("checkstyle:MethodName") + protected void safeBold_() { + try { sink.bold_(); - } - catch ( NoSuchMethodError e ) - { + } catch (NoSuchMethodError e) { // ignore Maven 2.1.0 } } - protected void safeItalic() - { - try - { + protected void safeItalic() { + try { sink.italic(); - } - catch ( NoSuchMethodError e ) - { + } catch (NoSuchMethodError e) { // ignore Maven 2.1.0 } } - @SuppressWarnings( "checkstyle:MethodName" ) - protected void safeItalic_() - { - try - { + @SuppressWarnings("checkstyle:MethodName") + protected void safeItalic_() { + try { sink.italic_(); - } - catch ( NoSuchMethodError e ) - { + } catch (NoSuchMethodError e) { // ignore Maven 2.1.0 } } @@ -148,43 +125,35 @@ protected void safeItalic_() * @param keys variable argument list containing keys of the property file to retrieve the * headers from */ - protected void renderTableHeaderCells( String... keys ) - { - Arrays.stream( keys ) - .map( this::getText ) - .forEachOrdered( str -> - { - sink.tableHeaderCell(); - sink.text( str ); - sink.tableHeaderCell_(); - } ); + protected void renderTableHeaderCells(String... keys) { + Arrays.stream(keys).map(this::getText).forEachOrdered(str -> { + sink.tableHeaderCell(); + sink.text(str); + sink.tableHeaderCell_(); + }); } /** * Renders a bold table cell containing the given text. * @param object the text to be rendered, or null for an empty cell. */ - protected void renderBoldCell( Object object ) - { - renderBoldCell( true, object ); + protected void renderBoldCell(Object object) { + renderBoldCell(true, object); } /** * Renders a table cell containing the given text. * @param object the text to be rendered, or null for an empty cell. */ - protected void renderCell( Object object ) - { - renderBoldCell( false, object ); + protected void renderCell(Object object) { + renderBoldCell(false, object); } /** * Renders multiple cells containing the given texts. * @param objects the texts to be rendered, null for empty cells. */ - protected void renderCells( Object... objects ) - { - for ( Object object : objects ) - { - renderBoldCell( false, object ); + protected void renderCells(Object... objects) { + for (Object object : objects) { + renderBoldCell(false, object); } } @@ -193,10 +162,9 @@ protected void renderCells( Object... objects ) * @param bold true to render the cell in bold, false otherwise. * @param object the text to be rendered, or null for an empty cell. */ - protected void renderBoldCell( boolean bold, Object object ) - { + protected void renderBoldCell(boolean bold, Object object) { sink.tableCell(); - renderBoldText( bold, object ); + renderBoldText(bold, object); sink.tableCell_(); } @@ -205,24 +173,18 @@ protected void renderBoldCell( boolean bold, Object object ) * @param bold true to render the text in bold, false otherwise. * @param object the text to be rendered, or null for an empty cell. */ - protected void renderBoldText( boolean bold, Object object ) - { - if ( object != null ) - { + protected void renderBoldText(boolean bold, Object object) { + if (object != null) { String text = object.toString(); - if ( !text.isEmpty() ) - { - if ( bold ) - { + if (!text.isEmpty()) { + if (bold) { safeBold(); } - sink.text( text ); - if ( bold ) - { + sink.text(text); + if (bold) { safeBold_(); } } } } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java index f3a6ba6365..d6855b9a31 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/AbstractUpdatesModel.java @@ -31,42 +31,38 @@ * Base class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API * @param class extending ArtifactVersion in the constructor */ -public abstract class AbstractUpdatesModel -{ +public abstract class AbstractUpdatesModel { private final Map artifactUpdates; private final Map artifactManagementUpdates; private final Map allUpdates; - public AbstractUpdatesModel( Map artifactUpdates, - Map artifactManagementUpdates, - Function supplier ) - { - this.artifactUpdates = artifactUpdates.entrySet().stream().collect( - () -> new TreeMap<>( DependencyComparator.INSTANCE ), - ( map, entry ) -> map.put( supplier.apply( entry.getKey() ), entry.getValue() ), - Map::putAll ); - this.artifactManagementUpdates = artifactManagementUpdates.entrySet().stream().collect( - () -> new TreeMap<>( DependencyComparator.INSTANCE ), - ( map, entry ) -> map.put( supplier.apply( entry.getKey() ), entry.getValue() ), - Map::putAll ); - allUpdates = new TreeMap<>( DependencyComparator.INSTANCE ); + public AbstractUpdatesModel( + Map artifactUpdates, Map artifactManagementUpdates, Function supplier) { + this.artifactUpdates = artifactUpdates.entrySet().stream() + .collect( + () -> new TreeMap<>(DependencyComparator.INSTANCE), + (map, entry) -> map.put(supplier.apply(entry.getKey()), entry.getValue()), + Map::putAll); + this.artifactManagementUpdates = artifactManagementUpdates.entrySet().stream() + .collect( + () -> new TreeMap<>(DependencyComparator.INSTANCE), + (map, entry) -> map.put(supplier.apply(entry.getKey()), entry.getValue()), + Map::putAll); + allUpdates = new TreeMap<>(DependencyComparator.INSTANCE); // overriding entries from dependencyManagementUpdates with dependencyUpdates - allUpdates.putAll( this.artifactManagementUpdates ); - allUpdates.putAll( this.artifactUpdates ); + allUpdates.putAll(this.artifactManagementUpdates); + allUpdates.putAll(this.artifactUpdates); } - public Map getArtifactUpdates() - { + public Map getArtifactUpdates() { return artifactUpdates; } - public Map getArtifactManagementUpdates() - { + public Map getArtifactManagementUpdates() { return artifactManagementUpdates; } - public Map getAllUpdates() - { + public Map getAllUpdates() { return allUpdates; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java index fd4ebadb85..c80c4ba6d7 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/DependencyUpdatesModel.java @@ -27,11 +27,10 @@ /** * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API */ -public class DependencyUpdatesModel extends AbstractUpdatesModel -{ - public DependencyUpdatesModel( Map dependencyUpdates, - Map dependencyManagementUpdates ) - { - super( dependencyUpdates, dependencyManagementUpdates, id -> id ); +public class DependencyUpdatesModel extends AbstractUpdatesModel { + public DependencyUpdatesModel( + Map dependencyUpdates, + Map dependencyManagementUpdates) { + super(dependencyUpdates, dependencyManagementUpdates, id -> id); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java index 9924a64154..a4bd329975 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/ParentUpdatesModel.java @@ -28,10 +28,8 @@ /** * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API */ -public class ParentUpdatesModel extends DependencyUpdatesModel -{ - public ParentUpdatesModel( Dependency parent, ArtifactVersions dependencyUpdates ) - { - super( singletonMap( parent, dependencyUpdates ), emptyMap() ); +public class ParentUpdatesModel extends DependencyUpdatesModel { + public ParentUpdatesModel(Dependency parent, ArtifactVersions dependencyUpdates) { + super(singletonMap(parent, dependencyUpdates), emptyMap()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java index fd3186aa27..2d67f31a20 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PluginUpdatesModel.java @@ -28,20 +28,19 @@ /** * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API */ -public class PluginUpdatesModel extends AbstractUpdatesModel -{ +public class PluginUpdatesModel extends AbstractUpdatesModel { /** * Creates a new instance * @param pluginUpdates map of plugin updates per plugin * @param pluginManagementUpdates map of plugin management updates per plugin */ - public PluginUpdatesModel( Map pluginUpdates, - Map pluginManagementUpdates ) - { - super( pluginUpdates, pluginManagementUpdates, p -> DependencyBuilder.newBuilder() - .withGroupId( p.getGroupId() ) - .withArtifactId( p.getArtifactId() ) - .withVersion( p.getVersion() ) - .build() ); + public PluginUpdatesModel( + Map pluginUpdates, + Map pluginManagementUpdates) { + super(pluginUpdates, pluginManagementUpdates, p -> DependencyBuilder.newBuilder() + .withGroupId(p.getGroupId()) + .withArtifactId(p.getArtifactId()) + .withVersion(p.getVersion()) + .build()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java index 44058e6982..53cba990d6 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/model/PropertyUpdatesModel.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.TreeMap; + import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.utils.PropertyComparator; @@ -28,19 +29,15 @@ /** * Model class for using with the {@linkplain org.codehaus.mojo.versions.api.ReportRenderer} API */ -public class PropertyUpdatesModel -{ +public class PropertyUpdatesModel { private final Map allUpdates; - public PropertyUpdatesModel( PropertyComparator comparator, Map propertyUpdates ) - { - this.allUpdates = new TreeMap<>( comparator ); - this.allUpdates.putAll( propertyUpdates ); + public PropertyUpdatesModel(PropertyComparator comparator, Map propertyUpdates) { + this.allUpdates = new TreeMap<>(comparator); + this.allUpdates.putAll(propertyUpdates); } - public Map getAllUpdates() - { + public Map getAllUpdates() { return allUpdates; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java index 12ff25b558..d2791ffc87 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/util/AggregateReportUtils.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; + import org.apache.maven.project.MavenProject; /** @@ -27,8 +28,7 @@ * * @since 2.14.0 * */ -public class AggregateReportUtils -{ +public class AggregateReportUtils { /** * Returns an aggregated list of {@link MavenProject} for the given project. @@ -37,17 +37,14 @@ public class AggregateReportUtils * * @return aggregated list of MavenProject objects for the given project(also containing the project itself) * */ - public static List getProjectsToProcess( final MavenProject project ) - { - if ( project == null ) - { + public static List getProjectsToProcess(final MavenProject project) { + if (project == null) { return Collections.emptyList(); } List result = new ArrayList<>(); - result.add( project ); - result.addAll( project.getCollectedProjects() ); + result.add(project); + result.addAll(project.getCollectedProjects()); return result; } - } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java index e828d3d785..e282381011 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/CommonXmlReportRendererUtils.java @@ -35,25 +35,18 @@ /** * Common utils for Xml report renderers */ -class CommonXmlReportRendererUtils -{ - static void setSection( AbstractVersionDetails versions, Segment segment, Consumer> setterFunction ) - { - ofNullable( versions.getAllUpdates( of( segment ) ) ) - .map( v -> Arrays.stream( v ) - .map( ArtifactVersion::toString ) - .collect( Collectors.toList() ) ) - .ifPresent( setterFunction ); +class CommonXmlReportRendererUtils { + static void setSection(AbstractVersionDetails versions, Segment segment, Consumer> setterFunction) { + ofNullable(versions.getAllUpdates(of(segment))) + .map(v -> Arrays.stream(v).map(ArtifactVersion::toString).collect(Collectors.toList())) + .ifPresent(setterFunction); } - static String statusFor( String lastVersion, Collection incrementals, Collection minors ) - { + static String statusFor(String lastVersion, Collection incrementals, Collection minors) { return lastVersion == null ? "no new available" : incrementals != null && !incrementals.isEmpty() - ? "incremental available" - : minors != null && !minors.isEmpty() - ? "minor available" - : "major available"; + ? "incremental available" + : minors != null && !minors.isEmpty() ? "minor available" : "major available"; } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java index d360a92ab1..863329ed21 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java @@ -56,19 +56,17 @@ * @author Illia Dubinin * @since 2.4 */ -public class DependencyUpdatesXmlReportRenderer implements ReportRenderer -{ +public class DependencyUpdatesXmlReportRenderer implements ReportRenderer { private final DependencyUpdatesModel model; private final Path outputFile; - private final ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); + private final ArtifactVersionsCache newestUpdateCache = + new ArtifactVersionsCache(AbstractVersionDetails::getNewestUpdate); /** * Creates a new instance * @param model object containing the updates model * @param outputFile output file for the report */ - public DependencyUpdatesXmlReportRenderer( DependencyUpdatesModel model, Path outputFile ) - { + public DependencyUpdatesXmlReportRenderer(DependencyUpdatesModel model, Path outputFile) { this.model = model; this.outputFile = outputFile; } @@ -77,53 +75,52 @@ public DependencyUpdatesXmlReportRenderer( DependencyUpdatesModel model, Path ou * Creates an XML report */ @Override - public void render() - { - try ( BufferedWriter writer = Files.newBufferedWriter( outputFile, - StandardCharsets.UTF_8 ) ) - { - new DependencyUpdatesReportXpp3Writer().write( writer, new DependencyUpdatesReport() - {{ - setSummary( new DependencyReportSummary() - {{ - OverviewStats overviewStats = OverviewStats.fromUpdates( model.getAllUpdates().values(), - newestUpdateCache ); - setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); - setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); - setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); - setNextMinorAvailable( String.valueOf( overviewStats.getMinor() ) ); - setNextMajorAvailable( String.valueOf( overviewStats.getMajor() ) ); - }} ); - setDependencyManagements( createDependencyInfo( model.getArtifactManagementUpdates() ) ); - setDependencies( createDependencyInfo( model.getArtifactUpdates() ) ); - }} ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); + public void render() { + try (BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) { + new DependencyUpdatesReportXpp3Writer().write(writer, new DependencyUpdatesReport() { + { + setSummary(new DependencyReportSummary() { + { + OverviewStats overviewStats = OverviewStats.fromUpdates( + model.getAllUpdates().values(), newestUpdateCache); + setUsingLastVersion(String.valueOf(overviewStats.getUpToDate())); + setNextVersionAvailable(String.valueOf(overviewStats.getAny())); + setNextIncrementalAvailable(String.valueOf(overviewStats.getIncremental())); + setNextMinorAvailable(String.valueOf(overviewStats.getMinor())); + setNextMajorAvailable(String.valueOf(overviewStats.getMajor())); + } + }); + setDependencyManagements(createDependencyInfo(model.getArtifactManagementUpdates())); + setDependencies(createDependencyInfo(model.getArtifactUpdates())); + } + }); + } catch (IOException e) { + throw new RuntimeException(e); } } - private static List createDependencyInfo( Map versions ) - { - return versions.entrySet().stream().map( e -> - new DependencyInfo() - {{ - setGroupId( e.getKey().getGroupId() ); - setArtifactId( e.getKey().getArtifactId() ); - setCurrentVersion( e.getKey().getVersion() ); - setScope( e.getKey().getScope() ); - setType( e.getKey().getType() ); - setClassifier( e.getKey().getClassifier() ); + private static List createDependencyInfo(Map versions) { + return versions.entrySet().stream() + .map(e -> new DependencyInfo() { + { + setGroupId(e.getKey().getGroupId()); + setArtifactId(e.getKey().getArtifactId()); + setCurrentVersion(e.getKey().getVersion()); + setScope(e.getKey().getScope()); + setType(e.getKey().getType()); + setClassifier(e.getKey().getClassifier()); - ofNullable( e.getValue().getNewestUpdate( empty() ) ) - .map( ArtifactVersion::toString ).ifPresent( this::setLastVersion ); + ofNullable(e.getValue().getNewestUpdate(empty())) + .map(ArtifactVersion::toString) + .ifPresent(this::setLastVersion); - setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); - setSection( e.getValue(), MINOR, this::setMinors ); - setSection( e.getValue(), MAJOR, this::setMajors ); + setSection(e.getValue(), INCREMENTAL, this::setIncrementals); + setSection(e.getValue(), MINOR, this::setMinors); + setSection(e.getValue(), MAJOR, this::setMajors); - setStatus( statusFor( getLastVersion(), getIncrementals(), getMinors() ) ); - }} ).collect( Collectors.toList() ); + setStatus(statusFor(getLastVersion(), getIncrementals(), getMinors())); + } + }) + .collect(Collectors.toList()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java index 42173d048b..b80fc6ee6c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PluginUpdatesXmlReportRenderer.java @@ -56,19 +56,17 @@ * @author Illia Dubinin * @since 2.4 */ -public class PluginUpdatesXmlReportRenderer implements ReportRenderer -{ +public class PluginUpdatesXmlReportRenderer implements ReportRenderer { private final PluginUpdatesModel model; private final Path outputFile; - private final ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); + private final ArtifactVersionsCache newestUpdateCache = + new ArtifactVersionsCache(AbstractVersionDetails::getNewestUpdate); /** * Creates a new instance * @param model object containing the updates model * @param outputFile output file for the report */ - public PluginUpdatesXmlReportRenderer( PluginUpdatesModel model, Path outputFile ) - { + public PluginUpdatesXmlReportRenderer(PluginUpdatesModel model, Path outputFile) { this.model = model; this.outputFile = outputFile; } @@ -77,54 +75,53 @@ public PluginUpdatesXmlReportRenderer( PluginUpdatesModel model, Path outputFile * Creates an XML report */ @Override - public void render() - { - try ( BufferedWriter writer = Files.newBufferedWriter( outputFile, - StandardCharsets.UTF_8 ) ) - { - new PluginUpdatesReportXpp3Writer().write( writer, new PluginUpdatesReport() - {{ - setSummary( new PluginReportSummary() - {{ - PluginOverviewStats overviewStats = PluginOverviewStats.fromUpdates( - model.getAllUpdates().values(), newestUpdateCache ); - setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); - setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); - setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); - setNextMinorAvailable( String.valueOf( overviewStats.getMinor() ) ); - setNextMajorAvailable( String.valueOf( overviewStats.getMajor() ) ); - setDependencyUpdates( String.valueOf( overviewStats.getDependencies() ) ); - }} ); - setPluginManagements( createPluginInfo( model.getArtifactManagementUpdates() ) ); - setPlugins( createPluginInfo( model.getArtifactUpdates() ) ); - }} ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); + public void render() { + try (BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) { + new PluginUpdatesReportXpp3Writer().write(writer, new PluginUpdatesReport() { + { + setSummary(new PluginReportSummary() { + { + PluginOverviewStats overviewStats = PluginOverviewStats.fromUpdates( + model.getAllUpdates().values(), newestUpdateCache); + setUsingLastVersion(String.valueOf(overviewStats.getUpToDate())); + setNextVersionAvailable(String.valueOf(overviewStats.getAny())); + setNextIncrementalAvailable(String.valueOf(overviewStats.getIncremental())); + setNextMinorAvailable(String.valueOf(overviewStats.getMinor())); + setNextMajorAvailable(String.valueOf(overviewStats.getMajor())); + setDependencyUpdates(String.valueOf(overviewStats.getDependencies())); + } + }); + setPluginManagements(createPluginInfo(model.getArtifactManagementUpdates())); + setPlugins(createPluginInfo(model.getArtifactUpdates())); + } + }); + } catch (IOException e) { + throw new RuntimeException(e); } } - private static List createPluginInfo( Map versions ) - { - return versions.entrySet().stream().map( e -> - new PluginInfo() - {{ - setGroupId( e.getKey().getGroupId() ); - setArtifactId( e.getKey().getArtifactId() ); - setCurrentVersion( e.getKey().getVersion() ); - setScope( e.getKey().getScope() ); - setType( e.getKey().getType() ); - setClassifier( e.getKey().getClassifier() ); + private static List createPluginInfo(Map versions) { + return versions.entrySet().stream() + .map(e -> new PluginInfo() { + { + setGroupId(e.getKey().getGroupId()); + setArtifactId(e.getKey().getArtifactId()); + setCurrentVersion(e.getKey().getVersion()); + setScope(e.getKey().getScope()); + setType(e.getKey().getType()); + setClassifier(e.getKey().getClassifier()); - ofNullable( e.getValue().getNewestUpdate( empty() ) ) - .map( ArtifactVersion::toString ).ifPresent( this::setLastVersion ); + ofNullable(e.getValue().getNewestUpdate(empty())) + .map(ArtifactVersion::toString) + .ifPresent(this::setLastVersion); - setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); - setSection( e.getValue(), MINOR, this::setMinors ); - setSection( e.getValue(), MAJOR, this::setMajors ); + setSection(e.getValue(), INCREMENTAL, this::setIncrementals); + setSection(e.getValue(), MINOR, this::setMinors); + setSection(e.getValue(), MAJOR, this::setMajors); - setStatus( statusFor( getLastVersion(), getIncrementals(), getMinors() ) ); - }} ).collect( Collectors.toList() ); + setStatus(statusFor(getLastVersion(), getIncrementals(), getMinors())); + } + }) + .collect(Collectors.toList()); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java index 2042858614..0068c32ee5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/xml/PropertyUpdatesXmlReportRenderer.java @@ -30,9 +30,9 @@ import java.util.stream.Collectors; import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersionsCache; +import org.codehaus.mojo.versions.api.Property; import org.codehaus.mojo.versions.api.PropertyVersions; import org.codehaus.mojo.versions.api.ReportRenderer; import org.codehaus.mojo.versions.reporting.OverviewStats; @@ -55,19 +55,17 @@ * XML renderer for PropertyUpdatesReport creates an xml file in target directory and writes report about available * dependency/dependency management updates. */ -public class PropertyUpdatesXmlReportRenderer implements ReportRenderer -{ +public class PropertyUpdatesXmlReportRenderer implements ReportRenderer { private final PropertyUpdatesModel model; private final Path outputFile; - private final ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); + private final ArtifactVersionsCache newestUpdateCache = + new ArtifactVersionsCache(AbstractVersionDetails::getNewestUpdate); /** * Creates a new instance * @param model object containing the updates model * @param outputFile output file for the report */ - public PropertyUpdatesXmlReportRenderer( PropertyUpdatesModel model, Path outputFile ) - { + public PropertyUpdatesXmlReportRenderer(PropertyUpdatesModel model, Path outputFile) { this.model = model; this.outputFile = outputFile; } @@ -76,59 +74,57 @@ public PropertyUpdatesXmlReportRenderer( PropertyUpdatesModel model, Path output * Creates an XML report */ @Override - public void render() - { - try ( BufferedWriter writer = Files.newBufferedWriter( outputFile, - StandardCharsets.UTF_8 ) ) - { - new PropertyUpdatesReportXpp3Writer().write( writer, new PropertyUpdatesReport() - {{ - setSummary( new PropertyReportSummary() - {{ - OverviewStats overviewStats = OverviewStats.fromUpdates( model.getAllUpdates().values(), - newestUpdateCache ); - setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); - setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); - setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); - setNextMinorAvailable( String.valueOf( overviewStats.getMinor() ) ); - setNextMajorAvailable( String.valueOf( overviewStats.getMajor() ) ); - }} ); - setProperties( createPropertyInfo( model.getAllUpdates() ) ); - }} ); - } - catch ( IOException e ) - { - throw new RuntimeException( e ); + public void render() { + try (BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) { + new PropertyUpdatesReportXpp3Writer().write(writer, new PropertyUpdatesReport() { + { + setSummary(new PropertyReportSummary() { + { + OverviewStats overviewStats = OverviewStats.fromUpdates( + model.getAllUpdates().values(), newestUpdateCache); + setUsingLastVersion(String.valueOf(overviewStats.getUpToDate())); + setNextVersionAvailable(String.valueOf(overviewStats.getAny())); + setNextIncrementalAvailable(String.valueOf(overviewStats.getIncremental())); + setNextMinorAvailable(String.valueOf(overviewStats.getMinor())); + setNextMajorAvailable(String.valueOf(overviewStats.getMajor())); + } + }); + setProperties(createPropertyInfo(model.getAllUpdates())); + } + }); + } catch (IOException e) { + throw new RuntimeException(e); } } - private static List createPropertyInfo( Map versions ) - { - return versions.entrySet().stream().map( e -> - new PropertyInfo() - {{ - setPropertyName( e.getKey().getName() ); - if ( e.getValue().getAssociations() != null - && e.getValue().getAssociations().length != 0 ) + private static List createPropertyInfo(Map versions) { + return versions.entrySet().stream() + .map(e -> new PropertyInfo() { { - setPropertyAssociations( Arrays.stream( e.getValue().getAssociations() ) - .map( a -> - { - PropertyAssociation pa = new PropertyAssociation(); - pa.setGroupId( a.getGroupId() ); - pa.setArtifactId( a.getArtifactId() ); - return pa; - } ).collect( Collectors.toList() ) ); - } - setCurrentVersion( e.getKey().getVersion() ); - ofNullable( e.getValue().getNewestUpdate( empty() ) ) - .map( ArtifactVersion::toString ).ifPresent( this::setLastVersion ); + setPropertyName(e.getKey().getName()); + if (e.getValue().getAssociations() != null + && e.getValue().getAssociations().length != 0) { + setPropertyAssociations(Arrays.stream(e.getValue().getAssociations()) + .map(a -> { + PropertyAssociation pa = new PropertyAssociation(); + pa.setGroupId(a.getGroupId()); + pa.setArtifactId(a.getArtifactId()); + return pa; + }) + .collect(Collectors.toList())); + } + setCurrentVersion(e.getKey().getVersion()); + ofNullable(e.getValue().getNewestUpdate(empty())) + .map(ArtifactVersion::toString) + .ifPresent(this::setLastVersion); - setSection( e.getValue(), INCREMENTAL, this::setIncrementals ); - setSection( e.getValue(), MINOR, this::setMinors ); - setSection( e.getValue(), MAJOR, this::setMajors ); + setSection(e.getValue(), INCREMENTAL, this::setIncrementals); + setSection(e.getValue(), MINOR, this::setMinors); + setSection(e.getValue(), MAJOR, this::setMajors); - setStatus( statusFor( getLastVersion(), getIncrementals(), getMinors() ) ); - }} ).collect( Collectors.toList() ); + setStatus(statusFor(getLastVersion(), getIncrementals(), getMinors())); + } + }) + .collect(Collectors.toList()); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java index b09a77f364..b7945227a1 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/AbstractVersionsUpdaterMojoTest.java @@ -31,14 +31,12 @@ * * @author Stephen Connolly */ -public class AbstractVersionsUpdaterMojoTest -{ +public class AbstractVersionsUpdaterMojoTest { private NumericVersionComparator instance = new NumericVersionComparator(); - private int instanceCompare( String v1, String v2 ) - { - return instance.compare( new DefaultArtifactVersion( v1 ), new DefaultArtifactVersion( v2 ) ); + private int instanceCompare(String v1, String v2) { + return instance.compare(new DefaultArtifactVersion(v1), new DefaultArtifactVersion(v2)); } /** @@ -46,15 +44,14 @@ private int instanceCompare( String v1, String v2 ) * */ @Test - public void testBasic() - { - assertEquals( 0, instanceCompare( "1", "1" ) ); - assertTrue( instanceCompare( "1", "2" ) < 0 ); - assertTrue( instanceCompare( "2", "1" ) > 0 ); - assertTrue( instanceCompare( "1", "1-SNAPSHOT" ) > 0 ); - assertTrue( instanceCompare( "1", "1.0" ) > 0 ); - assertTrue( instanceCompare( "1.1", "1" ) > 0 ); - assertTrue( instanceCompare( "5.1.0.0.24", "5.1.0.0.9" ) > 0 ); - assertTrue( instanceCompare( "5.1.0.0.2a4", "5.1.0.0.9" ) < 0 ); + public void testBasic() { + assertEquals(0, instanceCompare("1", "1")); + assertTrue(instanceCompare("1", "2") < 0); + assertTrue(instanceCompare("2", "1") > 0); + assertTrue(instanceCompare("1", "1-SNAPSHOT") > 0); + assertTrue(instanceCompare("1", "1.0") > 0); + assertTrue(instanceCompare("1.1", "1") > 0); + assertTrue(instanceCompare("5.1.0.0.24", "5.1.0.0.9") > 0); + assertTrue(instanceCompare("5.1.0.0.2a4", "5.1.0.0.9") < 0); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java index 81d7f92e51..110bf9e123 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojoTest.java @@ -60,240 +60,221 @@ * * @author Andrzej Jarmoniuk */ -public class DependencyUpdatesReportMojoTest -{ - private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesReportMojo - { +public class DependencyUpdatesReportMojoTest { + private static class TestDependencyUpdatesReportMojo extends DependencyUpdatesReportMojo { private static final I18N MOCK_I18N = mockI18N(); - TestDependencyUpdatesReportMojo() - { - super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), null, - new ReportRendererFactoryImpl( MOCK_I18N ) ); + TestDependencyUpdatesReportMojo() { + super( + MOCK_I18N, + mockRepositorySystem(), + mockAetherRepositorySystem(), + null, + new ReportRendererFactoryImpl(MOCK_I18N)); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); - project.setOriginalModel( new Model() ); - project.getOriginalModel().setDependencyManagement( new DependencyManagement() ); - project.getModel().setDependencyManagement( new DependencyManagement() ); + project.setOriginalModel(new Model()); + project.getOriginalModel().setDependencyManagement(new DependencyManagement()); + project.getModel().setDependencyManagement(new DependencyManagement()); session = mockMavenSession(); } - public TestDependencyUpdatesReportMojo withDependencies( Dependency... dependencies ) - { - project.setDependencies( Arrays.asList( dependencies ) ); + public TestDependencyUpdatesReportMojo withDependencies(Dependency... dependencies) { + project.setDependencies(Arrays.asList(dependencies)); return this; } public TestDependencyUpdatesReportMojo withAetherRepositorySystem( - org.eclipse.aether.RepositorySystem repositorySystem ) - { + org.eclipse.aether.RepositorySystem repositorySystem) { this.aetherRepositorySystem = repositorySystem; return this; } public TestDependencyUpdatesReportMojo withOriginalDependencyManagement( - Dependency... originalDependencyManagement ) - { - project.getOriginalModel().getDependencyManagement() - .setDependencies( Arrays.asList( originalDependencyManagement ) ); + Dependency... originalDependencyManagement) { + project.getOriginalModel() + .getDependencyManagement() + .setDependencies(Arrays.asList(originalDependencyManagement)); return this; } - public TestDependencyUpdatesReportMojo withDependencyManagement( Dependency... dependencyManagement ) - { - project.getModel().getDependencyManagement().setDependencies( Arrays.asList( dependencyManagement ) ); + public TestDependencyUpdatesReportMojo withDependencyManagement(Dependency... dependencyManagement) { + project.getModel().getDependencyManagement().setDependencies(Arrays.asList(dependencyManagement)); return this; } - public TestDependencyUpdatesReportMojo withOnlyUpgradable( boolean onlyUpgradable ) - { + public TestDependencyUpdatesReportMojo withOnlyUpgradable(boolean onlyUpgradable) { this.onlyUpgradable = onlyUpgradable; return this; } - public TestDependencyUpdatesReportMojo withProcessDependencyManagement( boolean processDependencyManagement ) - { + public TestDependencyUpdatesReportMojo withProcessDependencyManagement(boolean processDependencyManagement) { this.processDependencyManagement = processDependencyManagement; return this; } public TestDependencyUpdatesReportMojo withProcessDependencyManagementTransitive( - boolean processDependencyManagementTransitive ) - { + boolean processDependencyManagementTransitive) { this.processDependencyManagementTransitive = processDependencyManagementTransitive; return this; } - public TestDependencyUpdatesReportMojo withOnlyProjectDependencies( - boolean onlyProjectDependencies ) - { + public TestDependencyUpdatesReportMojo withOnlyProjectDependencies(boolean onlyProjectDependencies) { this.onlyProjectDependencies = onlyProjectDependencies; return this; } - public TestDependencyUpdatesReportMojo withRuleSet( - RuleSet ruleSet ) - { + public TestDependencyUpdatesReportMojo withRuleSet(RuleSet ruleSet) { this.ruleSet = ruleSet; return this; } - public TestDependencyUpdatesReportMojo withIgnoredVersions( - Set ignoredVersions ) - { + public TestDependencyUpdatesReportMojo withIgnoredVersions(Set ignoredVersions) { this.ignoredVersions = ignoredVersions; return this; } - public TestDependencyUpdatesReportMojo withAllowSnapshots( boolean allowSnapshots ) - { + public TestDependencyUpdatesReportMojo withAllowSnapshots(boolean allowSnapshots) { this.allowSnapshots = allowSnapshots; return this; } - public TestDependencyUpdatesReportMojo withOriginalProperty( String name, String value ) - { - project.getOriginalModel().getProperties().put( name, value ); + public TestDependencyUpdatesReportMojo withOriginalProperty(String name, String value) { + project.getOriginalModel().getProperties().put(name, value); return this; } } - private static Dependency dependencyOf( String artifactId ) - { - return DependencyBuilder.dependencyWith( "groupA", artifactId, "1.0.0", - "default", "pom", SCOPE_COMPILE ); + private static Dependency dependencyOf(String artifactId) { + return DependencyBuilder.dependencyWith("groupA", artifactId, "1.0.0", "default", "pom", SCOPE_COMPILE); } - private static Dependency dependencyOf( String artifactId, String version ) - { - return DependencyBuilder.dependencyWith( "groupA", artifactId, version, - "default", "pom", SCOPE_COMPILE ); + private static Dependency dependencyOf(String artifactId, String version) { + return DependencyBuilder.dependencyWith("groupA", artifactId, version, "default", "pom", SCOPE_COMPILE); } @Test - public void testOnlyUpgradableDependencies() throws IOException, MavenReportException, IllegalAccessException - { + public void testOnlyUpgradableDependencies() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withOnlyUpgradable( true ) - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); - }} ) ) - .withDependencies( - dependencyOf( "artifactA", "1.0.0" ), - dependencyOf( "artifactB", "1.0.0" ), - dependencyOf( "artifactC", "2.0.0" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOnlyUpgradable(true) + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + put("artifactC", new String[] {"1.0.0", "2.0.0"}); + } + })) + .withDependencies( + dependencyOf("artifactA", "1.0.0"), + dependencyOf("artifactB", "1.0.0"), + dependencyOf("artifactC", "2.0.0")) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, containsString( "artifactA" ) ); - assertThat( output, not( containsString( "artifactB" ) ) ); - assertThat( output, not( containsString( "artifactC" ) ) ); + assertThat(output, containsString("artifactA")); + assertThat(output, not(containsString("artifactB"))); + assertThat(output, not(containsString("artifactC"))); } @Test public void testOnlyUpgradableWithOriginalDependencyManagement() - throws IOException, MavenReportException, IllegalAccessException - { + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withOriginalDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOriginalDependencyManagement( + dependencyOf("artifactA"), dependencyOf("artifactB"), dependencyOf("artifactC")) + .withProcessDependencyManagement(true) + .withOnlyUpgradable(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); - assertThat( output, not( containsString( "artifactC" ) ) ); + assertThat(output, allOf(containsString("artifactA"), containsString("artifactB"))); + assertThat(output, not(containsString("artifactC"))); } @Test public void testOnlyUpgradableWithTransitiveDependencyManagement() - throws IOException, MavenReportException, IllegalAccessException - { + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withDependencyManagement( - dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withProcessDependencyManagementTransitive( true ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withDependencyManagement( + dependencyOf("artifactA"), dependencyOf("artifactB"), dependencyOf("artifactC")) + .withProcessDependencyManagement(true) + .withProcessDependencyManagementTransitive(true) + .withOnlyUpgradable(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, allOf( containsString( "artifactA" ), containsString( "artifactB" ) ) ); - assertThat( output, not( containsString( "artifactC" ) ) ); + assertThat(output, allOf(containsString("artifactA"), containsString("artifactB"))); + assertThat(output, not(containsString("artifactC"))); } @Test - public void testOnlyProjectDependencies() throws IOException, MavenReportException, IllegalAccessException - { + public void testOnlyProjectDependencies() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withDependencies( dependencyOf( "artifactA" ) ) - .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withOnlyProjectDependencies( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withDependencies(dependencyOf("artifactA")) + .withDependencyManagement( + dependencyOf("artifactA"), dependencyOf("artifactB"), dependencyOf("artifactC")) + .withProcessDependencyManagement(true) + .withOnlyProjectDependencies(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, containsString( "artifactA" ) ); - assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); + assertThat(output, containsString("artifactA")); + assertThat(output, not(anyOf(containsString("artifactB"), containsString("artifactC")))); } @Test public void testOnlyProjectDependenciesWithIgnoredVersions() - throws IOException, MavenReportException, IllegalAccessException - { + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withDependencies( dependencyOf( "artifactA" ) ) - .withDependencyManagement( dependencyOf( "artifactA" ), dependencyOf( "artifactB" ), - dependencyOf( "artifactC" ) ) - .withProcessDependencyManagement( true ) - .withOnlyProjectDependencies( true ) - .withIgnoredVersions( Collections.singleton( "2.0.0" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - - String output = os.toString().replaceAll( "\n", "" ); - assertThat( output, containsString( "report.noUpdatesAvailable" ) ); + .withDependencies(dependencyOf("artifactA")) + .withDependencyManagement( + dependencyOf("artifactA"), dependencyOf("artifactB"), dependencyOf("artifactC")) + .withProcessDependencyManagement(true) + .withOnlyProjectDependencies(true) + .withIgnoredVersions(Collections.singleton("2.0.0")) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); + + String output = os.toString().replaceAll("\n", ""); + assertThat(output, containsString("report.noUpdatesAvailable")); } /** * Dependencies should be rendered in alphabetical order */ @Test - public void testDependenciesInAlphabeticalOrder() throws IOException, MavenReportException, IllegalAccessException - { + public void testDependenciesInAlphabeticalOrder() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "amstrad", new String[] {"1.0.0", "2.0.0"} ); - put( "atari", new String[] {"1.0.0", "2.0.0"} ); - put( "commodore", new String[] {"1.0.0", "2.0.0"} ); - put( "spectrum", new String[] {"1.0.0", "2.0.0"} ); - }} ) ) - .withDependencies( dependencyOf( "spectrum" ), dependencyOf( "atari" ), - dependencyOf( "amstrad" ), dependencyOf( "commodore" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - - String output = os.toString().replaceAll( "\n", "" ); - assertThat( output, Matchers.stringContainsInOrder( "amstrad", "atari", "commodore", "spectrum" ) ); + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("amstrad", new String[] {"1.0.0", "2.0.0"}); + put("atari", new String[] {"1.0.0", "2.0.0"}); + put("commodore", new String[] {"1.0.0", "2.0.0"}); + put("spectrum", new String[] {"1.0.0", "2.0.0"}); + } + })) + .withDependencies( + dependencyOf("spectrum"), + dependencyOf("atari"), + dependencyOf("amstrad"), + dependencyOf("commodore")) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); + + String output = os.toString().replaceAll("\n", ""); + assertThat(output, Matchers.stringContainsInOrder("amstrad", "atari", "commodore", "spectrum")); } /** @@ -301,88 +282,86 @@ public void testDependenciesInAlphabeticalOrder() throws IOException, MavenRepor */ @Test public void testDependenciesShouldOverrideDependencyManagement() - throws IOException, MavenReportException, IllegalAccessException - { + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withProcessDependencyManagement( true ) - .withProcessDependencyManagementTransitive( true ) - .withDependencies( dependencyOf( "artifactA", "2.0.0" ), - dependencyOf( "artifactB" ) ) - .withDependencyManagement( dependencyOf( "artifactA" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - - String output = os.toString().replaceAll( "\n", "" ); - assertThat( output, Matchers.stringContainsInOrder( "artifactB" ) ); + .withProcessDependencyManagement(true) + .withProcessDependencyManagementTransitive(true) + .withDependencies(dependencyOf("artifactA", "2.0.0"), dependencyOf("artifactB")) + .withDependencyManagement(dependencyOf("artifactA")) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); + + String output = os.toString().replaceAll("\n", ""); + assertThat(output, Matchers.stringContainsInOrder("artifactB")); } @Test - public void testWrongReportBounds() throws IOException, MavenReportException, IllegalAccessException - { + public void testWrongReportBounds() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withOnlyUpgradable( true ) - .withDependencies( - dependencyOf( "test-artifact" ) ) - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "test-artifact", new String[] { "1.0.0", "2.0.0-M1" } ); - }} ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - - String output = os.toString().replaceAll( "\n", "" ).replaceAll( "\r", "" ); - assertThat( output, allOf( - matchesPattern( ".*report.overview.numNewerMajorAvailable\\s*1.*" ), - matchesPattern( ".*report.overview.numUpToDate\\s*0.*" ) ) ); + .withOnlyUpgradable(true) + .withDependencies(dependencyOf("test-artifact")) + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("test-artifact", new String[] {"1.0.0", "2.0.0-M1"}); + } + })) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); + + String output = os.toString().replaceAll("\n", "").replaceAll("\r", ""); + assertThat( + output, + allOf( + matchesPattern(".*report.overview.numNewerMajorAvailable\\s*1.*"), + matchesPattern(".*report.overview.numUpToDate\\s*0.*"))); } @Test - public void testIt001Overview() throws IOException, MavenReportException, IllegalAccessException - { + public void testIt001Overview() throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withOnlyUpgradable( true ) - .withDependencies( - dependencyOf( "test-artifact", "1.1" ) ) - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "test-artifact", new String[] { "1.1.0-2", "1.1", "1.1.1", "1.1.1-2", - "1.1.2", "1.1.3", "1.2", "1.2.1", "1.2.2", "1.3", "2.0", "2.1", "3.0"} ); - }} ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOnlyUpgradable(true) + .withDependencies(dependencyOf("test-artifact", "1.1")) + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("test-artifact", new String[] { + "1.1.0-2", "1.1", "1.1.1", "1.1.1-2", "1.1.2", "1.1.3", "1.2", "1.2.1", "1.2.2", "1.3", + "2.0", "2.1", "3.0" + }); + } + })) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString() - .replaceAll( "<[^>]+>", " " ) - .replaceAll( "&[^;]+;", " " ) - .replaceAll( "\\s+", " " ); - assertThat( "Did not generate summary correctly", output, - containsString( "groupA test-artifact 1.1 compile pom default 1.1.0-2 1.1.3 1.3 3.0" ) ); + .replaceAll("<[^>]+>", " ") + .replaceAll("&[^;]+;", " ") + .replaceAll("\\s+", " "); + assertThat( + "Did not generate summary correctly", + output, + containsString("groupA test-artifact 1.1 compile pom default 1.1.0-2 1.1.3 1.3 3.0")); } @Test public void testResolvedVersionsWithoutTransitiveDependencyManagement() - throws IOException, MavenReportException, IllegalAccessException - { + throws IOException, MavenReportException, IllegalAccessException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestDependencyUpdatesReportMojo() - .withOriginalDependencyManagement( - dependencyOf( "artifactA", "1.0.0" ), - dependencyOf( "artifactB", "${mycomponent.version}" ) ) - .withDependencyManagement( - dependencyOf( "artifactA", "1.0.0" ), - dependencyOf( "artifactB", "${mycomponent.version}" ) ) - .withProcessDependencyManagement( true ) - .withProcessDependencyManagementTransitive( false ) - .withOnlyUpgradable( false ) - .withOriginalProperty( "mycomponent.version", "1.2.3" ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withOriginalDependencyManagement( + dependencyOf("artifactA", "1.0.0"), dependencyOf("artifactB", "${mycomponent.version}")) + .withDependencyManagement( + dependencyOf("artifactA", "1.0.0"), dependencyOf("artifactB", "${mycomponent.version}")) + .withProcessDependencyManagement(true) + .withProcessDependencyManagementTransitive(false) + .withOnlyUpgradable(false) + .withOriginalProperty("mycomponent.version", "1.2.3") + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, Matchers - .stringContainsInOrder( "artifactA", "1.0.0", "artifactB", "1.2.3" ) ); + assertThat(output, Matchers.stringContainsInOrder("artifactA", "1.0.0", "artifactB", "1.2.3")); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java index bb8d851ae6..a398282d6d 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -46,59 +46,62 @@ * * @author Andrzej Jarmoniuk */ -public class DependencyUpdatesXmlRendererTest -{ +public class DependencyUpdatesXmlRendererTest { private Path tempFile; @Before - public void setUp() throws IOException - { - tempFile = Files.createTempFile( "xml-dependency-report", "" ); + public void setUp() throws IOException { + tempFile = Files.createTempFile("xml-dependency-report", ""); } @After - public void tearDown() throws IOException - { - if ( tempFile != null && Files.exists( tempFile ) ) - { - Files.delete( tempFile ); + public void tearDown() throws IOException { + if (tempFile != null && Files.exists(tempFile)) { + Files.delete(tempFile); } } @Test - public void testReportGeneration() throws IOException - { - new DependencyUpdatesXmlReportRenderer( new DependencyUpdatesModel( - singletonMap( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "artifactA" ) - .withVersion( "1.0.0" ) - .build(), new ArtifactVersions( - new DefaultArtifact( "default-group", "artifactA", - "1.0.0", SCOPE_COMPILE, "jar", "default", - null ), - Arrays.asList( - new DefaultArtifactVersion( "1.0.0" ), - new DefaultArtifactVersion( "1.0.1" ), - new DefaultArtifactVersion( "1.1.0" ), - new DefaultArtifactVersion( "2.0.0" ) - ), - new MavenVersionComparator() ) ), - emptyMap() ), tempFile ).render(); - String output = String.join( "", Files.readAllLines( tempFile ) ) - .replaceAll( ">\\s*<", "><" ); + public void testReportGeneration() throws IOException { + new DependencyUpdatesXmlReportRenderer( + new DependencyUpdatesModel( + singletonMap( + DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("artifactA") + .withVersion("1.0.0") + .build(), + new ArtifactVersions( + new DefaultArtifact( + "default-group", + "artifactA", + "1.0.0", + SCOPE_COMPILE, + "jar", + "default", + null), + Arrays.asList( + new DefaultArtifactVersion("1.0.0"), + new DefaultArtifactVersion("1.0.1"), + new DefaultArtifactVersion("1.1.0"), + new DefaultArtifactVersion("2.0.0")), + new MavenVersionComparator())), + emptyMap()), + tempFile) + .render(); + String output = String.join("", Files.readAllLines(tempFile)).replaceAll(">\\s*<", "><"); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "1" ) ); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "0" ) ); + assertThat(output, containsString("0")); + assertThat(output, containsString("0")); + assertThat(output, containsString("1")); + assertThat(output, containsString("0")); + assertThat(output, containsString("0")); - assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "2.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); - assertThat( output, containsString( "1.1.0" ) ); - assertThat( output, containsString( "2.0.0" ) ); - assertThat( output, containsString( "incremental available" ) ); + assertThat(output, containsString("1.0.0")); + assertThat(output, containsString("2.0.0")); + assertThat(output, containsString("1.0.1")); + assertThat(output, containsString("1.1.0")); + assertThat(output, containsString("2.0.0")); + assertThat(output, containsString("incremental available")); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java index 1119b5636b..035268371c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayDependencyUpdatesMojoTest.java @@ -61,385 +61,374 @@ * * @author Andrzej Jarmoniuk */ -public class DisplayDependencyUpdatesMojoTest extends AbstractMojoTestCase -{ +public class DisplayDependencyUpdatesMojoTest extends AbstractMojoTestCase { @Rule - public final MojoRule mojoRule = new MojoRule( this ); + public final MojoRule mojoRule = new MojoRule(this); @Test - public void testValidateGAVListSuccessful() throws MojoExecutionException - { - DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group", "group:artifact", - "group:artifact:version" ), 3, "" ); + public void testValidateGAVListSuccessful() throws MojoExecutionException { + DisplayDependencyUpdatesMojo.validateGAVList( + Arrays.asList("group", "group:artifact", "group:artifact:version"), 3, ""); } @Test - public void testValidateGAVListFailed() - { - try - { - DisplayDependencyUpdatesMojo.validateGAVList( Arrays.asList( "group:artifact:version", - "group:artifact:version:type" ), 3, "" ); - fail( "Method should have thrown a MojoExecutionException" ); - } - catch ( MojoExecutionException ignored ) - { + public void testValidateGAVListFailed() { + try { + DisplayDependencyUpdatesMojo.validateGAVList( + Arrays.asList("group:artifact:version", "group:artifact:version:type"), 3, ""); + fail("Method should have thrown a MojoExecutionException"); + } catch (MojoExecutionException ignored) { } } @Test - public void testRuleSetPresentAndWorking() throws Exception - { + public void testRuleSetPresentAndWorking() throws Exception { File outputFile = null; - try - { - outputFile = File.createTempFile( "display-dependency-updates", "" ); + try { + outputFile = File.createTempFile("display-dependency-updates", ""); assert outputFile.exists(); DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( - new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset" ), - "display-dependency-updates" ); - assertThat( mojo.ruleSet, notNullValue() ); - assertThat( mojo.ruleSet.getIgnoreVersions(), notNullValue() ); - assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); - assertThat( mojo.ruleSet.getIgnoreVersions(), hasItem( matches( - new TestIgnoreVersions().withVersion( "1.0.1" ) ) ) ); - assertThat( mojo.ruleSet.getIgnoreVersions(), containsInAnyOrder( - matches( new TestIgnoreVersions().withVersion( "1.0.1" ) ), - matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-SNAPSHOT" ) ), - matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-M\\d+" ) ) ) ); + new File("target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset"), + "display-dependency-updates"); + assertThat(mojo.ruleSet, notNullValue()); + assertThat(mojo.ruleSet.getIgnoreVersions(), notNullValue()); + assertThat(mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize(3)); + assertThat( + mojo.ruleSet.getIgnoreVersions(), hasItem(matches(new TestIgnoreVersions().withVersion("1.0.1")))); + assertThat( + mojo.ruleSet.getIgnoreVersions(), + containsInAnyOrder( + matches(new TestIgnoreVersions().withVersion("1.0.1")), + matches(new TestIgnoreVersions() + .withType(TYPE_REGEX) + .withVersion(".+-SNAPSHOT")), + matches(new TestIgnoreVersions() + .withType(TYPE_REGEX) + .withVersion(".+-M\\d+")))); // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() - {{ - put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); - }} ); + mojo.aetherRepositorySystem = mockAetherRepositorySystem(new HashMap() { + { + put("dummy-api", new String[] {"1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT"}); + } + }); - assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + assertThat(mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize(3)); mojo.execute(); - List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); - assertThat( output, not( hasItem( containsString( "1.1.0-M1" ) ) ) ); - } - finally - { + List output = Files.readAllLines(outputFile.toPath(), UTF_8); + assertThat(output, not(hasItem(containsString("1.1.0-M1")))); + } finally { assert outputFile == null || !outputFile.exists() || outputFile.delete(); } } - private MavenProject createProject() - { - return new MavenProject( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "default-artifact" ); - setVersion( "1.0.0-SNAPSHOT" ); - - setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "default-dependency" ) - .withVersion( "1.0.0" ) - .build() ) ); - }} ) - {{ - setOriginalModel( getModel() ); - }}; + private MavenProject createProject() { + return new MavenProject(new Model() { + { + setGroupId("default-group"); + setArtifactId("default-artifact"); + setVersion("1.0.0-SNAPSHOT"); + + setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("default-dependency") + .withVersion("1.0.0") + .build())); + } + }) { + { + setOriginalModel(getModel()); + } + }; } @Test public void testVersionsWithQualifiersNotConsideredAsMinorUpdates() - throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException - { + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException { Path tempPath = null; - try - { - tempPath = Files.createTempFile( "display-dependency-updates", "" ); + try { + tempPath = Files.createTempFile("display-dependency-updates", ""); final File tempFile = tempPath.toFile(); - new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", - "2.0.0-rc1"} ); - }} ), + new DisplayDependencyUpdatesMojo( + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put( + "default-dependency", + new String[] {"1.0.0", "1.1.0", "2.0.0-SNAPSHOT", "2.0.0-beta", "2.0.0-rc1"}); + } + }), null, - null ) - {{ - setProject( createProject() ); - setVariableValueToObject( this, "allowAnyUpdates", false ); - setVariableValueToObject( this, "allowMajorUpdates", false ); - setVariableValueToObject( this, "processDependencies", true ); - setVariableValueToObject( this, "dependencyIncludes", - singletonList( WildcardMatcher.WILDCARD ) ); - setVariableValueToObject( this, "dependencyExcludes", emptyList() ); - this.allowSnapshots = true; - this.outputFile = tempFile; - setPluginContext( new HashMap<>() ); - - session = mockMavenSession(); - }}.execute(); - - assertThat( String.join( "", Files.readAllLines( tempPath ) ), - not( anyOf( containsString( "2.0.0-SNAPSHOT" ), - containsString( "2.0.0-beta" ), - containsString( "2.0.0-rc1" ) ) ) ); - } - finally - { - if ( tempPath != null && Files.exists( tempPath ) ) - { - Files.delete( tempPath ); + null) { + { + setProject(createProject()); + setVariableValueToObject(this, "allowAnyUpdates", false); + setVariableValueToObject(this, "allowMajorUpdates", false); + setVariableValueToObject(this, "processDependencies", true); + setVariableValueToObject(this, "dependencyIncludes", singletonList(WildcardMatcher.WILDCARD)); + setVariableValueToObject(this, "dependencyExcludes", emptyList()); + this.allowSnapshots = true; + this.outputFile = tempFile; + setPluginContext(new HashMap<>()); + + session = mockMavenSession(); + } + }.execute(); + + assertThat( + String.join("", Files.readAllLines(tempPath)), + not(anyOf( + containsString("2.0.0-SNAPSHOT"), + containsString("2.0.0-beta"), + containsString("2.0.0-rc1")))); + } finally { + if (tempPath != null && Files.exists(tempPath)) { + Files.delete(tempPath); } } } @Test public void testAllowMajorUpdatesFalse() - throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException - { + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException { Path tempPath = null; - try - { - tempPath = Files.createTempFile( "display-dependency-updates", "" ); + try { + tempPath = Files.createTempFile("display-dependency-updates", ""); final File tempFile = tempPath.toFile(); - new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"} ); - }} ), + new DisplayDependencyUpdatesMojo( + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put("default-dependency", new String[] {"1.0.0", "1.1.0", "2.0.0"}); + } + }), null, - null ) - {{ - setProject( createProject() ); - setVariableValueToObject( this, "allowAnyUpdates", false ); - setVariableValueToObject( this, "allowMajorUpdates", false ); - setVariableValueToObject( this, "processDependencies", true ); - setVariableValueToObject( this, "dependencyIncludes", - singletonList( WildcardMatcher.WILDCARD ) ); - setVariableValueToObject( this, "dependencyExcludes", emptyList() ); - this.outputFile = tempFile; - setPluginContext( new HashMap<>() ); - - session = mockMavenSession(); - }}.execute(); - - String output = String.join( "", Files.readAllLines( tempPath ) ); - - assertThat( output, containsString( "1.1.0" ) ); - assertThat( output, not( containsString( "2.0.0" ) ) ); - } - finally - { - if ( tempPath != null && Files.exists( tempPath ) ) - { - Files.delete( tempPath ); + null) { + { + setProject(createProject()); + setVariableValueToObject(this, "allowAnyUpdates", false); + setVariableValueToObject(this, "allowMajorUpdates", false); + setVariableValueToObject(this, "processDependencies", true); + setVariableValueToObject(this, "dependencyIncludes", singletonList(WildcardMatcher.WILDCARD)); + setVariableValueToObject(this, "dependencyExcludes", emptyList()); + this.outputFile = tempFile; + setPluginContext(new HashMap<>()); + + session = mockMavenSession(); + } + }.execute(); + + String output = String.join("", Files.readAllLines(tempPath)); + + assertThat(output, containsString("1.1.0")); + assertThat(output, not(containsString("2.0.0"))); + } finally { + if (tempPath != null && Files.exists(tempPath)) { + Files.delete(tempPath); } } } @Test public void testAllowMinorUpdatesFalse() - throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException - { + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException { Path tempPath = null; - try - { - tempPath = Files.createTempFile( "display-dependency-updates", "" ); + try { + tempPath = Files.createTempFile("display-dependency-updates", ""); final File tempFile = tempPath.toFile(); - new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), + new DisplayDependencyUpdatesMojo( + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put("default-dependency", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0"}); + } + }), null, - null ) - {{ - setProject( createProject() ); - setVariableValueToObject( this, "allowAnyUpdates", false ); - setVariableValueToObject( this, "allowMinorUpdates", false ); - setVariableValueToObject( this, "processDependencies", true ); - setVariableValueToObject( this, "dependencyIncludes", - singletonList( WildcardMatcher.WILDCARD ) ); - setVariableValueToObject( this, "dependencyExcludes", emptyList() ); - this.outputFile = tempFile; - setPluginContext( new HashMap<>() ); - - session = mockMavenSession(); - }}.execute(); - - String output = String.join( "", Files.readAllLines( tempPath ) ); - - assertThat( output, containsString( "1.0.1" ) ); - assertThat( output, not( containsString( "1.1.0" ) ) ); - assertThat( output, not( containsString( "2.0.0" ) ) ); - } - finally - { - if ( tempPath != null && Files.exists( tempPath ) ) - { - Files.delete( tempPath ); + null) { + { + setProject(createProject()); + setVariableValueToObject(this, "allowAnyUpdates", false); + setVariableValueToObject(this, "allowMinorUpdates", false); + setVariableValueToObject(this, "processDependencies", true); + setVariableValueToObject(this, "dependencyIncludes", singletonList(WildcardMatcher.WILDCARD)); + setVariableValueToObject(this, "dependencyExcludes", emptyList()); + this.outputFile = tempFile; + setPluginContext(new HashMap<>()); + + session = mockMavenSession(); + } + }.execute(); + + String output = String.join("", Files.readAllLines(tempPath)); + + assertThat(output, containsString("1.0.1")); + assertThat(output, not(containsString("1.1.0"))); + assertThat(output, not(containsString("2.0.0"))); + } finally { + if (tempPath != null && Files.exists(tempPath)) { + Files.delete(tempPath); } } } @Test public void testAllowIncrementalUpdatesFalse() - throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException - { + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException { Path tempPath = null; - try - { - tempPath = Files.createTempFile( "display-dependency-updates", "" ); + try { + tempPath = Files.createTempFile("display-dependency-updates", ""); final File tempFile = tempPath.toFile(); - new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"} ); - }} ), + new DisplayDependencyUpdatesMojo( + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put("default-dependency", new String[] {"1.0.0", "1.0.0-1", "1.0.1", "1.1.0", "2.0.0"}); + } + }), null, - null ) - {{ - setProject( createProject() ); - setVariableValueToObject( this, "allowAnyUpdates", false ); - setVariableValueToObject( this, "allowIncrementalUpdates", false ); - setVariableValueToObject( this, "processDependencies", true ); - setVariableValueToObject( this, "dependencyIncludes", - singletonList( WildcardMatcher.WILDCARD ) ); - setVariableValueToObject( this, "dependencyExcludes", emptyList() ); - this.outputFile = tempFile; - setPluginContext( new HashMap<>() ); - - session = mockMavenSession(); - }}.execute(); - - String output = String.join( "", Files.readAllLines( tempPath ) ); - - assertThat( output, containsString( "1.0.0-1" ) ); - assertThat( output, not( containsString( "1.0.1" ) ) ); - assertThat( output, not( containsString( "1.1.0" ) ) ); - assertThat( output, not( containsString( "2.0.0" ) ) ); - } - finally - { - if ( tempPath != null && Files.exists( tempPath ) ) - { - Files.delete( tempPath ); + null) { + { + setProject(createProject()); + setVariableValueToObject(this, "allowAnyUpdates", false); + setVariableValueToObject(this, "allowIncrementalUpdates", false); + setVariableValueToObject(this, "processDependencies", true); + setVariableValueToObject(this, "dependencyIncludes", singletonList(WildcardMatcher.WILDCARD)); + setVariableValueToObject(this, "dependencyExcludes", emptyList()); + this.outputFile = tempFile; + setPluginContext(new HashMap<>()); + + session = mockMavenSession(); + } + }.execute(); + + String output = String.join("", Files.readAllLines(tempPath)); + + assertThat(output, containsString("1.0.0-1")); + assertThat(output, not(containsString("1.0.1"))); + assertThat(output, not(containsString("1.1.0"))); + assertThat(output, not(containsString("2.0.0"))); + } finally { + if (tempPath != null && Files.exists(tempPath)) { + Files.delete(tempPath); } } } @Test public void testVersionsWithQualifiersNotConsideredAsIncrementalUpdates() - throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException - { + throws MojoExecutionException, MojoFailureException, IllegalAccessException, IOException { Path tempPath = null; - try - { - tempPath = Files.createTempFile( "display-dependency-updates", "" ); + try { + tempPath = Files.createTempFile("display-dependency-updates", ""); final File tempFile = tempPath.toFile(); - new DisplayDependencyUpdatesMojo( mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-dependency", new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", - "1.9.0-rc1"} ); - }} ), + new DisplayDependencyUpdatesMojo( + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put( + "default-dependency", + new String[] {"1.0.0", "1.1.0", "1.9.0-SNAPSHOT", "1.9.0-beta", "1.9.0-rc1"}); + } + }), null, - null ) - {{ - setProject( createProject() ); - setVariableValueToObject( this, "allowAnyUpdates", false ); - setVariableValueToObject( this, "allowMinorUpdates", false ); - setVariableValueToObject( this, "processDependencies", true ); - setVariableValueToObject( this, "dependencyIncludes", - singletonList( WildcardMatcher.WILDCARD ) ); - setVariableValueToObject( this, "dependencyExcludes", emptyList() ); - this.allowSnapshots = true; - this.outputFile = tempFile; - setPluginContext( new HashMap<>() ); - - session = mockMavenSession(); - }}.execute(); - - assertThat( String.join( "", Files.readAllLines( tempPath ) ), - not( anyOf( containsString( "1.9.0-SNAPSHOT" ), - containsString( "1.9.0-beta" ), - containsString( "1.9.0-rc1" ) ) ) ); - } - finally - { - if ( tempPath != null && Files.exists( tempPath ) ) - { - Files.delete( tempPath ); + null) { + { + setProject(createProject()); + setVariableValueToObject(this, "allowAnyUpdates", false); + setVariableValueToObject(this, "allowMinorUpdates", false); + setVariableValueToObject(this, "processDependencies", true); + setVariableValueToObject(this, "dependencyIncludes", singletonList(WildcardMatcher.WILDCARD)); + setVariableValueToObject(this, "dependencyExcludes", emptyList()); + this.allowSnapshots = true; + this.outputFile = tempFile; + setPluginContext(new HashMap<>()); + + session = mockMavenSession(); + } + }.execute(); + + assertThat( + String.join("", Files.readAllLines(tempPath)), + not(anyOf( + containsString("1.9.0-SNAPSHOT"), + containsString("1.9.0-beta"), + containsString("1.9.0-rc1")))); + } finally { + if (tempPath != null && Files.exists(tempPath)) { + Files.delete(tempPath); } } } @Test - public void testDetermineUpdatedSegment() throws Exception - { + public void testDetermineUpdatedSegment() throws Exception { File outputFile = null; - try - { - outputFile = File.createTempFile( "display-dependency-updates", "" ); + try { + outputFile = File.createTempFile("display-dependency-updates", ""); assert outputFile.exists(); DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( - new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset" ), - "display-dependency-updates" ); - - assertThat( mojo.ruleSet, notNullValue() ); - assertThat( mojo.ruleSet.getIgnoreVersions(), notNullValue() ); - assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); - assertThat( mojo.ruleSet.getIgnoreVersions(), hasItem( matches( - new TestIgnoreVersions().withVersion( "1.0.1" ) ) ) ); - assertThat( mojo.ruleSet.getIgnoreVersions(), containsInAnyOrder( - matches( new TestIgnoreVersions().withVersion( "1.0.1" ) ), - matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-SNAPSHOT" ) ), - matches( new TestIgnoreVersions().withType( TYPE_REGEX ).withVersion( ".+-M\\d+" ) ) ) ); + new File("target/test-classes/org/codehaus/mojo/display-dependency-updates/ruleset"), + "display-dependency-updates"); + + assertThat(mojo.ruleSet, notNullValue()); + assertThat(mojo.ruleSet.getIgnoreVersions(), notNullValue()); + assertThat(mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize(3)); + assertThat( + mojo.ruleSet.getIgnoreVersions(), hasItem(matches(new TestIgnoreVersions().withVersion("1.0.1")))); + assertThat( + mojo.ruleSet.getIgnoreVersions(), + containsInAnyOrder( + matches(new TestIgnoreVersions().withVersion("1.0.1")), + matches(new TestIgnoreVersions() + .withType(TYPE_REGEX) + .withVersion(".+-SNAPSHOT")), + matches(new TestIgnoreVersions() + .withType(TYPE_REGEX) + .withVersion(".+-M\\d+")))); // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() - {{ - put( "dummy-api", new String[] { "1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT" } ); - }} ); + mojo.aetherRepositorySystem = mockAetherRepositorySystem(new HashMap() { + { + put("dummy-api", new String[] {"1.0.0", "1.0.1", "1.1.0-M1", "1.2.0-SNAPSHOT"}); + } + }); - assertThat( mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize( 3 ) ); + assertThat(mojo.ruleSet.getIgnoreVersions(), Matchers.hasSize(3)); mojo.execute(); - List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); - assertThat( output, not( hasItem( containsString( "1.1.0-M1" ) ) ) ); - } - finally - { + List output = Files.readAllLines(outputFile.toPath(), UTF_8); + assertThat(output, not(hasItem(containsString("1.1.0-M1")))); + } finally { assert outputFile == null || !outputFile.exists() || outputFile.delete(); } } @Test - public void testVersionInterpolation() throws Exception - { + public void testVersionInterpolation() throws Exception { File outputFile = null; - try - { - outputFile = File.createTempFile( "display-dependency-updates", "" ); + try { + outputFile = File.createTempFile("display-dependency-updates", ""); assert outputFile.exists(); DisplayDependencyUpdatesMojo mojo = (DisplayDependencyUpdatesMojo) mojoRule.lookupConfiguredMojo( - new File( "target/test-classes/org/codehaus/mojo/display-dependency-updates/version-interpolation" ), - "display-dependency-updates" ); + new File("target/test-classes/org/codehaus/mojo/display-dependency-updates/version-interpolation"), + "display-dependency-updates"); // This is just an example of how to create it-style tests as unit tests; the advantage is easier debugging mojo.outputFile = outputFile; - mojo.aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() - {{ - put( "dummy-api", new String[] { "2.0.1" } ); - }} ); - setVariableValueToObject( mojo, "processDependencyManagementTransitive", false ); + mojo.aetherRepositorySystem = mockAetherRepositorySystem(new HashMap() { + { + put("dummy-api", new String[] {"2.0.1"}); + } + }); + setVariableValueToObject(mojo, "processDependencyManagementTransitive", false); mojo.execute(); - List output = Files.readAllLines( outputFile.toPath(), UTF_8 ); - assertThat( output, not( hasItem( containsString( "mycomponent.version" ) ) ) ); - } - finally - { + List output = Files.readAllLines(outputFile.toPath(), UTF_8); + assertThat(output, not(hasItem(containsString("mycomponent.version")))); + } finally { assert outputFile == null || !outputFile.exists() || outputFile.delete(); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java index a1e78b1a3f..fabb909a41 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/DisplayPropertyUpdatesMojoTest.java @@ -40,72 +40,64 @@ /** * Unit tests for {@link DisplayPropertyUpdatesMojo} */ -public class DisplayPropertyUpdatesMojoTest extends AbstractMojoTestCase -{ +public class DisplayPropertyUpdatesMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); private Path tempDir; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - tempDir = TestUtils.createTempDir( "display-property-updates" ); + tempDir = TestUtils.createTempDir("display-property-updates"); } @After - public void tearDown() throws Exception - { - try - { - TestUtils.tearDownTempDir( tempDir ); - } - finally - { + public void tearDown() throws Exception { + try { + TestUtils.tearDownTempDir(tempDir); + } finally { super.tearDown(); } } @Test - public void testPropertiesFromParent() throws Exception - { - Path tempFile = Files.createTempFile( tempDir, "output", "" ); + public void testPropertiesFromParent() throws Exception { + Path tempFile = Files.createTempFile(tempDir, "output", ""); - TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367" ), - tempDir ); - DisplayPropertyUpdatesMojo mojo = - (DisplayPropertyUpdatesMojo) mojoRule.lookupConfiguredMojo( tempDir.resolve( "child" ).toFile(), - "display-property-updates" ); + TestUtils.copyDir( + Paths.get("src/test/resources/org/codehaus/mojo/display-property-updates/issue-367"), tempDir); + DisplayPropertyUpdatesMojo mojo = (DisplayPropertyUpdatesMojo) + mojoRule.lookupConfiguredMojo(tempDir.resolve("child").toFile(), "display-property-updates"); mojo.outputEncoding = UTF_8; mojo.outputFile = tempFile.toFile(); - mojo.setPluginContext( new HashMap<>() ); + mojo.setPluginContext(new HashMap<>()); mojo.aetherRepositorySystem = mockAetherRepositorySystem(); mojo.includeParent = true; mojo.execute(); - assertThat( String.join( "", Files.readAllLines( tempFile ) ), - matchesPattern( ".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*" ) ); + assertThat( + String.join("", Files.readAllLines(tempFile)), + matchesPattern(".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*")); } @Test - public void testDisablePropertiesFromParent() throws Exception - { - Path tempFile = Files.createTempFile( tempDir, "output", "" ); + public void testDisablePropertiesFromParent() throws Exception { + Path tempFile = Files.createTempFile(tempDir, "output", ""); - TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367" ), - tempDir ); - DisplayPropertyUpdatesMojo mojo = - (DisplayPropertyUpdatesMojo) mojoRule.lookupConfiguredMojo( tempDir.resolve( "child" ).toFile(), - "display-property-updates" ); + TestUtils.copyDir( + Paths.get("src/test/resources/org/codehaus/mojo/display-property-updates/issue-367"), tempDir); + DisplayPropertyUpdatesMojo mojo = (DisplayPropertyUpdatesMojo) + mojoRule.lookupConfiguredMojo(tempDir.resolve("child").toFile(), "display-property-updates"); mojo.outputEncoding = UTF_8; mojo.outputFile = tempFile.toFile(); - mojo.setPluginContext( new HashMap<>() ); + mojo.setPluginContext(new HashMap<>()); mojo.aetherRepositorySystem = mockAetherRepositorySystem(); mojo.includeParent = false; mojo.execute(); - assertThat( String.join( "", Files.readAllLines( tempFile ) ), - not( matchesPattern( ".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*" ) ) ); + assertThat( + String.join("", Files.readAllLines(tempFile)), + not(matchesPattern(".*\\$\\{ver} \\.* 1\\.0\\.0 -> 2\\.0\\.0.*"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java index 5f1aee06b8..6dd54904aa 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ForceReleasesMojoTest.java @@ -53,158 +53,167 @@ /** * Unit tests for {@link ForceReleasesMojo} */ -public class ForceReleasesMojoTest extends AbstractMojoTestCase -{ +public class ForceReleasesMojoTest extends AbstractMojoTestCase { private TestChangeRecorder changeRecorder; private ForceReleasesMojo mojo; @Before - public void setUp() throws IllegalAccessException - { + public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new ForceReleasesMojo( mockRepositorySystem(), - mockAetherRepositorySystem(), - null, - changeRecorder.asTestMap() ); - setVariableValueToObject( mojo, "reactorProjects", emptyList() ); - mojo.project = new MavenProject() - {{ - setModel( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "default-artifact" ); - setVersion( "1.0.0" ); - }} ); - }}; + mojo = new ForceReleasesMojo( + mockRepositorySystem(), mockAetherRepositorySystem(), null, changeRecorder.asTestMap()); + setVariableValueToObject(mojo, "reactorProjects", emptyList()); + mojo.project = new MavenProject() { + { + setModel(new Model() { + { + setGroupId("default-group"); + setArtifactId("default-artifact"); + setVersion("1.0.0"); + } + }); + } + }; mojo.session = mockMavenSession(); } @Test public void testProcessParent() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processParent", true ); - mojo.getProject().setParent( new MavenProject( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "artifactA" ); - setVersion( "1.0.0-SNAPSHOT" ); - }} ) ); - mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "artifactA", - "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processParent", true); + mojo.getProject().setParent(new MavenProject(new Model() { + { + setGroupId("default-group"); + setArtifactId("artifactA"); + setVersion("1.0.0-SNAPSHOT"); + } + })); + mojo.getProject() + .setParentArtifact(new DefaultArtifact( + "default-group", "artifactA", "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null)); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), anyString())) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0"))); } @Test public void testReplaceSnapshotWithRelease() - throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException - { - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "artifactA" ) - .withVersion( "1.0.0-SNAPSHOT" ) - .build() ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("artifactA") + .withVersion("1.0.0-SNAPSHOT") + .build())); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0"))); } @Test public void testUpgrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException - { - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "artifactA" ) - .withVersion( "1.1.0-SNAPSHOT" ) - .build() ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("artifactA") + .withVersion("1.1.0-SNAPSHOT") + .build())); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "1.1.0-SNAPSHOT", "2.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "1.1.0-SNAPSHOT", "2.0.0"))); } @Test public void testDowngrade() - throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException - { - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "artifactA" ) - .withVersion( "2.1.0-SNAPSHOT" ) - .build() ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("artifactA") + .withVersion("2.1.0-SNAPSHOT") + .build())); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "2.1.0-SNAPSHOT", "2.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "2.1.0-SNAPSHOT", "2.0.0"))); } @Test public void testFailIfNotReplaced() - throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException - { - mojo.aetherRepositorySystem = mockAetherRepositorySystem( singletonMap( "test-artifact", - new String[] {} ) ); - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "test-artifact" ) - .withVersion( "1.0.0-SNAPSHOT" ) - .build() ) ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.aetherRepositorySystem = mockAetherRepositorySystem(singletonMap("test-artifact", new String[] {})); + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("test-artifact") + .withVersion("1.0.0-SNAPSHOT") + .build())); mojo.failIfNotReplaced = true; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); - fail( "MojoExecutionException is expected" ); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), startsWith( "No matching" ) ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); + fail("MojoExecutionException is expected"); + } catch (MojoExecutionException e) { + assertThat(e.getMessage(), startsWith("No matching")); } } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java index 73bb50082d..a2caf7a981 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/MinimalMavenBuildVersionFinderTest.java @@ -9,40 +9,32 @@ /** * Unit tests for MinimalMavenBuildVersionFinder. */ -public class MinimalMavenBuildVersionFinderTest -{ +public class MinimalMavenBuildVersionFinderTest { @Test - public void testValidVersionRanges() - { - DefaultArtifactVersion expectedMinimumVersion = new DefaultArtifactVersion( "1.0" ); - assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0" ) ); - assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0]" ) ); - assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,)" ) ); - assertEquals( expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,)" ) ); - assertEquals( expectedMinimumVersion, - MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,2.0]" ) ); - assertEquals( expectedMinimumVersion, - MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,2.0)" ) ); - assertEquals( expectedMinimumVersion, - MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0,2.0]" ) ); - assertEquals( expectedMinimumVersion, - MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "[1.0,2.0)" ) ); + public void testValidVersionRanges() { + DefaultArtifactVersion expectedMinimumVersion = new DefaultArtifactVersion("1.0"); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0)")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0,2.0]")); + assertEquals(expectedMinimumVersion, MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("[1.0,2.0)")); } @Test - public void testInvalidVersionRanges() - { - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0]" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0)" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.0],[1.2,)" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.1),(1.1,)" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(,1.1),[1.1,)" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0)" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "1.0()" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "()1.0" ) ); - assertNull( MinimalMavenBuildVersionFinder.getMinimumVersionFromRange( "(1.0]" ) ); + public void testInvalidVersionRanges() { + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0]")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.0],[1.2,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),(1.1,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(,1.1),[1.1,)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0)")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("1.0()")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("()1.0")); + assertNull(MinimalMavenBuildVersionFinder.getMinimumVersionFromRange("(1.0]")); } - } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java index 449f3d025c..78a82608a6 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/ParentUpdatesReportMojoTest.java @@ -51,45 +51,61 @@ * * @author Andrzej Jarmoniuk */ -public class ParentUpdatesReportMojoTest -{ +public class ParentUpdatesReportMojoTest { private static final I18N MOCK_I18N = mockI18N(); + @Test - public void testAllowSnapshots() throws IOException, MavenReportException - { + public void testAllowSnapshots() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - new ParentUpdatesReportMojo( MOCK_I18N, mockRepositorySystem(), - mockAetherRepositorySystem( new HashMap() - {{ - put( "default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"} ); - }} ), null, new ReportRendererFactoryImpl( MOCK_I18N ) ) - {{ - allowSnapshots = true; - project = new MavenProject( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "child-artifact" ); - setVersion( "1.0.0" ); - }} ); - project.setParent( new MavenProject( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "default-artifact" ); - setVersion( "1.0.0" ); - }} ) ); - reactorProjects = new ArrayList<>(); - project.setParentArtifact( new DefaultArtifact( project.getParent().getGroupId(), - project.getParent().getArtifactId(), project.getParent().getVersion(), - Artifact.SCOPE_COMPILE, "pom", "default", - new DefaultArtifactHandlerStub( "default" ) ) ); + new ParentUpdatesReportMojo( + MOCK_I18N, + mockRepositorySystem(), + mockAetherRepositorySystem(new HashMap() { + { + put("default-artifact", new String[] {"1.0.0", "1.0.1", "1.1.0", "2.0.0", "2.0.1-SNAPSHOT"}); + } + }), + null, + new ReportRendererFactoryImpl(MOCK_I18N)) { + { + allowSnapshots = true; + project = new MavenProject(new Model() { + { + setGroupId("default-group"); + setArtifactId("child-artifact"); + setVersion("1.0.0"); + } + }); + project.setParent(new MavenProject(new Model() { + { + setGroupId("default-group"); + setArtifactId("default-artifact"); + setVersion("1.0.0"); + } + })); + reactorProjects = new ArrayList<>(); + project.setParentArtifact(new DefaultArtifact( + project.getParent().getGroupId(), + project.getParent().getArtifactId(), + project.getParent().getVersion(), + Artifact.SCOPE_COMPILE, + "pom", + "default", + new DefaultArtifactHandlerStub("default"))); - session = mockMavenSession(); - }}.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + session = mockMavenSession(); + } + }.generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, allOf( containsString( "1.0.0" ), - containsString( "1.0.1" ), containsString( "1.1.0" ), - containsString( "2.0.0" ), containsString( "2.0.1-SNAPSHOT" ) ) ); + assertThat( + output, + allOf( + containsString("1.0.0"), + containsString("1.0.1"), + containsString("1.1.0"), + containsString("2.0.0"), + containsString("2.0.1-SNAPSHOT"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java index 2342f299bd..4a752b081f 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesReportMojoTest.java @@ -62,183 +62,169 @@ * * @author Andrzej Jarmoniuk */ -public class PluginUpdatesReportMojoTest -{ - private static class TestPluginUpdatesReportMojo extends PluginUpdatesReportMojo - { +public class PluginUpdatesReportMojoTest { + private static class TestPluginUpdatesReportMojo extends PluginUpdatesReportMojo { static final I18N MOCK_I18N = mockI18N(); - TestPluginUpdatesReportMojo() - { - super( MOCK_I18N, mockRepositorySystem(), mockAetherRepositorySystem(), - null, new ReportRendererFactoryImpl( MOCK_I18N ) ); + + TestPluginUpdatesReportMojo() { + super( + MOCK_I18N, + mockRepositorySystem(), + mockAetherRepositorySystem(), + null, + new ReportRendererFactoryImpl(MOCK_I18N)); siteTool = MockUtils.mockSiteTool(); project = new MavenProject(); - project.setBuild( new Build() ); - project.getBuild().setPluginManagement( new PluginManagement() ); + project.setBuild(new Build()); + project.getBuild().setPluginManagement(new PluginManagement()); session = mockMavenSession(); } - public TestPluginUpdatesReportMojo withPlugins( Plugin... plugins ) - { - project.getBuild().setPlugins( Arrays.asList( plugins ) ); + public TestPluginUpdatesReportMojo withPlugins(Plugin... plugins) { + project.getBuild().setPlugins(Arrays.asList(plugins)); return this; } public TestPluginUpdatesReportMojo withAetherRepositorySystem( - org.eclipse.aether.RepositorySystem repositorySystem ) - { + org.eclipse.aether.RepositorySystem repositorySystem) { this.aetherRepositorySystem = repositorySystem; return this; } - public TestPluginUpdatesReportMojo withPluginManagement( Plugin... pluginManagement ) - { - project.getBuild().getPluginManagement().setPlugins( Arrays.asList( pluginManagement ) ); + public TestPluginUpdatesReportMojo withPluginManagement(Plugin... pluginManagement) { + project.getBuild().getPluginManagement().setPlugins(Arrays.asList(pluginManagement)); return this; } - public TestPluginUpdatesReportMojo withOnlyUpgradable( boolean onlyUpgradable ) - { + public TestPluginUpdatesReportMojo withOnlyUpgradable(boolean onlyUpgradable) { this.onlyUpgradable = onlyUpgradable; return this; } - public TestPluginUpdatesReportMojo withOnlyProjectPlugins( boolean onlyProjectPlugins ) - { + public TestPluginUpdatesReportMojo withOnlyProjectPlugins(boolean onlyProjectPlugins) { this.onlyProjectPlugins = onlyProjectPlugins; return this; } - public TestPluginUpdatesReportMojo withRuleSet( - RuleSet ruleSet ) - { + public TestPluginUpdatesReportMojo withRuleSet(RuleSet ruleSet) { this.ruleSet = ruleSet; return this; } - public TestPluginUpdatesReportMojo withIgnoredVersions( - Set ignoredVersions ) - { + public TestPluginUpdatesReportMojo withIgnoredVersions(Set ignoredVersions) { this.ignoredVersions = ignoredVersions; return this; } - private static RepositorySystem mockRepositorySystem() - { - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createPluginArtifact( any( Plugin.class ) ) ).thenAnswer( - invocation -> - { - Plugin plugin = invocation.getArgument( 0 ); - return new DefaultArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), - SCOPE_RUNTIME, "maven-plugin", "jar", - new DefaultArtifactHandlerStub( "default" ) ); - } ); + private static RepositorySystem mockRepositorySystem() { + RepositorySystem repositorySystem = mock(RepositorySystem.class); + when(repositorySystem.createPluginArtifact(any(Plugin.class))).thenAnswer(invocation -> { + Plugin plugin = invocation.getArgument(0); + return new DefaultArtifact( + plugin.getGroupId(), + plugin.getArtifactId(), + plugin.getVersion(), + SCOPE_RUNTIME, + "maven-plugin", + "jar", + new DefaultArtifactHandlerStub("default")); + }); return repositorySystem; } } - private static Plugin pluginOf( String artifactId ) - { - return pluginOf( artifactId, "1.0.0" ); + private static Plugin pluginOf(String artifactId) { + return pluginOf(artifactId, "1.0.0"); } - private static Plugin pluginOf( String artifactId, String version ) - { - return new Plugin() - { + private static Plugin pluginOf(String artifactId, String version) { + return new Plugin() { { - setGroupId( "defaultGroup" ); - setArtifactId( artifactId ); - setVersion( version ); + setGroupId("defaultGroup"); + setArtifactId(artifactId); + setVersion(version); } }; } @Test - public void testOnlyUpgradablePlugins() throws IOException, MavenReportException - { + public void testOnlyUpgradablePlugins() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); - }} ) ) - .withPlugins( pluginOf( "artifactA", "1.0.0" ), - pluginOf( "artifactB", "1.0.0" ), - pluginOf( "artifactC", "2.0.0" ) ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + put("artifactC", new String[] {"1.0.0", "2.0.0"}); + } + })) + .withPlugins( + pluginOf("artifactA", "1.0.0"), pluginOf("artifactB", "1.0.0"), pluginOf("artifactC", "2.0.0")) + .withOnlyUpgradable(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, containsString( "artifactA" ) ); - assertThat( output, not( containsString( "artifactB" ) ) ); - assertThat( output, not( containsString( "artifactC" ) ) ); + assertThat(output, containsString("artifactA")); + assertThat(output, not(containsString("artifactB"))); + assertThat(output, not(containsString("artifactC"))); } @Test - public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenReportException - { + public void testOnlyUpgradableWithPluginManagement() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withAetherRepositorySystem( mockAetherRepositorySystem( new HashMap() - {{ - put( "artifactA", new String[] { "1.0.0", "2.0.0" } ); - put( "artifactB", new String[] { "1.0.0" } ); - put( "artifactC", new String[] { "1.0.0", "2.0.0" } ); - }} ) ) - .withPluginManagement( pluginOf( "artifactA", "1.0.0" ), - pluginOf( "artifactB", "1.0.0" ), - pluginOf( "artifactC", "2.0.0" ) ) - .withOnlyUpgradable( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withAetherRepositorySystem(mockAetherRepositorySystem(new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0"}); + put("artifactC", new String[] {"1.0.0", "2.0.0"}); + } + })) + .withPluginManagement( + pluginOf("artifactA", "1.0.0"), pluginOf("artifactB", "1.0.0"), pluginOf("artifactC", "2.0.0")) + .withOnlyUpgradable(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, containsString( "artifactA" ) ); - assertThat( output, not( containsString( "artifactB" ) ) ); - assertThat( output, not( containsString( "artifactC" ) ) ); + assertThat(output, containsString("artifactA")); + assertThat(output, not(containsString("artifactB"))); + assertThat(output, not(containsString("artifactC"))); } @Test - public void testOnlyProjectPlugins() throws IOException, MavenReportException - { + public void testOnlyProjectPlugins() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withPlugins( pluginOf( "artifactA" ) ) - .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .withOnlyProjectPlugins( true ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + .withPlugins(pluginOf("artifactA")) + .withPluginManagement(pluginOf("artifactA"), pluginOf("artifactB"), pluginOf("artifactC")) + .withOnlyUpgradable(true) + .withOnlyProjectPlugins(true) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString(); - assertThat( output, containsString( "artifactA" ) ); - assertThat( output, not( anyOf( containsString( "artifactB" ), containsString( "artifactC" ) ) ) ); + assertThat(output, containsString("artifactA")); + assertThat(output, not(anyOf(containsString("artifactB"), containsString("artifactC")))); } @Test - public void testOnlyProjectPluginsWithIgnoredVersions() throws IOException, MavenReportException - { + public void testOnlyProjectPluginsWithIgnoredVersions() throws IOException, MavenReportException { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); new TestPluginUpdatesReportMojo() - .withPlugins( pluginOf( "artifactA" ) ) - .withPluginManagement( pluginOf( "artifactA" ), pluginOf( "artifactB" ), - pluginOf( "artifactC" ) ) - .withOnlyUpgradable( true ) - .withOnlyProjectPlugins( true ) - .withIgnoredVersions( Collections.singleton( "2.0.0" ) ) - .generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); - - String output = os.toString().replaceAll( "\\s", " " ) - .replaceAll( "<[^>]+>", " " ).replaceAll( "&[^;]+;", " " ); - assertThat( output, matchesPattern( ".*\\breport.overview.numNewerVersionAvailable\\s+0\\b.*" ) ); + .withPlugins(pluginOf("artifactA")) + .withPluginManagement(pluginOf("artifactA"), pluginOf("artifactB"), pluginOf("artifactC")) + .withOnlyUpgradable(true) + .withOnlyProjectPlugins(true) + .withIgnoredVersions(Collections.singleton("2.0.0")) + .generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); + + String output = + os.toString().replaceAll("\\s", " ").replaceAll("<[^>]+>", " ").replaceAll("&[^;]+;", " "); + assertThat(output, matchesPattern(".*\\breport.overview.numNewerVersionAvailable\\s+0\\b.*")); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java index a0b9cb2e15..a25b092bc0 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java @@ -50,80 +50,73 @@ * * @author Andrzej Jarmoniuk */ -public class PluginUpdatesXmlRendererTest -{ +public class PluginUpdatesXmlRendererTest { private Path tempFile; @Before - public void setUp() throws IOException - { - tempFile = Files.createTempFile( "xml-plugin-report", "" ); + public void setUp() throws IOException { + tempFile = Files.createTempFile("xml-plugin-report", ""); } @After - public void tearDown() throws IOException - { - if ( tempFile != null && Files.exists( tempFile ) ) - { - Files.delete( tempFile ); + public void tearDown() throws IOException { + if (tempFile != null && Files.exists(tempFile)) { + Files.delete(tempFile); } } @Test - public void testReportGeneration() throws IOException - { + public void testReportGeneration() throws IOException { PluginUpdatesModel pluginUpdates = new PluginUpdatesModel( singletonMap( - pluginOf( "default-group", "artifactA", "1.0.0" ), + pluginOf("default-group", "artifactA", "1.0.0"), new PluginUpdatesDetails( new ArtifactVersions( - artifactOf( "default-group", "artifactA", "1.0.0" ), - Stream.of( "1.0.0", "1.0.1", "1.1.0", "2.0.0" ) - .map( DefaultArtifactVersion::new ) - .collect( Collectors.toList() ), - new MavenVersionComparator() ), - singletonMap( DependencyBuilder.dependencyWith( "default-group", "artifactB", - "1.0.0" ), + artifactOf("default-group", "artifactA", "1.0.0"), + Stream.of("1.0.0", "1.0.1", "1.1.0", "2.0.0") + .map(DefaultArtifactVersion::new) + .collect(Collectors.toList()), + new MavenVersionComparator()), + singletonMap( + DependencyBuilder.dependencyWith("default-group", "artifactB", "1.0.0"), new ArtifactVersions( - artifactOf( "default-group", "artifactB", "1.0.0" ), - Stream.of( "1.0.0", "1.0.1-SNAPSHOT", "1.1.0-rc1", "2.0.0" ) - .map( DefaultArtifactVersion::new ) - .collect( Collectors.toList() ), - new MavenVersionComparator() ) ), false ) ), - emptyMap() ); - new PluginUpdatesXmlReportRenderer( pluginUpdates, tempFile ).render(); + artifactOf("default-group", "artifactB", "1.0.0"), + Stream.of("1.0.0", "1.0.1-SNAPSHOT", "1.1.0-rc1", "2.0.0") + .map(DefaultArtifactVersion::new) + .collect(Collectors.toList()), + new MavenVersionComparator())), + false)), + emptyMap()); + new PluginUpdatesXmlReportRenderer(pluginUpdates, tempFile).render(); - String output = String.join( "", Files.readAllLines( tempFile ) ) - .replaceAll( ">\\s*<", "><" ); + String output = String.join("", Files.readAllLines(tempFile)).replaceAll(">\\s*<", "><"); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "1" ) ); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "0" ) ); - assertThat( output, containsString( "1" ) ); + assertThat(output, containsString("0")); + assertThat(output, containsString("0")); + assertThat(output, containsString("1")); + assertThat(output, containsString("0")); + assertThat(output, containsString("0")); + assertThat(output, containsString("1")); - assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "2.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); - assertThat( output, containsString( "1.1.0" ) ); - assertThat( output, containsString( "2.0.0" ) ); - assertThat( output, containsString( "incremental available" ) ); + assertThat(output, containsString("1.0.0")); + assertThat(output, containsString("2.0.0")); + assertThat(output, containsString("1.0.1")); + assertThat(output, containsString("1.1.0")); + assertThat(output, containsString("2.0.0")); + assertThat(output, containsString("incremental available")); } - private static DefaultArtifact artifactOf( String groupId, String artifactId, String version ) - { - return new DefaultArtifact( groupId, artifactId, version, SCOPE_COMPILE, "jar", "default", - null ); + private static DefaultArtifact artifactOf(String groupId, String artifactId, String version) { + return new DefaultArtifact(groupId, artifactId, version, SCOPE_COMPILE, "jar", "default", null); } - private static Plugin pluginOf( String groupId, String artifactId, String version ) - { - return new Plugin() - {{ - setGroupId( groupId ); - setArtifactId( artifactId ); - setVersion( version ); - }}; + private static Plugin pluginOf(String groupId, String artifactId, String version) { + return new Plugin() { + { + setGroupId(groupId); + setArtifactId(artifactId); + setVersion(version); + } + }; } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java index 89f0a75cc7..7dba45d2e7 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojoTest.java @@ -40,54 +40,50 @@ /** * Unit tests for {@link PropertyUpdatesReportMojo} */ -public class PropertyUpdatesReportMojoTest extends AbstractMojoTestCase -{ +public class PropertyUpdatesReportMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); + private static final org.eclipse.aether.RepositorySystem AETHER_REPOSITORY_SYSTEM = mockAetherRepositorySystem(); private static final SiteTool SITE_TOOL = mockSiteTool(); @Test - public void testIncludeParentTrueShouldContainProperty() throws Exception - { + public void testIncludeParentTrueShouldContainProperty() throws Exception { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - PropertyUpdatesReportMojo mojo = - (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( - new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), - "property-updates-report" ); - setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); - setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); - setVariableValueToObject( mojo, "includeParent", true ); - mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + PropertyUpdatesReportMojo mojo = (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( + new File("src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child"), + "property-updates-report"); + setVariableValueToObject(mojo, "siteTool", SITE_TOOL); + setVariableValueToObject(mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM); + setVariableValueToObject(mojo, "includeParent", true); + mojo.generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString() - .replaceAll( "<[^>]+>", " " ) - .replaceAll( "&[^;]+;", " " ) - .replaceAll( "\\s+", " " ); - assertThat( output, containsString( "${ver}" ) ); + .replaceAll("<[^>]+>", " ") + .replaceAll("&[^;]+;", " ") + .replaceAll("\\s+", " "); + assertThat(output, containsString("${ver}")); } @Test - public void testIncludeParentFalseShouldNotContainProperty() throws Exception - { + public void testIncludeParentFalseShouldNotContainProperty() throws Exception { OutputStream os = new ByteArrayOutputStream(); SinkFactory sinkFactory = new Xhtml5SinkFactory(); - PropertyUpdatesReportMojo mojo = - (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( - new File( "src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child" ), - "property-updates-report" ); - setVariableValueToObject( mojo, "siteTool", SITE_TOOL ); - setVariableValueToObject( mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM ); - setVariableValueToObject( mojo, "includeParent", false ); - mojo.generate( sinkFactory.createSink( os ), sinkFactory, Locale.getDefault() ); + PropertyUpdatesReportMojo mojo = (PropertyUpdatesReportMojo) mojoRule.lookupConfiguredMojo( + new File("src/test/resources/org/codehaus/mojo/display-property-updates/issue-367/child"), + "property-updates-report"); + setVariableValueToObject(mojo, "siteTool", SITE_TOOL); + setVariableValueToObject(mojo, "aetherRepositorySystem", AETHER_REPOSITORY_SYSTEM); + setVariableValueToObject(mojo, "includeParent", false); + mojo.generate(sinkFactory.createSink(os), sinkFactory, Locale.getDefault()); String output = os.toString() - .replaceAll( "<[^>]+>", " " ) - .replaceAll( "&[^;]+;", " " ) - .replaceAll( "\\s+", " " ); - assertThat( output, not( containsString( "${ver}" ) ) ); + .replaceAll("<[^>]+>", " ") + .replaceAll("&[^;]+;", " ") + .replaceAll("\\s+", " "); + assertThat(output, not(containsString("${ver}"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java index ceb31ea1e6..8e84921307 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RevertMojoTest.java @@ -42,52 +42,43 @@ * * @author Andrzej Jarmoniuk */ -public class RevertMojoTest extends AbstractMojoTestCase -{ +public class RevertMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); + private Path pomDir; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - pomDir = Files.createTempDirectory( "revert-" ); + pomDir = Files.createTempDirectory("revert-"); } @After - public void tearDown() throws Exception - { - try - { - if ( pomDir != null && pomDir.toFile().exists() ) - { - Arrays.stream( Objects.requireNonNull( pomDir.toFile().listFiles() ) ).forEach( File::delete ); + public void tearDown() throws Exception { + try { + if (pomDir != null && pomDir.toFile().exists()) { + Arrays.stream(Objects.requireNonNull(pomDir.toFile().listFiles())) + .forEach(File::delete); pomDir.toFile().delete(); } - } - finally - { + } finally { super.tearDown(); } } - public void testRevert() throws Exception - { - copyDirectory( new File( getBasedir(), - "target/test-classes/org/codehaus/mojo/revert/issue-265" ), pomDir.toFile() ); - RevertMojo myMojo = (RevertMojo) mojoRule.lookupConfiguredMojo( - new File( pomDir.toString(), "aggregate" ), "revert" ); + public void testRevert() throws Exception { + copyDirectory( + new File(getBasedir(), "target/test-classes/org/codehaus/mojo/revert/issue-265"), pomDir.toFile()); + RevertMojo myMojo = + (RevertMojo) mojoRule.lookupConfiguredMojo(new File(pomDir.toString(), "aggregate"), "revert"); myMojo.execute(); - assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "aggregate/pom.xml" ) ) ), - containsString( "OLD" ) ); - assertThat( Files.exists( pomDir.resolve( "aggregate/pom.xml.versionsBackup" ) ), is( false ) ); - assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-a/pom.xml" ) ) ), - containsString( "OLD" ) ); - assertThat( Files.exists( pomDir.resolve( "module-a/pom.xml.versionsBackup" ) ), is( false ) ); - assertThat( join( "\n", Files.readAllLines( pomDir.resolve( "module-b/pom.xml" ) ) ), - containsString( "OLD" ) ); - assertThat( Files.exists( pomDir.resolve( "module-b/pom.xml.versionsBackup" ) ), is( false ) ); + assertThat(join("\n", Files.readAllLines(pomDir.resolve("aggregate/pom.xml"))), containsString("OLD")); + assertThat(Files.exists(pomDir.resolve("aggregate/pom.xml.versionsBackup")), is(false)); + assertThat(join("\n", Files.readAllLines(pomDir.resolve("module-a/pom.xml"))), containsString("OLD")); + assertThat(Files.exists(pomDir.resolve("module-a/pom.xml.versionsBackup")), is(false)); + assertThat(join("\n", Files.readAllLines(pomDir.resolve("module-b/pom.xml"))), containsString("OLD")); + assertThat(Files.exists(pomDir.resolve("module-b/pom.xml.versionsBackup")), is(false)); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java index 76a70b1471..459a55ea71 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/RewriteWithStAXTest.java @@ -44,199 +44,205 @@ * * @author Stephen Connolly */ -public class RewriteWithStAXTest -{ +public class RewriteWithStAXTest { @Test - public void testBasic() - throws Exception - { + public void testBasic() throws Exception { String input = "\n" + "\n\r\n\r\n\r\n\r" + " \r\n" - + " org.codehaus.mojo\n" - + " mojo-&sandbox-parent\n" + " 5-SNAPSHOT\r" - + " \r" + ""; + + " org.codehaus.mojo\n" + + " mojo-&sandbox-parent\n" + " 5-SNAPSHOT\r" + + " \r" + ""; - byte[] rawInput = input.getBytes( StandardCharsets.UTF_8 ); - ByteArrayInputStream source = new ByteArrayInputStream( rawInput ); + byte[] rawInput = input.getBytes(StandardCharsets.UTF_8); + ByteArrayInputStream source = new ByteArrayInputStream(rawInput); ByteArrayOutputStream dest = new ByteArrayOutputStream(); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); + inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); - XMLEventReader eventReader = inputFactory.createXMLEventReader( source ); - XMLEventWriter eventWriter = outputFactory.createXMLEventWriter( dest, "utf-8" ); - while ( eventReader.hasNext() ) - { - eventWriter.add( eventReader.nextEvent() ); + XMLEventReader eventReader = inputFactory.createXMLEventReader(source); + XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(dest, "utf-8"); + while (eventReader.hasNext()) { + eventWriter.add(eventReader.nextEvent()); } - String output = dest.toString( "utf-8" ); + String output = dest.toString("utf-8"); - assertNotEquals( "StAX implementation is not good enough", input, output ); + assertNotEquals("StAX implementation is not good enough", input, output); } @Test - public void testReplace() - throws Exception - { + public void testReplace() throws Exception { String input = "\n" + "\n\r\n\r\n\r\n\r" + " \r\n" - + " org.codehaus.mojo\n" - + " mojo-&sandbox-parent\n" + " 5-SNAPSHOT\r" - + " \r" + ""; + + " org.codehaus.mojo\n" + + " mojo-&sandbox-parent\n" + " 5-SNAPSHOT\r" + + " \r" + ""; String expected = "\n" + "\n\r\n\r\n\r\n\r" + " \r\n" - + " org.codehaus.mojo\n" + " my-artifact\n" - + " 5-SNAPSHOT\r" + " \r" + ""; + + " org.codehaus.mojo\n" + + " my-artifact\n" + + " 5-SNAPSHOT\r" + " \r" + ""; - StringBuilder output = new StringBuilder( input ); + StringBuilder output = new StringBuilder(input); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); - ModifiedPomXMLEventReader eventReader = new ModifiedPomXMLEventReader( output, inputFactory, null ); - while ( eventReader.hasNext() ) - { + inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE); + ModifiedPomXMLEventReader eventReader = new ModifiedPomXMLEventReader(output, inputFactory, null); + while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); - if ( event instanceof StartElement - && event.asStartElement().getName().getLocalPart().equals( "artifactId" ) ) - { - eventReader.mark( 0 ); + if (event instanceof StartElement + && event.asStartElement().getName().getLocalPart().equals("artifactId")) { + eventReader.mark(0); } - if ( event instanceof EndElement && event.asEndElement().getName().getLocalPart().equals( "artifactId" ) ) - { - eventReader.mark( 1 ); - if ( eventReader.hasMark( 0 ) ) - { - eventReader.replaceBetween( 0, 1, "my-artifact" ); + if (event instanceof EndElement + && event.asEndElement().getName().getLocalPart().equals("artifactId")) { + eventReader.mark(1); + if (eventReader.hasMark(0)) { + eventReader.replaceBetween(0, 1, "my-artifact"); } } } - assertEquals( expected, output.toString() ); + assertEquals(expected, output.toString()); } - @SuppressWarnings( {"checkstyle:MethodLength", "checkstyle:LineLength"} ) + @SuppressWarnings({"checkstyle:MethodLength", "checkstyle:LineLength"}) @Test - public void testReplaceFancy() - throws Exception - { + public void testReplaceFancy() throws Exception { String input = - "\n" - + " 4.0.0\n" + "\n" + " \n" - + " org.codehaus.mojo\n" + " mojo-sandbox-parent\n" - + " 5-SNAPSHOT\n" + " \n" + "\n" - + " org.codehaus.mojo\n" + " versions-maven-plugin\n" - + " 1.0.0-alpha-1-SNAPSHOT\n" + " maven-plugin\n" + "\n" - + " Versions Maven Plugin\n" + " \n" - + " Versions plugin for Maven 2. The versions plugin updates the versions of components in the pom.\n" - + " \n" + " 2008\n" + " \n" - + " \n" + " The Apache Software License, Version 2.0\n" - + " http://www.apache.org/licenses/LICENSE-2.0\n" - + " repo\n" + " \n" + " \n" + "\n" - + " \n" - + " scm:svn:http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" - + " scm:svn:https://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" - + " http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + " \n" - + "\n" + " \n" + " \n" + " Stephen Connolly\n" - + " stephen.alan.connolly@gmail.com\n" + " \n" - + " Java Developer\n" + " \n" + " 0\n" - + " \n" + " \n" + "\n" + " \n" - + " 2.0.6\n" + " \n" + "\n" + " \n" - + " \n" + " junit\n" + " junit\n" - + " 3.8.1\n" + " test\n" + " \n" - + " \n" + " org.apache.maven\n" - + " maven-project\n" + " 2.0\n" - + " \n" + " \n" + " org.apache.maven\n" - + " maven-settings\n" + " 2.0\n" - + " \n" + " \n" + " org.apache.maven\n" - + " maven-plugin-api\n" + " 2.0\n" - + " \n" + " \n" + " org.codehaus.plexus\n" - + " plexus-utils\n" + " 1.3\n" - + " \n" + " \n" + " org.codehaus.plexus\n" - + " plexus-interactivity-api\n" + " 1.0-alpha-6\n" - + " \n" + " \n" + " plexus-utils\n" - + " plexus\n" + " \n" + " \n" - + " \n" + " \n" + " javax.xml.stream\n" - + " stax-api\n" + " 1.0-2\n" - + " \n" + " \n" + " stax\n" - + " stax\n" + " 1.1.1-dev\n" - + " \n" + " \n" + "\n" + " \n" + " \n" - + " \n" + " maven-plugin-plugin\n" - + " 2.3\n" + " \n" - + " versions\n" + " \n" + " \n" - + " \n" + " \n" + "\n" + ""; + "\n" + + " 4.0.0\n" + "\n" + " \n" + + " org.codehaus.mojo\n" + + " mojo-sandbox-parent\n" + + " 5-SNAPSHOT\n" + " \n" + "\n" + + " org.codehaus.mojo\n" + + " versions-maven-plugin\n" + + " 1.0.0-alpha-1-SNAPSHOT\n" + " maven-plugin\n" + + "\n" + + " Versions Maven Plugin\n" + " \n" + + " Versions plugin for Maven 2. The versions plugin updates the versions of components in the pom.\n" + + " \n" + " 2008\n" + " \n" + + " \n" + " The Apache Software License, Version 2.0\n" + + " http://www.apache.org/licenses/LICENSE-2.0\n" + + " repo\n" + " \n" + " \n" + "\n" + + " \n" + + " scm:svn:http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " scm:svn:https://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " \n" + + "\n" + " \n" + " \n" + " Stephen Connolly\n" + + " stephen.alan.connolly@gmail.com\n" + " \n" + + " Java Developer\n" + " \n" + + " 0\n" + + " \n" + " \n" + "\n" + " \n" + + " 2.0.6\n" + " \n" + "\n" + " \n" + + " \n" + " junit\n" + + " junit\n" + + " 3.8.1\n" + " test\n" + " \n" + + " \n" + " org.apache.maven\n" + + " maven-project\n" + " 2.0\n" + + " \n" + " \n" + " org.apache.maven\n" + + " maven-settings\n" + " 2.0\n" + + " \n" + " \n" + " org.apache.maven\n" + + " maven-plugin-api\n" + " 2.0\n" + + " \n" + " \n" + + " org.codehaus.plexus\n" + + " plexus-utils\n" + " 1.3\n" + + " \n" + " \n" + + " org.codehaus.plexus\n" + + " plexus-interactivity-api\n" + + " 1.0-alpha-6\n" + + " \n" + " \n" + + " plexus-utils\n" + + " plexus\n" + " \n" + " \n" + + " \n" + " \n" + " javax.xml.stream\n" + + " stax-api\n" + " 1.0-2\n" + + " \n" + " \n" + " stax\n" + + " stax\n" + " 1.1.1-dev\n" + + " \n" + " \n" + "\n" + " \n" + " \n" + + " \n" + " maven-plugin-plugin\n" + + " 2.3\n" + " \n" + + " versions\n" + " \n" + + " \n" + + " \n" + " \n" + "\n" + ""; String expected = - "\n" - + " 4.0.0\n" + "\n" + " \n" - + " org.codehaus.mojo\n" + " mojo-sandbox-parent\n" - + " 4\n" + " \n" + "\n" + " org.codehaus.mojo\n" - + " versions-maven-plugin\n" + " 1.0.0-alpha-1-SNAPSHOT\n" - + " maven-plugin\n" + "\n" + " Versions Maven Plugin\n" - + " \n" - + " Versions plugin for Maven 2. The versions plugin updates the versions of components in the pom.\n" - + " \n" + " 2008\n" + " \n" - + " \n" + " The Apache Software License, Version 2.0\n" - + " http://www.apache.org/licenses/LICENSE-2.0\n" - + " repo\n" + " \n" + " \n" + "\n" - + " \n" - + " scm:svn:http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" - + " scm:svn:https://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" - + " http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + " \n" - + "\n" + " \n" + " \n" + " Stephen Connolly\n" - + " stephen.alan.connolly@gmail.com\n" + " \n" - + " Java Developer\n" + " \n" + " 0\n" - + " \n" + " \n" + "\n" + " \n" - + " 2.0.6\n" + " \n" + "\n" + " \n" - + " \n" + " junit\n" + " junit\n" - + " 3.8.2\n" + " test\n" + " \n" - + " \n" + " org.apache.maven\n" - + " maven-project\n" + " 2.0\n" - + " \n" + " \n" + " org.apache.maven\n" - + " maven-settings\n" + " 2.0\n" - + " \n" + " \n" + " org.apache.maven\n" - + " maven-plugin-api\n" + " 2.0\n" - + " \n" + " \n" + " org.codehaus.plexus\n" - + " plexus-utils\n" + " 1.3\n" - + " \n" + " \n" + " org.codehaus.plexus\n" - + " plexus-interactivity-api\n" + " 1.0-alpha-6\n" - + " \n" + " \n" + " plexus-utils\n" - + " plexus\n" + " \n" + " \n" - + " \n" + " \n" + " javax.xml.stream\n" - + " stax-api\n" + " 1.0-2\n" - + " \n" + " \n" + " stax\n" - + " stax\n" + " 1.1.1-dev\n" - + " \n" + " \n" + "\n" + " \n" + " \n" - + " \n" + " maven-plugin-plugin\n" - + " 2.3\n" + " \n" - + " versions\n" + " \n" + " \n" - + " \n" + " \n" + "\n" + ""; + "\n" + + " 4.0.0\n" + "\n" + " \n" + + " org.codehaus.mojo\n" + + " mojo-sandbox-parent\n" + + " 4\n" + " \n" + "\n" + + " org.codehaus.mojo\n" + + " versions-maven-plugin\n" + + " 1.0.0-alpha-1-SNAPSHOT\n" + + " maven-plugin\n" + "\n" + " Versions Maven Plugin\n" + + " \n" + + " Versions plugin for Maven 2. The versions plugin updates the versions of components in the pom.\n" + + " \n" + " 2008\n" + " \n" + + " \n" + " The Apache Software License, Version 2.0\n" + + " http://www.apache.org/licenses/LICENSE-2.0\n" + + " repo\n" + " \n" + " \n" + "\n" + + " \n" + + " scm:svn:http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " scm:svn:https://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " http://svn.codehaus.org/mojo/trunk/sandbox/versions-maven-plugin\n" + + " \n" + + "\n" + " \n" + " \n" + " Stephen Connolly\n" + + " stephen.alan.connolly@gmail.com\n" + " \n" + + " Java Developer\n" + " \n" + + " 0\n" + + " \n" + " \n" + "\n" + " \n" + + " 2.0.6\n" + " \n" + "\n" + " \n" + + " \n" + " junit\n" + + " junit\n" + + " 3.8.2\n" + " test\n" + " \n" + + " \n" + " org.apache.maven\n" + + " maven-project\n" + " 2.0\n" + + " \n" + " \n" + " org.apache.maven\n" + + " maven-settings\n" + " 2.0\n" + + " \n" + " \n" + " org.apache.maven\n" + + " maven-plugin-api\n" + " 2.0\n" + + " \n" + " \n" + + " org.codehaus.plexus\n" + + " plexus-utils\n" + " 1.3\n" + + " \n" + " \n" + + " org.codehaus.plexus\n" + + " plexus-interactivity-api\n" + + " 1.0-alpha-6\n" + + " \n" + " \n" + + " plexus-utils\n" + + " plexus\n" + " \n" + " \n" + + " \n" + " \n" + " javax.xml.stream\n" + + " stax-api\n" + " 1.0-2\n" + + " \n" + " \n" + " stax\n" + + " stax\n" + " 1.1.1-dev\n" + + " \n" + " \n" + "\n" + " \n" + " \n" + + " \n" + " maven-plugin-plugin\n" + + " 2.3\n" + " \n" + + " versions\n" + " \n" + + " \n" + + " \n" + " \n" + "\n" + ""; - StringBuilder output = new StringBuilder( input ); + StringBuilder output = new StringBuilder(input); XMLInputFactory inputFactory = XMLInputFactory2.newInstance(); - inputFactory.setProperty( XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE ); - ModifiedPomXMLEventReader eventReader = new ModifiedPomXMLEventReader( output, inputFactory, null ); + inputFactory.setProperty(XMLInputFactory2.P_PRESERVE_LOCATION, Boolean.TRUE); + ModifiedPomXMLEventReader eventReader = new ModifiedPomXMLEventReader(output, inputFactory, null); Stack stack = new Stack<>(); String path = ""; - while ( eventReader.hasNext() ) - { + while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); - if ( event.isStartElement() ) - { - stack.push( path ); + if (event.isStartElement()) { + stack.push(path); path += "/" + event.asStartElement().getName().getLocalPart(); - if ( "/project/parent/version".equals( path ) ) - { - eventReader.mark( 0 ); + if ("/project/parent/version".equals(path)) { + eventReader.mark(0); } } - if ( event.isEndElement() ) - { - if ( "/project/parent/version".equals( path ) ) - { - eventReader.mark( 1 ); - if ( eventReader.hasMark( 0 ) ) - { - eventReader.replaceBetween( 0, 1, "4" ); + if (event.isEndElement()) { + if ("/project/parent/version".equals(path)) { + eventReader.mark(1); + if (eventReader.hasMark(0)) { + eventReader.replaceBetween(0, 1, "4"); } } path = stack.pop(); @@ -248,50 +254,33 @@ public void testReplaceFancy() boolean artifactIdMatches = false; eventReader.rewind(); - while ( eventReader.hasNext() ) - { + while (eventReader.hasNext()) { XMLEvent event = eventReader.nextEvent(); - if ( event.isStartElement() ) - { + if (event.isStartElement()) { String name = event.asStartElement().getName().getLocalPart(); - if ( inDependency ) - { - if ( "groupId".equals( name ) ) - { - groupIdMatches = "junit".equals( eventReader.getElementText() ); + if (inDependency) { + if ("groupId".equals(name)) { + groupIdMatches = "junit".equals(eventReader.getElementText()); + } else if ("artifactId".equals(name)) { + artifactIdMatches = "junit".equals(eventReader.getElementText()); + } else if ("version".equals(name)) { + eventReader.mark(1); } - else if ( "artifactId".equals( name ) ) - { - artifactIdMatches = "junit".equals( eventReader.getElementText() ); - } - else if ( "version".equals( name ) ) - { - eventReader.mark( 1 ); - } - } - else if ( "dependency".equals( name ) ) - { + } else if ("dependency".equals(name)) { inDependency = true; groupIdMatches = false; artifactIdMatches = false; } } - if ( event.isEndElement() ) - { + if (event.isEndElement()) { String name = event.asEndElement().getName().getLocalPart(); - if ( inDependency ) - { - if ( "version".equals( name ) ) - { - eventReader.mark( 2 ); + if (inDependency) { + if ("version".equals(name)) { + eventReader.mark(2); - } - else if ( "dependency".equals( name ) ) - { - if ( groupIdMatches && artifactIdMatches && eventReader.hasMark( 1 ) - && eventReader.hasMark( 2 ) ) - { - eventReader.replaceBetween( 1, 2, "3.8.2" ); + } else if ("dependency".equals(name)) { + if (groupIdMatches && artifactIdMatches && eventReader.hasMark(1) && eventReader.hasMark(2)) { + eventReader.replaceBetween(1, 2, "3.8.2"); } inDependency = false; } @@ -299,7 +288,6 @@ else if ( "dependency".equals( name ) ) } } - assertEquals( expected, output.toString() ); + assertEquals(expected, output.toString()); } - } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java index d5a4f51e34..eddda8473c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SeparatePatternsForIncludesAnExcludesTest.java @@ -8,80 +8,67 @@ import static org.junit.Assert.assertEquals; -public class SeparatePatternsForIncludesAnExcludesTest -{ +public class SeparatePatternsForIncludesAnExcludesTest { AbstractVersionsDependencyUpdaterMojo mojo; @Before - public void setUp() - throws Exception - { - mojo = new AbstractVersionsDependencyUpdaterMojo( null, null, null, null ) - { + public void setUp() throws Exception { + mojo = new AbstractVersionsDependencyUpdaterMojo(null, null, null, null) { @Override - protected void update( ModifiedPomXMLEventReader pom ) - { - } + protected void update(ModifiedPomXMLEventReader pom) {} }; } @Test - public void testSeparatePatternsWithNull() - { - List patterns = mojo.separatePatterns( null ); - assertEquals( 0, patterns.size() ); + public void testSeparatePatternsWithNull() { + List patterns = mojo.separatePatterns(null); + assertEquals(0, patterns.size()); } @Test - public void testSeparatePatternsWithSinglePattern() - { - List patterns = mojo.separatePatterns( "group:artifact:type:version" ); - assertEquals( 1, patterns.size() ); - assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); + public void testSeparatePatternsWithSinglePattern() { + List patterns = mojo.separatePatterns("group:artifact:type:version"); + assertEquals(1, patterns.size()); + assertEquals("group:artifact:type:version", patterns.get(0)); } @Test - public void testSeparatePatternWithSingleRange() - { - List patterns = mojo.separatePatterns( "group:artifact:type:[1.0.2,2.0.0]" ); - assertEquals( 1, patterns.size() ); - assertEquals( "group:artifact:type:[1.0.2,2.0.0]", patterns.get( 0 ) ); + public void testSeparatePatternWithSingleRange() { + List patterns = mojo.separatePatterns("group:artifact:type:[1.0.2,2.0.0]"); + assertEquals(1, patterns.size()); + assertEquals("group:artifact:type:[1.0.2,2.0.0]", patterns.get(0)); - patterns = mojo.separatePatterns( "group:artifact:type:(1.0.2,2.0.0]" ); - assertEquals( 1, patterns.size() ); - assertEquals( "group:artifact:type:(1.0.2,2.0.0]", patterns.get( 0 ) ); + patterns = mojo.separatePatterns("group:artifact:type:(1.0.2,2.0.0]"); + assertEquals(1, patterns.size()); + assertEquals("group:artifact:type:(1.0.2,2.0.0]", patterns.get(0)); } @Test - public void testSeparatePatternWithSeveralPatternsAndRanges() - { - List patterns = mojo.separatePatterns( - "group:artifact:type:[1.0.2,2.0.0),group2:artifact:type:(1.0.2,2.0.0]" ); - assertEquals( 2, patterns.size() ); - assertEquals( "group:artifact:type:[1.0.2,2.0.0)", patterns.get( 0 ) ); - assertEquals( "group2:artifact:type:(1.0.2,2.0.0]", patterns.get( 1 ) ); + public void testSeparatePatternWithSeveralPatternsAndRanges() { + List patterns = + mojo.separatePatterns("group:artifact:type:[1.0.2,2.0.0),group2:artifact:type:(1.0.2,2.0.0]"); + assertEquals(2, patterns.size()); + assertEquals("group:artifact:type:[1.0.2,2.0.0)", patterns.get(0)); + assertEquals("group2:artifact:type:(1.0.2,2.0.0]", patterns.get(1)); } @Test - public void testSeparatePatternsWithTwoCommaSeparatedPatterns() - { - List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2" ); - assertEquals( 2, patterns.size() ); - assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); - assertEquals( "group:artifact:type:version2", patterns.get( 1 ) ); + public void testSeparatePatternsWithTwoCommaSeparatedPatterns() { + List patterns = mojo.separatePatterns("group:artifact:type:version,group:artifact:type:version2"); + assertEquals(2, patterns.size()); + assertEquals("group:artifact:type:version", patterns.get(0)); + assertEquals("group:artifact:type:version2", patterns.get(1)); } @Test - public void testSeparatePatternsWithSeveralCommaSeparatedPatterns() - { - List patterns = mojo.separatePatterns( "group:artifact:type:version,group:artifact:type:version2," - + "group:artifact:type:version3,group:artifact:type:version4" ); - assertEquals( 4, patterns.size() ); - assertEquals( "group:artifact:type:version", patterns.get( 0 ) ); - assertEquals( "group:artifact:type:version2", patterns.get( 1 ) ); - assertEquals( "group:artifact:type:version3", patterns.get( 2 ) ); - assertEquals( "group:artifact:type:version4", patterns.get( 3 ) ); + public void testSeparatePatternsWithSeveralCommaSeparatedPatterns() { + List patterns = mojo.separatePatterns("group:artifact:type:version,group:artifact:type:version2," + + "group:artifact:type:version3,group:artifact:type:version4"); + assertEquals(4, patterns.size()); + assertEquals("group:artifact:type:version", patterns.get(0)); + assertEquals("group:artifact:type:version2", patterns.get(1)); + assertEquals("group:artifact:type:version3", patterns.get(2)); + assertEquals("group:artifact:type:version4", patterns.get(3)); } - } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java index 0342773f0e..1decf8f987 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetMojoTest.java @@ -24,155 +24,138 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -public class SetMojoTest extends AbstractMojoTestCase -{ +public class SetMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); private Path tempDir; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - tempDir = TestUtils.createTempDir( "set" ); + tempDir = TestUtils.createTempDir("set"); } @After - public void tearDown() throws IOException - { - TestUtils.tearDownTempDir( tempDir ); + public void tearDown() throws IOException { + TestUtils.tearDownTempDir(tempDir); } @Test - public void testGetIncrementedVersion() throws MojoExecutionException - { - new SetMojo( null, null, null, null, null, null ) - { + public void testGetIncrementedVersion() throws MojoExecutionException { + new SetMojo(null, null, null, null, null, null) { { - assertThat( getIncrementedVersion( "1.0.0", null ), is( "1.0.1-SNAPSHOT" ) ); - assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", null ), is( "1.0.1-SNAPSHOT" ) ); - assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 1 ), is( "2.0.0-SNAPSHOT" ) ); - assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 2 ), is( "1.1.0-SNAPSHOT" ) ); - assertThat( getIncrementedVersion( "1.0.0-SNAPSHOT", 3 ), is( "1.0.1-SNAPSHOT" ) ); + assertThat(getIncrementedVersion("1.0.0", null), is("1.0.1-SNAPSHOT")); + assertThat(getIncrementedVersion("1.0.0-SNAPSHOT", null), is("1.0.1-SNAPSHOT")); + assertThat(getIncrementedVersion("1.0.0-SNAPSHOT", 1), is("2.0.0-SNAPSHOT")); + assertThat(getIncrementedVersion("1.0.0-SNAPSHOT", 2), is("1.1.0-SNAPSHOT")); + assertThat(getIncrementedVersion("1.0.0-SNAPSHOT", 3), is("1.0.1-SNAPSHOT")); } }; } @Test - public void testNextSnapshotIndexLowerBound() - { - new SetMojo( null, null, null, null, null, null ) - { + public void testNextSnapshotIndexLowerBound() { + new SetMojo(null, null, null, null, null, null) { { - try - { - getIncrementedVersion( "1.0.0", 0 ); + try { + getIncrementedVersion("1.0.0", 0); fail(); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), - containsString( "nextSnapshotIndexToIncrement cannot be less than 1" ) ); + } catch (MojoExecutionException e) { + assertThat(e.getMessage(), containsString("nextSnapshotIndexToIncrement cannot be less than 1")); } } }; } @Test - public void testNextSnapshotIndexUpperBound() - { - new SetMojo( null, null, null, null, null, null ) - { + public void testNextSnapshotIndexUpperBound() { + new SetMojo(null, null, null, null, null, null) { { - try - { - getIncrementedVersion( "1.0.0", 4 ); + try { + getIncrementedVersion("1.0.0", 4); fail(); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), containsString( - "nextSnapshotIndexToIncrement cannot be greater than the last version index" ) ); + } catch (MojoExecutionException e) { + assertThat( + e.getMessage(), + containsString( + "nextSnapshotIndexToIncrement cannot be greater than the last version index")); } } }; } @Test - public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureException - { - try - { - new SetMojo( null, null, null, null, null, null ) - { + public void testNextSnapshotIndexWithoutNextSnapshot() throws MojoFailureException { + try { + new SetMojo(null, null, null, null, null, null) { { project = new MavenProject(); - project.setParent( new MavenProject() ); - project.setOriginalModel( new Model() ); - project.getOriginalModel().setVersion( "1.2.3-SNAPSHOT" ); + project.setParent(new MavenProject()); + project.setOriginalModel(new Model()); + project.getOriginalModel().setVersion("1.2.3-SNAPSHOT"); nextSnapshotIndexToIncrement = 4; } }.execute(); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), - containsString( "nextSnapshotIndexToIncrement is not valid when nextSnapshot is false" ) ); + } catch (MojoExecutionException e) { + assertThat( + e.getMessage(), + containsString("nextSnapshotIndexToIncrement is not valid when nextSnapshot is false")); } } @Test - public void testVersionlessDependency() throws Exception - { + public void testVersionlessDependency() throws Exception { SetMojo myMojo = (SetMojo) mojoRule.lookupConfiguredMojo( - new File( "target/test-classes/org/codehaus/mojo/set/versionless-01" ), "set" ); + new File("target/test-classes/org/codehaus/mojo/set/versionless-01"), "set"); myMojo.execute(); } @Test - public void testRemoveSnapshotIdempotency() - throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml" ), - Paths.get( tempDir.toString(), "pom.xml" ), REPLACE_EXISTING ); + public void testRemoveSnapshotIdempotency() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/set/remove-snapshot/pom.xml"), + Paths.get(tempDir.toString(), "pom.xml"), + REPLACE_EXISTING); - SetMojo firstRun = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); + SetMojo firstRun = (SetMojo) mojoRule.lookupConfiguredMojo(tempDir.toFile(), "set"); firstRun.execute(); - assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), - containsString( "1.0" ) ); + assertThat( + String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))), + containsString("1.0")); // no exception should be thrown, the file should stay with version "1.0" - SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); - secondRun.session.getSettings().setInteractiveMode( false ); + SetMojo secondRun = (SetMojo) mojoRule.lookupConfiguredMojo(tempDir.toFile(), "set"); + secondRun.session.getSettings().setInteractiveMode(false); secondRun.execute(); - assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), - containsString( "1.0" ) ); + assertThat( + String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))), + containsString("1.0")); } @Test - public void testSetOldVersionMismatch() throws Exception - { - TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set/issue-794" ), tempDir ); - SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); - setVariableValueToObject( mojo, "oldVersion", "foo" ); - setVariableValueToObject( mojo, "newVersion", "bar" ); + public void testSetOldVersionMismatch() throws Exception { + TestUtils.copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set/issue-794"), tempDir); + SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo(tempDir.toFile(), "set"); + setVariableValueToObject(mojo, "oldVersion", "foo"); + setVariableValueToObject(mojo, "newVersion", "bar"); mojo.execute(); - assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), - not( containsString( "bar" ) ) ); + assertThat( + String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))), + not(containsString("bar"))); } @Test - public void testSetOldVersionMismatchProcessAllModules() throws Exception - { - TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set/issue-794" ), tempDir ); - SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo( tempDir.toFile(), "set" ); - setVariableValueToObject( mojo, "oldVersion", "foo" ); - setVariableValueToObject( mojo, "newVersion", "bar" ); - setVariableValueToObject( mojo, "processAllModules", true ); + public void testSetOldVersionMismatchProcessAllModules() throws Exception { + TestUtils.copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set/issue-794"), tempDir); + SetMojo mojo = (SetMojo) mojoRule.lookupConfiguredMojo(tempDir.toFile(), "set"); + setVariableValueToObject(mojo, "oldVersion", "foo"); + setVariableValueToObject(mojo, "newVersion", "bar"); + setVariableValueToObject(mojo, "processAllModules", true); mojo.execute(); - assertThat( String.join( "", Files.readAllLines( tempDir.resolve( "pom.xml" ) ) ), - not( containsString( "bar" ) ) ); + assertThat( + String.join("", Files.readAllLines(tempDir.resolve("pom.xml"))), + not(containsString("bar"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java index b4cffc0894..c2890ebcbc 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetPropertyMojoTest.java @@ -48,93 +48,77 @@ * * @author Andrzej Jarmoniuk */ -public class SetPropertyMojoTest extends AbstractMojoTestCase -{ +public class SetPropertyMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); private Path pomDir; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - pomDir = createTempDir( "set-property" ); + pomDir = createTempDir("set-property"); } @After - public void tearDown() throws Exception - { - try - { - tearDownTempDir( pomDir ); - } - finally - { + public void tearDown() throws Exception { + try { + tearDownTempDir(pomDir); + } finally { super.tearDown(); } } + @Test - public void testNullNewVersion() - throws Exception - { - copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version" ), pomDir ); - SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), - "set-property" ); + public void testNullNewVersion() throws Exception { + copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set-property/null-new-version"), pomDir); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo(pomDir.toFile(), "set-property"); - mojo.aetherRepositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); - when( mojo.aetherRepositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) - .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) ); + mojo.aetherRepositorySystem = mock(org.eclipse.aether.RepositorySystem.class); + when(mojo.aetherRepositorySystem.resolveVersionRange(any(), any(VersionRangeRequest.class))) + .then(i -> new VersionRangeResult(i.getArgument(1))); - setVariableValueToObject( mojo, "newVersion", null ); + setVariableValueToObject(mojo, "newVersion", null); mojo.execute(); - String output = String.join( "", Files.readAllLines( mojo.getProject().getFile().toPath() ) ) - .replaceAll( "\\s*", "" ); - assertThat( output, - matchesPattern( ".*.*.*.*" ) ); + String output = String.join( + "", Files.readAllLines(mojo.getProject().getFile().toPath())) + .replaceAll("\\s*", ""); + assertThat(output, matchesPattern(".*.*.*.*")); } @Test - public void testNewVersionEmpty() - throws Exception - { - copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-new-version" ), pomDir ); - SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), - "set-property" ); + public void testNewVersionEmpty() throws Exception { + copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set-property/null-new-version"), pomDir); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo(pomDir.toFile(), "set-property"); - mojo.aetherRepositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); - when( mojo.aetherRepositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) - .then( i -> new VersionRangeResult( i.getArgument( 1 ) ) ); + mojo.aetherRepositorySystem = mock(org.eclipse.aether.RepositorySystem.class); + when(mojo.aetherRepositorySystem.resolveVersionRange(any(), any(VersionRangeRequest.class))) + .then(i -> new VersionRangeResult(i.getArgument(1))); - setVariableValueToObject( mojo, "newVersion", "" ); + setVariableValueToObject(mojo, "newVersion", ""); mojo.execute(); - String output = String.join( "", Files.readAllLines( mojo.getProject().getFile().toPath() ) ) - .replaceAll( "\\s*", "" ); - assertThat( output, - matchesPattern( ".*.*.*.*" ) ); + String output = String.join( + "", Files.readAllLines(mojo.getProject().getFile().toPath())) + .replaceAll("\\s*", ""); + assertThat(output, matchesPattern(".*.*.*.*")); } @Test - public void testNullProperty() - throws Exception - { - copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/set-property/null-property" ), pomDir ); - SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo( pomDir.toFile(), - "set-property" ); - - try - { - mojo.update( null ); + public void testNullProperty() throws Exception { + copyDir(Paths.get("src/test/resources/org/codehaus/mojo/set-property/null-property"), pomDir); + SetPropertyMojo mojo = (SetPropertyMojo) mojoRule.lookupConfiguredMojo(pomDir.toFile(), "set-property"); + + try { + mojo.update(null); fail(); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), - containsString( "Please provide either 'property' or 'propertiesVersionsFile' parameter." ) ); + } catch (MojoExecutionException e) { + assertThat( + e.getMessage(), + containsString("Please provide either 'property' or 'propertiesVersionsFile' parameter.")); } } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java index ebe2d50833..fdc12dcb52 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/SetScmTagMojoTest.java @@ -37,26 +37,23 @@ * * @author Andrzej Jarmoniuk */ -public class SetScmTagMojoTest extends AbstractMojoTestCase -{ +public class SetScmTagMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); @Test - public void testNewScmValues() throws Exception - { - Path pomFile = Paths.get( "target/test-classes/org/codehaus/mojo/set-scm-tag/pom.xml" ); - mojoRule.lookupConfiguredMojo( pomFile.toFile().getParentFile(), "set-scm-tag" ) + public void testNewScmValues() throws Exception { + Path pomFile = Paths.get("target/test-classes/org/codehaus/mojo/set-scm-tag/pom.xml"); + mojoRule.lookupConfiguredMojo(pomFile.toFile().getParentFile(), "set-scm-tag") .execute(); - String output = String.join( "", Files.readAllLines( pomFile ) ) - .replaceAll( "\\s*", "" ); - assertThat( output, allOf( - matchesPattern( ".*.*\\s*newTag\\s*.*.*" ), - matchesPattern( ".*.*\\s*url\\s*.*.*" ), - matchesPattern( ".*.*\\s*connection\\s*.*.*" ), - matchesPattern( ".*.*\\s*" - + "developerConnection\\s*.*.*" ) - ) - ); + String output = String.join("", Files.readAllLines(pomFile)).replaceAll("\\s*", ""); + assertThat( + output, + allOf( + matchesPattern(".*.*\\s*newTag\\s*.*.*"), + matchesPattern(".*.*\\s*url\\s*.*.*"), + matchesPattern(".*.*\\s*connection\\s*.*.*"), + matchesPattern(".*.*\\s*" + + "developerConnection\\s*.*.*"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java index f7a25407ee..56619688b3 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java @@ -43,8 +43,7 @@ import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -public class UpdateParentMojoTest -{ +public class UpdateParentMojoTest { private TestChangeRecorder changeRecorder; private UpdateParentMojo mojo; @@ -54,355 +53,358 @@ public class UpdateParentMojoTest private static org.eclipse.aether.RepositorySystem aetherRepositorySystem; @BeforeClass - public static void setUpStatic() - { + public static void setUpStatic() { repositorySystem = mockRepositorySystem(); - aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() - {{ - put( "parent-artifact", new String[] { "0.9.0", "1.0.0", "1.0.1-SNAPSHOT" } ); - put( "issue-670-artifact", new String[] { "0.0.1-1", "0.0.1-1-impl-SNAPSHOT" } ); - put( "dummy-parent2", new String[] { "1.0", "2.0", "3.0", "3.0-alpha-1", "3.0-beta-1" } ); - put( "test-incremental", new String[] { "1.0.0", "1.1.0", "1.1.1", "2.0.0" } ); - put( "unknown-artifact", new String[0] ); - }} ); + aetherRepositorySystem = mockAetherRepositorySystem(new HashMap() { + { + put("parent-artifact", new String[] {"0.9.0", "1.0.0", "1.0.1-SNAPSHOT"}); + put("issue-670-artifact", new String[] {"0.0.1-1", "0.0.1-1-impl-SNAPSHOT"}); + put("dummy-parent2", new String[] {"1.0", "2.0", "3.0", "3.0-alpha-1", "3.0-beta-1"}); + put("test-incremental", new String[] {"1.0.0", "1.1.0", "1.1.1", "2.0.0"}); + put("unknown-artifact", new String[0]); + } + }); } @Before - public void setUp() throws IllegalAccessException - { + public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new UpdateParentMojo( repositorySystem, aetherRepositorySystem, null, changeRecorder.asTestMap() ) - {{ - setProject( createProject() ); - reactorProjects = Collections.emptyList(); - session = mockMavenSession(); - }}; + mojo = new UpdateParentMojo(repositorySystem, aetherRepositorySystem, null, changeRecorder.asTestMap()) { + { + setProject(createProject()); + reactorProjects = Collections.emptyList(); + session = mockMavenSession(); + } + }; } - private MavenProject createProject() - { - return new MavenProject() - {{ - setModel( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "project-artifact" ); - setVersion( "1.0.1-SNAPSHOT" ); - }} ); - - setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - setVersion( "1.0.1-SNAPSHOT" ); - }} ); - }}; + private MavenProject createProject() { + return new MavenProject() { + { + setModel(new Model() { + { + setGroupId("default-group"); + setArtifactId("project-artifact"); + setVersion("1.0.1-SNAPSHOT"); + } + }); + + setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + setVersion("1.0.1-SNAPSHOT"); + } + }); + } + }; } - private static RepositorySystem mockRepositorySystem() - { - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), dependency.getClassifier() != null - ? dependency.getClassifier() : "default", - new DefaultArtifactHandlerStub( "default" ) ); - } ); + private static RepositorySystem mockRepositorySystem() { + RepositorySystem repositorySystem = mock(RepositorySystem.class); + when(repositorySystem.createDependencyArtifact(any(Dependency.class))).thenAnswer(invocation -> { + Dependency dependency = invocation.getArgument(0); + return new DefaultArtifact( + dependency.getGroupId(), + dependency.getArtifactId(), + dependency.getVersion(), + dependency.getScope(), + dependency.getType(), + dependency.getClassifier() != null ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub("default")); + }); return repositorySystem; } @Test - @SuppressWarnings( "deprecation" ) + @SuppressWarnings("deprecation") public void testArtifactIdDoesNotExist() - throws VersionRetrievalException, MojoExecutionException, - XMLStreamException, MojoFailureException, InvalidVersionSpecificationException, - VersionRetrievalException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "unknown-artifact" ); - setVersion( "1.0.1-SNAPSHOT" ); - }} ); - - Artifact artifact = - new DefaultArtifact( "default-group", "unknown-artifact", "1.0.1-SNAPSHOT", SCOPE_COMPILE, "pom", - "default", new DefaultArtifactHandlerStub( "default" ) ); + throws VersionRetrievalException, MojoExecutionException, XMLStreamException, MojoFailureException, + InvalidVersionSpecificationException, VersionRetrievalException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("unknown-artifact"); + setVersion("1.0.1-SNAPSHOT"); + } + }); + + Artifact artifact = new DefaultArtifact( + "default-group", + "unknown-artifact", + "1.0.1-SNAPSHOT", + SCOPE_COMPILE, + "pom", + "default", + new DefaultArtifactHandlerStub("default")); assertThat( - mojo.findLatestVersion( artifact, VersionRange.createFromVersionSpec( "1.0.1-SNAPSHOT" ), null, false ), - is( nullValue() ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); - mojo.update( null ); + mojo.findLatestVersion(artifact, VersionRange.createFromVersionSpec("1.0.1-SNAPSHOT"), null, false), + is(nullValue())); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } } @Test public void testParentDowngradeAllowed() - throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.allowDowngrade = true; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "parent-artifact", "1.0.1-SNAPSHOT", - "1.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "parent-artifact", "1.0.1-SNAPSHOT", "1.0.0"))); } @Test public void testParentDowngradeForbidden() - throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.allowDowngrade = false; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), is( empty() ) ); + assertThat(changeRecorder.getChanges(), is(empty())); } @Test public void testParentDowngradeAllowedWithRange() - throws MojoExecutionException, VersionRetrievalException, - InvalidVersionSpecificationException, InvalidSegmentException - { + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { mojo.allowDowngrade = true; - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - }} ); - - ArtifactVersion newVersion = mojo.resolveTargetVersion( "[1.0.1-SNAPSHOT,)" ); - assertThat( newVersion, notNullValue() ); - assertThat( newVersion.toString(), is( "1.0.0" ) ); + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + } + }); + + ArtifactVersion newVersion = mojo.resolveTargetVersion("[1.0.1-SNAPSHOT,)"); + assertThat(newVersion, notNullValue()); + assertThat(newVersion.toString(), is("1.0.0")); } @Test public void testParentDowngradeForbiddenWithRange() - throws MojoExecutionException, VersionRetrievalException, - InvalidVersionSpecificationException, InvalidSegmentException - { + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { mojo.allowDowngrade = false; - ArtifactVersion newVersion = mojo.resolveTargetVersion( "[1.0.1-SNAPSHOT,)" ); - assertThat( newVersion, nullValue() ); + ArtifactVersion newVersion = mojo.resolveTargetVersion("[1.0.1-SNAPSHOT,)"); + assertThat(newVersion, nullValue()); } @Test public void testAllowSnapshots() - throws MojoExecutionException, VersionRetrievalException, - InvalidVersionSpecificationException, InvalidSegmentException - { + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { mojo.allowSnapshots = true; - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "issue-670-artifact" ); - }} ); - - ArtifactVersion newVersion = mojo.resolveTargetVersion( "0.0.1-1" ); - assertThat( newVersion, notNullValue() ); - assertThat( newVersion.toString(), is( "0.0.1-1-impl-SNAPSHOT" ) ); + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("issue-670-artifact"); + } + }); + + ArtifactVersion newVersion = mojo.resolveTargetVersion("0.0.1-1"); + assertThat(newVersion, notNullValue()); + assertThat(newVersion.toString(), is("0.0.1-1-impl-SNAPSHOT")); } @Test public void testAllowSnapshotsWithParentVersion() - throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { mojo.allowSnapshots = true; mojo.parentVersion = "0.0.1-1-impl-SNAPSHOT"; - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "issue-670-artifact" ); - setVersion( "0.0.1-1" ); - }} ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("issue-670-artifact"); + setVersion("0.0.1-1"); + } + }); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasItem( new DefaultVersionChange( "default-group", - "issue-670-artifact", "0.0.1-1", - "0.0.1-1-impl-SNAPSHOT" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "issue-670-artifact", "0.0.1-1", "0.0.1-1-impl-SNAPSHOT"))); } @Test public void testIgnoredVersions() - throws MojoExecutionException, IllegalAccessException, - VersionRetrievalException, InvalidVersionSpecificationException, InvalidSegmentException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - }} ); - setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.0.0" ) ); - assertThat( mojo.resolveTargetVersion( "0.9.0" ), nullValue() ); + throws MojoExecutionException, IllegalAccessException, VersionRetrievalException, + InvalidVersionSpecificationException, InvalidSegmentException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + } + }); + setVariableValueToObject(mojo, "ignoredVersions", singleton("1.0.0")); + assertThat(mojo.resolveTargetVersion("0.9.0"), nullValue()); } @Test - public void testSkipResolutionDowngradeUnknownVersion() throws VersionRetrievalException - { - testSkipResolution( "0.8.0" ); + public void testSkipResolutionDowngradeUnknownVersion() throws VersionRetrievalException { + testSkipResolution("0.8.0"); } @Test - public void testSkipResolutionDowngrade() throws VersionRetrievalException - { - testSkipResolution( "0.9.0" ); + public void testSkipResolutionDowngrade() throws VersionRetrievalException { + testSkipResolution("0.9.0"); } @Test - public void testSkipResolutionUpgradeUnknownVersion() throws VersionRetrievalException - { - testSkipResolution( "2.0.0" ); + public void testSkipResolutionUpgradeUnknownVersion() throws VersionRetrievalException { + testSkipResolution("2.0.0"); } - private void testSkipResolution( String version ) throws VersionRetrievalException - { + private void testSkipResolution(String version) throws VersionRetrievalException { mojo.parentVersion = version; mojo.skipResolution = true; - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - setVersion( "1.0.0" ); - }} ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); - } - catch ( MojoExecutionException | XMLStreamException | MojoFailureException e ) - { - throw new RuntimeException( e ); + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + setVersion("1.0.0"); + } + }); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); + } catch (MojoExecutionException | XMLStreamException | MojoFailureException e) { + throw new RuntimeException(e); } - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "parent-artifact", "1.0.0", version ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "parent-artifact", "1.0.0", version))); } @Test - public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - setVersion( "0.9.0" ); - }} ); + public void testShouldUpgradeToSnapshot() + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + setVersion("0.9.0"); + } + }); mojo.allowSnapshots = true; mojo.parentVersion = "[0,1.0.1-SNAPSHOT]"; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "parent-artifact", "0.9.0", - "1.0.1-SNAPSHOT" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "parent-artifact", "0.9.0", "1.0.1-SNAPSHOT"))); } @Test public void testAllowMinorUpdates() - throws MojoExecutionException, VersionRetrievalException, - InvalidVersionSpecificationException, InvalidSegmentException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "parent-artifact" ); - setVersion( "0.8.0" ); - }} ); + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("parent-artifact"); + setVersion("0.8.0"); + } + }); mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = true; mojo.allowIncrementalUpdates = true; - ArtifactVersion newVersion = mojo.resolveTargetVersion( "0.8.0" ); + ArtifactVersion newVersion = mojo.resolveTargetVersion("0.8.0"); - assertThat( newVersion, notNullValue() ); - assertThat( newVersion.toString(), is( "0.9.0" ) ); + assertThat(newVersion, notNullValue()); + assertThat(newVersion.toString(), is("0.9.0")); } @Test public void testAllowIncrementalUpdates() - throws MojoExecutionException, VersionRetrievalException, - InvalidVersionSpecificationException, InvalidSegmentException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "test-incremental" ); - }} ); + throws MojoExecutionException, VersionRetrievalException, InvalidVersionSpecificationException, + InvalidSegmentException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("test-incremental"); + } + }); mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.allowIncrementalUpdates = true; - ArtifactVersion newVersion = mojo.resolveTargetVersion( "1.1.0" ); + ArtifactVersion newVersion = mojo.resolveTargetVersion("1.1.0"); - assertThat( newVersion, notNullValue() ); - assertThat( newVersion.toString(), is( "1.1.1" ) ); + assertThat(newVersion, notNullValue()); + assertThat(newVersion.toString(), is("1.1.1")); } @Test - public void testParentVersionRange() throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "dummy-parent2" ); - setVersion( "1.0" ); - }} ); + public void testParentVersionRange() + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("dummy-parent2"); + setVersion("1.0"); + } + }); mojo.allowSnapshots = true; mojo.parentVersion = "[,3.0-!)"; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "dummy-parent2", "1.0", - "2.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "dummy-parent2", "1.0", "2.0"))); } @Test - public void testParentVersionRange2() throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( "default-group" ); - setArtifactId( "dummy-parent2" ); - setVersion( "2.0" ); - }} ); + public void testParentVersionRange2() + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject().setParent(new MavenProject() { + { + setGroupId("default-group"); + setArtifactId("dummy-parent2"); + setVersion("2.0"); + } + }); mojo.allowSnapshots = true; mojo.parentVersion = "[,3.0-!)"; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), empty() ); + assertThat(changeRecorder.getChanges(), empty()); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java index 2da6749d03..af9be7435c 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTest.java @@ -35,56 +35,59 @@ /** * Unit tests for {@link UpdatePropertiesMojo} */ -public class UpdatePropertiesMojoTest extends UpdatePropertiesMojoTestBase -{ +public class UpdatePropertiesMojoTest extends UpdatePropertiesMojoTestBase { @Test - public void testAllowMajorUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - setUpMojo( "update-properties" ).execute(); - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); + public void testAllowMajorUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + setUpMojo("update-properties").execute(); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); } @Test - public void testAllowMinorUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); + public void testAllowMinorUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + UpdatePropertiesMojo mojo = setUpMojo("update-properties"); mojo.allowMajorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); } @Test - public void testAllowIncrementalUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); + public void testAllowIncrementalUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + UpdatePropertiesMojo mojo = setUpMojo("update-properties"); mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); } @Test - public void testChangesNotRegisteredIfNoUpdatesInPom() - throws Exception - { - TestUtils.copyDir( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-837" ), - pomDir ); - UpdatePropertiesMojo mojo = setUpMojo( "update-properties" ); + public void testChangesNotRegisteredIfNoUpdatesInPom() throws Exception { + TestUtils.copyDir(Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-837"), pomDir); + UpdatePropertiesMojo mojo = setUpMojo("update-properties"); TestChangeRecorder changeRecorder = new TestChangeRecorder(); - setVariableValueToObject( mojo, "changeRecorders", changeRecorder.asTestMap() ); - setVariableValueToObject( mojo, "changeRecorderFormat", "none" ); -// pomHelperClass.when( () -> PomHelper.setPropertyVersion( any(), anyString(), anyString(), anyString() ) ) -// .thenReturn( false ); - mojo.execute( ); - assertThat( changeRecorder.getChanges(), is( empty() ) ); + setVariableValueToObject(mojo, "changeRecorders", changeRecorder.asTestMap()); + setVariableValueToObject(mojo, "changeRecorderFormat", "none"); + // pomHelperClass.when( () -> PomHelper.setPropertyVersion( any(), anyString(), anyString(), + // anyString() ) ) + // .thenReturn( false ); + mojo.execute(); + assertThat(changeRecorder.getChanges(), is(empty())); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java index ba3b7b8c7a..c4b971f18a 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertiesMojoTestBase.java @@ -38,48 +38,42 @@ /** * Base class for {@link UpdatePropertiesMojo} and {@link UpdatePropertyMojo} test suites */ -public abstract class UpdatePropertiesMojoTestBase extends AbstractMojoTestCase -{ +public abstract class UpdatePropertiesMojoTestBase extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); + protected Path pomDir; protected org.eclipse.aether.RepositorySystem aetherRepositorySystem; protected TestChangeRecorder changeRecorder; @Before - public void setUp() throws Exception - { + public void setUp() throws Exception { super.setUp(); - pomDir = createTempDir( "update-property" ); - aetherRepositorySystem = mockAetherRepositorySystem( new HashMap() - {{ - put( "default-artifact", new String[] {"1.0.0", "1.0.1-rc1", "1.1.0-alpha", "2.0.0-M1"} ); - }} ); + pomDir = createTempDir("update-property"); + aetherRepositorySystem = mockAetherRepositorySystem(new HashMap() { + { + put("default-artifact", new String[] {"1.0.0", "1.0.1-rc1", "1.1.0-alpha", "2.0.0-M1"}); + } + }); } @After - public void tearDown() throws Exception - { - try - { - tearDownTempDir( pomDir ); - } - finally - { + public void tearDown() throws Exception { + try { + tearDownTempDir(pomDir); + } finally { super.tearDown(); } } - @SuppressWarnings( "unchecked" ) - protected T setUpMojo( String goal ) throws Exception - { - T mojo = (T) mojoRule.lookupConfiguredMojo( pomDir.toFile(), goal ); - setVariableValueToObject( mojo, "aetherRepositorySystem", aetherRepositorySystem ); - setVariableValueToObject( mojo, "generateBackupPoms", false ); - setVariableValueToObject( mojo, "changeRecorderFormat", "test" ); + @SuppressWarnings("unchecked") + protected T setUpMojo(String goal) throws Exception { + T mojo = (T) mojoRule.lookupConfiguredMojo(pomDir.toFile(), goal); + setVariableValueToObject(mojo, "aetherRepositorySystem", aetherRepositorySystem); + setVariableValueToObject(mojo, "generateBackupPoms", false); + setVariableValueToObject(mojo, "changeRecorderFormat", "test"); changeRecorder = (TestChangeRecorder) - ( (Map) getVariableValueFromObject( mojo, "changeRecorders" ) ) - .get( "test" ); + ((Map) getVariableValueFromObject(mojo, "changeRecorders")).get("test"); return (T) mojo; } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java index 1a63831a8d..3005da328b 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UpdatePropertyMojoTest.java @@ -31,44 +31,50 @@ /** * Unit tests for {@link UpdatePropertiesMojo} */ -public class UpdatePropertyMojoTest extends UpdatePropertiesMojoTestBase -{ +public class UpdatePropertyMojoTest extends UpdatePropertiesMojoTestBase { @Test - public void testAllowMajorUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - UpdatePropertyMojo mojo = setUpMojo( "update-property" ); + public void testAllowMajorUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + UpdatePropertyMojo mojo = setUpMojo("update-property"); mojo.property = "artifact-version"; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "2.0.0-M1" ) ) ); + assertThat( + changeRecorder.getChanges(), + Matchers.hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "2.0.0-M1"))); } @Test - public void testAllowMinorUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - UpdatePropertyMojo mojo = setUpMojo( "update-property" ); + public void testAllowMinorUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + UpdatePropertyMojo mojo = setUpMojo("update-property"); mojo.property = "artifact-version"; mojo.allowMajorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.1.0-alpha" ) ) ); + assertThat( + changeRecorder.getChanges(), + Matchers.hasItem( + new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.1.0-alpha"))); } @Test - public void testAllowIncrementalUpdates() throws Exception - { - Files.copy( Paths.get( "src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml" ), - Paths.get( pomDir.toString(), "pom.xml" ), REPLACE_EXISTING ); - UpdatePropertyMojo mojo = setUpMojo( "update-property" ); + public void testAllowIncrementalUpdates() throws Exception { + Files.copy( + Paths.get("src/test/resources/org/codehaus/mojo/update-properties/issue-454-pom.xml"), + Paths.get(pomDir.toString(), "pom.xml"), + REPLACE_EXISTING); + UpdatePropertyMojo mojo = setUpMojo("update-property"); mojo.property = "artifact-version"; mojo.allowMajorUpdates = false; mojo.allowMinorUpdates = false; mojo.execute(); - assertThat( changeRecorder.getChanges(), Matchers.hasItem( - new DefaultVersionChange( "default-group", "default-artifact", "1.0.0", "1.0.1-rc1" ) ) ); + assertThat( + changeRecorder.getChanges(), + Matchers.hasItem(new DefaultVersionChange("default-group", "default-artifact", "1.0.0", "1.0.1-rc1"))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java index 290a021942..31c04aa7cb 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseDepVersionMojoTest.java @@ -32,23 +32,20 @@ * * @author Andrzej Jarmoniuk */ -public class UseDepVersionMojoTest extends AbstractMojoTestCase -{ +public class UseDepVersionMojoTest extends AbstractMojoTestCase { @Rule - public MojoRule mojoRule = new MojoRule( this ); + public MojoRule mojoRule = new MojoRule(this); @Test - public void testIssue673() throws Exception - { + public void testIssue673() throws Exception { UseDepVersionMojo mojo = (UseDepVersionMojo) mojoRule.lookupConfiguredMojo( - new File( "target/test-classes/org/codehaus/mojo/use-dep-version/issue-637" ), - "use-dep-version" ); - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "processDependencyManagement", true ); - setVariableValueToObject( mojo, "excludeReactor", true ); - setVariableValueToObject( mojo, "serverId", "serverId" ); - setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( mojo.getProject() ) ); + new File("target/test-classes/org/codehaus/mojo/use-dep-version/issue-637"), "use-dep-version"); + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "processDependencyManagement", true); + setVariableValueToObject(mojo, "excludeReactor", true); + setVariableValueToObject(mojo, "serverId", "serverId"); + setVariableValueToObject(mojo, "reactorProjects", Collections.singletonList(mojo.getProject())); mojo.execute(); } -} \ No newline at end of file +} diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java index a02eef31f3..f103df7359 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestReleasesMojoTest.java @@ -33,82 +33,86 @@ import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -public class UseLatestReleasesMojoTest -{ +public class UseLatestReleasesMojoTest { private UseLatestReleasesMojo mojo; private TestChangeRecorder changeRecorder; @Before - public void setUp() throws Exception - { - RepositorySystem repositorySystemMock = mock( RepositorySystem.class ); - when( repositorySystemMock.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), - dependency.getClassifier() != null ? dependency.getClassifier() : "default", - new DefaultArtifactHandlerStub( "default" ) ); - } ); + public void setUp() throws Exception { + RepositorySystem repositorySystemMock = mock(RepositorySystem.class); + when(repositorySystemMock.createDependencyArtifact(any(Dependency.class))) + .thenAnswer(invocation -> { + Dependency dependency = invocation.getArgument(0); + return new DefaultArtifact( + dependency.getGroupId(), + dependency.getArtifactId(), + dependency.getVersion(), + dependency.getScope(), + dependency.getType(), + dependency.getClassifier() != null ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub("default")); + }); - org.eclipse.aether.RepositorySystem aetherRepositorySystem = mockAetherRepositorySystem( - new HashMap() - {{ - put( "dependency-artifact", new String[] {"0.9.0", "1.0.0-beta"} ); - }} ); + org.eclipse.aether.RepositorySystem aetherRepositorySystem = + mockAetherRepositorySystem(new HashMap() { + { + put("dependency-artifact", new String[] {"0.9.0", "1.0.0-beta"}); + } + }); changeRecorder = new TestChangeRecorder(); - mojo = new UseLatestReleasesMojo( repositorySystemMock, - aetherRepositorySystem, - null, - changeRecorder.asTestMap() ) - {{ - reactorProjects = emptyList(); - MavenProject project = new MavenProject() - {{ - setModel( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "project-artifact" ); - setVersion( "1.0.0-SNAPSHOT" ); + mojo = + new UseLatestReleasesMojo( + repositorySystemMock, aetherRepositorySystem, null, changeRecorder.asTestMap()) { + { + reactorProjects = emptyList(); + MavenProject project = new MavenProject() { + { + setModel(new Model() { + { + setGroupId("default-group"); + setArtifactId("project-artifact"); + setVersion("1.0.0-SNAPSHOT"); - setDependencies( singletonList( - DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "dependency-artifact" ) - .withVersion( "0.9.0" ) - .withScope( SCOPE_COMPILE ) - .withType( "jar" ) - .withClassifier( "default" ) - .build() ) ); - }} ); - }}; - setProject( project ); + setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("dependency-artifact") + .withVersion("0.9.0") + .withScope(SCOPE_COMPILE) + .withType("jar") + .withClassifier("default") + .build())); + } + }); + } + }; + setProject(project); - session = mockMavenSession(); - }}; + session = mockMavenSession(); + } + }; } @Test public void testDontUpgradeToBeta() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", false ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", false); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), Matchers.empty() ); + assertThat(changeRecorder.getChanges(), Matchers.empty()); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java index 9a3db80a40..0c3095af84 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseLatestVersionsMojoTest.java @@ -41,295 +41,325 @@ import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -@SuppressWarnings( "deprecation" ) -public class UseLatestVersionsMojoTest -{ +@SuppressWarnings("deprecation") +public class UseLatestVersionsMojoTest { private UseLatestVersionsMojo mojo; private TestChangeRecorder changeRecorder; @Before - public void setUp() throws Exception - { - RepositorySystem repositorySystemMock = mock( RepositorySystem.class ); - when( repositorySystemMock.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), - dependency.getScope(), dependency.getType(), - dependency.getClassifier() != null ? dependency.getClassifier() : "default", - new DefaultArtifactHandlerStub( "default" ) ); - } ); - - org.eclipse.aether.RepositorySystem aetherRepositorySystem = mockAetherRepositorySystem( - new HashMap() - {{ - put( "dependency-artifact", new String[] {"1.1.1-SNAPSHOT", "1.1.0", "1.1.0-SNAPSHOT", "1.0.0", - "1.0.0-SNAPSHOT", "0.9.0"} ); - put( "poison-artifact", new String[] {"1.1.1.1-SNAPSHOT", "1.1.1.0", "1.1.1.0-SNAPSHOT", "1.0.0.0", - "1.0.0.0-SNAPSHOT", "0.9.0.0"} ); - put( "other-artifact", new String[] {"1.0", "2.0"} ); - }} ); + public void setUp() throws Exception { + RepositorySystem repositorySystemMock = mock(RepositorySystem.class); + when(repositorySystemMock.createDependencyArtifact(any(Dependency.class))) + .thenAnswer(invocation -> { + Dependency dependency = invocation.getArgument(0); + return new DefaultArtifact( + dependency.getGroupId(), + dependency.getArtifactId(), + dependency.getVersion(), + dependency.getScope(), + dependency.getType(), + dependency.getClassifier() != null ? dependency.getClassifier() : "default", + new DefaultArtifactHandlerStub("default")); + }); + + org.eclipse.aether.RepositorySystem aetherRepositorySystem = + mockAetherRepositorySystem(new HashMap() { + { + put("dependency-artifact", new String[] { + "1.1.1-SNAPSHOT", "1.1.0", "1.1.0-SNAPSHOT", "1.0.0", "1.0.0-SNAPSHOT", "0.9.0" + }); + put("poison-artifact", new String[] { + "1.1.1.1-SNAPSHOT", "1.1.1.0", "1.1.1.0-SNAPSHOT", "1.0.0.0", "1.0.0.0-SNAPSHOT", "0.9.0.0" + }); + put("other-artifact", new String[] {"1.0", "2.0"}); + } + }); changeRecorder = new TestChangeRecorder(); - mojo = new UseLatestVersionsMojo( repositorySystemMock, - aetherRepositorySystem, - null, - changeRecorder.asTestMap() ) - {{ - reactorProjects = emptyList(); - MavenProject project = new MavenProject() - {{ - setModel( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "project-artifact" ); - setVersion( "1.0.0-SNAPSHOT" ); - - setDependencies( Collections.singletonList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "default", "pom", SCOPE_COMPILE ) ) ); - - setDependencyManagement( new DependencyManagement() ); - getDependencyManagement().setDependencies( Collections.singletonList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "default", "pom", SCOPE_COMPILE ) ) ); - }} ); - }}; - setProject( project ); - - session = mockMavenSession(); - }}; - setVariableValueToObject( mojo, "processDependencyManagement", false ); + mojo = + new UseLatestVersionsMojo( + repositorySystemMock, aetherRepositorySystem, null, changeRecorder.asTestMap()) { + { + reactorProjects = emptyList(); + MavenProject project = new MavenProject() { + { + setModel(new Model() { + { + setGroupId("default-group"); + setArtifactId("project-artifact"); + setVersion("1.0.0-SNAPSHOT"); + + setDependencies(Collections.singletonList(DependencyBuilder.dependencyWith( + "default-group", + "dependency-artifact", + "1.1.1-SNAPSHOT", + "default", + "pom", + SCOPE_COMPILE))); + + setDependencyManagement(new DependencyManagement()); + getDependencyManagement() + .setDependencies( + Collections.singletonList(DependencyBuilder.dependencyWith( + "default-group", + "dependency-artifact", + "1.1.1-SNAPSHOT", + "default", + "pom", + SCOPE_COMPILE))); + } + }); + } + }; + setProject(project); + + session = mockMavenSession(); + } + }; + setVariableValueToObject(mojo, "processDependencyManagement", false); } @Test public void testDependenciesDowngradeIncremental() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test public void testDependenciesDowngradeMinor() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - mojo.getProject().getModel().setDependencies( Collections.singletonList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.0-SNAPSHOT", - "default", "pom", SCOPE_COMPILE ) ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + mojo.getProject() + .getModel() + .setDependencies(Collections.singletonList(DependencyBuilder.dependencyWith( + "default-group", "dependency-artifact", "1.1.0-SNAPSHOT", "default", "pom", SCOPE_COMPILE))); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "dependency-artifact", - "1.1.0-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "dependency-artifact", + "1.1.0-SNAPSHOT", "1.1.0"))); } @Test public void testDependenciesDowngradeMajor() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", true ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", true); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "dependency-artifact", - "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "dependency-artifact", + "1.1.1-SNAPSHOT", "1.1.0"))); } @Test public void testDependencyManagementDowngrade() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencyManagement", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencyManagement", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test public void testParentDowngrade() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processParent", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - mojo.getProject().setParentArtifact( - new DefaultArtifact( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "compile", "pom", - "default", null ) ); - mojo.getProject().setParent( new MavenProject() - {{ - setGroupId( mojo.getProject().getParentArtifact().getGroupId() ); - setArtifactId( mojo.getProject().getParentArtifact().getArtifactId() ); - setVersion( mojo.getProject().getParentArtifact().getVersion() ); - }} ); - - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processParent", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + mojo.getProject() + .setParentArtifact(new DefaultArtifact( + "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "compile", "pom", "default", null)); + mojo.getProject().setParent(new MavenProject() { + { + setGroupId(mojo.getProject().getParentArtifact().getGroupId()); + setArtifactId(mojo.getProject().getParentArtifact().getArtifactId()); + setVersion(mojo.getProject().getParentArtifact().getVersion()); + } + }); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test public void testPoisonDependencyVersion() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - mojo.getProject().getModel().setDependencies( Arrays.asList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", - "default", "pom", SCOPE_COMPILE ), - DependencyBuilder.dependencyWith( "default-group", "poison-artifact", "1.1.1.1-SNAPSHOT", - "default", "pom", SCOPE_COMPILE ) - ) ); - - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "allowSnapshots", false ); - setVariableValueToObject( mojo, "allowMajorUpdates", false ); - setVariableValueToObject( mojo, "allowMinorUpdates", true ); - setVariableValueToObject( mojo, "allowIncrementalUpdates", true ); - setVariableValueToObject( mojo, "allowDowngrade", true ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + mojo.getProject() + .getModel() + .setDependencies(Arrays.asList( + DependencyBuilder.dependencyWith( + "default-group", + "dependency-artifact", + "1.1.1-SNAPSHOT", + "default", + "pom", + SCOPE_COMPILE), + DependencyBuilder.dependencyWith( + "default-group", + "poison-artifact", + "1.1.1.1-SNAPSHOT", + "default", + "pom", + SCOPE_COMPILE))); + + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "allowSnapshots", false); + setVariableValueToObject(mojo, "allowMajorUpdates", false); + setVariableValueToObject(mojo, "allowMinorUpdates", true); + setVariableValueToObject(mojo, "allowIncrementalUpdates", true); + setVariableValueToObject(mojo, "allowDowngrade", true); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } // So, the regular update should take place despite an irregular, or — if I may — "poison", dependency // being present in the dependency list - assertThat( changeRecorder.getChanges(), hasItem( - new DefaultVersionChange( "default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "dependency-artifact", "1.1.1-SNAPSHOT", "1.1.0"))); } @Test public void testIgnoredVersions() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "ignoredVersions", singleton( "1.1.0" ) ); - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "ignoredVersions", singleton("1.1.0")); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), Is.is( empty() ) ); + assertThat(changeRecorder.getChanges(), Is.is(empty())); } @Test public void testIncludeFilter() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - mojo.getProject().getModel().setDependencies( Arrays.asList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", - "default", "pom", SCOPE_COMPILE ), - DependencyBuilder.dependencyWith( "default-group", "other-artifact", "1.0", - "default", "pom", SCOPE_COMPILE ) - ) ); - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "includes", new String[] {"default-group:other-artifact"} ); - - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + mojo.getProject() + .getModel() + .setDependencies(Arrays.asList( + DependencyBuilder.dependencyWith( + "default-group", "dependency-artifact", "0.9.0", "default", "pom", SCOPE_COMPILE), + DependencyBuilder.dependencyWith( + "default-group", "other-artifact", "1.0", "default", "pom", SCOPE_COMPILE))); + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "includes", new String[] {"default-group:other-artifact"}); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "other-artifact", "1.0", "2.0" ) ) ); + assertThat(changeRecorder.getChanges(), hasSize(1)); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange("default-group", "other-artifact", "1.0", "2.0"))); } @Test public void testExcludeFilter() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - mojo.getProject().getModel().setDependencies( Arrays.asList( - DependencyBuilder.dependencyWith( "default-group", "dependency-artifact", "0.9.0", - "default", "pom", SCOPE_COMPILE ), - DependencyBuilder.dependencyWith( "default-group", "other-artifact", "1.0", - "default", "pom", SCOPE_COMPILE ) - ) ); - setVariableValueToObject( mojo, "processDependencies", true ); - setVariableValueToObject( mojo, "excludes", new String[] {"default-group:other-artifact"} ); - - - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), any(), any(), any(), any(), any() ) ) - .thenReturn( true ); - mojo.update( null ); + VersionRetrievalException { + mojo.getProject() + .getModel() + .setDependencies(Arrays.asList( + DependencyBuilder.dependencyWith( + "default-group", "dependency-artifact", "0.9.0", "default", "pom", SCOPE_COMPILE), + DependencyBuilder.dependencyWith( + "default-group", "other-artifact", "1.0", "default", "pom", SCOPE_COMPILE))); + setVariableValueToObject(mojo, "processDependencies", true); + setVariableValueToObject(mojo, "excludes", new String[] {"default-group:other-artifact"}); + + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion(any(), any(), any(), any(), any(), any())) + .thenReturn(true); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), hasSize( 1 ) ); - assertThat( changeRecorder.getChanges(), - not( hasItem( new DefaultVersionChange( "default-group", "other-artifact", "1.0", - "2.0" ) ) ) ); + assertThat(changeRecorder.getChanges(), hasSize(1)); + assertThat( + changeRecorder.getChanges(), + not(hasItem(new DefaultVersionChange("default-group", "other-artifact", "1.0", "2.0")))); } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java index 8f108b7447..cfac64c8c1 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/UseReleasesMojoTest.java @@ -53,112 +53,113 @@ /** * Unit tests for {@link UseReleasesMojo} */ -public class UseReleasesMojoTest extends AbstractMojoTestCase -{ +public class UseReleasesMojoTest extends AbstractMojoTestCase { private TestChangeRecorder changeRecorder; private UseReleasesMojo mojo; @Before - public void setUp() throws IllegalAccessException - { + public void setUp() throws IllegalAccessException { changeRecorder = new TestChangeRecorder(); - mojo = new UseReleasesMojo( mockRepositorySystem(), - mockAetherRepositorySystem(), - null, - changeRecorder.asTestMap() ); - setVariableValueToObject( mojo, "reactorProjects", emptyList() ); - mojo.project = new MavenProject() - {{ - setModel( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "default-artifact" ); - setVersion( "1.0.0" ); - }} ); - }}; + mojo = new UseReleasesMojo( + mockRepositorySystem(), mockAetherRepositorySystem(), null, changeRecorder.asTestMap()); + setVariableValueToObject(mojo, "reactorProjects", emptyList()); + mojo.project = new MavenProject() { + { + setModel(new Model() { + { + setGroupId("default-group"); + setArtifactId("default-artifact"); + setVersion("1.0.0"); + } + }); + } + }; mojo.session = mockMavenSession(); } @Test public void testProcessParent() throws MojoExecutionException, XMLStreamException, MojoFailureException, IllegalAccessException, - VersionRetrievalException - { - setVariableValueToObject( mojo, "processParent", true ); - mojo.getProject().setParent( new MavenProject( new Model() - {{ - setGroupId( "default-group" ); - setArtifactId( "artifactA" ); - setVersion( "1.0.0-SNAPSHOT" ); - }} ) ); - mojo.getProject().setParentArtifact( new DefaultArtifact( "default-group", "artifactA", - "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null ) ); + VersionRetrievalException { + setVariableValueToObject(mojo, "processParent", true); + mojo.getProject().setParent(new MavenProject(new Model() { + { + setGroupId("default-group"); + setArtifactId("artifactA"); + setVersion("1.0.0-SNAPSHOT"); + } + })); + mojo.getProject() + .setParentArtifact(new DefaultArtifact( + "default-group", "artifactA", "1.0.0-SNAPSHOT", SCOPE_COMPILE, "pom", "default", null)); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), anyString() ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setProjectParentVersion(any(), anyString())) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0"))); } @Test public void testReplaceSnapshotWithRelease() - throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "artifactA" ) - .withVersion( "1.0.0-SNAPSHOT" ) - .build() ) ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("artifactA") + .withVersion("1.0.0-SNAPSHOT") + .build())); - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); } - assertThat( changeRecorder.getChanges(), - hasItem( new DefaultVersionChange( "default-group", "artifactA", - "1.0.0-SNAPSHOT", "1.0.0" ) ) ); + assertThat( + changeRecorder.getChanges(), + hasItem(new DefaultVersionChange( + "default-group", "artifactA", + "1.0.0-SNAPSHOT", "1.0.0"))); } @Test public void testFailIfNotReplaced() - throws MojoExecutionException, XMLStreamException, MojoFailureException, - VersionRetrievalException - { - mojo.aetherRepositorySystem = mockAetherRepositorySystem( singletonMap( "test-artifact", - new String[] {} ) ); - mojo.getProject().setDependencies( singletonList( DependencyBuilder.newBuilder() - .withGroupId( "default-group" ) - .withArtifactId( "test-artifact" ) - .withVersion( "1.0.0-SNAPSHOT" ) - .build() ) ); + throws MojoExecutionException, XMLStreamException, MojoFailureException, VersionRetrievalException { + mojo.aetherRepositorySystem = mockAetherRepositorySystem(singletonMap("test-artifact", new String[] {})); + mojo.getProject() + .setDependencies(singletonList(DependencyBuilder.newBuilder() + .withGroupId("default-group") + .withArtifactId("test-artifact") + .withVersion("1.0.0-SNAPSHOT") + .build())); mojo.failIfNotReplaced = true; - try ( MockedStatic pomHelper = mockStatic( PomHelper.class ) ) - { - pomHelper.when( () -> PomHelper.setDependencyVersion( any(), anyString(), anyString(), anyString(), - anyString(), any( Model.class ) ) ) - .thenReturn( true ); - pomHelper.when( () -> PomHelper.getRawModel( any( MavenProject.class ) ) ) - .thenReturn( mojo.getProject().getModel() ); - mojo.update( null ); - fail( "MojoExecutionException is expected" ); - } - catch ( MojoExecutionException e ) - { - assertThat( e.getMessage(), startsWith( "No matching" ) ); + try (MockedStatic pomHelper = mockStatic(PomHelper.class)) { + pomHelper + .when(() -> PomHelper.setDependencyVersion( + any(), anyString(), anyString(), anyString(), anyString(), any(Model.class))) + .thenReturn(true); + pomHelper + .when(() -> PomHelper.getRawModel(any(MavenProject.class))) + .thenReturn(mojo.getProject().getModel()); + mojo.update(null); + fail("MojoExecutionException is expected"); + } catch (MojoExecutionException e) { + assertThat(e.getMessage(), startsWith("No matching")); } } } diff --git a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java index e70da476ea..fcd2b9cd6f 100644 --- a/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java +++ b/versions-maven-plugin/src/test/java/org/codehaus/mojo/versions/model/TestIgnoreVersions.java @@ -28,8 +28,7 @@ /** * Convenience class for quickly creating {@link IgnoreVersion} instances. */ -public class TestIgnoreVersions extends IgnoreVersion -{ +public class TestIgnoreVersions extends IgnoreVersion { public static final String TYPE_REGEX = "regex"; public static final String TYPE_EXACT = "exact"; @@ -40,9 +39,8 @@ public class TestIgnoreVersions extends IgnoreVersion * @param type required type * @return modified instance */ - public TestIgnoreVersions withType( String type ) - { - setType( type ); + public TestIgnoreVersions withType(String type) { + setType(type); return this; } @@ -52,9 +50,8 @@ public TestIgnoreVersions withType( String type ) * @param version required version * @return modified instance */ - public TestIgnoreVersions withVersion( String version ) - { - setVersion( version ); + public TestIgnoreVersions withVersion(String version) { + setVersion(version); return this; } @@ -65,29 +62,23 @@ public TestIgnoreVersions withVersion( String version ) * @return Matcher returning true if another object matches the given instance * @param

    class of the ignoreVersion instance */ - public static

    Matcher

    matches( P ignoreVersion ) - { - return new TypeSafeMatcher

    () - { + public static

    Matcher

    matches(P ignoreVersion) { + return new TypeSafeMatcher

    () { @Override - public void describeTo( Description description ) - { - description.appendText( Objects.toString( ignoreVersion ) ); + public void describeTo(Description description) { + description.appendText(Objects.toString(ignoreVersion)); } @Override - protected void describeMismatchSafely( P other, Description description ) - { - description.appendText( Objects.toString( other ) ); + protected void describeMismatchSafely(P other, Description description) { + description.appendText(Objects.toString(other)); } @Override - protected boolean matchesSafely( P other ) - { - return Objects.equals( ignoreVersion.getType(), other.getType() ) - && Objects.equals( ignoreVersion.getVersion(), other.getVersion() ); + protected boolean matchesSafely(P other) { + return Objects.equals(ignoreVersion.getType(), other.getType()) + && Objects.equals(ignoreVersion.getVersion(), other.getVersion()); } }; } - } diff --git a/versions-model-report/pom.xml b/versions-model-report/pom.xml index 6ba1fbb1bf..f92e09bb0b 100644 --- a/versions-model-report/pom.xml +++ b/versions-model-report/pom.xml @@ -1,83 +1,81 @@ - - - versions - org.codehaus.mojo.versions - 2.14.0-SNAPSHOT - - 4.0.0 + + 4.0.0 + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + - versions-model-report + versions-model-report - Versions Model Report - Modello models used in reports + Versions Model Report + Modello models used in reports - - - org.codehaus.plexus - plexus-utils - 3.5.0 - - + + + org.codehaus.plexus + plexus-utils + 3.5.0 + + - - - - org.codehaus.modello - modello-maven-plugin - - - generate-rule - generate-sources - - - xpp3-reader - - xpp3-writer - - java - - - - site-doc - pre-site - - xdoc - - - - site-xsd - pre-site - - xsd - - - ${project.build.directory}/generated-site/resources/xsd - - - - - - src/main/mdo/dependency-updates-report.mdo - src/main/mdo/plugin-updates-report.mdo - src/main/mdo/property-updates-report.mdo - - ${modelloNamespaceReportVersion} - - + + + + org.codehaus.modello + modello-maven-plugin + + + src/main/mdo/dependency-updates-report.mdo + src/main/mdo/plugin-updates-report.mdo + src/main/mdo/property-updates-report.mdo + + ${modelloNamespaceReportVersion} + + + + generate-rule + + + xpp3-reader + + xpp3-writer + + java + + generate-sources + + + site-doc + + xdoc + + pre-site + + + site-xsd + + xsd + + pre-site + + ${project.build.directory}/generated-site/resources/xsd + + + + - - org.apache.maven.plugins - maven-checkstyle-plugin - - true - - + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + - + - + diff --git a/versions-model/pom.xml b/versions-model/pom.xml index b813ea9eb8..3abd59ef69 100644 --- a/versions-model/pom.xml +++ b/versions-model/pom.xml @@ -1,77 +1,75 @@ - - - versions - org.codehaus.mojo.versions - 2.14.0-SNAPSHOT - - 4.0.0 + + 4.0.0 + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + - versions-model + versions-model - Versions Model - Modello models used in plugin + Versions Model + Modello models used in plugin - - - org.codehaus.plexus - plexus-utils - 3.5.0 - - + + + org.codehaus.plexus + plexus-utils + 3.5.0 + + - - - - org.codehaus.modello - modello-maven-plugin - - - generate-rule - generate-sources - - - xpp3-reader - - java - - - - site-doc - pre-site - - xdoc - - - - site-xsd - pre-site - - xsd - - - ${project.build.directory}/generated-site/resources/xsd - - - - - - src/main/mdo/rule.mdo - - ${modelloNamespaceRuleVersion} - - + + + + org.codehaus.modello + modello-maven-plugin + + + src/main/mdo/rule.mdo + + ${modelloNamespaceRuleVersion} + + + + generate-rule + + + xpp3-reader + + java + + generate-sources + + + site-doc + + xdoc + + pre-site + + + site-xsd + + xsd + + pre-site + + ${project.build.directory}/generated-site/resources/xsd + + + + - - org.apache.maven.plugins - maven-checkstyle-plugin - - true - - - - + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + diff --git a/versions-test/pom.xml b/versions-test/pom.xml index 3c81525f99..1f1d02f1c2 100644 --- a/versions-test/pom.xml +++ b/versions-test/pom.xml @@ -17,61 +17,58 @@ ~ specific language governing permissions and limitations ~ under the License. --> + + 4.0.0 + + org.codehaus.mojo.versions + versions + 2.14.0-SNAPSHOT + - - 4.0.0 - - versions - org.codehaus.mojo.versions - 2.14.0-SNAPSHOT - + versions-test - versions-test + Versions Test + Internal test utilities used in project - Versions Test - Internal test utilities used in project + + + org.apache.maven + maven-core + ${mavenVersion} + provided + + + org.eclipse.aether + aether-api + 1.1.0 + + + org.apache.maven.doxia + doxia-integration-tools + ${doxiaVersion} + + + org.apache.maven.doxia + doxia-site-renderer + ${doxia-sitetoolsVersion} + + + org.codehaus.mojo.versions + versions-common + ${project.version} + + + org.apache.commons + commons-text + + + org.mockito + mockito-inline + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + + - - - org.apache.maven - maven-core - ${mavenVersion} - provided - - - org.eclipse.aether - aether-api - 1.1.0 - - - org.apache.maven.doxia - doxia-integration-tools - ${doxiaVersion} - - - org.apache.maven.doxia - doxia-site-renderer - ${doxia-sitetoolsVersion} - - - org.codehaus.mojo.versions - versions-common - ${project.version} - - - org.apache.commons - commons-text - - - org.mockito - mockito-inline - - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - - - - \ No newline at end of file + diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java index b19b3a2ead..92a1d0cab7 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/MockUtils.java @@ -53,22 +53,21 @@ /** * Various mock creating utilities */ -public class MockUtils -{ - private static final Map DEFAULT_VERSION_MAP = new HashMap() - {{ - put( "artifactA", new String[] {"1.0.0", "2.0.0"} ); - put( "artifactB", new String[] {"1.0.0", "1.1.0"} ); - put( "artifactC", new String[] {"1.0.0"} ); - }}; +public class MockUtils { + private static final Map DEFAULT_VERSION_MAP = new HashMap() { + { + put("artifactA", new String[] {"1.0.0", "2.0.0"}); + put("artifactB", new String[] {"1.0.0", "1.1.0"}); + put("artifactC", new String[] {"1.0.0"}); + } + }; /** * Creates a mocked {@linkplain org.eclipse.aether.RepositorySystem}, providing the default version set * @return mocked {@linkplain org.eclipse.aether.RepositorySystem} */ - public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem() - { - return mockAetherRepositorySystem( DEFAULT_VERSION_MAP ); + public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem() { + return mockAetherRepositorySystem(DEFAULT_VERSION_MAP); } /** @@ -77,84 +76,73 @@ public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem() * @param versionMap requested version map * @return mocked {@linkplain org.eclipse.aether.RepositorySystem} */ - public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem( Map versionMap ) - { - org.eclipse.aether.RepositorySystem repositorySystem = mock( org.eclipse.aether.RepositorySystem.class ); - try - { - when( repositorySystem.resolveVersionRange( any(), any( VersionRangeRequest.class ) ) ) - .then( invocation -> - { - VersionRangeRequest request = invocation.getArgument( 1 ); + public static org.eclipse.aether.RepositorySystem mockAetherRepositorySystem(Map versionMap) { + org.eclipse.aether.RepositorySystem repositorySystem = mock(org.eclipse.aether.RepositorySystem.class); + try { + when(repositorySystem.resolveVersionRange(any(), any(VersionRangeRequest.class))) + .then(invocation -> { + VersionRangeRequest request = invocation.getArgument(1); return versionMap.entrySet().stream() - .filter( e -> e.getKey().equals( request.getArtifact().getArtifactId() ) ) + .filter(e -> + e.getKey().equals(request.getArtifact().getArtifactId())) .findAny() - .map( e -> Arrays.stream( e.getValue() ) - .map( VersionStub::new ) - .collect( () -> new ArrayList(), ArrayList::add, ArrayList::addAll ) ) - .map( versions -> new VersionRangeResult( request ).setVersions( versions ) ) - .orElse( null ); // should tell us if we haven't populated all cases in the test - } ); - when( repositorySystem.resolveArtifact( any( RepositorySystemSession.class ), - any( ArtifactRequest.class ) ) ) - .then( invocation -> - { - ArtifactRequest request = invocation.getArgument( 1 ); + .map(e -> Arrays.stream(e.getValue()) + .map(VersionStub::new) + .collect(() -> new ArrayList(), ArrayList::add, ArrayList::addAll)) + .map(versions -> new VersionRangeResult(request).setVersions(versions)) + .orElse(null); // should tell us if we haven't populated all cases in the test + }); + when(repositorySystem.resolveArtifact(any(RepositorySystemSession.class), any(ArtifactRequest.class))) + .then(invocation -> { + ArtifactRequest request = invocation.getArgument(1); org.eclipse.aether.artifact.Artifact copiedArtifact = new org.eclipse.aether.artifact.DefaultArtifact( request.getArtifact().getGroupId(), request.getArtifact().getArtifactId(), request.getArtifact().getClassifier(), request.getArtifact().getExtension(), - request.getArtifact().getVersion() ); - copiedArtifact.setFile( mock( File.class ) ); - return new ArtifactResult( request ) - .setArtifact( copiedArtifact ); - } ); - } - catch ( VersionRangeResolutionException | ArtifactResolutionException e ) - { - throw new RuntimeException( e ); + request.getArtifact().getVersion()); + copiedArtifact.setFile(mock(File.class)); + return new ArtifactResult(request).setArtifact(copiedArtifact); + }); + } catch (VersionRangeResolutionException | ArtifactResolutionException e) { + throw new RuntimeException(e); } return repositorySystem; } - public static I18N mockI18N() - { - I18N i18n = mock( I18N.class ); - when( i18n.getString( anyString(), any(), anyString() ) ).thenAnswer( - invocation -> invocation.getArgument( 2 ) ); + public static I18N mockI18N() { + I18N i18n = mock(I18N.class); + when(i18n.getString(anyString(), any(), anyString())).thenAnswer(invocation -> invocation.getArgument(2)); return i18n; } - public static SiteTool mockSiteTool() - { - Artifact skinArtifact = mock( Artifact.class ); - when( skinArtifact.getId() ).thenReturn( "" ); - SiteTool siteTool = mock( SiteTool.class ); - try - { - when( siteTool.getSkinArtifactFromRepository( any(), any(), any() ) ).thenReturn( skinArtifact ); - } - catch ( SiteToolException e ) - { - throw new RuntimeException( e ); + public static SiteTool mockSiteTool() { + Artifact skinArtifact = mock(Artifact.class); + when(skinArtifact.getId()).thenReturn(""); + SiteTool siteTool = mock(SiteTool.class); + try { + when(siteTool.getSkinArtifactFromRepository(any(), any(), any())).thenReturn(skinArtifact); + } catch (SiteToolException e) { + throw new RuntimeException(e); } return siteTool; } - public static RepositorySystem mockRepositorySystem() - { - RepositorySystem repositorySystem = mock( RepositorySystem.class ); - when( repositorySystem.createDependencyArtifact( any( Dependency.class ) ) ).thenAnswer( - invocation -> - { - Dependency dependency = invocation.getArgument( 0 ); - return new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), - dependency.getVersion(), dependency.getScope(), dependency.getType(), - dependency.getClassifier(), new DefaultArtifactHandlerStub( "default" ) ); - } ); + public static RepositorySystem mockRepositorySystem() { + RepositorySystem repositorySystem = mock(RepositorySystem.class); + when(repositorySystem.createDependencyArtifact(any(Dependency.class))).thenAnswer(invocation -> { + Dependency dependency = invocation.getArgument(0); + return new DefaultArtifact( + dependency.getGroupId(), + dependency.getArtifactId(), + dependency.getVersion(), + dependency.getScope(), + dependency.getType(), + dependency.getClassifier(), + new DefaultArtifactHandlerStub("default")); + }); return repositorySystem; } @@ -163,14 +151,12 @@ public static RepositorySystem mockRepositorySystem() * by providing only a non-{@code null} implementation of its {@link MavenSession#getRepositorySession()} method. * @return mocked {@link MavenSession} */ - public static MavenSession mockMavenSession() - { - MavenSession session = mock( MavenSession.class ); - when( session.getRepositorySession() ) - .thenReturn( mock( RepositorySystemSession.class ) ); - when( session.getCurrentProject() ).thenReturn( mock( MavenProject.class ) ); - when( session.getCurrentProject().getRemotePluginRepositories() ).thenReturn( emptyList() ); - when( session.getCurrentProject().getRemoteProjectRepositories() ).thenReturn( emptyList() ); + public static MavenSession mockMavenSession() { + MavenSession session = mock(MavenSession.class); + when(session.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class)); + when(session.getCurrentProject()).thenReturn(mock(MavenProject.class)); + when(session.getCurrentProject().getRemotePluginRepositories()).thenReturn(emptyList()); + when(session.getCurrentProject().getRemoteProjectRepositories()).thenReturn(emptyList()); return session; } } diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java index 93dad6ec69..b591d600b6 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestChangeRecorder.java @@ -31,31 +31,25 @@ import org.codehaus.mojo.versions.api.recording.ChangeRecord; import org.codehaus.mojo.versions.api.recording.ChangeRecorder; -@Named( "test" ) -public class TestChangeRecorder implements ChangeRecorder -{ +@Named("test") +public class TestChangeRecorder implements ChangeRecorder { private final List changes = new LinkedList<>(); @Override - public void recordChange( ChangeRecord changeRecord ) - { - changes.add( changeRecord.getVersionChange() ); + public void recordChange(ChangeRecord changeRecord) { + changes.add(changeRecord.getVersionChange()); } @Override - public void writeReport( Path outputPath ) - { - } + public void writeReport(Path outputPath) {} - public List getChanges() - { + public List getChanges() { return changes; } - public Map asTestMap() - { + public Map asTestMap() { HashMap map = new HashMap<>(); - map.put( "none", this ); + map.put("none", this); return map; } } diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java index 950a9d184d..7a97591f2d 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/TestUtils.java @@ -32,8 +32,7 @@ /** * Auxiliary test utilities */ -public class TestUtils -{ +public class TestUtils { /** * Creates a temporary directory with the given name * @@ -41,9 +40,8 @@ public class TestUtils * @return {@linkplain Path} object pointing to the directory * @throws IOException should the I/O operation fail */ - public static Path createTempDir( String name ) throws IOException - { - return Files.createTempDirectory( toCamelCase( name, false ) ); + public static Path createTempDir(String name) throws IOException { + return Files.createTempDirectory(toCamelCase(name, false)); } /** @@ -52,26 +50,21 @@ public static Path createTempDir( String name ) throws IOException * @param dir directory to delete * @throws IOException should an I/O operation fail */ - public static void tearDownTempDir( Path dir ) throws IOException - { - if ( dir != null && Files.exists( dir ) ) - { - Files.walkFileTree( dir, new SimpleFileVisitor() - { + public static void tearDownTempDir(Path dir) throws IOException { + if (dir != null && Files.exists(dir)) { + Files.walkFileTree(dir, new SimpleFileVisitor() { @Override - public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throws IOException - { - Files.delete( file ); + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); return CONTINUE; } @Override - public FileVisitResult postVisitDirectory( Path dir, IOException exc ) throws IOException - { - Files.delete( dir ); + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); return CONTINUE; } - } ); + }); } } @@ -83,25 +76,19 @@ public FileVisitResult postVisitDirectory( Path dir, IOException exc ) throws IO * @param dst destination directory path * @throws IOException should an I/O error occur */ - public static void copyDir( Path src, Path dst ) throws IOException - { - Files.walkFileTree( src, new SimpleFileVisitor() - { + public static void copyDir(Path src, Path dst) throws IOException { + Files.walkFileTree(src, new SimpleFileVisitor() { @Override - public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs ) - throws IOException - { - Files.createDirectories( dst.resolve( src.relativize( dir ) ) ); + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + Files.createDirectories(dst.resolve(src.relativize(dir))); return CONTINUE; } @Override - public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) - throws IOException - { - Files.copy( file, dst.resolve( src.relativize( file ) ), REPLACE_EXISTING ); + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.copy(file, dst.resolve(src.relativize(file)), REPLACE_EXISTING); return CONTINUE; } - } ); + }); } } diff --git a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java index 807e21574f..925d38fe01 100644 --- a/versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java +++ b/versions-test/src/main/java/org/codehaus/mojo/versions/utils/VersionStub.java @@ -24,53 +24,43 @@ /** * Stubs the {@link Version} */ -public class VersionStub implements Version -{ +public class VersionStub implements Version { private final String version; /** * Creates a new instance with the given version string * @param version version to be set */ - public VersionStub( String version ) - { + public VersionStub(String version) { assert version != null; this.version = version; } @Override - public String toString() - { + public String toString() { return version; } @Override - public int compareTo( Version o ) - { - return o != null - ? version.compareTo( o.toString() ) - : 1; + public int compareTo(Version o) { + return o != null ? version.compareTo(o.toString()) : 1; } @Override - public boolean equals( Object o ) - { - if ( this == o ) - { + public boolean equals(Object o) { + if (this == o) { return true; } - if ( !( o instanceof Version ) ) - { + if (!(o instanceof Version)) { return false; } - return version.equals( o.toString() ); + return version.equals(o.toString()); } @Override - public int hashCode() - { + public int hashCode() { return version.hashCode(); } } From 30b44a0fc55bcc0c8268e5ac91b20f08112e75c8 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 11 Dec 2022 23:23:18 +0100 Subject: [PATCH 232/441] Ignore code reformat form git blame after spotless --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..c3f5559221 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# code reformat after spotless +1fb9f3be46943a2c67e32ff23ed2246d1b4e4fd9 \ No newline at end of file From 84dc123e1a549ebcad7ac75f1582d811cc11e11e Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 12 Dec 2022 00:25:57 +0100 Subject: [PATCH 233/441] Add 404 page --- pom.xml | 4 +++- src/site/xdoc/404.xml.vm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/site/xdoc/404.xml.vm diff --git a/pom.xml b/pom.xml index 67eb0fe9d4..915ca16ce5 100644 --- a/pom.xml +++ b/pom.xml @@ -130,9 +130,11 @@ 1.11.1 ${project.version} 3.7 + + ${maven-fluido-skin.version} 2.1.0 2.0.0 - ${project.build.directory}/staging + ${project.build.directory}/staging/versions 2022-10-23T15:41:47Z 0.9.0.M1 diff --git a/src/site/xdoc/404.xml.vm b/src/site/xdoc/404.xml.vm new file mode 100644 index 0000000000..aed1cc9a80 --- /dev/null +++ b/src/site/xdoc/404.xml.vm @@ -0,0 +1,35 @@ + + + + + + Page Not Found + + + + + + + +