From dafdd7f49d4f96f4d3c9e9b525d6150c40b4784b Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Fri, 6 May 2022 09:17:28 +0200 Subject: [PATCH] [MRELEASE-1087] Upgrade Maven to 3.2.5 (and de-plexus) (#118) Mass changes to plugin: * update maven 3.0 -> 3.2.5 * update resolver from org.sonatype to org.eclipse package * off plexus XML, move fully to JSR330 * off plexus APIs like LogEnabled, Contextualize, etc * use slf4j API for logging instead of Plexus Logger * tests: off from Junit3 PlexusTestCase w/ XMLs to modern(er) Junit 4 * tests: off from PlexusTestCase XMLs (one exception remains) * reformat --- maven-release-api/pom.xml | 7 +- .../release/phase/AbstractReleasePhase.java | 11 +- maven-release-manager/pom.xml | 107 +++--- .../src/main/components-fragment.xml | 276 --------------- .../shared/release/DefaultReleaseManager.java | 66 ++-- .../PropertiesReleaseDescriptorStore.java | 163 +++------ .../config/ReleaseDescriptorBuilder.java | 37 +- .../config/ReleaseDescriptorStore.java | 4 +- .../ReleaseDescriptorStoreException.java | 4 +- .../shared/release/config/ReleaseUtils.java | 32 +- .../env/DefaultReleaseEnvironment.java | 4 +- .../release/exec/AbstractMavenExecutor.java | 117 ++---- .../release/exec/CommandLineFactory.java | 4 +- .../exec/DefaultCommandLineFactory.java | 11 +- .../release/exec/ForkedMavenExecutor.java | 58 +-- .../release/exec/InvokerMavenExecutor.java | 272 ++++++++------ .../shared/release/exec/MavenExecutor.java | 6 +- .../release/exec/MavenExecutorException.java | 6 +- .../shared/release/exec/RawStreamPumper.java | 25 +- .../shared/release/exec/TeeConsumer.java | 13 +- .../shared/release/exec/TeeOutputStream.java | 13 +- .../phase/AbstractBackupPomsPhase.java | 6 +- ...mPhase.java => AbstractCheckPomPhase.java} | 32 +- .../phase/AbstractInputVariablesPhase.java | 310 ++++++++++++++++ ...ase.java => AbstractMapVersionsPhase.java} | 81 +++-- .../phase/AbstractReleasePomsPhase.java | 19 +- .../phase/AbstractRewritePomsPhase.java | 136 +++---- .../release/phase/AbstractRunGoalsPhase.java | 25 +- .../AbstractScmCommitDevelopmentPhase.java | 111 ++++++ .../release/phase/AbstractScmCommitPhase.java | 82 +++-- ...=> AbstractScmCommitPreparationPhase.java} | 30 +- .../phase/BranchInputVariablesPhase.java | 48 +++ .../CheckCompletedPreparePhasesPhase.java | 17 +- .../phase/CheckDependencySnapshotsPhase.java | 150 ++++---- .../shared/release/phase/CheckPomsPhase.java | 43 +++ .../phase/CheckPomsUpdateversionsPhase.java | 43 +++ .../release/phase/CheckoutProjectFromScm.java | 42 ++- .../release/phase/CreateBackupPomsPhase.java | 15 +- .../shared/release/phase/EndReleasePhase.java | 17 +- .../phase/GenerateReleasePomsPhase.java | 133 +++---- .../release/phase/InputVariablesPhase.java | 269 +------------- .../release/phase/MapBranchVersionsPhase.java | 68 ++++ .../phase/MapDevelopmentVersionsPhase.java | 68 ++++ .../phase/MapReleaseVersionsPhase.java | 68 ++++ .../release/phase/RemoveReleasePomsPhase.java | 31 +- .../release/phase/RemoveScmTagPhase.java | 59 ++-- .../release/phase/RestoreBackupPomsPhase.java | 42 ++- .../phase/RewritePomVersionsPhase.java | 24 +- .../phase/RewritePomsForBranchPhase.java | 38 +- .../phase/RewritePomsForDevelopmentPhase.java | 29 +- .../phase/RewritePomsForReleasePhase.java | 32 +- .../release/phase/RunCompleteGoalsPhase.java | 26 +- .../release/phase/RunPerformGoalsPhase.java | 32 +- .../release/phase/RunPrepareGoalsPhase.java | 32 +- .../shared/release/phase/ScmBranchPhase.java | 42 ++- .../phase/ScmCheckModificationsPhase.java | 27 +- .../release/phase/ScmCommitBranchPhase.java | 43 +++ .../phase/ScmCommitDevelopmentPhase.java | 81 +---- .../release/phase/ScmCommitReleasePhase.java | 43 +++ .../release/phase/ScmCommitRollbackPhase.java | 43 +++ .../shared/release/phase/ScmTagPhase.java | 18 +- .../release/policies/DefaultNamingPolicy.java | 9 +- .../policies/DefaultVersionPolicy.java | 17 +- .../release/scm/ClearCaseScmTranslator.java | 8 +- .../shared/release/scm/CvsScmTranslator.java | 8 +- .../scm/DefaultScmRepositoryConfigurator.java | 71 ++-- .../shared/release/scm/GitScmTranslator.java | 8 +- .../shared/release/scm/HgScmTranslator.java | 8 +- .../shared/release/scm/JazzScmTranslator.java | 10 +- .../release/scm/SubversionScmTranslator.java | 7 +- .../release/strategies/DefaultStrategy.java | 120 ++++--- .../transform/jdom2/JDomModelETLFactory.java | 10 +- .../shared/release/util/MavenCrypto.java | 171 +++++++++ .../maven/shared/release/util/PomFinder.java | 33 +- .../resources/META-INF/plexus/components.xml | 45 --- .../release/DefaultReleaseManagerTest.java | 63 +++- .../shared/release/PlexusJUnit4TestCase.java | 43 ++- .../PropertiesReleaseDescriptorStoreTest.java | 33 +- .../release/config/ReleaseUtilsTest.java | 14 +- .../exec/AbstractMavenExecutorTest.java | 11 +- .../release/exec/CommandLineFactoryTest.java | 14 +- .../release/exec/ForkedMavenExecutorTest.java | 52 +-- .../exec/InvokerMavenExecutorTest.java | 38 +- .../shared/release/exec/TeeConsumerTest.java | 19 +- .../release/exec/TeeOutputStreamTest.java | 24 +- ...EditModeRewritingReleasePhaseTestCase.java | 9 +- .../phase/AbstractReleaseTestCase.java | 38 +- ...AbstractRewritingReleasePhaseTestCase.java | 4 +- .../phase/AbstractScmCommitPhaseTest.java | 4 - .../phase/BranchInputVariablesPhaseTest.java | 15 +- .../release/phase/CheckPomPhaseTest.java | 29 +- .../phase/CheckoutProjectFromScmTest.java | 10 +- .../phase/GenerateReleasePomsPhaseTest.java | 27 ++ .../phase/InputVariablesPhaseTest.java | 30 +- .../phase/MapDevelopmentVersionPhaseIT.java | 16 +- .../release/phase/MapVersionsPhaseTest.java | 333 ++++++++---------- .../phase/RewritePomsForBranchPhaseTest.java | 2 - .../phase/RewritePomsForReleasePhaseTest.java | 4 + .../release/phase/ScmBranchPhaseTest.java | 8 +- .../phase/ScmCommitPreparationPhaseTest.java | 6 +- .../shared/release/phase/ScmTagPhaseTest.java | 20 ++ .../policies/DefaultNamingPolicyTest.java | 2 +- .../policies/DefaultVersionPolicyTest.java | 2 +- .../scm/ClearCaseScmTranslatorTest.java | 11 +- .../release/scm/CvsScmTranslatorTest.java | 11 +- .../DefaultScmRepositoryConfiguratorTest.java | 30 +- .../release/scm/GitScmTranslatorTest.java | 10 +- .../release/scm/HgScmTranslatorTest.java | 11 +- .../release/scm/JazzScmTranslatorTest.java | 12 +- .../scm/SubversionScmTranslatorTest.java | 12 +- .../release/stubs/MavenExecutorWrapper.java | 5 + .../release/stubs/NamingPolicyStub.java | 5 + .../shared/release/stubs/ScmManagerStub.java | 11 +- .../shared/release/util/PomFinderTest.java | 29 +- .../versions/DefaultVersionInfoTest.java | 41 ++- .../release/exec/ForkedMavenExecutorTest.xml | 32 -- .../phase/BranchInputVariablesPhaseTest.xml | 41 --- .../CheckDependencySnapshotsPhaseTest.xml | 32 -- .../phase/CheckoutProjectFromScmTest.xml | 36 -- .../release/phase/EndReleasePhaseTest.xml | 32 -- .../phase/GenerateReleasePomsPhaseTest.xml | 41 --- .../release/phase/MapVersionsPhaseTest.xml | 82 ----- .../phase/RemoveReleasePomsPhaseTest.xml | 36 -- .../release/phase/RemoveScmTagPhaseTest.xml | 36 -- .../phase/RewritePomsForBranchPhaseTest.xml | 32 -- .../RewritePomsForDevelopmentPhaseTest.xml | 32 -- .../phase/RewritePomsForReleasePhaseTest.xml | 32 -- .../phase/RunCompleteGoalsPhaseTest.xml | 37 -- .../phase/RunPerformGoalsPhaseTest.xml | 37 -- .../phase/RunPrepareGoalsPhaseTest.xml | 37 -- .../release/phase/ScmBranchPhaseTest.xml | 36 -- .../phase/ScmCheckModificationsPhaseTest.xml | 36 -- .../phase/ScmCommitDevelopmentPhaseTest.xml | 36 -- .../phase/ScmCommitPreparationPhaseTest.xml | 36 -- .../shared/release/phase/ScmTagPhaseTest.xml | 36 -- .../expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom-with-schema.xml | 8 +- .../basic-pom/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 6 +- .../subproject2/expected-release-pom.xml | 6 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 6 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 6 +- .../subproject3/expected-release-pom.xml | 6 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../subproject3/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../subproject3/expected-release-pom.xml | 8 +- .../subproject4/expected-release-pom.xml | 8 +- .../subsubproject/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../subproject3/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../subproject3/expected-release-pom.xml | 8 +- .../subproject4/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../subproject3/expected-release-pom.xml | 8 +- .../subproject4/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom-version-changed.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../pom-with-parent/expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../expected-release-pom.xml | 8 +- .../subproject1/expected-release-pom.xml | 8 +- .../subproject2/expected-release-pom.xml | 8 +- .../test/resources/simplelogger.properties | 17 + maven-release-plugin/pom.xml | 12 +- .../maven-release-oddeven-policy/pom.xml | 38 +- .../policy/oddeven/OddEvenVersionPolicy.java | 13 +- .../oddeven/OddEvenVersionPolicyTestCase.java | 16 +- .../maven-release-semver-policy/pom.xml | 32 +- .../policy/semver/SemVerVersionPolicy.java | 22 +- .../semver/SemVerVersionPolicyTest.java | 18 +- pom.xml | 107 +++++- 213 files changed, 3568 insertions(+), 3278 deletions(-) delete mode 100644 maven-release-manager/src/main/components-fragment.xml rename maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/{CheckPomPhase.java => AbstractCheckPomPhase.java} (78%) create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java rename maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/{MapVersionsPhase.java => AbstractMapVersionsPhase.java} (85%) create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitDevelopmentPhase.java rename maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/{ScmCommitPreparationPhase.java => AbstractScmCommitPreparationPhase.java} (75%) create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsUpdateversionsPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapBranchVersionsPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionsPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapReleaseVersionsPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitBranchPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitReleasePhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitRollbackPhase.java create mode 100644 maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenCrypto.java delete mode 100644 maven-release-manager/src/main/resources/META-INF/plexus/components.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/EndReleasePhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveReleasePomsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.xml delete mode 100644 maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmTagPhaseTest.xml create mode 100644 maven-release-manager/src/test/resources/simplelogger.properties diff --git a/maven-release-api/pom.xml b/maven-release-api/pom.xml index a801ea9be..9b833650f 100644 --- a/maven-release-api/pom.xml +++ b/maven-release-api/pom.xml @@ -55,8 +55,11 @@ org.eclipse.aether aether-util - 1.0.0.v20140518 - true + + + + org.slf4j + slf4j-api diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePhase.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePhase.java index 271849343..898bc0af6 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePhase.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePhase.java @@ -20,7 +20,8 @@ */ import org.apache.maven.shared.release.ReleaseResult; -import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base class for all phases. @@ -28,9 +29,15 @@ * @author Brett Porter */ public abstract class AbstractReleasePhase - extends AbstractLogEnabled implements ReleasePhase { + private final Logger logger = LoggerFactory.getLogger( getClass() ); + + protected Logger getLogger() + { + return logger; + } + /** *

logInfo.

* diff --git a/maven-release-manager/pom.xml b/maven-release-manager/pom.xml index 81501fb17..717b5b2e3 100644 --- a/maven-release-manager/pom.xml +++ b/maven-release-manager/pom.xml @@ -37,6 +37,7 @@ maven-release-api 3.0.0-M6-SNAPSHOT
+ org.codehaus.plexus plexus-utils @@ -59,14 +60,14 @@ - org.sonatype.plexus + org.codehaus.plexus plexus-sec-dispatcher - 1.3 + 2.0 - org.sonatype.plexus + org.codehaus.plexus plexus-cipher - 1.7 + 2.0 @@ -85,6 +86,23 @@ org.apache.maven maven-settings + + + org.slf4j + slf4j-api + + + + javax.inject + javax.inject + provided + + + org.eclipse.sisu + org.eclipse.sisu.inject + provided + + org.apache.maven.shared maven-invoker @@ -98,7 +116,7 @@ commons-cli commons-cli - 1.2 + 1.5.0 commons-lang @@ -106,6 +124,17 @@ + + + org.eclipse.aether + aether-api + + + org.eclipse.aether + aether-util + + + org.apache.maven.scm @@ -130,6 +159,12 @@ org.apache.maven.shared maven-artifact-transfer 0.13.1 + + + org.sonatype.sisu + sisu-inject-plexus + + @@ -163,15 +198,35 @@ test - org.sonatype.aether - aether-connector-file - 1.7 + org.slf4j + slf4j-simple test + - org.sonatype.aether - aether-connector-wagon - 1.7 + org.eclipse.sisu + org.eclipse.sisu.plexus + test + + + + org.eclipse.aether + aether-connector-basic + test + + + org.eclipse.aether + aether-transport-file + test + + + org.eclipse.aether + aether-transport-wagon + test + + + org.apache.maven.wagon + wagon-http test @@ -208,36 +263,6 @@ - - org.codehaus.plexus - plexus-component-metadata - - - - generate-metadata - - - - class - - - - - merge - process-classes - - merge-metadata - - - ${project.build.outputDirectory}/META-INF/plexus/components.xml - - ${project.build.outputDirectory}/META-INF/plexus/components.xml - src/main/components-fragment.xml - - - - - org.apache.maven.plugins maven-failsafe-plugin diff --git a/maven-release-manager/src/main/components-fragment.xml b/maven-release-manager/src/main/components-fragment.xml deleted file mode 100644 index 3a3668253..000000000 --- a/maven-release-manager/src/main/components-fragment.xml +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - org.apache.maven.shared.release.strategy.Strategy - default - org.apache.maven.shared.release.strategies.DefaultStrategy - - - - - check-poms - scm-check-modifications - check-dependency-snapshots - create-backup-poms - map-release-versions - input-variables - map-development-versions - rewrite-poms-for-release - generate-release-poms - run-preparation-goals - scm-commit-release - scm-tag - rewrite-poms-for-development - remove-release-poms - run-completion-goals - scm-commit-development - end-release - - - - - - verify-completed-prepare-phases - checkout-project-from-scm - run-perform-goals - - - - - - restore-backup-poms - scm-commit-rollback - remove-scm-tag - - - - - - check-poms - scm-check-modifications - create-backup-poms - map-branch-versions - branch-input-variables - map-development-versions - rewrite-poms-for-branch - scm-commit-branch - scm-branch - rewrite-poms-for-development - scm-commit-development - end-release - - - - - - check-poms-updateversions - create-backup-poms - map-development-versions - rewrite-pom-versions - - - - - - - org.apache.maven.shared.release.phase.ReleasePhase - map-release-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - false - - - - org.codehaus.plexus.components.interactivity.Prompter - default - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - map-development-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - true - - - - org.codehaus.plexus.components.interactivity.Prompter - default - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - map-branch-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - true - true - - - - org.codehaus.plexus.components.interactivity.Prompter - default - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - scm-commit-release - org.apache.maven.shared.release.phase.ScmCommitPreparationPhase - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - getScmReleaseCommitComment - - - - org.apache.maven.shared.release.phase.ReleasePhase - scm-commit-development - org.apache.maven.shared.release.phase.ScmCommitDevelopmentPhase - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - getScmDevelopmentCommitComment - rollback changes from release preparation of {0} - - - - org.apache.maven.shared.release.phase.ReleasePhase - scm-commit-branch - org.apache.maven.shared.release.phase.ScmCommitPreparationPhase - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - getScmBranchCommitComment - - - - org.apache.maven.shared.release.phase.ReleasePhase - scm-commit-rollback - org.apache.maven.shared.release.phase.ScmCommitPreparationPhase - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - getScmRollbackCommitComment - - - - org.apache.maven.shared.release.phase.ReleasePhase - check-poms - org.apache.maven.shared.release.phase.CheckPomPhase - - true - true - - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - - org.apache.maven.shared.release.phase.ReleasePhase - check-poms-updateversions - org.apache.maven.shared.release.phase.CheckPomPhase - - false - false - - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - - - org.apache.maven.shared.release.phase.ReleasePhase - input-variables - org.apache.maven.shared.release.phase.InputVariablesPhase - - false - default - - - - org.codehaus.plexus.components.interactivity.Prompter - default - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - org.apache.maven.shared.release.policy.naming.NamingPolicy - namingPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - branch-input-variables - org.apache.maven.shared.release.phase.InputVariablesPhase - - true - - - - org.codehaus.plexus.components.interactivity.Prompter - default - - - org.apache.maven.shared.release.scm.ScmRepositoryConfigurator - - - org.apache.maven.shared.release.policy.naming.NamingPolicy - namingPolicies - - - - - diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java index c04dd674c..c2732d9f5 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -26,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.lang3.BooleanUtils; import org.apache.maven.shared.release.config.ReleaseDescriptor; @@ -37,38 +42,56 @@ import org.apache.maven.shared.release.phase.ReleasePhase; import org.apache.maven.shared.release.phase.ResourceGenerator; import org.apache.maven.shared.release.strategy.Strategy; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; /** * Implementation of the release manager. * * @author Brett Porter */ -@Component( role = ReleaseManager.class ) +@Singleton +@Named public class DefaultReleaseManager - extends AbstractLogEnabled implements ReleaseManager { - @Requirement - private Map strategies; + private final Logger logger = LoggerFactory.getLogger( getClass() ); + + private final Map strategies; /** * The available phases. */ - @Requirement - private Map releasePhases; + private final Map releasePhases; /** * The configuration storage. */ - @Requirement( hint = "properties" ) - private ReleaseDescriptorStore configStore; + private final AtomicReference configStore; private static final int PHASE_SKIP = 0, PHASE_START = 1, PHASE_END = 2, GOAL_END = 12, ERROR = 99; + @Inject + public DefaultReleaseManager( Map strategies, + Map releasePhases, + @Named( "properties" ) ReleaseDescriptorStore configStore ) + { + this.strategies = requireNonNull( strategies ); + this.releasePhases = requireNonNull( releasePhases ); + this.configStore = new AtomicReference<>( requireNonNull( configStore ) ); + } + + /** + * For easier testing only! + */ + public void setConfigStore( ReleaseDescriptorStore configStore ) + { + this.configStore.set( configStore ); + } + @Override public ReleaseResult prepareWithResult( ReleasePrepareRequest prepareRequest ) { @@ -218,7 +241,7 @@ else if ( index >= 0 ) config.setCompletedPhase( name ); try { - configStore.write( config ); + configStore.get().write( config ); } catch ( ReleaseDescriptorStoreException e ) { @@ -311,8 +334,8 @@ private void perform( ReleasePerformRequest performRequest, ReleaseResult result if ( specificProfiles != null && !specificProfiles.isEmpty() ) { - List allProfiles = new ArrayList<>(); - allProfiles.addAll( ReleaseUtils.buildReleaseDescriptor( builder ).getActivateProfiles() ); + List allProfiles = + new ArrayList<>( ReleaseUtils.buildReleaseDescriptor( builder ).getActivateProfiles() ); for ( String specificProfile : specificProfiles ) { if ( !allProfiles.contains( specificProfile ) ) @@ -538,7 +561,7 @@ private ReleaseDescriptorBuilder loadReleaseDescriptorBuilder( ReleaseDescriptor try { updateListener( listener, "verify-release-configuration", PHASE_START ); - ReleaseDescriptorBuilder result = configStore.read( builder ); + ReleaseDescriptorBuilder result = configStore.get().read( builder ); updateListener( listener, "verify-release-configuration", PHASE_END ); return result; } @@ -571,12 +594,12 @@ public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureExcep { updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_START ); - getLogger().info( "Cleaning up after release..." ); + logger.info( "Cleaning up after release..." ); ReleaseDescriptor releaseDescriptor = ReleaseUtils.buildReleaseDescriptor( cleanRequest.getReleaseDescriptorBuilder() ); - configStore.delete( releaseDescriptor ); + configStore.get().delete( releaseDescriptor ); Strategy releaseStrategy = getStrategy( releaseDescriptor.getReleaseStrategyId() ); @@ -597,11 +620,6 @@ public void clean( ReleaseCleanRequest cleanRequest ) throws ReleaseFailureExcep updateListener( cleanRequest.getReleaseManagerListener(), "cleanup", PHASE_END ); } - void setConfigStore( ReleaseDescriptorStore configStore ) - { - this.configStore = configStore; - } - void goalStart( ReleaseManagerListener listener, String goal, List phases ) { if ( listener != null ) @@ -693,7 +711,7 @@ else if ( "updateVersions".equals( goal ) ) phases = null; } - return Collections.unmodifiableList( phases ); + return Collections.unmodifiableList( phases ); // TODO: NPE here in phases=null above! } private void logInfo( ReleaseResult result, String message ) @@ -703,7 +721,7 @@ private void logInfo( ReleaseResult result, String message ) result.appendInfo( message ); } - getLogger().info( message ); + logger.info( message ); } private void captureException( ReleaseResult result, ReleaseManagerListener listener, Exception e ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java index 3033a45de..fdacb6d2d 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStore.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -32,39 +36,37 @@ import org.apache.maven.model.Scm; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder.BuilderReleaseDescriptor; import org.apache.maven.shared.release.scm.IdentifiedScm; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.apache.maven.shared.release.util.MavenCrypto; +import org.apache.maven.shared.release.util.MavenCrypto.MavenCryptoException; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; -import org.sonatype.plexus.components.cipher.PlexusCipherException; -import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; -import org.sonatype.plexus.components.sec.dispatcher.SecUtil; -import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; /** * Read and write release configuration and state from a properties file. * * @author Brett Porter */ -@Component( role = ReleaseDescriptorStore.class, hint = "properties" ) +@Singleton +@Named( "properties" ) public class PropertiesReleaseDescriptorStore - extends AbstractLogEnabled - implements ReleaseDescriptorStore + implements ReleaseDescriptorStore { + private final Logger logger = LoggerFactory.getLogger( getClass() ); - /** - * When this plugin requires Maven 3.0 as minimum, this component can be removed and o.a.m.s.c.SettingsDecrypter be - * used instead. - */ - @Requirement( role = SecDispatcher.class, hint = "mng-4384" ) - private DefaultSecDispatcher secDispatcher; + private final MavenCrypto mavenCrypto; + + @Inject + public PropertiesReleaseDescriptorStore( MavenCrypto mavenCrypto ) + { + this.mavenCrypto = requireNonNull( mavenCrypto ); + } @Override public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor ) - throws ReleaseDescriptorStoreException + throws ReleaseDescriptorStoreException { return read( mergeDescriptor, getDefaultReleasePropertiesFile( mergeDescriptor.build() ) ); } @@ -77,7 +79,7 @@ public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor ) * @throws org.apache.maven.shared.release.config.ReleaseDescriptorStoreException if any. */ public ReleaseDescriptorBuilder read( File file ) - throws ReleaseDescriptorStoreException + throws ReleaseDescriptorStoreException { return read( null, file ); } @@ -86,12 +88,12 @@ public ReleaseDescriptorBuilder read( File file ) *

read.

* * @param mergeDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object - * @param file a {@link java.io.File} object + * @param file a {@link java.io.File} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object * @throws org.apache.maven.shared.release.config.ReleaseDescriptorStoreException if any. */ public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor, File file ) - throws ReleaseDescriptorStoreException + throws ReleaseDescriptorStoreException { Properties properties = new Properties(); @@ -101,21 +103,21 @@ public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor, } catch ( FileNotFoundException e ) { - getLogger().debug( file.getName() + " not found - using empty properties" ); + logger.debug( file.getName() + " not found - using empty properties" ); } catch ( IOException e ) { throw new ReleaseDescriptorStoreException( - "Error reading properties file '" + file.getName() + "': " + e.getMessage(), e ); + "Error reading properties file '" + file.getName() + "': " + e.getMessage(), e ); } - + try { - decryptProperties( properties ); + mavenCrypto.decryptProperties( properties ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { - getLogger().debug( e.getMessage() ); + logger.debug( e.getMessage() ); } ReleaseDescriptorBuilder builder; @@ -125,9 +127,9 @@ public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor, } else { - builder = new ReleaseDescriptorBuilder(); + builder = new ReleaseDescriptorBuilder(); } - + ReleaseUtils.copyPropertiesToReleaseDescriptor( properties, builder ); return builder; @@ -135,7 +137,7 @@ public ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor, @Override public void write( ReleaseDescriptor config ) - throws ReleaseDescriptorStoreException + throws ReleaseDescriptorStoreException { write( (BuilderReleaseDescriptor) config, getDefaultReleasePropertiesFile( config ) ); } @@ -155,11 +157,11 @@ public void delete( ReleaseDescriptor config ) * * @param config a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder.BuilderReleaseDescriptor} * object - * @param file a {@link java.io.File} object + * @param file a {@link java.io.File} object * @throws org.apache.maven.shared.release.config.ReleaseDescriptorStoreException if any. */ public void write( BuilderReleaseDescriptor config, File file ) - throws ReleaseDescriptorStoreException + throws ReleaseDescriptorStoreException { Properties properties = new Properties(); properties.setProperty( "completedPhase", config.getCompletedPhase() ); @@ -181,11 +183,11 @@ public void write( BuilderReleaseDescriptor config, File file ) String password = config.getScmPassword(); try { - password = encryptAndDecorate( password ); + password = mavenCrypto.encryptAndDecorate( password ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { - getLogger().debug( e.getMessage() ); + logger.debug( e.getMessage() ); } properties.setProperty( "scm.password", password ); } @@ -198,13 +200,13 @@ public void write( BuilderReleaseDescriptor config, File file ) String passPhrase = config.getScmPrivateKeyPassPhrase(); try { - passPhrase = encryptAndDecorate( passPhrase ); + passPhrase = mavenCrypto.encryptAndDecorate( passPhrase ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { - getLogger().debug( e.getMessage() ); + logger.debug( e.getMessage() ); } - properties.setProperty( "scm.passphrase", passPhrase ); + properties.setProperty( "scm.passphrase", passPhrase ); } if ( config.getScmTagBase() != null ) { @@ -253,7 +255,7 @@ public void write( BuilderReleaseDescriptor config, File file ) if ( !config.getActivateProfiles().isEmpty() ) { properties.setProperty( "exec.activateProfiles", - StringUtils.join( config.getActivateProfiles().iterator(), "," ) ); + StringUtils.join( config.getActivateProfiles().iterator(), "," ) ); } if ( config.getPreparationGoals() != null ) { @@ -277,7 +279,7 @@ public void write( BuilderReleaseDescriptor config, File file ) } properties.setProperty( "exec.snapshotReleasePluginAllowed", - Boolean.toString( config.isSnapshotReleasePluginAllowed() ) ); + Boolean.toString( config.isSnapshotReleasePluginAllowed() ) ); properties.setProperty( "remoteTagging", Boolean.toString( config.isRemoteTagging() ) ); @@ -298,7 +300,7 @@ public void write( BuilderReleaseDescriptor config, File file ) // others boolean properties are not written to the properties file because the value from the caller is always // used - + for ( Map.Entry entry : config.getProjectVersions().entrySet() ) { if ( entry.getValue().getRelease() != null ) @@ -349,7 +351,7 @@ public void write( BuilderReleaseDescriptor config, File file ) } if ( ( config.getResolvedSnapshotDependencies() != null ) - && ( config.getResolvedSnapshotDependencies().size() > 0 ) ) + && ( config.getResolvedSnapshotDependencies().size() > 0 ) ) { processResolvedDependencies( properties, config.getResolvedSnapshotDependencies() ); } @@ -361,7 +363,7 @@ public void write( BuilderReleaseDescriptor config, File file ) catch ( IOException e ) { throw new ReleaseDescriptorStoreException( - "Error writing properties file '" + file.getName() + "': " + e.getMessage(), e ); + "Error writing properties file '" + file.getName() + "': " + e.getMessage(), e ); } } @@ -370,11 +372,11 @@ private void processResolvedDependencies( Properties prop, Map currentEntry : resolvedDependencies.entrySet() ) { ReleaseStageVersions versionMap = currentEntry.getValue(); - + prop.setProperty( "dependency." + currentEntry.getKey() + ".release", - versionMap.getRelease() ); + versionMap.getRelease() ); prop.setProperty( "dependency." + currentEntry.getKey() + ".development", - versionMap.getDevelopment() ); + versionMap.getDevelopment() ); } } @@ -382,67 +384,4 @@ private static File getDefaultReleasePropertiesFile( ReleaseDescriptor mergeDesc { return new File( mergeDescriptor.getWorkingDirectory(), "release.properties" ); } - - private void decryptProperties( Properties properties ) - throws IllegalStateException, SecDispatcherException, PlexusCipherException - { - String[] keys = new String[] { "scm.password", "scm.passphrase" }; - - for ( String key : keys ) - { - String value = properties.getProperty( key ); - if ( value != null ) - { - properties.put( key, decrypt( value ) ); - } - } - } - - // From org.apache.maven.cli.MavenCli.encryption(CliRequest) - private String encryptAndDecorate( String passwd ) - throws IllegalStateException, SecDispatcherException, PlexusCipherException - { - final String master = getMaster(); - - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); - return cipher.encryptAndDecorate( passwd, masterPasswd ); - } - - private String decrypt( String value ) throws IllegalStateException, SecDispatcherException, PlexusCipherException - { - final String master = getMaster(); - - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); - return cipher.decryptDecorated( value, masterPasswd ); - } - - private String getMaster() throws SecDispatcherException - { - String configurationFile = secDispatcher.getConfigurationFile(); - - if ( configurationFile.startsWith( "~" ) ) - { - configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); - } - - String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); - - String master = null; - - SettingsSecurity sec = SecUtil.read( file, true ); - if ( sec != null ) - { - master = sec.getMaster(); - } - - if ( master == null ) - { - throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); - } - - return master; - } - } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java index 1cf3f9c37..0d7399955 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java @@ -34,9 +34,8 @@ public class ReleaseDescriptorBuilder { /** * Hides inner logic of the release descriptor - * - * @author Robert Scholte * + * @author Robert Scholte */ public static final class BuilderReleaseDescriptor extends ModelloReleaseDescriptor implements ReleaseDescriptor { @@ -44,9 +43,9 @@ private BuilderReleaseDescriptor() { } } - + private final BuilderReleaseDescriptor releaseDescriptor; - + /** *

Constructor for ReleaseDescriptorBuilder.

*/ @@ -443,9 +442,9 @@ public ReleaseDescriptorBuilder setScmCommentPrefix( String scmCommentPrefix ) /** *

setScmReleaseCommitComment.

* - * @since 3.0.0-M1 * @param scmReleaseCommitComment a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object + * @since 3.0.0-M1 */ public ReleaseDescriptorBuilder setScmReleaseCommitComment( String scmReleaseCommitComment ) { @@ -456,9 +455,9 @@ public ReleaseDescriptorBuilder setScmReleaseCommitComment( String scmReleaseCom /** *

setScmDevelopmentCommitComment.

* - * @since 3.0.0-M1 * @param scmDevelopmentCommitComment a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object + * @since 3.0.0-M1 */ public ReleaseDescriptorBuilder setScmDevelopmentCommitComment( String scmDevelopmentCommitComment ) { @@ -469,9 +468,9 @@ public ReleaseDescriptorBuilder setScmDevelopmentCommitComment( String scmDevelo /** *

setScmBranchCommitComment.

* - * @since 3.0.0-M1 * @param scmBranchCommitComment a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object + * @since 3.0.0-M1 */ public ReleaseDescriptorBuilder setScmBranchCommitComment( String scmBranchCommitComment ) { @@ -482,9 +481,9 @@ public ReleaseDescriptorBuilder setScmBranchCommitComment( String scmBranchCommi /** *

setScmRollbackCommitComment.

* - * @since 3.0.0-M1 * @param scmRollbackCommitComment a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object + * @since 3.0.0-M1 */ public ReleaseDescriptorBuilder setScmRollbackCommitComment( String scmRollbackCommitComment ) { @@ -759,7 +758,7 @@ public ReleaseDescriptorBuilder setWorkingDirectory( String workingDirectory ) /** *

addReleaseVersion.

* - * @param key a {@link java.lang.String} object + * @param key a {@link java.lang.String} object * @param value a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ @@ -772,7 +771,7 @@ public ReleaseDescriptorBuilder addReleaseVersion( String key, String value ) /** *

addDevelopmentVersion.

* - * @param key a {@link java.lang.String} object + * @param key a {@link java.lang.String} object * @param value a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ @@ -785,7 +784,7 @@ public ReleaseDescriptorBuilder addDevelopmentVersion( String key, String value /** *

addOriginalScmInfo.

* - * @param key a {@link java.lang.String} object + * @param key a {@link java.lang.String} object * @param value a {@link org.apache.maven.model.Scm} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ @@ -799,32 +798,32 @@ public ReleaseDescriptorBuilder addOriginalScmInfo( String key, Scm value ) *

putOriginalVersion.

* * @param projectKey a {@link java.lang.String} object - * @param version a {@link java.lang.String} object + * @param version a {@link java.lang.String} object */ public void putOriginalVersion( String projectKey, String version ) { releaseDescriptor.addOriginalVersion( projectKey, version ); } - + /** *

addDependencyOriginalVersion.

* * @param dependencyKey a {@link java.lang.String} object - * @param version a {@link java.lang.String} object + * @param version a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ public ReleaseDescriptorBuilder addDependencyOriginalVersion( String dependencyKey, String version ) { releaseDescriptor.addDependencyOriginalVersion( dependencyKey, version ); return this; - + } - + /** *

addDependencyReleaseVersion.

* * @param dependencyKey a {@link java.lang.String} object - * @param version a {@link java.lang.String} object + * @param version a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ public ReleaseDescriptorBuilder addDependencyReleaseVersion( String dependencyKey, String version ) @@ -832,12 +831,12 @@ public ReleaseDescriptorBuilder addDependencyReleaseVersion( String dependencyKe releaseDescriptor.addDependencyReleaseVersion( dependencyKey, version ); return this; } - + /** *

addDependencyDevelopmentVersion.

* * @param dependencyKey a {@link java.lang.String} object - * @param version a {@link java.lang.String} object + * @param version a {@link java.lang.String} object * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ public ReleaseDescriptorBuilder addDependencyDevelopmentVersion( String dependencyKey, String version ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStore.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStore.java index 4327be101..86b1f5a84 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStore.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStore.java @@ -35,7 +35,7 @@ public interface ReleaseDescriptorStore * @throws org.apache.maven.shared.release.config.ReleaseDescriptorStoreException if any. */ ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor ) - throws ReleaseDescriptorStoreException; + throws ReleaseDescriptorStoreException; /** * Save a configuration. @@ -44,7 +44,7 @@ ReleaseDescriptorBuilder read( ReleaseDescriptorBuilder mergeDescriptor ) * @throws org.apache.maven.shared.release.config.ReleaseDescriptorStoreException if any. */ void write( ReleaseDescriptor config ) - throws ReleaseDescriptorStoreException; + throws ReleaseDescriptorStoreException; /** * Remove a configuration. diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStoreException.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStoreException.java index e6f3d708b..75eccb449 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStoreException.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorStoreException.java @@ -25,13 +25,13 @@ * @author Brett Porter */ public class ReleaseDescriptorStoreException - extends Exception + extends Exception { /** *

Constructor for ReleaseDescriptorStoreException.

* * @param message a {@link java.lang.String} object - * @param t a {@link java.lang.Throwable} object + * @param t a {@link java.lang.Throwable} object */ public ReleaseDescriptorStoreException( String message, Throwable t ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java index 8ede3e5ea..3847b52d0 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseUtils.java @@ -59,7 +59,7 @@ public static BuilderReleaseDescriptor buildReleaseDescriptor( ReleaseDescriptor *

copyPropertiesToReleaseDescriptor.

* * @param properties a {@link java.util.Properties} object - * @param builder a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object + * @param builder a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object */ public static void copyPropertiesToReleaseDescriptor( Properties properties, ReleaseDescriptorBuilder builder ) { @@ -141,8 +141,8 @@ public static void copyPropertiesToReleaseDescriptor( Properties properties, Rel } if ( properties.containsKey( "exec.activateProfiles" ) ) { - builder.setActivateProfiles( - Arrays.asList( properties.getProperty( "exec.activateProfiles" ).split( "," ) ) ); + builder.setActivateProfiles( + Arrays.asList( properties.getProperty( "exec.activateProfiles" ).split( "," ) ) ); } if ( properties.containsKey( "preparationGoals" ) ) { @@ -167,22 +167,22 @@ public static void copyPropertiesToReleaseDescriptor( Properties properties, Rel if ( properties.containsKey( "exec.snapshotReleasePluginAllowed" ) ) { String snapshotReleasePluginAllowedStr = properties.getProperty( "exec.snapshotReleasePluginAllowed" ); - builder.setSnapshotReleasePluginAllowed( Boolean.valueOf( snapshotReleasePluginAllowedStr ) ); + builder.setSnapshotReleasePluginAllowed( Boolean.parseBoolean( snapshotReleasePluginAllowedStr ) ); } if ( properties.containsKey( "remoteTagging" ) ) { String remoteTaggingStr = properties.getProperty( "remoteTagging" ); - builder.setRemoteTagging( Boolean.valueOf( remoteTaggingStr ) ); + builder.setRemoteTagging( Boolean.parseBoolean( remoteTaggingStr ) ); } if ( properties.containsKey( "pinExternals" ) ) { String pinExternals = properties.getProperty( "pinExternals" ); - builder.setPinExternals( Boolean.valueOf( pinExternals ) ); + builder.setPinExternals( Boolean.parseBoolean( pinExternals ) ); } if ( properties.containsKey( "pushChanges" ) ) { String pushChanges = properties.getProperty( "pushChanges" ); - builder.setPushChanges( Boolean.valueOf( pushChanges ) ); + builder.setPushChanges( Boolean.parseBoolean( pushChanges ) ); } if ( properties.containsKey( "workItem" ) ) { @@ -198,28 +198,28 @@ public static void copyPropertiesToReleaseDescriptor( Properties properties, Rel // boolean properties are not written to the properties file because the value from the caller is always used - for ( Iterator i = properties.keySet().iterator(); i.hasNext(); ) + for ( Object o : properties.keySet() ) { - String property = (String) i.next(); + String property = (String) o; if ( property.startsWith( "project.rel." ) ) { builder.addReleaseVersion( property.substring( "project.rel.".length() ), - properties.getProperty( property ) ); + properties.getProperty( property ) ); } else if ( property.startsWith( "project.dev." ) ) { builder.addDevelopmentVersion( property.substring( "project.dev.".length() ), - properties.getProperty( property ) ); + properties.getProperty( property ) ); } else if ( property.startsWith( "dependency.rel." ) ) { builder.addDependencyReleaseVersion( property.substring( "dependency.rel.".length() ), - properties.getProperty( property ) ); + properties.getProperty( property ) ); } else if ( property.startsWith( "dependency.dev." ) ) { builder.addDependencyDevelopmentVersion( property.substring( "dependency.dev.".length() ), - properties.getProperty( property ) ); + properties.getProperty( property ) ); } else if ( property.startsWith( "project.scm." ) ) { @@ -239,7 +239,7 @@ else if ( property.startsWith( "project.scm." ) ) IdentifiedScm scm = new IdentifiedScm(); scm.setConnection( properties.getProperty( "project.scm." + key + ".connection" ) ); scm.setDeveloperConnection( - properties.getProperty( "project.scm." + key + ".developerConnection" ) ); + properties.getProperty( "project.scm." + key + ".developerConnection" ) ); scm.setUrl( properties.getProperty( "project.scm." + key + ".url" ) ); scm.setTag( properties.getProperty( "project.scm." + key + ".tag" ) ); scm.setId( properties.getProperty( "project.scm." + key + ".id" ) ); @@ -271,12 +271,12 @@ private static void loadResolvedDependencies( Properties prop, ReleaseDescriptor int endIndex; String versionType; - if ( propertyName.indexOf( ".development" ) != -1 ) + if ( propertyName.contains( ".development" ) ) { endIndex = propertyName.lastIndexOf( ".development" ); versionType = DEVELOPMENT_KEY; } - else if ( propertyName.indexOf( ".release" ) != -1 ) + else if ( propertyName.contains( ".release" ) ) { endIndex = propertyName.lastIndexOf( ".release" ); versionType = RELEASE_KEY; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/env/DefaultReleaseEnvironment.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/env/DefaultReleaseEnvironment.java index 1562c2e09..e26684450 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/env/DefaultReleaseEnvironment.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/env/DefaultReleaseEnvironment.java @@ -26,12 +26,10 @@ /** *

DefaultReleaseEnvironment class.

- * */ public class DefaultReleaseEnvironment - implements ReleaseEnvironment + implements ReleaseEnvironment { - private File mavenHome; private File javaHome; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/AbstractMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/AbstractMavenExecutor.java index 0041351f2..f63d2bf68 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/AbstractMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/AbstractMavenExecutor.java @@ -21,6 +21,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.maven.settings.Proxy; @@ -30,54 +31,34 @@ import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.LogEnabled; -import org.codehaus.plexus.logging.Logger; +import org.apache.maven.shared.release.util.MavenCrypto; +import org.apache.maven.shared.release.util.MavenCrypto.MavenCryptoException; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; -import org.sonatype.plexus.components.cipher.PlexusCipher; -import org.sonatype.plexus.components.cipher.PlexusCipherException; -import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; -import org.sonatype.plexus.components.sec.dispatcher.SecUtil; -import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; /** *

Abstract AbstractMavenExecutor class.

- * */ public abstract class AbstractMavenExecutor - implements MavenExecutor, LogEnabled + implements MavenExecutor { + private final Logger logger = LoggerFactory.getLogger( getClass() ); - private Logger logger; - - /** - * When this plugin requires Maven 3.0 as minimum, this component can be removed and o.a.m.s.c.SettingsDecrypter be - * used instead. - */ - @Requirement( role = SecDispatcher.class, hint = "mng-4384" ) - private DefaultSecDispatcher secDispatcher; - - /** - * - */ - @Requirement - private PlexusCipher cipher; + private final MavenCrypto mavenCrypto; - /** - *

Constructor for AbstractMavenExecutor.

- */ - protected AbstractMavenExecutor() + protected AbstractMavenExecutor( MavenCrypto mavenCrypto ) { + this.mavenCrypto = requireNonNull( mavenCrypto ); } @Override public void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result ) - throws MavenExecutorException + throws MavenExecutorException { List goalsList = new ArrayList<>(); if ( goals != null ) @@ -85,37 +66,27 @@ public void executeGoals( File workingDirectory, String goals, ReleaseEnvironmen // accept both space and comma, so the old way still work // also accept line separators, so that goal lists can be spread // across multiple lines in the POM. - for ( String token : StringUtils.split( goals, ", \n\r\t" ) ) - { - goalsList.add( token ); - } + Collections.addAll( goalsList, StringUtils.split( goals, ", \n\r\t" ) ); } executeGoals( workingDirectory, goalsList, releaseEnvironment, interactive, additionalArguments, pomFileName, - result ); + result ); } protected abstract void executeGoals( File workingDirectory, List goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result ) - throws MavenExecutorException; + throws MavenExecutorException; /** *

Getter for the field logger.

* - * @return a {@link org.codehaus.plexus.logging.Logger} object + * @return a {@link Logger} object */ protected final Logger getLogger() { return logger; } - @Override - public void enableLogging( Logger logger ) - { - this.logger = logger; - } - - /** *

encryptSettings.

* @@ -129,26 +100,26 @@ protected Settings encryptSettings( Settings settings ) for ( Server server : encryptedSettings.getServers() ) { String password = server.getPassword(); - if ( password != null && !isEncryptedString( password ) ) + if ( password != null && !mavenCrypto.isEncryptedString( password ) ) { try { - server.setPassword( encryptAndDecorate( password ) ); + server.setPassword( mavenCrypto.encryptAndDecorate( password ) ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { // ignore } } String passphrase = server.getPassphrase(); - if ( passphrase != null && !isEncryptedString( passphrase ) ) + if ( passphrase != null && !mavenCrypto.isEncryptedString( passphrase ) ) { try { - server.setPassphrase( encryptAndDecorate( passphrase ) ); + server.setPassphrase( mavenCrypto.encryptAndDecorate( passphrase ) ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { // ignore } @@ -158,13 +129,13 @@ protected Settings encryptSettings( Settings settings ) for ( Proxy proxy : encryptedSettings.getProxies() ) { String password = proxy.getPassword(); - if ( password != null && !isEncryptedString( password ) ) + if ( password != null && !mavenCrypto.isEncryptedString( password ) ) { try { - proxy.setPassword( encryptAndDecorate( password ) ); + proxy.setPassword( mavenCrypto.encryptAndDecorate( password ) ); } - catch ( IllegalStateException | SecDispatcherException | PlexusCipherException e ) + catch ( MavenCryptoException e ) { // ignore } @@ -174,42 +145,6 @@ protected Settings encryptSettings( Settings settings ) return encryptedSettings; } - // From org.apache.maven.cli.MavenCli.encryption(CliRequest) - private String encryptAndDecorate( String passwd ) - throws IllegalStateException, SecDispatcherException, PlexusCipherException - { - String configurationFile = secDispatcher.getConfigurationFile(); - - if ( configurationFile.startsWith( "~" ) ) - { - configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); - } - - String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); - - String master = null; - - SettingsSecurity sec = SecUtil.read( file, true ); - if ( sec != null ) - { - master = sec.getMaster(); - } - - if ( master == null ) - { - throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); - } - - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); - return cipher.encryptAndDecorate( passwd, masterPasswd ); - } - - private boolean isEncryptedString( String str ) - { - return cipher.isEncryptedString( str ); - } - /** *

getSettingsWriter.

* diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/CommandLineFactory.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/CommandLineFactory.java index c90d69c11..50e7a12ed 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/CommandLineFactory.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/CommandLineFactory.java @@ -34,8 +34,8 @@ public interface CommandLineFactory * @param executable the executable * @return the command line * @throws org.apache.maven.shared.release.exec.MavenExecutorException if there was a problem creating - * the command line + * the command line */ Commandline createCommandLine( String executable ) - throws MavenExecutorException; + throws MavenExecutorException; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/DefaultCommandLineFactory.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/DefaultCommandLineFactory.java index e89b42bdc..cdf8a1914 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/DefaultCommandLineFactory.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/DefaultCommandLineFactory.java @@ -19,7 +19,9 @@ * under the License. */ -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; + import org.codehaus.plexus.util.cli.Commandline; /** @@ -27,13 +29,14 @@ * * @author Brett Porter */ -@Component( role = CommandLineFactory.class ) +@Singleton +@Named public class DefaultCommandLineFactory - implements CommandLineFactory + implements CommandLineFactory { @Override public Commandline createCommandLine( String executable ) - throws MavenExecutorException + throws MavenExecutorException { Commandline commandline = new Commandline(); commandline.setExecutable( executable ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java index 2c8907d0a..240c62a1b 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -29,26 +33,35 @@ import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; +import org.apache.maven.shared.release.util.MavenCrypto; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.Commandline; +import static java.util.Objects.requireNonNull; + /** - * Fork Maven to executed a series of goals. + * Fork Maven to execute a series of goals. * * @author Brett Porter */ -@Component( role = MavenExecutor.class, hint = "forked-path" ) +@Singleton +@Named( "forked-path" ) public class ForkedMavenExecutor - extends AbstractMavenExecutor + extends AbstractMavenExecutor { /** * Command line factory. */ - @Requirement - private CommandLineFactory commandLineFactory; + private final CommandLineFactory commandLineFactory; + + @Inject + public ForkedMavenExecutor( MavenCrypto mavenCrypto, + CommandLineFactory commandLineFactory ) + { + super( mavenCrypto ); + this.commandLineFactory = requireNonNull( commandLineFactory ); + } /* * @noinspection UseOfSystemOutOrSystemErr @@ -57,9 +70,9 @@ public class ForkedMavenExecutor public void executeGoals( File workingDirectory, List goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult relResult ) - throws MavenExecutorException + throws MavenExecutorException { - String mavenPath = null; + String mavenPath; // if null we use the current one if ( releaseEnvironment.getMavenHome() != null ) { @@ -78,7 +91,7 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi { settingsFile = File.createTempFile( "release-settings", ".xml" ); SettingsXpp3Writer writer = getSettingsWriter(); - + try ( FileWriter fileWriter = new FileWriter( settingsFile ) ) { writer.write( fileWriter, encryptSettings( releaseEnvironment.getSettings() ) ); @@ -93,7 +106,7 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi { Commandline cl = - commandLineFactory.createCommandLine( mavenPath + File.separator + "bin" + File.separator + "mvn" ); + commandLineFactory.createCommandLine( mavenPath + File.separator + "bin" + File.separator + "mvn" ); cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); @@ -134,14 +147,14 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi try { - relResult.appendInfo( "Executing: " + cl.toString() ); - getLogger().info( "Executing: " + cl.toString() ); + relResult.appendInfo( "Executing: " + cl ); + getLogger().info( "Executing: " + cl ); int result = executeCommandLine( cl, System.in, stdOut, stdErr ); if ( result != 0 ) { - throw new MavenExecutorException( "Maven execution failed, exit code: \'" + result + "\'", result ); + throw new MavenExecutorException( "Maven execution failed, exit code: '" + result + "'", result ); } } catch ( CommandLineException e ) @@ -162,22 +175,11 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi } } - /** - *

Setter for the field commandLineFactory.

- * - * @param commandLineFactory a {@link org.apache.maven.shared.release.exec.CommandLineFactory} object - */ - public void setCommandLineFactory( CommandLineFactory commandLineFactory ) - { - this.commandLineFactory = commandLineFactory; - } - - /** *

executeCommandLine.

* - * @param cl a {@link org.codehaus.plexus.util.cli.Commandline} object - * @param systemIn a {@link java.io.InputStream} object + * @param cl a {@link org.codehaus.plexus.util.cli.Commandline} object + * @param systemIn a {@link java.io.InputStream} object * @param systemOut a {@link java.io.OutputStream} object * @param systemErr a {@link java.io.OutputStream} object * @return a int @@ -185,7 +187,7 @@ public void setCommandLineFactory( CommandLineFactory commandLineFactory ) */ public static int executeCommandLine( Commandline cl, InputStream systemIn, OutputStream systemOut, OutputStream systemErr ) - throws CommandLineException + throws CommandLineException { if ( cl == null ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java index 2a6e061bc..bed98cbd5 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -27,9 +31,9 @@ import java.util.Properties; import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.DefaultParser; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; -import org.apache.commons.cli.PosixParser; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.apache.maven.shared.invoker.DefaultInvocationRequest; import org.apache.maven.shared.invoker.DefaultInvoker; @@ -41,44 +45,44 @@ import org.apache.maven.shared.invoker.MavenInvocationException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.logging.Logger; +import org.apache.maven.shared.release.util.MavenCrypto; import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.slf4j.Logger; /** * Fork Maven using the maven-invoker shared library. */ -@Component( role = MavenExecutor.class, hint = "invoker" ) -@SuppressWarnings( "static-access" ) +@Singleton +@Named( "invoker" ) public class InvokerMavenExecutor - extends AbstractMavenExecutor + extends AbstractMavenExecutor { private static final Options OPTIONS = new Options(); - private static final char SET_SYSTEM_PROPERTY = 'D'; + private static final String SET_SYSTEM_PROPERTY = "D"; - private static final char OFFLINE = 'o'; + private static final String OFFLINE = "o"; - private static final char REACTOR = 'r'; + private static final String REACTOR = "r"; - private static final char QUIET = 'q'; + private static final String QUIET = "q"; - private static final char DEBUG = 'X'; + private static final String DEBUG = "X"; - private static final char ERRORS = 'e'; + private static final String ERRORS = "e"; - private static final char NON_RECURSIVE = 'N'; + private static final String NON_RECURSIVE = "N"; - private static final char UPDATE_SNAPSHOTS = 'U'; + private static final String UPDATE_SNAPSHOTS = "U"; - private static final char ACTIVATE_PROFILES = 'P'; + private static final String ACTIVATE_PROFILES = "P"; - private static final char CHECKSUM_FAILURE_POLICY = 'C'; + private static final String CHECKSUM_FAILURE_POLICY = "C"; - private static final char CHECKSUM_WARNING_POLICY = 'c'; + private static final String CHECKSUM_WARNING_POLICY = "c"; - private static final char ALTERNATE_USER_SETTINGS = 's'; + private static final String ALTERNATE_USER_SETTINGS = "s"; private static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; @@ -87,108 +91,178 @@ public class InvokerMavenExecutor private static final String FAIL_AT_END = "fae"; private static final String FAIL_NEVER = "fn"; - + private static final String ALTERNATE_POM_FILE = "f"; - + private static final String THREADS = "T"; private static final String BATCH_MODE = "B"; - - /** Constant ALTERNATE_USER_TOOLCHAINS='t' */ - public static final char ALTERNATE_USER_TOOLCHAINS = 't'; - + + public static final String ALTERNATE_USER_TOOLCHAINS = "t"; + static { OPTIONS.addOption( - OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create( - SET_SYSTEM_PROPERTY ) ); + Option.builder( SET_SYSTEM_PROPERTY ) + .longOpt( "define" ) + .numberOfArgs( 2 ) + .valueSeparator( '=' ) + .desc( "Define a system property" ) + .build() ); + + OPTIONS.addOption( + Option.builder( OFFLINE ) + .longOpt( "offline" ) + .desc( "Work offline" ) + .build() ); + + OPTIONS.addOption( + Option.builder( QUIET ) + .longOpt( "quiet" ) + .desc( "Quiet output - only show errors" ) + .build() ); + + OPTIONS.addOption( + Option.builder( DEBUG ) + .longOpt( "debug" ) + .desc( "Produce execution debug output" ) + .build() ); + + OPTIONS.addOption( + Option.builder( ERRORS ) + .longOpt( "errors" ) + .desc( "Produce execution error messages" ) + .build() ); + + OPTIONS.addOption( + Option.builder( REACTOR ) + .longOpt( "reactor" ) + .desc( "Execute goals for project found in the reactor" ) + .build() ); + + OPTIONS.addOption( + Option.builder( NON_RECURSIVE ) + .longOpt( "non-recursive" ) + .desc( "Do not recurse into sub-projects" ) + .build() ); + + OPTIONS.addOption( + Option.builder( UPDATE_SNAPSHOTS ) + .longOpt( "update-snapshots" ) + .desc( "Forces a check for updated releases and snapshots on remote repositories" ) + .build() ); + + OPTIONS.addOption( + Option.builder( ACTIVATE_PROFILES ) + .longOpt( "activate-profiles" ) + .desc( "Comma-delimited list of profiles to activate" ) + .hasArg() + .build() ); - OPTIONS.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) ); + OPTIONS.addOption( + Option.builder( CHECKSUM_FAILURE_POLICY ) + .longOpt( "strict-checksums" ) + .desc( "Fail the build if checksums don't match" ) + .build() ); OPTIONS.addOption( - OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) ); + Option.builder( CHECKSUM_WARNING_POLICY ) + .longOpt( "lax-checksums" ) + .desc( "Warn if checksums don't match" ) + .build() ); OPTIONS.addOption( - OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) ); + Option.builder( ALTERNATE_USER_SETTINGS ) + .longOpt( "settings" ) + .desc( "Alternate path for the user settings file" ) + .hasArg() + .build() ); OPTIONS.addOption( - OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create( - ERRORS ) ); + Option.builder( ALTERNATE_GLOBAL_SETTINGS ) + .longOpt( "global-settings" ) + .desc( "Alternate path for the global settings file" ) + .hasArg() + .build() ); - OPTIONS.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription( - "Execute goals for project found in the reactor" ).create( REACTOR ) ); + OPTIONS.addOption( + Option.builder( FAIL_FAST ) + .longOpt( "fail-fast" ) + .desc( "Stop at first failure in reactorized builds" ) + .build() ); OPTIONS.addOption( - OptionBuilder.withLongOpt( "non-recursive" ).withDescription( "Do not recurse into sub-projects" ).create( - NON_RECURSIVE ) ); + Option.builder( FAIL_AT_END ) + .longOpt( "fail-at-end" ) + .desc( "Only fail the build afterwards; allow all non-impacted builds to continue" ) + .build() ); - OPTIONS.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription( - "Forces a check for updated releases and snapshots on remote repositories" ).create( UPDATE_SNAPSHOTS ) ); + OPTIONS.addOption( + Option.builder( FAIL_NEVER ) + .longOpt( "fail-never" ) + .desc( "NEVER fail the build, regardless of project result" ) + .build() ); - OPTIONS.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription( - "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) ); + OPTIONS.addOption( + Option.builder( ALTERNATE_POM_FILE ) + .longOpt( "file" ) + .desc( "Force the use of an alternate POM file." ) + .hasArg() + .build() ); - OPTIONS.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( - "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) ); + OPTIONS.addOption( + Option.builder( THREADS ) + .longOpt( "threads" ) + .desc( "Thread count, for instance 2.0C where C is core multiplied" ) + .hasArg() + .build() ); OPTIONS.addOption( - OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( - CHECKSUM_WARNING_POLICY ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "settings" ).withDescription( - "Alternate path for the user settings file" ).hasArg().create( ALTERNATE_USER_SETTINGS ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "global-settings" ).withDescription( - " Alternate path for the global settings file" ).hasArg().create( ALTERNATE_GLOBAL_SETTINGS ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription( - "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription( - "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription( - "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "file" ).withDescription( - "Force the use of an alternate POM file." ).hasArg().create( ALTERNATE_POM_FILE ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "threads" ).withDescription( - "Thread count, for instance 2.0C where C is core multiplied" ).hasArg().create( THREADS ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription( - "Run in non-interactive (batch) mode" ).create( BATCH_MODE ) ); - - OPTIONS.addOption( OptionBuilder.withLongOpt( "toolchains" ).withDescription( - "Alternate path for the user toolchains file" ).hasArg().create( ALTERNATE_USER_TOOLCHAINS ) ); + Option.builder( BATCH_MODE ) + .longOpt( "batch-mode" ) + .desc( "Run in non-interactive (batch) mode" ) + .build() ); + + OPTIONS.addOption( + Option.builder( ALTERNATE_USER_TOOLCHAINS ) + .longOpt( "toolchains" ) + .desc( "Alternate path for the user toolchains file" ) + .hasArg() + .build() ); + } + + @Inject + public InvokerMavenExecutor( MavenCrypto mavenCrypto ) + { + super( mavenCrypto ); } // TODO: Configuring an invocation request from a command line could as well be part of the Invoker API + /** *

setupRequest.

* - * @param req a {@link org.apache.maven.shared.invoker.InvocationRequest} object - * @param bridge a {@link org.apache.maven.shared.invoker.InvokerLogger} object + * @param req a {@link org.apache.maven.shared.invoker.InvocationRequest} object + * @param bridge a {@link org.apache.maven.shared.invoker.InvokerLogger} object * @param additionalArguments a {@link java.lang.String} object * @throws org.apache.maven.shared.release.exec.MavenExecutorException if any. */ protected void setupRequest( InvocationRequest req, InvokerLogger bridge, - String additionalArguments ) - throws MavenExecutorException + String additionalArguments ) + throws MavenExecutorException { try { String[] args = CommandLineUtils.translateCommandline( additionalArguments ); - CommandLine cli = new PosixParser().parse( OPTIONS, args ); + CommandLine cli = new DefaultParser().parse( OPTIONS, args ); if ( cli.hasOption( SET_SYSTEM_PROPERTY ) ) { String[] properties = cli.getOptionValues( SET_SYSTEM_PROPERTY ); Properties props = new Properties(); - for ( int i = 0; i < properties.length; i++ ) + for ( String property : properties ) { - String property = properties[i]; String name, value; int sep = property.indexOf( "=" ); if ( sep <= 0 ) @@ -242,7 +316,7 @@ else if ( cli.hasOption( NON_RECURSIVE ) ) if ( cli.hasOption( ACTIVATE_PROFILES ) ) { String[] profiles = cli.getOptionValues( ACTIVATE_PROFILES ); - + if ( profiles != null ) { req.setProfiles( Arrays.asList( profiles ) ); @@ -262,7 +336,7 @@ else if ( cli.hasOption( CHECKSUM_WARNING_POLICY ) ) { req.setUserSettingsFile( new File( cli.getOptionValue( ALTERNATE_USER_SETTINGS ) ) ); } - + if ( cli.hasOption( ALTERNATE_GLOBAL_SETTINGS ) ) { req.setGlobalSettingsFile( new File( cli.getOptionValue( ALTERNATE_GLOBAL_SETTINGS ) ) ); @@ -291,22 +365,22 @@ else if ( cli.hasOption( FAIL_FAST ) ) req.setPomFileName( cli.getOptionValue( ALTERNATE_POM_FILE ) ); } } - + if ( cli.hasOption( THREADS ) ) { req.setThreads( cli.getOptionValue( THREADS ) ); } - + if ( cli.hasOption( BATCH_MODE ) ) { req.setBatchMode( true ); } - + if ( cli.hasOption( ALTERNATE_USER_TOOLCHAINS ) ) { req.setToolchainsFile( new File( cli.getOptionValue( ALTERNATE_USER_TOOLCHAINS ) ) ); } - + } catch ( Exception e ) { @@ -318,12 +392,12 @@ else if ( cli.hasOption( FAIL_FAST ) ) public void executeGoals( File workingDirectory, List goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result ) - throws MavenExecutorException + throws MavenExecutorException { InvocationOutputHandler handler = getOutputHandler(); InvokerLogger bridge = getInvokerLogger(); - File mavenPath = null; + File mavenPath; // if null we use the current one if ( releaseEnvironment.getMavenHome() != null ) { @@ -367,7 +441,7 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi { settingsFile = File.createTempFile( "release-settings", ".xml" ); SettingsXpp3Writer writer = getSettingsWriter(); - + try ( FileWriter fileWriter = new FileWriter( settingsFile ) ) { writer.write( fileWriter, encryptSettings( releaseEnvironment.getSettings() ) ); @@ -398,13 +472,13 @@ public void executeGoals( File workingDirectory, List goals, ReleaseEnvi if ( invocationResult.getExecutionException() != null ) { throw new MavenExecutorException( "Error executing Maven.", - invocationResult.getExecutionException() ); + invocationResult.getExecutionException() ); } if ( invocationResult.getExitCode() != 0 ) { throw new MavenExecutorException( - "Maven execution failed, exit code: \'" + invocationResult.getExitCode() + "\'", - invocationResult.getExitCode() ); + "Maven execution failed, exit code: '" + invocationResult.getExitCode() + "'", + invocationResult.getExitCode() ); } } catch ( MavenInvocationException e ) @@ -442,9 +516,9 @@ protected InvocationOutputHandler getOutputHandler() } private static final class Handler - implements InvocationOutputHandler + implements InvocationOutputHandler { - private Logger logger; + private final Logger logger; Handler( Logger logger ) { @@ -458,10 +532,10 @@ public void consumeLine( String line ) } private static final class LoggerBridge - implements InvokerLogger + implements InvokerLogger { - private Logger logger; + private final Logger logger; LoggerBridge( Logger logger ) { @@ -495,19 +569,19 @@ public void error( String message ) @Override public void fatalError( String message, Throwable error ) { - logger.fatalError( message, error ); + logger.error( message, error ); } @Override public void fatalError( String message ) { - logger.fatalError( message ); + logger.error( message ); } @Override public int getThreshold() { - return logger.getThreshold(); + return InvokerLogger.DEBUG; } @Override @@ -537,7 +611,7 @@ public boolean isErrorEnabled() @Override public boolean isFatalErrorEnabled() { - return logger.isFatalErrorEnabled(); + return logger.isErrorEnabled(); } @Override @@ -556,7 +630,7 @@ public boolean isWarnEnabled() public void setThreshold( int level ) { // NOTE: - // logger.setThreadhold( level ) + // logger.setThreshold( level ) // is not supported in plexus-container-default:1.0-alpha-9 as used in Maven 2.x } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutor.java index e3fd6f137..53475a7ed 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutor.java @@ -19,11 +19,11 @@ * under the License. */ +import java.io.File; + import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import java.io.File; - /** * Execute Maven. May be implemented as a forked instance, or embedded. * @@ -45,5 +45,5 @@ public interface MavenExecutor */ void executeGoals( File workingDirectory, String goals, ReleaseEnvironment releaseEnvironment, boolean interactive, String additionalArguments, String pomFileName, ReleaseResult result ) - throws MavenExecutorException; + throws MavenExecutorException; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutorException.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutorException.java index 9d8c8154e..7a6894930 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutorException.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/MavenExecutorException.java @@ -25,14 +25,14 @@ * @author Brett Porter */ public class MavenExecutorException - extends Exception + extends Exception { private int exitCode; /** *

Constructor for MavenExecutorException.

* - * @param message a {@link java.lang.String} object + * @param message a {@link java.lang.String} object * @param exitCode a int */ public MavenExecutorException( String message, int exitCode ) @@ -46,7 +46,7 @@ public MavenExecutorException( String message, int exitCode ) *

Constructor for MavenExecutorException.

* * @param message a {@link java.lang.String} object - * @param cause a {@link java.lang.Throwable} object + * @param cause a {@link java.lang.Throwable} object */ public MavenExecutorException( String message, Throwable cause ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/RawStreamPumper.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/RawStreamPumper.java index de38e44b7..34da69704 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/RawStreamPumper.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/RawStreamPumper.java @@ -25,29 +25,28 @@ /** *

RawStreamPumper class.

- * */ public class RawStreamPumper - extends Thread + extends Thread { - private InputStream in; + private final InputStream in; - private OutputStream out; + private final OutputStream out; boolean done; boolean poll; - byte buffer[] = new byte[256]; + byte[] buffer = new byte[256]; /** *

Constructor for RawStreamPumper.

* - * @param in a {@link java.io.InputStream} object - * @param out a {@link java.io.OutputStream} object + * @param in a {@link java.io.InputStream} object + * @param out a {@link java.io.OutputStream} object * @param poll a boolean */ - public RawStreamPumper( InputStream in , OutputStream out, boolean poll ) + public RawStreamPumper( InputStream in, OutputStream out, boolean poll ) { this.in = in; this.out = out; @@ -57,10 +56,10 @@ public RawStreamPumper( InputStream in , OutputStream out, boolean poll ) /** *

Constructor for RawStreamPumper.

* - * @param in a {@link java.io.InputStream} object + * @param in a {@link java.io.InputStream} object * @param out a {@link java.io.OutputStream} object */ - public RawStreamPumper( InputStream in , OutputStream out ) + public RawStreamPumper( InputStream in, OutputStream out ) { this.in = in; this.out = out; @@ -81,7 +80,7 @@ public void setDone() * @throws java.io.IOException if any. */ public void closeInput() - throws IOException + throws IOException { in.close(); } @@ -92,7 +91,7 @@ public void closeInput() * @throws java.io.IOException if any. */ public void closeOutput() - throws IOException + throws IOException { out.close(); } @@ -145,7 +144,7 @@ public void run() } catch ( Throwable e ) { - // Catched everything + // Caught everything } finally { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeConsumer.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeConsumer.java index c10788e0b..c30d588ac 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeConsumer.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeConsumer.java @@ -19,28 +19,28 @@ * under the License. */ -import org.codehaus.plexus.util.cli.StreamConsumer; - import java.io.PrintStream; +import org.codehaus.plexus.util.cli.StreamConsumer; + /** * Consumer that both funnels to System.out/err, and stores in an internal buffer. * * @author Brett Porter */ public class TeeConsumer - implements StreamConsumer + implements StreamConsumer { - private PrintStream stream; + private final PrintStream stream; /** * @noinspection StringBufferField */ - private StringBuffer content = new StringBuffer(); + private final StringBuffer content = new StringBuffer(); private static final String LS = System.getProperty( "line.separator" ); - private String indent; + private final String indent; /** *

Constructor for TeeConsumer.

@@ -61,7 +61,6 @@ public TeeConsumer( PrintStream stream ) public TeeConsumer( PrintStream stream, String indent ) { this.stream = stream; - this.indent = indent; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeOutputStream.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeOutputStream.java index bfa6143d4..363e76ad7 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeOutputStream.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/TeeOutputStream.java @@ -26,13 +26,12 @@ /** *

TeeOutputStream class.

- * */ public class TeeOutputStream - extends FilterOutputStream + extends FilterOutputStream { - private ByteArrayOutputStream bout = new ByteArrayOutputStream( 1024 * 8 ); - private byte indent[]; + private final ByteArrayOutputStream bout = new ByteArrayOutputStream( 1024 * 8 ); + private final byte[] indent; private int last = '\n'; /** @@ -49,7 +48,7 @@ public TeeOutputStream( OutputStream out ) *

Constructor for TeeOutputStream.

* * @param out a {@link java.io.OutputStream} object - * @param i a {@link java.lang.String} object + * @param i a {@link java.lang.String} object */ public TeeOutputStream( OutputStream out, String i ) { @@ -59,7 +58,7 @@ public TeeOutputStream( OutputStream out, String i ) @Override public void write( byte[] b, int off, int len ) - throws IOException + throws IOException { for ( int x = 0; x < len; x++ ) { @@ -81,7 +80,7 @@ public void write( byte[] b, int off, int len ) @Override public void write( int b ) - throws IOException + throws IOException { if ( last == '\n' || ( last == '\r' && b != '\n' ) ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java index 81963de50..25770ecbe 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractBackupPomsPhase.java @@ -19,18 +19,18 @@ * under the License. */ +import java.io.File; + import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.util.ReleaseUtil; -import java.io.File; - /** *

Abstract AbstractBackupPomsPhase class.

* * @author Edwin Punzalan */ public abstract class AbstractBackupPomsPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { private final String backupSuffix = ".releaseBackup"; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java similarity index 78% rename from maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java rename to maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java index 128721fd8..37c5e4c6c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java @@ -19,6 +19,8 @@ * under the License. */ +import java.util.List; + import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.manager.NoSuchScmProviderException; @@ -32,33 +34,41 @@ import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.codehaus.plexus.util.StringUtils; -import java.util.List; +import static java.util.Objects.requireNonNull; /** * Phase that checks the validity of the POM before release. * * @author Brett Porter */ -public class CheckPomPhase - extends AbstractReleasePhase +public abstract class AbstractCheckPomPhase + extends AbstractReleasePhase { + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + /** * @since 2.4 */ - private boolean scmRequired = true; + private final boolean scmRequired; /** * @since 2.5.2 */ - private boolean snapshotsRequired = true; + private final boolean snapshotsRequired; - private ScmRepositoryConfigurator scmRepositoryConfigurator; + public AbstractCheckPomPhase( ScmRepositoryConfigurator scmRepositoryConfigurator, boolean scmRequired, + boolean snapshotsRequired ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + this.scmRequired = scmRequired; + this.snapshotsRequired = snapshotsRequired; + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -68,13 +78,13 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro if ( StringUtils.isEmpty( releaseDescriptor.getScmSourceUrl() ) ) { throw new ReleaseFailureException( - "Missing required setting: scm connection or developerConnection must be specified." ); + "Missing required setting: scm connection or developerConnection must be specified." ); } try { scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + releaseEnvironment.getSettings() ); } catch ( ScmRepositoryException e ) { @@ -83,7 +93,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro catch ( NoSuchScmProviderException e ) { throw new ReleaseFailureException( - "The provider given in the SCM URL could not be found: " + e.getMessage() ); + "The provider given in the SCM URL could not be found: " + e.getMessage() ); } } @@ -112,7 +122,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { // It makes no modifications, so simulate is the same as execute return execute( releaseDescriptor, releaseEnvironment, reactorProjects ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java new file mode 100644 index 000000000..bae1798be --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java @@ -0,0 +1,310 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.Map; +import java.util.Properties; +import java.util.concurrent.atomic.AtomicReference; + +import org.apache.maven.artifact.ArtifactUtils; +import org.apache.maven.project.MavenProject; +import org.apache.maven.scm.manager.NoSuchScmProviderException; +import org.apache.maven.scm.provider.ScmProvider; +import org.apache.maven.scm.repository.ScmRepository; +import org.apache.maven.scm.repository.ScmRepositoryException; +import org.apache.maven.shared.release.ReleaseExecutionException; +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.env.ReleaseEnvironment; +import org.apache.maven.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.naming.NamingPolicy; +import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; +import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; +import org.apache.maven.shared.release.util.ReleaseUtil; +import org.codehaus.plexus.components.interactivity.Prompter; +import org.codehaus.plexus.components.interactivity.PrompterException; +import org.codehaus.plexus.interpolation.InterpolationException; +import org.codehaus.plexus.interpolation.Interpolator; +import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; +import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource; +import org.codehaus.plexus.interpolation.RecursionInterceptor; +import org.codehaus.plexus.interpolation.StringSearchInterpolator; +import org.codehaus.plexus.util.StringUtils; + +import static java.util.Objects.requireNonNull; + +/** + * Input any variables that were not yet configured. + * + * @author Brett Porter + */ +public abstract class AbstractInputVariablesPhase + extends AbstractReleasePhase +{ + /** + * Component used to prompt for input. + */ + private final AtomicReference prompter; + + /** + * Tool that gets a configured SCM repository from release configuration. + */ + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + /** + * Component used for custom or default naming policy + */ + private final Map namingPolicies; + + /** + * Whether this is a branch or a tag operation. + */ + private final boolean branchOperation; + + /** + * The default naming policy to apply, if any + */ + private final String defaultNamingPolicy; + + protected AbstractInputVariablesPhase( Prompter prompter, ScmRepositoryConfigurator scmRepositoryConfigurator, + Map namingPolicies, boolean branchOperation, + String defaultNamingPolicy ) + { + this.prompter = new AtomicReference<>( requireNonNull( prompter ) ); + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + this.namingPolicies = requireNonNull( namingPolicies ); + this.branchOperation = branchOperation; + this.defaultNamingPolicy = defaultNamingPolicy; + } + + /** + * For easier testing only! + */ + public void setPrompter( Prompter prompter ) + { + this.prompter.set( prompter ); + } + + boolean isBranchOperation() + { + return branchOperation; + } + + /** + *

getScmProvider.

+ * + * @param releaseDescriptor a {@link ReleaseDescriptor} object + * @param releaseEnvironment a {@link ReleaseEnvironment} object + * @return a {@link ScmProvider} object + * @throws ReleaseScmRepositoryException if any. + * @throws ReleaseExecutionException if any. + */ + protected ScmProvider getScmProvider( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment ) + throws ReleaseScmRepositoryException, ReleaseExecutionException + { + try + { + ScmRepository repository = + scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, + releaseEnvironment.getSettings() ); + + return scmRepositoryConfigurator.getRepositoryProvider( repository ); + } + catch ( ScmRepositoryException e ) + { + throw new ReleaseScmRepositoryException( + e.getMessage() + " for URL: " + releaseDescriptor.getScmSourceUrl(), e.getValidationMessages() ); + } + catch ( NoSuchScmProviderException e ) + { + throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e ); + } + } + + @Override + public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, + List reactorProjects ) + throws ReleaseExecutionException + { + ReleaseResult result = new ReleaseResult(); + + // get the root project + MavenProject project = ReleaseUtil.getRootProject( reactorProjects ); + + String tag = releaseDescriptor.getScmReleaseLabel(); + + if ( tag == null ) + { + // Must get default version from mapped versions, as the project will be the incorrect snapshot + String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); + String releaseVersion = releaseDescriptor.getProjectReleaseVersion( key ); + if ( releaseVersion == null ) + { + throw new ReleaseExecutionException( "Project tag cannot be selected if version is not yet mapped" ); + } + + String suggestedName; + String scmTagNameFormat = releaseDescriptor.getScmTagNameFormat(); + if ( releaseDescriptor.getProjectNamingPolicyId() != null ) + { + try + { + suggestedName = + resolveSuggestedName( releaseDescriptor.getProjectNamingPolicyId(), releaseVersion, + project ); + } + catch ( PolicyException e ) + { + throw new ReleaseExecutionException( e.getMessage(), e ); + } + } + else if ( scmTagNameFormat != null ) + { + Interpolator interpolator = new StringSearchInterpolator( "@{", "}" ); + List possiblePrefixes = Arrays.asList( "project", "pom" ); + Properties values = new Properties(); + values.setProperty( "artifactId", project.getArtifactId() ); + values.setProperty( "groupId", project.getGroupId() ); + values.setProperty( "version", releaseVersion ); + interpolator.addValueSource( new PrefixedPropertiesValueSource( possiblePrefixes, values, true ) ); + RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( possiblePrefixes ); + try + { + suggestedName = interpolator.interpolate( scmTagNameFormat, recursionInterceptor ); + } + catch ( InterpolationException e ) + { + throw new ReleaseExecutionException( + "Could not interpolate specified tag name format: " + scmTagNameFormat, e ); + } + } + else + { + try + { + suggestedName = resolveSuggestedName( defaultNamingPolicy, releaseVersion, project ); + } + catch ( PolicyException e ) + { + throw new ReleaseExecutionException( e.getMessage(), e ); + } + } + + ScmProvider provider; + try + { + provider = getScmProvider( releaseDescriptor, releaseEnvironment ); + } + catch ( ReleaseScmRepositoryException e ) + { + throw new ReleaseExecutionException( + "No scm provider can be found for url: " + releaseDescriptor.getScmSourceUrl(), e ); + } + + suggestedName = provider.sanitizeTagName( suggestedName ); + + if ( releaseDescriptor.isInteractive() ) + { + try + { + if ( branchOperation ) + { + tag = prompter.get().prompt( "What is the branch name for \"" + project.getName() + "\"? (" + + project.getGroupId() + ":" + project.getArtifactId() + ")" ); + if ( StringUtils.isEmpty( tag ) ) + { + throw new ReleaseExecutionException( "No branch name was given." ); + } + } + else + { + tag = prompter.get().prompt( "What is the SCM release tag or label for \"" + project.getName() + + "\"? (" + project.getGroupId() + ":" + project.getArtifactId() + ")", suggestedName ); + } + } + catch ( PrompterException e ) + { + throw new ReleaseExecutionException( "Error reading version from input handler: " + e.getMessage(), + e ); + } + } + else if ( suggestedName == null ) + { + if ( isBranchOperation() ) + { + throw new ReleaseExecutionException( "No branch name was given." ); + } + else + { + throw new ReleaseExecutionException( "No tag name was given." ); + } + } + else + { + tag = suggestedName; + } + releaseDescriptor.setScmReleaseLabel( tag ); + } + + result.setResultCode( ReleaseResult.SUCCESS ); + + return result; + } + + @Override + public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, + List reactorProjects ) + throws ReleaseExecutionException + { + ReleaseResult result = new ReleaseResult(); + + // It makes no modifications, so simulate is the same as execute + execute( releaseDescriptor, releaseEnvironment, reactorProjects ); + + result.setResultCode( ReleaseResult.SUCCESS ); + + return result; + } + + private String resolveSuggestedName( String policyId, String version, MavenProject project ) + throws PolicyException + { + if ( policyId == null ) + { + return null; + } + + NamingPolicy policy = namingPolicies.get( policyId ); + if ( policy == null ) + { + throw new PolicyException( "Policy '" + policyId + "' is unknown, available: " + + namingPolicies.keySet() ); + } + + NamingPolicyRequest request = new NamingPolicyRequest() + .setGroupId( project.getGroupId() ) + .setArtifactId( project.getArtifactId() ) + .setVersion( version ); + return policy.getName( request ).getName(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java similarity index 85% rename from maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java rename to maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java index a04f027d8..b75a4b1d8 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java @@ -40,9 +40,11 @@ import org.codehaus.plexus.components.interactivity.PrompterException; import org.codehaus.plexus.util.StringUtils; +import static java.util.Objects.requireNonNull; + /** * Map projects to their new versions after release / into the next development cycle. - * + *

* The map-phases per goal are: *

*
release:prepare
map-release-versions + map-development-versions; RD.isBranchCreation() = false
@@ -67,49 +69,47 @@ * @author Brett Porter * @author Robert Scholte */ -public class MapVersionsPhase - extends AbstractReleasePhase +public abstract class AbstractMapVersionsPhase + extends AbstractReleasePhase { - private ResourceBundle resourceBundle; - /** - * Whether to convert to a snapshot or a release. + * Component used to prompt for input. */ - private boolean convertToSnapshot; + private final Prompter prompter; /** - * Whether to convert to a snapshot or a release. + * Component used for custom or default version policy */ - private boolean convertToBranch; + private final Map versionPolicies; /** - * Component used to prompt for input. + * Whether to convert to a snapshot or a release. */ - private Prompter prompter; - + private final boolean convertToSnapshot; /** - * Component used for custom or default version policy + * Whether to convert to a snapshot or a release. */ - private Map versionPolicies; + private final boolean convertToBranch; - void setConvertToSnapshot( boolean convertToSnapshot ) + public AbstractMapVersionsPhase( Prompter prompter, Map versionPolicies, + boolean convertToSnapshot, boolean convertToBranch ) { + this.prompter = requireNonNull( prompter ); + this.versionPolicies = requireNonNull( versionPolicies ); this.convertToSnapshot = convertToSnapshot; - } - void setPrompter( Prompter prompter ) - { - this.prompter = prompter; + this.convertToBranch = convertToBranch; + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); - resourceBundle = getResourceBundle( releaseEnvironment.getLocale() ); + ResourceBundle resourceBundle = getResourceBundle( releaseEnvironment.getLocale() ); MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); @@ -120,7 +120,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor ); + String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor, resourceBundle ); if ( !convertToSnapshot ) { @@ -138,7 +138,7 @@ else if ( releaseDescriptor.isBranchCreation() && convertToBranch ) for ( MavenProject subProject : reactorProjects ) { String subProjectId = - ArtifactUtils.versionlessKey( subProject.getGroupId(), subProject.getArtifactId() ); + ArtifactUtils.versionlessKey( subProject.getGroupId(), subProject.getArtifactId() ); if ( convertToSnapshot ) { @@ -186,7 +186,7 @@ else if ( ArtifactUtils.isSnapshot( subProject.getVersion() ) ) { String projectId = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor ); + String nextVersion = resolveNextVersion( project, projectId, releaseDescriptor, resourceBundle ); if ( !convertToSnapshot ) { @@ -209,17 +209,18 @@ else if ( releaseDescriptor.isBranchCreation() && convertToBranch ) } private String resolveNextVersion( MavenProject project, - String projectId, - ReleaseDescriptor releaseDescriptor ) - throws ReleaseExecutionException + String projectId, + ReleaseDescriptor releaseDescriptor, + ResourceBundle resourceBundle ) + throws ReleaseExecutionException { String defaultVersion; if ( convertToBranch ) { // no branch modification if ( !( releaseDescriptor.isUpdateBranchVersions() - && ( ArtifactUtils.isSnapshot( project.getVersion() ) - || releaseDescriptor.isUpdateVersionsToSnapshot() ) ) ) + && ( ArtifactUtils.isSnapshot( project.getVersion() ) + || releaseDescriptor.isUpdateVersionsToSnapshot() ) ) ) { return project.getVersion(); } @@ -234,7 +235,7 @@ else if ( releaseDescriptor.isBranchCreation() ) { // no working copy modification if ( !( ArtifactUtils.isSnapshot( project.getVersion() ) - && releaseDescriptor.isUpdateWorkingCopyVersions() ) ) + && releaseDescriptor.isUpdateWorkingCopyVersions() ) ) { return project.getVersion(); } @@ -278,19 +279,20 @@ else if ( releaseDescriptor.isBranchCreation() ) try { suggestedVersion = - resolveSuggestedVersion( baseVersion, releaseDescriptor.getProjectVersionPolicyId() ); + resolveSuggestedVersion( baseVersion, + releaseDescriptor.getProjectVersionPolicyId() ); } catch ( VersionParseException e ) { if ( releaseDescriptor.isInteractive() ) { suggestedVersion = - resolveSuggestedVersion( "1.0", releaseDescriptor.getProjectVersionPolicyId() ); + resolveSuggestedVersion( "1.0", releaseDescriptor.getProjectVersionPolicyId() ); } else { throw new ReleaseExecutionException( "Error parsing version, cannot determine next " - + "version: " + e.getMessage(), e ); + + "version: " + e.getMessage(), e ); } } } @@ -307,10 +309,11 @@ else if ( releaseDescriptor.isBranchCreation() ) messageKey = getMapversionPromptKey( releaseDescriptor ); } String message = - MessageFormat.format( resourceBundle.getString( messageKey ), project.getName(), projectId ); + MessageFormat.format( resourceBundle.getString( messageKey ), project.getName(), + projectId ); nextVersion = prompter.prompt( message, suggestedVersion ); - //@todo validate next version, maybe with DefaultArtifactVersion + //@todo validate next version, maybe with DefaultArtifactVersion } else if ( defaultVersion == null ) { @@ -334,7 +337,7 @@ else if ( convertToSnapshot ) } private String resolveSuggestedVersion( String baseVersion, String policyId ) - throws PolicyException, VersionParseException + throws PolicyException, VersionParseException { VersionPolicy policy = versionPolicies.get( policyId ); if ( policy == null ) @@ -344,7 +347,7 @@ private String resolveSuggestedVersion( String baseVersion, String policyId ) VersionPolicyRequest request = new VersionPolicyRequest().setVersion( baseVersion ); return convertToSnapshot ? policy.getDevelopmentVersion( request ).getVersion() - : policy.getReleaseVersion( request ).getVersion(); + : policy.getReleaseVersion( request ).getVersion(); } private String getDevelopmentVersion( String projectId, ReleaseDescriptor releaseDescriptor ) @@ -407,7 +410,7 @@ else if ( releaseDescriptor.isBranchCreation() ) @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); @@ -421,6 +424,6 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir private ResourceBundle getResourceBundle( Locale locale ) { - return ResourceBundle.getBundle( "release-messages", locale, MapVersionsPhase.class.getClassLoader() ); + return ResourceBundle.getBundle( "release-messages", locale, AbstractMapVersionsPhase.class.getClassLoader() ); } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePomsPhase.java index 0555c08c9..5794501b3 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractReleasePomsPhase.java @@ -29,7 +29,6 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; -import org.codehaus.plexus.component.annotations.Requirement; /** * Abstract release POM phase. @@ -41,17 +40,21 @@ public abstract class AbstractReleasePomsPhase extends AbstractReleasePhase /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + protected AbstractReleasePomsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = scmRepositoryConfigurator; + } protected ScmRepository getScmRepository( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { try { return scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + releaseEnvironment.getSettings() ); } catch ( ScmRepositoryException exception ) { @@ -60,12 +63,12 @@ protected ScmRepository getScmRepository( ReleaseDescriptor releaseDescriptor, catch ( NoSuchScmProviderException exception ) { throw new ReleaseExecutionException( "Unable to configure SCM repository: " + exception.getMessage(), - exception ); + exception ); } } protected ScmProvider getScmProvider( ScmRepository scmRepository ) - throws ReleaseExecutionException + throws ReleaseExecutionException { try { @@ -74,7 +77,7 @@ protected ScmProvider getScmProvider( ScmRepository scmRepository ) catch ( NoSuchScmProviderException exception ) { throw new ReleaseExecutionException( "Unable to configure SCM repository: " + exception.getMessage(), - exception ); + exception ); } } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java index 3e5525d60..47525a469 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java @@ -55,42 +55,51 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; -import org.apache.maven.shared.release.transform.ModelETLRequest; import org.apache.maven.shared.release.transform.MavenCoordinate; import org.apache.maven.shared.release.transform.ModelETL; import org.apache.maven.shared.release.transform.ModelETLFactory; +import org.apache.maven.shared.release.transform.ModelETLRequest; import org.apache.maven.shared.release.transform.jdom2.JDomModelETLFactory; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; +import static java.util.Objects.requireNonNull; + /** * Base class for rewriting phases. * * @author Brett Porter */ public abstract class AbstractRewritePomsPhase - extends AbstractReleasePhase implements ResourceGenerator + extends AbstractReleasePhase implements ResourceGenerator { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; - @Requirement( role = ModelETLFactory.class ) - private Map modelETLFactories; + private final Map modelETLFactories; /** - * Use jdom2-sax as default + * SCM URL translators mapped by provider name. */ - private String modelETL = JDomModelETLFactory.ROLE_HINT; + private Map scmTranslators; /** - * SCM URL translators mapped by provider name. + * Use jdom2-sax as default */ - @Requirement( role = ScmTranslator.class ) - private Map scmTranslators; + private String modelETL = JDomModelETLFactory.NAME; + + private long startTime = -1 * 1000; + + protected AbstractRewritePomsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator, + Map modelETLFactories, + Map scmTranslators ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + this.modelETLFactories = requireNonNull( modelETLFactories ); + this.scmTranslators = requireNonNull( scmTranslators ); + } /** *

Getter for the field scmTranslators.

@@ -112,8 +121,6 @@ public void setModelETL( String modelETL ) this.modelETL = modelETL; } - private long startTime = -1 * 1000; - /** *

Setter for the field startTime.

* @@ -134,7 +141,7 @@ public void setStartTime( long startTime ) @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -148,7 +155,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -188,7 +195,7 @@ public ReleaseResult clean( List reactorProjects ) private void transform( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, boolean simulate, ReleaseResult result ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { result.setStartTime( ( startTime >= 0 ) ? startTime : System.currentTimeMillis() ); @@ -203,7 +210,7 @@ private void transform( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment private void transformProject( MavenProject project, ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, boolean simulate, ReleaseResult result ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { File pomFile = ReleaseUtil.getStandardPom( project ); @@ -223,7 +230,7 @@ private void transformProject( MavenProject project, ReleaseDescriptor releaseDe try { scmRepository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + releaseEnvironment.getSettings() ); provider = scmRepositoryConfigurator.getRepositoryProvider( scmRepository ); } @@ -238,7 +245,7 @@ private void transformProject( MavenProject project, ReleaseDescriptor releaseDe } transformDocument( project, etl.getModel(), releaseDescriptor, scmRepository, result, - simulate ); + simulate ); File outputFile; if ( simulate ) @@ -257,7 +264,7 @@ private void transformProject( MavenProject project, ReleaseDescriptor releaseDe private void transformDocument( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, ScmRepository scmRepository, ReleaseResult result, boolean simulate ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { Model model = project.getModel(); @@ -273,28 +280,28 @@ private void transformDocument( MavenProject project, Model modelTarget, Release if ( buildTarget != null ) { // profile.build.extensions doesn't exist, so only rewrite project.build.extensions - rewriteArtifactVersions( toMavenCoordinates( buildTarget.getExtensions() ), - model, properties, result, releaseDescriptor, simulate ); + rewriteArtifactVersions( toMavenCoordinates( buildTarget.getExtensions() ), + model, properties, result, releaseDescriptor, simulate ); - rewriteArtifactVersions( toMavenCoordinates( buildTarget.getPlugins() ), - model, properties, result, releaseDescriptor, simulate ); + rewriteArtifactVersions( toMavenCoordinates( buildTarget.getPlugins() ), + model, properties, result, releaseDescriptor, simulate ); for ( Plugin plugin : buildTarget.getPlugins() ) { rewriteArtifactVersions( toMavenCoordinates( plugin.getDependencies() ), - model, properties, - result, releaseDescriptor, simulate ); + model, properties, + result, releaseDescriptor, simulate ); } if ( buildTarget.getPluginManagement() != null ) { rewriteArtifactVersions( toMavenCoordinates( buildTarget.getPluginManagement().getPlugins() ), model, - properties, result, releaseDescriptor, simulate ); + properties, result, releaseDescriptor, simulate ); for ( Plugin plugin : buildTarget.getPluginManagement().getPlugins() ) { rewriteArtifactVersions( toMavenCoordinates( plugin.getDependencies() ), model, properties, result, - releaseDescriptor, simulate ); + releaseDescriptor, simulate ); } } } @@ -305,23 +312,23 @@ private void transformDocument( MavenProject project, Model modelTarget, Release if ( profileBuild != null ) { rewriteArtifactVersions( toMavenCoordinates( profileBuild.getPlugins() ), model, properties, result, - releaseDescriptor, simulate ); + releaseDescriptor, simulate ); for ( Plugin plugin : profileBuild.getPlugins() ) { rewriteArtifactVersions( toMavenCoordinates( plugin.getDependencies() ), model, properties, result, - releaseDescriptor, simulate ); + releaseDescriptor, simulate ); } if ( profileBuild.getPluginManagement() != null ) { rewriteArtifactVersions( toMavenCoordinates( profileBuild.getPluginManagement().getPlugins() ), - model, properties, result, releaseDescriptor, simulate ); + model, properties, result, releaseDescriptor, simulate ); for ( Plugin plugin : profileBuild.getPluginManagement().getPlugins() ) { rewriteArtifactVersions( toMavenCoordinates( plugin.getDependencies() ), model, properties, - result, releaseDescriptor, simulate ); + result, releaseDescriptor, simulate ); } } } @@ -334,18 +341,18 @@ private void transformDocument( MavenProject project, Model modelTarget, Release for ( ModelBase modelBase : modelBases ) { rewriteArtifactVersions( toMavenCoordinates( modelBase.getDependencies() ), model, properties, result, - releaseDescriptor, simulate ); + releaseDescriptor, simulate ); if ( modelBase.getDependencyManagement() != null ) { rewriteArtifactVersions( toMavenCoordinates( modelBase.getDependencyManagement().getDependencies() ), - model, properties, result, releaseDescriptor, simulate ); + model, properties, result, releaseDescriptor, simulate ); } if ( modelBase.getReporting() != null ) { rewriteArtifactVersions( toMavenCoordinates( modelBase.getReporting().getPlugins() ), model, properties, - result, releaseDescriptor, simulate ); + result, releaseDescriptor, simulate ); } } @@ -388,7 +395,7 @@ else if ( buildOutputTimestamp.length() <= 1 ) private void rewriteVersion( Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, MavenProject project ) - throws ReleaseFailureException + throws ReleaseFailureException { String version = getNextVersion( releaseDescriptor, projectId ); if ( version == null ) @@ -399,9 +406,9 @@ private void rewriteVersion( Model modelTarget, ReleaseDescriptor releaseDescrip modelTarget.setVersion( version ); } - private String rewriteParent( MavenProject project, Model targetModel, + private String rewriteParent( MavenProject project, Model targetModel, ReleaseDescriptor releaseDescriptor, boolean simulate ) - throws ReleaseFailureException + throws ReleaseFailureException { String parentVersion = null; if ( project.hasParent() ) @@ -433,7 +440,7 @@ private String rewriteParent( MavenProject project, Model targetModel, private void rewriteArtifactVersions( Collection elements, Model projectModel, Properties properties, ReleaseResult result, ReleaseDescriptor releaseDescriptor, boolean simulate ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { if ( elements == null ) { @@ -483,7 +490,7 @@ private void rewriteArtifactVersions( Collection elements, Mode // MRELEASE-220 if ( mappedVersion != null && mappedVersion.endsWith( Artifact.SNAPSHOT_VERSION ) - && !rawVersion.endsWith( Artifact.SNAPSHOT_VERSION ) && !releaseDescriptor.isUpdateDependencies() ) + && !rawVersion.endsWith( Artifact.SNAPSHOT_VERSION ) && !releaseDescriptor.isUpdateDependencies() ) { continue; } @@ -500,7 +507,7 @@ else if ( rawVersion.matches( "\\$\\{.+\\}" ) ) String expression = rawVersion.substring( 2, rawVersion.length() - 1 ); if ( expression.startsWith( "project." ) || expression.startsWith( "pom." ) - || "version".equals( expression ) ) + || "version".equals( expression ) ) { if ( !mappedVersion.equals( getNextVersion( releaseDescriptor, projectId ) ) ) { @@ -530,25 +537,28 @@ else if ( mappedVersion.equals( propertyValue ) ) { // this property may have been updated during processing a sibling. logInfo( result, " Ignoring artifact version update for expression " + rawVersion - + " because it is already updated" ); + + " because it is already updated" ); } else if ( !mappedVersion.equals( rawVersion ) ) { + // WARNING: ${pom.*} prefix support and ${version} is about to be dropped in mvn4! + // https://issues.apache.org/jira/browse/MNG-7404 + // https://issues.apache.org/jira/browse/MNG-7244 if ( mappedVersion.matches( "\\$\\{project.+\\}" ) - || mappedVersion.matches( "\\$\\{pom.+\\}" ) - || "${version}".equals( mappedVersion ) ) + || mappedVersion.matches( "\\$\\{pom.+\\}" ) + || "${version}".equals( mappedVersion ) ) { logInfo( result, " Ignoring artifact version update for expression " - + mappedVersion ); + + mappedVersion ); // ignore... we cannot update this expression } else { // the value of the expression conflicts with what the user wanted to release throw new ReleaseFailureException( "The artifact (" + key + ") requires a " - + "different version (" + mappedVersion + ") than what is found (" - + propertyValue + ") for the expression (" + expression + ") in the " - + "project (" + projectId + ")." ); + + "different version (" + mappedVersion + ") than what is found (" + + propertyValue + ") for the expression (" + expression + ") in the " + + "project (" + projectId + ")." ); } } } @@ -579,15 +589,15 @@ else if ( resolvedSnapshotVersion != null ) } private void prepareScm( File pomFile, ReleaseDescriptor releaseDescriptor, ScmRepository repository, - ScmProvider provider ) - throws ReleaseExecutionException, ReleaseScmCommandException + ScmProvider provider ) + throws ReleaseExecutionException, ReleaseScmCommandException { try { if ( isUpdateScm() && ( releaseDescriptor.isScmUseEditMode() || provider.requiresEditMode() ) ) { EditScmResult result = provider.edit( repository, new ScmFileSet( - new File( releaseDescriptor.getWorkingDirectory() ), pomFile ) ); + new File( releaseDescriptor.getWorkingDirectory() ), pomFile ) ); if ( !result.isSuccess() ) { @@ -606,7 +616,7 @@ private void prepareScm( File pomFile, ReleaseDescriptor releaseDescriptor, ScmR *

getResolvedSnapshotVersion.

* * @param artifactVersionlessKey a {@link java.lang.String} object - * @param releaseDscriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object + * @param releaseDscriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object * @return a {@link java.lang.String} object */ protected abstract String getResolvedSnapshotVersion( String artifactVersionlessKey, @@ -616,8 +626,8 @@ protected abstract String getResolvedSnapshotVersion( String artifactVersionless *

getOriginalVersion.

* * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param projectKey a {@link java.lang.String} object - * @param simulate a boolean + * @param projectKey a {@link java.lang.String} object + * @param simulate a boolean * @return a {@link java.lang.String} object */ protected abstract String getOriginalVersion( ReleaseDescriptor releaseDescriptor, String projectKey, @@ -627,7 +637,7 @@ protected abstract String getOriginalVersion( ReleaseDescriptor releaseDescripto *

getNextVersion.

* * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param key a {@link java.lang.String} object + * @param key a {@link java.lang.String} object * @return a {@link java.lang.String} object */ protected abstract String getNextVersion( ReleaseDescriptor releaseDescriptor, String key ); @@ -635,18 +645,18 @@ protected abstract String getOriginalVersion( ReleaseDescriptor releaseDescripto /** *

transformScm.

* - * @param project a {@link org.apache.maven.project.MavenProject} object - * @param modelTarget a {@link org.apache.maven.model.Model} object + * @param project a {@link org.apache.maven.project.MavenProject} object + * @param modelTarget a {@link org.apache.maven.model.Model} object * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param projectId a {@link java.lang.String} object - * @param scmRepository a {@link org.apache.maven.scm.repository.ScmRepository} object - * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object + * @param projectId a {@link java.lang.String} object + * @param scmRepository a {@link org.apache.maven.scm.repository.ScmRepository} object + * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. */ protected abstract void transformScm( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, ScmRepository scmRepository, ReleaseResult result ) - throws ReleaseExecutionException; + throws ReleaseExecutionException; /** *

isUpdateScm.

@@ -663,7 +673,7 @@ protected boolean isUpdateScm() *

getOriginalResolvedSnapshotVersion.

* * @param artifactVersionlessKey a {@link java.lang.String} object - * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object + * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object * @return a {@link java.lang.String} object */ protected String getOriginalResolvedSnapshotVersion( String artifactVersionlessKey, diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java index 23d4cce71..12ba401d8 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java @@ -28,26 +28,31 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.exec.MavenExecutorException; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.StringUtils; +import static java.util.Objects.requireNonNull; + /** * Run the integration tests for the project to verify that it builds before committing. * * @author Brett Porter */ public abstract class AbstractRunGoalsPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { /** * Component to assist in executing Maven. */ - @Requirement( role = MavenExecutor.class ) - private Map mavenExecutors; + private final Map mavenExecutors; + + protected AbstractRunGoalsPhase( Map mavenExecutors ) + { + this.mavenExecutors = requireNonNull( mavenExecutors ); + } public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, File workingDirectory, String additionalArguments ) - throws ReleaseExecutionException + throws ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); @@ -63,7 +68,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro if ( mavenExecutor == null ) { throw new ReleaseExecutionException( - "Cannot find Maven executor with id: " + releaseEnvironment.getMavenExecutorId() ); + "Cannot find Maven executor with id: " + releaseEnvironment.getMavenExecutorId() ); } File executionRoot; @@ -79,10 +84,10 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro executionRoot = workingDirectory; pomFileName = null; } - + mavenExecutor.executeGoals( executionRoot, goals, releaseEnvironment, - releaseDescriptor.isInteractive(), additionalArguments, - pomFileName, result ); + releaseDescriptor.isInteractive(), additionalArguments, + pomFileName, result ); } } catch ( MavenExecutorException e ) @@ -109,7 +114,7 @@ protected String getAdditionalArguments( ReleaseDescriptor releaseDescriptor ) if ( !releaseDescriptor.getActivateProfiles().isEmpty() ) { builder.append( " -P " ) - .append( StringUtils.join( releaseDescriptor.getActivateProfiles().iterator(), "," ) ); + .append( StringUtils.join( releaseDescriptor.getActivateProfiles().iterator(), "," ) ); } return builder.length() > 0 ? builder.toString().trim() : null; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitDevelopmentPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitDevelopmentPhase.java new file mode 100644 index 000000000..15ea93914 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitDevelopmentPhase.java @@ -0,0 +1,111 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.text.MessageFormat; +import java.util.Collection; +import java.util.List; + +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.ReleaseExecutionException; +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.env.ReleaseEnvironment; +import org.apache.maven.shared.release.scm.ReleaseScmCommandException; +import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Commit the changes that were done to prepare the branch or tag to the SCM. + * + * @author Brett Porter + */ +public abstract class AbstractScmCommitDevelopmentPhase + extends AbstractScmCommitPhase +{ + /** + * The format for the + */ + private final String rollbackMessageFormat; + + protected AbstractScmCommitDevelopmentPhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + String descriptorCommentGetter, String rollbackMessageFormat ) + { + super( scmRepositoryConfigurator, descriptorCommentGetter ); + this.rollbackMessageFormat = rollbackMessageFormat; + } + + @Override + protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, + List reactorProjects, ReleaseResult result, boolean simulating ) + throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException + { + // no rollback required + if ( + // was there no commit that has to be rolled back by a new one + releaseDescriptor.isSuppressCommitBeforeTagOrBranch() + // and working copy should not be touched + && !releaseDescriptor.isUpdateWorkingCopyVersions() ) + { + if ( simulating ) + { + logInfo( result, "Full run would not commit changes, because updateWorkingCopyVersions is false." ); + } + else + { + logInfo( result, "Modified POMs are not committed because updateWorkingCopyVersions is set to false." ); + } + } + // rollback or commit development versions required + else + { + String message; + if ( !releaseDescriptor.isUpdateWorkingCopyVersions() ) + { + // the commit is a rollback + message = createRollbackMessage( releaseDescriptor ); + } + else + { + // a normal commit + message = createMessage( reactorProjects, releaseDescriptor ); + } + if ( simulating ) + { + Collection pomFiles = createPomFiles( releaseDescriptor, reactorProjects ); + logInfo( result, + "Full run would commit " + pomFiles.size() + " files with message: '" + message + "'" ); + } + else + { + performCheckins( releaseDescriptor, releaseEnvironment, reactorProjects, message ); + } + } + } + + private String createRollbackMessage( ReleaseDescriptor releaseDescriptor ) + { + return MessageFormat.format( releaseDescriptor.getScmCommentPrefix() + rollbackMessageFormat, + releaseDescriptor.getScmReleaseLabel() ); + } + +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java index b9b1a5a1c..a5a61eac8 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhase.java @@ -19,6 +19,11 @@ * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -38,10 +43,7 @@ import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import static java.util.Objects.requireNonNull; /** * Holds the basic concept of committing changes to the current working copy. @@ -50,26 +52,29 @@ * @author Lars Corneliussen */ public abstract class AbstractScmCommitPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { - protected boolean beforeBranchOrTag = false; - - protected boolean afterBranchOrTag = false; - /** * Tool that gets a configured SCM repository from release configuration. */ - protected ScmRepositoryConfigurator scmRepositoryConfigurator; + protected final ScmRepositoryConfigurator scmRepositoryConfigurator; /** * The getter in the descriptor for the comment. */ - protected String descriptorCommentGetter; + protected final String descriptorCommentGetter; + + protected AbstractScmCommitPhase( ScmRepositoryConfigurator scmRepositoryConfigurator, + String descriptorCommentGetter ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + this.descriptorCommentGetter = requireNonNull( descriptorCommentGetter ); + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult relResult = new ReleaseResult(); @@ -85,7 +90,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -100,33 +105,33 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir /** *

runLogic.

* - * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object + * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object * @param releaseEnvironment a {@link org.apache.maven.shared.release.env.ReleaseEnvironment} object - * @param reactorProjects a {@link java.util.List} object - * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object - * @param simulating a boolean - * @throws org.apache.maven.shared.release.scm.ReleaseScmCommandException if any. - * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. + * @param reactorProjects a {@link java.util.List} object + * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object + * @param simulating a boolean + * @throws org.apache.maven.shared.release.scm.ReleaseScmCommandException if any. + * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. * @throws org.apache.maven.shared.release.scm.ReleaseScmRepositoryException if any. */ protected abstract void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, ReleaseResult result, boolean simulating ) - throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException; + throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException; /** *

performCheckins.

* - * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object + * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object * @param releaseEnvironment a {@link org.apache.maven.shared.release.env.ReleaseEnvironment} object - * @param reactorProjects a {@link java.util.List} object - * @param message a {@link java.lang.String} object + * @param reactorProjects a {@link java.util.List} object + * @param message a {@link java.lang.String} object * @throws org.apache.maven.shared.release.scm.ReleaseScmRepositoryException if any. - * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. - * @throws org.apache.maven.shared.release.scm.ReleaseScmCommandException if any. + * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. + * @throws org.apache.maven.shared.release.scm.ReleaseScmCommandException if any. */ protected void performCheckins( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, String message ) - throws ReleaseScmRepositoryException, ReleaseExecutionException, ReleaseScmCommandException + throws ReleaseScmRepositoryException, ReleaseExecutionException, ReleaseScmCommandException { getLogger().info( "Checking in modified POMs..." ); @@ -136,7 +141,7 @@ protected void performCheckins( ReleaseDescriptor releaseDescriptor, ReleaseEnvi try { repository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + releaseEnvironment.getSettings() ); repository.getProviderRepository().setPushChanges( releaseDescriptor.isPushChanges() ); @@ -174,7 +179,7 @@ protected void performCheckins( ReleaseDescriptor releaseDescriptor, ReleaseEnvi private void checkin( ScmProvider provider, ScmRepository repository, ScmFileSet fileSet, ReleaseDescriptor releaseDescriptor, String message ) - throws ReleaseExecutionException, ReleaseScmCommandException + throws ReleaseExecutionException, ReleaseScmCommandException { CheckInScmResult result; try @@ -200,9 +205,9 @@ private void checkin( ScmProvider provider, ScmRepository repository, ScmFileSet *

simulateCheckins.

* * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param reactorProjects a {@link java.util.List} object - * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object - * @param message a {@link java.lang.String} object + * @param reactorProjects a {@link java.util.List} object + * @param result a {@link org.apache.maven.shared.release.ReleaseResult} object + * @param message a {@link java.lang.String} object */ protected void simulateCheckins( ReleaseDescriptor releaseDescriptor, List reactorProjects, ReleaseResult result, String message ) @@ -218,7 +223,7 @@ protected void simulateCheckins( ReleaseDescriptor releaseDescriptor, ListcreateMessage.

* - * @param reactorProjects a {@link java.util.List} object + * @param reactorProjects a {@link java.util.List} object * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object * @return a {@link java.lang.String} object * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. */ protected String createMessage( List reactorProjects, ReleaseDescriptor releaseDescriptor ) - throws ReleaseExecutionException + throws ReleaseExecutionException { String comment; boolean branch = false; @@ -259,9 +264,10 @@ else if ( "getScmRollbackCommitComment".equals( descriptorCommentGetter ) ) } else { - throw new ReleaseExecutionException( "Invalid configuration in components-fragment.xml" ); + throw new ReleaseExecutionException( + "Invalid configuration of descriptorCommentGetter='" + descriptorCommentGetter + "'" ); } - + MavenProject project = ReleaseUtil.getRootProject( reactorProjects ); comment = comment.replace( "@{prefix}", releaseDescriptor.getScmCommentPrefix().trim() ); comment = comment.replace( "@{groupId}", project.getGroupId() ); @@ -281,7 +287,7 @@ else if ( "getScmRollbackCommitComment".equals( descriptorCommentGetter ) ) *

createPomFiles.

* * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param project a {@link org.apache.maven.project.MavenProject} object + * @param project a {@link org.apache.maven.project.MavenProject} object * @return a {@link java.util.List} object */ protected static List createPomFiles( ReleaseDescriptor releaseDescriptor, MavenProject project ) @@ -302,7 +308,7 @@ protected static List createPomFiles( ReleaseDescriptor releaseDescriptor, *

createPomFiles.

* * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param reactorProjects a {@link java.util.List} object + * @param reactorProjects a {@link java.util.List} object * @return a {@link java.util.List} object */ protected static List createPomFiles( ReleaseDescriptor releaseDescriptor, diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPreparationPhase.java similarity index 75% rename from maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhase.java rename to maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPreparationPhase.java index b4a5bbfe7..5c36a2f5f 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractScmCommitPreparationPhase.java @@ -19,6 +19,8 @@ * under the License. */ +import java.util.List; + import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; @@ -27,31 +29,37 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; - -import java.util.List; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; /** * Commit the changes that were done to prepare the branch or tag to the SCM. * * @author Brett Porter */ -public class ScmCommitPreparationPhase - extends AbstractScmCommitPhase +public abstract class AbstractScmCommitPreparationPhase + extends AbstractScmCommitPhase { + protected AbstractScmCommitPreparationPhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + String descriptorCommentGetter ) + { + super( scmRepositoryConfigurator, descriptorCommentGetter ); + } + @Override protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, ReleaseResult result, boolean simulating ) - throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException + throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException { // no prepare-commit required if ( releaseDescriptor.isSuppressCommitBeforeTagOrBranch() ) { String parameterName; - if ( releaseDescriptor.isBranchCreation() ) + if ( releaseDescriptor.isBranchCreation() ) { parameterName = "suppressCommitBeforeBranch"; } - else + else { parameterName = "suppressCommitBeforeTag"; } @@ -59,12 +67,12 @@ protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment if ( simulating ) { logInfo( result, - "Full run would not commit changes, " + "because " + parameterName + " is set to true." ); + "Full run would not commit changes, " + "because " + parameterName + " is set to true." ); } else { logInfo( result, - "Modified POMs are not committed because " + parameterName + " is set to true." ); + "Modified POMs are not committed because " + parameterName + " is set to true." ); } } // commit development versions required @@ -83,14 +91,14 @@ protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment } protected void validateConfiguration( ReleaseDescriptor releaseDescriptor ) - throws ReleaseFailureException + throws ReleaseFailureException { super.validateConfiguration( releaseDescriptor ); if ( releaseDescriptor.isSuppressCommitBeforeTagOrBranch() && releaseDescriptor.isRemoteTagging() ) { throw new ReleaseFailureException( - "Cannot perform a remote tag or branch without committing the working copy first." ); + "Cannot perform a remote tag or branch without committing the working copy first." ); } } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhase.java new file mode 100644 index 000000000..c0ca7f540 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhase.java @@ -0,0 +1,48 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.Map; + +import org.apache.maven.shared.release.policy.naming.NamingPolicy; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; +import org.codehaus.plexus.components.interactivity.Prompter; + +/** + * Input any variables that were not yet configured. + * + * @author Brett Porter + */ +@Singleton +@Named( "branch-input-variables" ) +public class BranchInputVariablesPhase + extends AbstractInputVariablesPhase +{ + @Inject + public BranchInputVariablesPhase( Prompter prompter, ScmRepositoryConfigurator scmRepositoryConfigurator, + Map namingPolicies ) + { + super( prompter, scmRepositoryConfigurator, namingPolicies, true, null ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckCompletedPreparePhasesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckCompletedPreparePhasesPhase.java index 3424c1e34..15bc7a0f9 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckCompletedPreparePhasesPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckCompletedPreparePhasesPhase.java @@ -19,6 +19,9 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.List; import org.apache.maven.project.MavenProject; @@ -27,29 +30,29 @@ import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; /** * @author Emmanuel Venisse */ -@Component( role = ReleasePhase.class, hint = "verify-completed-prepare-phases" ) +@Singleton +@Named( "verify-completed-prepare-phases" ) public class CheckCompletedPreparePhasesPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); // if we stopped mid-way through preparation - don't perform if ( releaseDescriptor.getCompletedPhase() != null - && !"end-release".equals( releaseDescriptor.getCompletedPhase() ) ) + && !"end-release".equals( releaseDescriptor.getCompletedPhase() ) ) { String message = "Cannot perform release - the preparation step was stopped mid-way. Please re-run " - + "release:prepare to continue, or perform the release from an SCM tag."; + + "release:prepare to continue, or perform the release from an SCM tag."; result.setResultCode( ReleaseResult.ERROR ); @@ -78,7 +81,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects ); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java index 8c3614fa2..bc278ca7a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhase.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -28,6 +32,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -40,21 +45,22 @@ import org.apache.maven.shared.release.versions.DefaultVersionInfo; import org.apache.maven.shared.release.versions.VersionInfo; import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; +import static java.util.Objects.requireNonNull; + /** * Check the dependencies of all projects being released to see if there are any unreleased snapshots. * * @author Brett Porter */ - // TODO plugins with no version will be resolved to RELEASE which is not a snapshot, but remains unresolved to this point. This is a potential hole in the check, and should be revisited after the release pom writing is done and resolving versions to verify whether it is. - // TODO plugins injected by the lifecycle are not tested here. They will be injected with a RELEASE version so are covered under the above point. -@Component( role = ReleasePhase.class, hint = "check-dependency-snapshots" ) +// TODO plugins with no version will be resolved to RELEASE which is not a snapshot, but remains unresolved to this point. This is a potential hole in the check, and should be revisited after the release pom writing is done and resolving versions to verify whether it is. +// TODO plugins injected by the lifecycle are not tested here. They will be injected with a RELEASE version so are covered under the above point. +@Singleton +@Named( "check-dependency-snapshots" ) public class CheckDependencySnapshotsPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { public static final String RESOLVE_SNAPSHOT_MESSAGE = "There are still some remaining snapshot dependencies.\n"; @@ -63,30 +69,43 @@ public class CheckDependencySnapshotsPhase public static final String RESOLVE_SNAPSHOT_TYPE_MESSAGE = "Dependency type to resolve,"; public static final String RESOLVE_SNAPSHOT_TYPE_PROMPT = - "specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ):"; + "specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ):"; /** * Component used to prompt for input. */ - @Requirement - private Prompter prompter; - + private final AtomicReference prompter; + // Be aware of the difference between usedSnapshots and specifiedSnapshots: // UsedSnapshots end up on the classpath. // SpecifiedSnapshots are defined anywhere in the pom. // We'll probably need to introduce specifiedSnapshots as well. // @TODO MRELEASE-378: verify custom dependencies in plugins. Be aware of deprecated/removed Components in M3, such as PluginCollector // @TODO MRELEASE-763: verify all dependencies in inactive profiles - + // Don't prompt for every project in reactor, remember state of questions private String resolveSnapshot; private String resolveSnapshotType; - + + @Inject + public CheckDependencySnapshotsPhase( Prompter prompter ) + { + this.prompter = new AtomicReference<>( requireNonNull( prompter ) ); + } + + /** + * For easier testing only! + */ + public void setPrompter( Prompter prompter ) + { + this.prompter.set( prompter ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -109,10 +128,10 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro } private void checkProject( MavenProject project, ReleaseDescriptor releaseDescriptor ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { Map artifactMap = ArtifactUtils.artifactMapByVersionlessId( project.getArtifacts() ); - + Set usedSnapshotDependencies = new HashSet<>(); if ( project.getParentArtifact() != null ) @@ -142,16 +161,16 @@ private void checkProject( MavenProject project, ReleaseDescriptor releaseDescri //@todo check profiles if ( !usedSnapshotDependencies.isEmpty() || !usedSnapshotReports.isEmpty() - || !usedSnapshotExtensions.isEmpty() || !usedSnapshotPlugins.isEmpty() ) + || !usedSnapshotExtensions.isEmpty() || !usedSnapshotPlugins.isEmpty() ) { if ( releaseDescriptor.isInteractive() || null != releaseDescriptor.getAutoResolveSnapshots() ) { resolveSnapshots( usedSnapshotDependencies, usedSnapshotReports, usedSnapshotExtensions, - usedSnapshotPlugins, releaseDescriptor ); + usedSnapshotPlugins, releaseDescriptor ); } if ( !usedSnapshotDependencies.isEmpty() || !usedSnapshotReports.isEmpty() - || !usedSnapshotExtensions.isEmpty() || !usedSnapshotPlugins.isEmpty() ) + || !usedSnapshotExtensions.isEmpty() || !usedSnapshotPlugins.isEmpty() ) { StringBuilder message = new StringBuilder(); @@ -162,14 +181,14 @@ private void checkProject( MavenProject project, ReleaseDescriptor releaseDescri message.append( "in project '" + project.getName() + "' (" + project.getId() + ")" ); throw new ReleaseFailureException( - "Can't release project due to non released dependencies :\n" + message ); + "Can't release project due to non released dependencies :\n" + message ); } } } private Set checkPlugins( ReleaseDescriptor releaseDescriptor, - Map artifactMap, Set pluginArtifacts ) - throws ReleaseExecutionException + Map artifactMap, Set pluginArtifacts ) + throws ReleaseExecutionException { Set usedSnapshotPlugins = new HashSet<>(); for ( Artifact artifact : pluginArtifacts ) @@ -179,7 +198,7 @@ private Set checkPlugins( ReleaseDescriptor releaseDescriptor, boolean addToFailures; if ( "org.apache.maven.plugins".equals( artifact.getGroupId() ) && "maven-release-plugin".equals( - artifact.getArtifactId() ) ) + artifact.getArtifactId() ) ) { // It's a snapshot of the release plugin. Maybe just testing - ask // By default, we fail as for any other plugin @@ -194,24 +213,17 @@ else if ( releaseDescriptor.isInteractive() ) String result; if ( !releaseDescriptor.isSnapshotReleasePluginAllowed() ) { - prompter.showMessage( "This project relies on a SNAPSHOT of the release plugin. " - + "This may be necessary during testing.\n" ); - result = prompter.prompt( "Do you want to continue with the release?", - Arrays.asList( "yes", "no" ), "no" ); + prompter.get().showMessage( "This project relies on a SNAPSHOT of the release plugin. " + + "This may be necessary during testing.\n" ); + result = prompter.get().prompt( "Do you want to continue with the release?", + Arrays.asList( "yes", "no" ), "no" ); } else { result = "yes"; } - if ( result.toLowerCase( Locale.ENGLISH ).startsWith( "y" ) ) - { - addToFailures = false; - } - else - { - addToFailures = true; - } + addToFailures = !result.toLowerCase( Locale.ENGLISH ).startsWith( "y" ); } catch ( PrompterException e ) { @@ -238,8 +250,8 @@ else if ( releaseDescriptor.isInteractive() ) } private Set checkDependencies( ReleaseDescriptor releaseDescriptor, - Map artifactMap, - Set dependencyArtifacts ) + Map artifactMap, + Set dependencyArtifacts ) { Set usedSnapshotDependencies = new HashSet<>(); for ( Artifact artifact : dependencyArtifacts ) @@ -253,7 +265,7 @@ private Set checkDependencies( ReleaseDescriptor releaseDescriptor, } private Set checkReports( ReleaseDescriptor releaseDescriptor, - Map artifactMap, Set reportArtifacts ) + Map artifactMap, Set reportArtifacts ) { Set usedSnapshotReports = new HashSet<>(); for ( Artifact artifact : reportArtifacts ) @@ -268,7 +280,7 @@ private Set checkReports( ReleaseDescriptor releaseDescriptor, } private Set checkExtensions( ReleaseDescriptor releaseDescriptor, - Map artifactMap, Set extensionArtifacts ) + Map artifactMap, Set extensionArtifacts ) { Set usedSnapshotExtensions = new HashSet<>(); for ( Artifact artifact : extensionArtifacts ) @@ -308,19 +320,19 @@ private static boolean checkArtifact( Artifact artifact, ReleaseDescriptor relea String releaseDescriptorResolvedVersion = releaseDescriptor.getDependencyReleaseVersion( versionlessKey ); boolean releaseDescriptorResolvedVersionIsSnapshot = releaseDescriptorResolvedVersion == null - || releaseDescriptorResolvedVersion.contains( Artifact.SNAPSHOT_VERSION ); - + || releaseDescriptorResolvedVersion.contains( Artifact.SNAPSHOT_VERSION ); + // We are only looking at dependencies external to the project - ignore anything found in the reactor as // it's version will be updated boolean bannedVersion = artifact.isSnapshot() && !artifact.getBaseVersion().equals( releaseDescriptor.getProjectOriginalVersion( versionlessKey ) ) - && releaseDescriptorResolvedVersionIsSnapshot; + && releaseDescriptorResolvedVersionIsSnapshot; // If we have a snapshot but allowTimestampedSnapshots is true, accept the artifact if the version // indicates that it is a timestamped snapshot. if ( bannedVersion && releaseDescriptor.isAllowTimestampedSnapshots() ) { - bannedVersion = artifact.getVersion().indexOf( Artifact.SNAPSHOT_VERSION ) >= 0; + bannedVersion = artifact.getVersion().contains( Artifact.SNAPSHOT_VERSION ); } return bannedVersion; @@ -329,18 +341,13 @@ private static boolean checkArtifact( Artifact artifact, ReleaseDescriptor relea @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { // It makes no modifications, so simulate is the same as execute return execute( releaseDescriptor, releaseEnvironment, reactorProjects ); } - public void setPrompter( Prompter prompter ) - { - this.prompter = prompter; - } - - private StringBuilder printSnapshotDependencies( Set snapshotsSet, StringBuilder message ) + private void printSnapshotDependencies( Set snapshotsSet, StringBuilder message ) { List snapshotsList = new ArrayList<>( snapshotsSet ); @@ -354,29 +361,28 @@ private StringBuilder printSnapshotDependencies( Set snapshotsSet, Str message.append( "\n" ); } - - return message; } private void resolveSnapshots( Set projectDependencies, Set reportDependencies, Set extensionDependencies, Set pluginDependencies, ReleaseDescriptor releaseDescriptor ) - throws ReleaseExecutionException + throws ReleaseExecutionException { try { String autoResolveSnapshots = releaseDescriptor.getAutoResolveSnapshots(); if ( resolveSnapshot == null ) { - prompter.showMessage( RESOLVE_SNAPSHOT_MESSAGE ); + prompter.get().showMessage( RESOLVE_SNAPSHOT_MESSAGE ); if ( autoResolveSnapshots != null ) { resolveSnapshot = "yes"; - prompter.showMessage( RESOLVE_SNAPSHOT_PROMPT + " " + resolveSnapshot ); + prompter.get().showMessage( RESOLVE_SNAPSHOT_PROMPT + " " + resolveSnapshot ); } else { - resolveSnapshot = prompter.prompt( RESOLVE_SNAPSHOT_PROMPT, Arrays.asList( "yes", "no" ), "no" ); + resolveSnapshot = + prompter.get().prompt( RESOLVE_SNAPSHOT_PROMPT, Arrays.asList( "yes", "no" ), "no" ); } } @@ -384,7 +390,7 @@ private void resolveSnapshots( Set projectDependencies, Set { if ( resolveSnapshotType == null ) { - prompter.showMessage( RESOLVE_SNAPSHOT_TYPE_MESSAGE ); + prompter.get().showMessage( RESOLVE_SNAPSHOT_TYPE_MESSAGE ); int defaultAnswer = -1; if ( autoResolveSnapshots != null ) { @@ -422,13 +428,15 @@ else if ( "extensions".equalsIgnoreCase( autoResolveSnapshots ) ) } if ( defaultAnswer >= 0 && defaultAnswer <= 4 ) { - prompter.showMessage( RESOLVE_SNAPSHOT_TYPE_PROMPT + " " + autoResolveSnapshots ); + prompter.get().showMessage( RESOLVE_SNAPSHOT_TYPE_PROMPT + " " + autoResolveSnapshots ); resolveSnapshotType = Integer.toString( defaultAnswer ); } else { resolveSnapshotType = - prompter.prompt( RESOLVE_SNAPSHOT_TYPE_PROMPT, Arrays.asList( "0", "1", "2", "3" ), "1" ); + prompter.get() + .prompt( RESOLVE_SNAPSHOT_TYPE_PROMPT, Arrays.asList( "0", "1", "2", "3" ), + "1" ); } } @@ -442,22 +450,22 @@ else if ( "extensions".equalsIgnoreCase( autoResolveSnapshots ) ) processSnapshot( extensionDependencies, releaseDescriptor, autoResolveSnapshots ); break; - // project dependencies + // project dependencies case 1: processSnapshot( projectDependencies, releaseDescriptor, autoResolveSnapshots ); break; - // plugins + // plugins case 2: processSnapshot( pluginDependencies, releaseDescriptor, autoResolveSnapshots ); break; - // reports + // reports case 3: processSnapshot( reportDependencies, releaseDescriptor, autoResolveSnapshots ); break; - // extensions + // extensions case 4: processSnapshot( extensionDependencies, releaseDescriptor, autoResolveSnapshots ); break; @@ -474,7 +482,7 @@ else if ( "extensions".equalsIgnoreCase( autoResolveSnapshots ) ) private void processSnapshot( Set snapshotSet, ReleaseDescriptor releaseDescriptor, String autoResolveSnapshots ) - throws PrompterException, VersionParseException + throws PrompterException, VersionParseException { Iterator iterator = snapshotSet.iterator(); @@ -486,20 +494,20 @@ private void processSnapshot( Set snapshotSet, ReleaseDescriptor relea VersionInfo versionInfo = new DefaultVersionInfo( currentArtifact.getBaseVersion() ); releaseDescriptor.addDependencyOriginalVersion( versionlessKey, versionInfo.toString() ); - prompter.showMessage( - "Dependency '" + versionlessKey + "' is a snapshot (" + currentArtifact.getVersion() + ")\n" ); + prompter.get().showMessage( + "Dependency '" + versionlessKey + "' is a snapshot (" + currentArtifact.getVersion() + ")\n" ); String message = "Which release version should it be set to?"; String result; if ( null != autoResolveSnapshots ) { result = versionInfo.getReleaseVersionString(); - prompter.showMessage( message + " " + result ); + prompter.get().showMessage( message + " " + result ); } else { - result = prompter.prompt( message, versionInfo.getReleaseVersionString() ); + result = prompter.get().prompt( message, versionInfo.getReleaseVersionString() ); } - + releaseDescriptor.addDependencyReleaseVersion( versionlessKey, result ); iterator.remove(); @@ -522,13 +530,13 @@ private void processSnapshot( Set snapshotSet, ReleaseDescriptor relea if ( null != autoResolveSnapshots ) { result = nextVersion; - prompter.showMessage( message + " " + result ); + prompter.get().showMessage( message + " " + result ); } else { - result = prompter.prompt( message, nextVersion ); + result = prompter.get().prompt( message, nextVersion ); } - + releaseDescriptor.addDependencyDevelopmentVersion( versionlessKey, result ); } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsPhase.java new file mode 100644 index 000000000..f1f15c6b6 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsPhase.java @@ -0,0 +1,43 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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 org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Phase that checks the validity of the POM before release. + * + * @author Brett Porter + */ +@Singleton +@Named( "check-poms" ) +public class CheckPomsPhase + extends AbstractCheckPomPhase +{ + @Inject + public CheckPomsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator, true, true ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsUpdateversionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsUpdateversionsPhase.java new file mode 100644 index 000000000..108e5ba0a --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckPomsUpdateversionsPhase.java @@ -0,0 +1,43 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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 org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Phase that checks the validity of the POM before release. + * + * @author Brett Porter + */ +@Singleton +@Named( "check-poms-updateversions" ) +public class CheckPomsUpdateversionsPhase + extends AbstractCheckPomPhase +{ + @Inject + public CheckPomsUpdateversionsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator, false, false ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java index 76e55343d..29e4308fd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.IOException; import java.nio.file.LinkOption; @@ -46,30 +50,36 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; +import static java.util.Objects.requireNonNull; + /** * @author Emmanuel Venisse */ -@Component( role = ReleasePhase.class, hint = "checkout-project-from-scm" ) +@Singleton +@Named( "checkout-project-from-scm" ) public class CheckoutProjectFromScm - extends AbstractReleasePhase + extends AbstractReleasePhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + @Inject + public CheckoutProjectFromScm( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) throws ReleaseExecutionException, ReleaseFailureException { - ReleaseResult releaseResult = null; + ReleaseResult releaseResult; if ( releaseDescriptor.isLocalCheckout() ) { @@ -133,7 +143,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro // when there is no localCheckout, then we just do a standard SCM checkout. try { - releaseResult = performCheckout( releaseDescriptor, releaseEnvironment, reactorProjects ); + releaseResult = performCheckout( releaseDescriptor, releaseEnvironment, reactorProjects ); } catch ( ScmException e ) { @@ -142,7 +152,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro logError( releaseResult, e.getMessage() ); throw new ReleaseExecutionException( "An error is occurred in the checkout process: " - + e.getMessage(), e ); + + e.getMessage(), e ); } } @@ -152,8 +162,8 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, - List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException, ScmException + List reactorProjects ) + throws ReleaseExecutionException, ReleaseFailureException, ScmException { ReleaseResult result = new ReleaseResult(); @@ -165,7 +175,7 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele try { repository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + releaseEnvironment.getSettings() ); provider = scmRepositoryConfigurator.getRepositoryProvider( repository ); } @@ -188,7 +198,7 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele // TODO: sanity check that it is not . or .. or lower File checkoutDirectory = - FileUtils.resolveFile( rootProject.getBasedir(), releaseDescriptor.getCheckoutDirectory() ); + FileUtils.resolveFile( rootProject.getBasedir(), releaseDescriptor.getCheckoutDirectory() ); if ( checkoutDirectory.exists() ) { @@ -211,7 +221,7 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele commandParameters.setString( CommandParameter.SHALLOW, Boolean.TRUE.toString() ); CheckOutScmResult scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ), - new ScmTag( releaseDescriptor.getScmReleaseLabel() ), commandParameters ); + new ScmTag( releaseDescriptor.getScmReleaseLabel() ), commandParameters ); if ( releaseDescriptor.isLocalCheckout() && !scmResult.isSuccess() ) { @@ -234,7 +244,7 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele { throw new ReleaseExecutionException( e.getMessage(), e ); } - + scmRelativePathProjectDirectory = workingDirectory.relativize( rootProjectBasedir ).toString(); } releaseDescriptor.setScmRelativePathProjectDirectory( scmRelativePathProjectDirectory ); @@ -255,7 +265,7 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java index bf07fd629..866c9a20e 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CreateBackupPomsPhase.java @@ -19,6 +19,9 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.IOException; import java.util.List; @@ -29,20 +32,20 @@ import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.FileUtils; /** * @author Edwin Punzalan */ -@Component( role = ReleasePhase.class, hint = "create-backup-poms" ) +@Singleton +@Named( "create-backup-poms" ) public class CreateBackupPomsPhase - extends AbstractBackupPomsPhase implements ResourceGenerator + extends AbstractBackupPomsPhase implements ResourceGenerator { @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -77,13 +80,13 @@ public ReleaseResult clean( List reactorProjects ) @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects ); } private void createPomBackup( MavenProject project ) - throws ReleaseExecutionException + throws ReleaseExecutionException { // delete any existing backup first deletePomBackup( project ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/EndReleasePhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/EndReleasePhase.java index 123c0a35f..b55cf2f93 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/EndReleasePhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/EndReleasePhase.java @@ -19,29 +19,32 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.List; + import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; - -import java.util.List; /** * Finalise release preparation so it can be flagged complete.. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "end-release" ) +@Singleton +@Named( "end-release" ) public class EndReleasePhase - extends AbstractReleasePhase + extends AbstractReleasePhase { @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -55,7 +58,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java index fc6381487..9a2ec0f9e 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhase.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.io.IOException; import java.io.Writer; @@ -38,7 +42,6 @@ import org.apache.maven.model.Extension; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; -import org.apache.maven.model.Profile; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.Reporting; import org.apache.maven.model.Resource; @@ -60,35 +63,46 @@ import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.WriterFactory; +import static java.util.Objects.requireNonNull; + /** * Generate release POMs. * * @author Brett Porter * @author Mark Hobson */ -@Component( role = ReleasePhase.class, hint = "generate-release-poms" ) +@Singleton +@Named( "generate-release-poms" ) public class GenerateReleasePomsPhase - extends AbstractReleasePomsPhase implements ResourceGenerator + extends AbstractReleasePomsPhase implements ResourceGenerator { private static final String FINALNAME_EXPRESSION = "${project.artifactId}-${project.version}"; - @Requirement - private SuperPomProvider superPomProvider; + private final SuperPomProvider superPomProvider; - @Requirement - private ModelInterpolator modelInterpolator; + private final ModelInterpolator modelInterpolator; /** * SCM URL translators mapped by provider name. */ - @Requirement( role = ScmTranslator.class ) - private Map scmTranslators; + private final Map scmTranslators; + + @Inject + public GenerateReleasePomsPhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + SuperPomProvider superPomProvider, ModelInterpolator modelInterpolator, + Map scmTranslators ) + { + super( scmRepositoryConfigurator ); + this.superPomProvider = requireNonNull( superPomProvider ); + this.modelInterpolator = requireNonNull( modelInterpolator ); + this.scmTranslators = requireNonNull( scmTranslators ); + } /* * @see org.apache.maven.shared.release.phase.ReleasePhase#execute(org.apache.maven.shared.release.config.ReleaseDescriptor, @@ -97,14 +111,14 @@ public class GenerateReleasePomsPhase @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects, false ); } private ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, boolean simulate ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -126,7 +140,7 @@ private ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvir private void generateReleasePoms( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, boolean simulate, ReleaseResult result ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { List releasePoms = new ArrayList<>(); @@ -143,7 +157,7 @@ private void generateReleasePoms( ReleaseDescriptor releaseDescriptor, ReleaseEn private File generateReleasePom( MavenProject project, ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, ReleaseResult result ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { // create release pom @@ -161,9 +175,8 @@ private File generateReleasePom( MavenProject project, ReleaseDescriptor release throw new ReleaseExecutionException( "Cannot generate release POM : pom file is null" ); } - - try ( Writer fileWriter = WriterFactory.newXmlWriter( releasePomFile ) ) + try ( Writer fileWriter = WriterFactory.newXmlWriter( releasePomFile ) ) { pomWriter.write( fileWriter, releasePom ); } @@ -178,7 +191,7 @@ private File generateReleasePom( MavenProject project, ReleaseDescriptor release private void addReleasePomsToScm( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, boolean simulate, ReleaseResult result, List releasePoms ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { if ( simulate ) { @@ -204,7 +217,7 @@ private void addReleasePomsToScm( ReleaseDescriptor releaseDescriptor, ReleaseEn catch ( ScmException exception ) { throw new ReleaseExecutionException( "Cannot add release POM to SCM: " + exception.getMessage(), - exception ); + exception ); } } } @@ -212,7 +225,7 @@ private void addReleasePomsToScm( ReleaseDescriptor releaseDescriptor, ReleaseEn private Model createReleaseModel( MavenProject project, ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, ReleaseResult result ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { MavenProject releaseProject = project.clone(); Model releaseModel = releaseProject.getModel(); @@ -220,14 +233,14 @@ private Model createReleaseModel( MavenProject project, ReleaseDescriptor releas // the release POM should reflect bits of these which were injected at build time... // we don't need these polluting the POM. releaseModel.setParent( null ); - releaseModel.setProfiles( Collections.emptyList() ); + releaseModel.setProfiles( Collections.emptyList() ); releaseModel.setDependencyManagement( null ); releaseProject.getBuild().setPluginManagement( null ); // update project version String projectVersion = releaseModel.getVersion(); String releaseVersion = - getNextVersion( releaseDescriptor, project.getGroupId(), project.getArtifactId() ); + getNextVersion( releaseDescriptor, project.getGroupId(), project.getArtifactId() ); releaseModel.setVersion( releaseVersion ); String originalFinalName = releaseModel.getBuild().getFinalName(); @@ -247,10 +260,10 @@ private Model createReleaseModel( MavenProject project, ReleaseDescriptor releas String finalName = ReleaseUtil.interpolate( originalFinalName, releaseModel ); // still required? - if ( finalName.indexOf( Artifact.SNAPSHOT_VERSION ) != -1 ) + if ( finalName.contains( Artifact.SNAPSHOT_VERSION ) ) { throw new ReleaseFailureException( "Cannot reliably adjust the finalName of project: " - + releaseProject.getId() ); + + releaseProject.getId() ); } releaseModel.getBuild().setFinalName( finalName ); @@ -284,12 +297,12 @@ private Model createReleaseModel( MavenProject project, ReleaseDescriptor releas releaseModel.getBuild().setPlugins( createReleasePlugins( releaseDescriptor, releaseProject ) ); // rewrite reports - releaseModel.getReporting().setPlugins( createReleaseReportPlugins( releaseDescriptor, - releaseProject ) ); + releaseModel.getReporting().setPlugins( createReleaseReportPlugins( releaseDescriptor, + releaseProject ) ); // rewrite extensions - releaseModel.getBuild().setExtensions( createReleaseExtensions( releaseDescriptor, - releaseProject ) ); + releaseModel.getBuild().setExtensions( createReleaseExtensions( releaseDescriptor, + releaseProject ) ); unalignFromBaseDirectory( releaseModel, project.getBasedir() ); @@ -311,63 +324,62 @@ private void unalignFromBaseDirectory( Model releaseModel, File basedir ) buildingRequest.setUserProperties( properties ); Model interpolatedSuperModel = - modelInterpolator.interpolateModel( rawSuperModel.clone(), basedir, buildingRequest, null ); + modelInterpolator.interpolateModel( rawSuperModel.clone(), basedir, buildingRequest, null ); Build currentBuild = releaseModel.getBuild(); Build interpolatedSuperBuild = interpolatedSuperModel.getBuild(); Build rawSuperBuild = rawSuperModel.getBuild(); currentBuild.setSourceDirectory( resolvePath( basedir.toPath(), currentBuild.getSourceDirectory(), - interpolatedSuperBuild.getSourceDirectory(), - rawSuperBuild.getSourceDirectory() ) ); + interpolatedSuperBuild.getSourceDirectory(), + rawSuperBuild.getSourceDirectory() ) ); currentBuild.setScriptSourceDirectory( resolvePath( basedir.toPath(), currentBuild.getScriptSourceDirectory(), - interpolatedSuperBuild.getScriptSourceDirectory(), - rawSuperBuild.getScriptSourceDirectory() ) ); + interpolatedSuperBuild.getScriptSourceDirectory(), + rawSuperBuild.getScriptSourceDirectory() ) ); currentBuild.setTestSourceDirectory( resolvePath( basedir.toPath(), currentBuild.getTestSourceDirectory(), - interpolatedSuperBuild.getTestSourceDirectory(), - rawSuperBuild.getTestSourceDirectory() ) ); + interpolatedSuperBuild.getTestSourceDirectory(), + rawSuperBuild.getTestSourceDirectory() ) ); currentBuild.setOutputDirectory( resolvePath( basedir.toPath(), currentBuild.getOutputDirectory(), - interpolatedSuperBuild.getOutputDirectory(), - rawSuperBuild.getOutputDirectory() ) ); + interpolatedSuperBuild.getOutputDirectory(), + rawSuperBuild.getOutputDirectory() ) ); currentBuild.setTestOutputDirectory( resolvePath( basedir.toPath(), currentBuild.getTestOutputDirectory(), - interpolatedSuperBuild.getTestOutputDirectory(), - rawSuperBuild.getTestOutputDirectory() ) ); + interpolatedSuperBuild.getTestOutputDirectory(), + rawSuperBuild.getTestOutputDirectory() ) ); currentBuild.setDirectory( resolvePath( basedir.toPath(), currentBuild.getDirectory(), - interpolatedSuperBuild.getDirectory(), - rawSuperBuild.getDirectory() ) ); + interpolatedSuperBuild.getDirectory(), + rawSuperBuild.getDirectory() ) ); for ( Resource currentResource : currentBuild.getResources() ) { Map superResourceDirectories = - new LinkedHashMap<>( interpolatedSuperBuild.getResources().size() ); + new LinkedHashMap<>( interpolatedSuperBuild.getResources().size() ); for ( int i = 0; i < interpolatedSuperBuild.getResources().size(); i++ ) { superResourceDirectories.put( interpolatedSuperBuild.getResources().get( i ).getDirectory(), - rawSuperBuild.getResources().get( i ).getDirectory() ); + rawSuperBuild.getResources().get( i ).getDirectory() ); } currentResource.setDirectory( resolvePath( basedir.toPath(), currentResource.getDirectory(), - superResourceDirectories ) ); + superResourceDirectories ) ); } for ( Resource currentResource : currentBuild.getTestResources() ) { Map superResourceDirectories = - new LinkedHashMap<>( interpolatedSuperBuild.getTestResources().size() ); + new LinkedHashMap<>( interpolatedSuperBuild.getTestResources().size() ); for ( int i = 0; i < interpolatedSuperBuild.getTestResources().size(); i++ ) { superResourceDirectories.put( interpolatedSuperBuild.getTestResources().get( i ).getDirectory(), - rawSuperBuild.getTestResources().get( i ).getDirectory() ); + rawSuperBuild.getTestResources().get( i ).getDirectory() ); } currentResource.setDirectory( resolvePath( basedir.toPath(), currentResource.getDirectory(), - superResourceDirectories ) ); + superResourceDirectories ) ); } - releaseModel.getReporting().setOutputDirectory( resolvePath( basedir.toPath(), - releaseModel.getReporting().getOutputDirectory(), - interpolatedSuperModel.getReporting().getOutputDirectory(), - rawSuperModel.getReporting().getOutputDirectory() ) ); + releaseModel.getReporting().getOutputDirectory(), + interpolatedSuperModel.getReporting().getOutputDirectory(), + rawSuperModel.getReporting().getOutputDirectory() ) ); } private String resolvePath( Path basedir, String current, String superInterpolated, String superRaw ) @@ -392,7 +404,7 @@ private String resolvePath( Path basedir, private String findOriginalFinalName( MavenProject project ) { if ( project.getOriginalModel().getBuild() != null - && project.getOriginalModel().getBuild().getFinalName() != null ) + && project.getOriginalModel().getBuild().getFinalName() != null ) { return project.getOriginalModel().getBuild().getFinalName(); } @@ -409,13 +421,13 @@ else if ( project.hasParent() ) @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects, true ); } private String getNextVersion( ReleaseDescriptor releaseDescriptor, String groupId, String artifactId ) - throws ReleaseFailureException + throws ReleaseFailureException { // TODO: share with RewritePomsForReleasePhase.rewriteVersion @@ -474,7 +486,7 @@ private Scm createReleaseScm( Scm scm, ScmTranslator scmTranslator, ReleaseDescr private List createReleaseDependencies( ReleaseDescriptor releaseDescriptor, MavenProject project ) - throws ReleaseFailureException + throws ReleaseFailureException { Set artifacts = project.getArtifacts(); @@ -483,8 +495,7 @@ private List createReleaseDependencies( ReleaseDescriptor releaseDes if ( artifacts != null ) { // make dependency order deterministic for tests (related to MNG-1412) - List orderedArtifacts = new ArrayList<>(); - orderedArtifacts.addAll( artifacts ); + List orderedArtifacts = new ArrayList<>( artifacts ); Collections.sort( orderedArtifacts ); releaseDependencies = new ArrayList<>(); @@ -512,7 +523,7 @@ private List createReleaseDependencies( ReleaseDescriptor releaseDes private String getReleaseVersion( ReleaseDescriptor releaseDescriptor, Artifact artifact ) - throws ReleaseFailureException + throws ReleaseFailureException { String key = ArtifactUtils.versionlessKey( artifact ); @@ -545,7 +556,7 @@ private String getReleaseVersion( ReleaseDescriptor releaseDescriptor, private List createReleasePlugins( ReleaseDescriptor releaseDescriptor, MavenProject project ) - throws ReleaseFailureException + throws ReleaseFailureException { List releasePlugins = null; @@ -592,7 +603,7 @@ private List createReleasePlugins( ReleaseDescriptor releaseDescriptor, private List createReleaseReportPlugins( ReleaseDescriptor releaseDescriptor, MavenProject project ) - throws ReleaseFailureException + throws ReleaseFailureException { List releaseReportPlugins = null; @@ -632,7 +643,7 @@ private List createReleaseReportPlugins( ReleaseDescriptor release private List createReleaseExtensions( ReleaseDescriptor releaseDescriptor, MavenProject project ) - throws ReleaseFailureException + throws ReleaseFailureException { List releaseExtensions = null; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java index bdf292fbd..4460b7b93 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/InputVariablesPhase.java @@ -19,277 +19,30 @@ * under the License. */ -import java.util.List; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.Map; -import java.util.Properties; -import org.apache.maven.artifact.ArtifactUtils; -import org.apache.maven.project.MavenProject; -import org.apache.maven.scm.manager.NoSuchScmProviderException; -import org.apache.maven.scm.provider.ScmProvider; -import org.apache.maven.scm.repository.ScmRepository; -import org.apache.maven.scm.repository.ScmRepositoryException; -import org.apache.maven.shared.release.ReleaseExecutionException; -import org.apache.maven.shared.release.ReleaseResult; -import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.apache.maven.shared.release.policy.PolicyException; import org.apache.maven.shared.release.policy.naming.NamingPolicy; -import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; -import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; -import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.components.interactivity.Prompter; -import org.codehaus.plexus.components.interactivity.PrompterException; -import org.codehaus.plexus.interpolation.InterpolationException; -import org.codehaus.plexus.interpolation.Interpolator; -import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor; -import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource; -import org.codehaus.plexus.interpolation.RecursionInterceptor; -import org.codehaus.plexus.interpolation.StringSearchInterpolator; -import org.codehaus.plexus.util.StringUtils; /** * Input any variables that were not yet configured. * * @author Brett Porter */ +@Singleton +@Named( "input-variables" ) public class InputVariablesPhase - extends AbstractReleasePhase + extends AbstractInputVariablesPhase { - /** - * Component used to prompt for input. - */ - @Requirement - private Prompter prompter; - - /** - * Whether this is a branch or a tag operation. - */ - private boolean branchOperation; - - /** - * Tool that gets a configured SCM repository from release configuration. - */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; - - /** - * Component used for custom or default naming policy - */ - @Requirement - private Map namingPolicies; - - /** - * The default naming policy to apply, if any - */ - private String defaultNamingPolicy; - - void setPrompter( Prompter prompter ) - { - this.prompter = prompter; - } - - boolean isBranchOperation() - { - return branchOperation; - } - - /** - *

getScmProvider.

- * - * @param releaseDescriptor a {@link org.apache.maven.shared.release.config.ReleaseDescriptor} object - * @param releaseEnvironment a {@link org.apache.maven.shared.release.env.ReleaseEnvironment} object - * @return a {@link org.apache.maven.scm.provider.ScmProvider} object - * @throws org.apache.maven.shared.release.scm.ReleaseScmRepositoryException if any. - * @throws org.apache.maven.shared.release.ReleaseExecutionException if any. - */ - protected ScmProvider getScmProvider( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment ) - throws ReleaseScmRepositoryException, ReleaseExecutionException - { - try - { - ScmRepository repository = - scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); - - return scmRepositoryConfigurator.getRepositoryProvider( repository ); - } - catch ( ScmRepositoryException e ) - { - throw new ReleaseScmRepositoryException( - e.getMessage() + " for URL: " + releaseDescriptor.getScmSourceUrl(), e.getValidationMessages() ); - } - catch ( NoSuchScmProviderException e ) - { - throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e ); - } - } - - @Override - public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, - List reactorProjects ) - throws ReleaseExecutionException - { - ReleaseResult result = new ReleaseResult(); - - // get the root project - MavenProject project = ReleaseUtil.getRootProject( reactorProjects ); - - String tag = releaseDescriptor.getScmReleaseLabel(); - - if ( tag == null ) - { - // Must get default version from mapped versions, as the project will be the incorrect snapshot - String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ); - String releaseVersion = releaseDescriptor.getProjectReleaseVersion( key ); - if ( releaseVersion == null ) - { - throw new ReleaseExecutionException( "Project tag cannot be selected if version is not yet mapped" ); - } - - String suggestedName; - String scmTagNameFormat = releaseDescriptor.getScmTagNameFormat(); - if ( releaseDescriptor.getProjectNamingPolicyId() != null ) - { - try - { - suggestedName = - resolveSuggestedName( releaseDescriptor.getProjectNamingPolicyId(), releaseVersion, project ); - } - catch ( PolicyException e ) - { - throw new ReleaseExecutionException( e.getMessage(), e ); - } - } - else if ( scmTagNameFormat != null ) - { - Interpolator interpolator = new StringSearchInterpolator( "@{", "}" ); - List possiblePrefixes = java.util.Arrays.asList( "project", "pom" ); - Properties values = new Properties(); - values.setProperty( "artifactId", project.getArtifactId() ); - values.setProperty( "groupId", project.getGroupId() ); - values.setProperty( "version", releaseVersion ); - interpolator.addValueSource( new PrefixedPropertiesValueSource( possiblePrefixes, values, true ) ); - RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( possiblePrefixes ); - try - { - suggestedName = interpolator.interpolate( scmTagNameFormat, recursionInterceptor ); - } - catch ( InterpolationException e ) - { - throw new ReleaseExecutionException( - "Could not interpolate specified tag name format: " + scmTagNameFormat, e ); - } - } - else - { - try - { - suggestedName = resolveSuggestedName( defaultNamingPolicy, releaseVersion, project ); - } - catch ( PolicyException e ) - { - throw new ReleaseExecutionException( e.getMessage(), e ); - } - } - - ScmProvider provider = null; - try - { - provider = getScmProvider( releaseDescriptor, releaseEnvironment ); - } - catch ( ReleaseScmRepositoryException e ) - { - throw new ReleaseExecutionException( - "No scm provider can be found for url: " + releaseDescriptor.getScmSourceUrl(), e ); - } - - suggestedName = provider.sanitizeTagName( suggestedName ); - - if ( releaseDescriptor.isInteractive() ) - { - try - { - if ( branchOperation ) - { - tag = prompter.prompt( "What is the branch name for \"" + project.getName() + "\"? (" - + project.getGroupId() + ":" + project.getArtifactId() + ")" ); - if ( StringUtils.isEmpty( tag ) ) - { - throw new ReleaseExecutionException( "No branch name was given." ); - } - } - else - { - tag = prompter.prompt( "What is the SCM release tag or label for \"" + project.getName() - + "\"? (" + project.getGroupId() + ":" + project.getArtifactId() + ")", suggestedName ); - } - } - catch ( PrompterException e ) - { - throw new ReleaseExecutionException( "Error reading version from input handler: " + e.getMessage(), - e ); - } - } - else if ( suggestedName == null ) - { - if ( isBranchOperation() ) - { - throw new ReleaseExecutionException( "No branch name was given." ); - } - else - { - throw new ReleaseExecutionException( "No tag name was given." ); - } - } - else - { - tag = suggestedName; - } - releaseDescriptor.setScmReleaseLabel( tag ); - } - - result.setResultCode( ReleaseResult.SUCCESS ); - - return result; - } - - @Override - public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, - List reactorProjects ) - throws ReleaseExecutionException + @Inject + public InputVariablesPhase( Prompter prompter, ScmRepositoryConfigurator scmRepositoryConfigurator, + Map namingPolicies ) { - ReleaseResult result = new ReleaseResult(); - - // It makes no modifications, so simulate is the same as execute - execute( releaseDescriptor, releaseEnvironment, reactorProjects ); - - result.setResultCode( ReleaseResult.SUCCESS ); - - return result; - } - - private String resolveSuggestedName( String policyId, String version, MavenProject project ) - throws PolicyException - { - if ( policyId == null ) - { - return null; - } - - NamingPolicy policy = namingPolicies.get( policyId ); - if ( policy == null ) - { - throw new PolicyException( "Policy '" + policyId + "' is unknown, available: " - + namingPolicies.keySet() ); - } - - NamingPolicyRequest request = new NamingPolicyRequest() - .setGroupId( project.getGroupId() ) - .setArtifactId( project.getArtifactId() ) - .setVersion( version ); - return policy.getName( request ).getName(); + super( prompter, scmRepositoryConfigurator, namingPolicies, false, "default" ); } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapBranchVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapBranchVersionsPhase.java new file mode 100644 index 000000000..ae81496fd --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapBranchVersionsPhase.java @@ -0,0 +1,68 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.Map; + +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.codehaus.plexus.components.interactivity.Prompter; + +/** + * Map projects to their new versions after release / into the next development cycle. + *

+ * The map-phases per goal are: + *

+ *
release:prepare
map-release-versions + map-development-versions; RD.isBranchCreation() = false
+ *
release:branch
map-branch-versions + map-development-versions; RD.isBranchCreation() = true
+ *
release:update-versions
map-development-versions; RD.isBranchCreation() = false
+ *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
MapVersionsPhase
MapVersionsPhase fieldmap-release-versionsmap-branch-versionsmap-development-versions
convertToSnapshot false true true
convertToBranch false true false
+ * + * @author Brett Porter + * @author Robert Scholte + */ +@Singleton +@Named( "map-branch-versions" ) +public class MapBranchVersionsPhase + extends AbstractMapVersionsPhase +{ + @Inject + public MapBranchVersionsPhase( Prompter prompter, Map versionPolicies ) + { + super( prompter, versionPolicies, true, true ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionsPhase.java new file mode 100644 index 000000000..d0ab04af7 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionsPhase.java @@ -0,0 +1,68 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.Map; + +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.codehaus.plexus.components.interactivity.Prompter; + +/** + * Map projects to their new versions after release / into the next development cycle. + *

+ * The map-phases per goal are: + *

+ *
release:prepare
map-release-versions + map-development-versions; RD.isBranchCreation() = false
+ *
release:branch
map-branch-versions + map-development-versions; RD.isBranchCreation() = true
+ *
release:update-versions
map-development-versions; RD.isBranchCreation() = false
+ *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
MapVersionsPhase
MapVersionsPhase fieldmap-release-versionsmap-branch-versionsmap-development-versions
convertToSnapshot false true true
convertToBranch false true false
+ * + * @author Brett Porter + * @author Robert Scholte + */ +@Singleton +@Named( "map-development-versions" ) +public class MapDevelopmentVersionsPhase + extends AbstractMapVersionsPhase +{ + @Inject + public MapDevelopmentVersionsPhase( Prompter prompter, Map versionPolicies ) + { + super( prompter, versionPolicies, true, false ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapReleaseVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapReleaseVersionsPhase.java new file mode 100644 index 000000000..c785f8aba --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/MapReleaseVersionsPhase.java @@ -0,0 +1,68 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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.Map; + +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.codehaus.plexus.components.interactivity.Prompter; + +/** + * Map projects to their new versions after release / into the next development cycle. + *

+ * The map-phases per goal are: + *

+ *
release:prepare
map-release-versions + map-development-versions; RD.isBranchCreation() = false
+ *
release:branch
map-branch-versions + map-development-versions; RD.isBranchCreation() = true
+ *
release:update-versions
map-development-versions; RD.isBranchCreation() = false
+ *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + *
MapVersionsPhase
MapVersionsPhase fieldmap-release-versionsmap-branch-versionsmap-development-versions
convertToSnapshot false true true
convertToBranch false true false
+ * + * @author Brett Porter + * @author Robert Scholte + */ +@Singleton +@Named( "map-release-versions" ) +public class MapReleaseVersionsPhase + extends AbstractMapVersionsPhase +{ + @Inject + public MapReleaseVersionsPhase( Prompter prompter, Map versionPolicies ) + { + super( prompter, versionPolicies, false, false ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveReleasePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveReleasePomsPhase.java index 032271ff5..839889edb 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveReleasePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveReleasePomsPhase.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -35,8 +39,8 @@ import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; /** * Remove release POMs. @@ -44,14 +48,21 @@ * @author Brett Porter * @author Mark Hobson */ -@Component( role = ReleasePhase.class, hint = "remove-release-poms" ) +@Singleton +@Named( "remove-release-poms" ) public class RemoveReleasePomsPhase - extends AbstractReleasePomsPhase + extends AbstractReleasePomsPhase { + @Inject + public RemoveReleasePomsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects, false ); } @@ -59,14 +70,14 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects, true ); } private ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects, boolean simulate ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); @@ -86,7 +97,7 @@ private ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvir private void removeReleasePoms( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, boolean simulate, ReleaseResult result, List projects ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { List releasePoms = new ArrayList<>(); @@ -124,7 +135,7 @@ private void removeReleasePomsFromFilesystem( boolean simulate, ReleaseResult re private void removeReleasePomsFromScm( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, boolean simulate, ReleaseResult result, List releasePoms ) - throws ReleaseFailureException, ReleaseExecutionException + throws ReleaseFailureException, ReleaseExecutionException { if ( simulate ) { @@ -140,7 +151,7 @@ private void removeReleasePomsFromScm( ReleaseDescriptor releaseDescriptor, Rele try { RemoveScmResult scmResult = - scmProvider.remove( scmRepository, scmFileSet, "Removing for next development iteration." ); + scmProvider.remove( scmRepository, scmFileSet, "Removing for next development iteration." ); if ( !scmResult.isSuccess() ) { @@ -150,7 +161,7 @@ private void removeReleasePomsFromScm( ReleaseDescriptor releaseDescriptor, Rele catch ( ScmException exception ) { throw new ReleaseExecutionException( "Cannot remove release POMs from SCM: " + exception.getMessage(), - exception ); + exception ); } } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java index 25e031496..1d4299fbe 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RemoveScmTagPhase.java @@ -19,16 +19,14 @@ * under the License. */ -import java.io.File; -import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.release.ReleaseExecutionException; -import org.apache.maven.shared.release.ReleaseFailureException; -import org.apache.maven.shared.release.ReleaseResult; -import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; +import java.io.File; import java.util.List; + +import org.apache.maven.project.MavenProject; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -38,28 +36,40 @@ import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.repository.ScmRepositoryException; +import org.apache.maven.shared.release.ReleaseExecutionException; +import org.apache.maven.shared.release.ReleaseFailureException; +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Requirement; + +import static java.util.Objects.requireNonNull; /** * Remove tag from SCM repository during rollback */ -@Component( role = ReleasePhase.class, hint = "remove-scm-tag" ) +@Singleton +@Named( "remove-scm-tag" ) public class RemoveScmTagPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + @Inject + public RemoveScmTagPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult releaseResult = new ReleaseResult(); @@ -68,16 +78,17 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro logInfo( releaseResult, "Removing tag with the label " + releaseDescriptor.getScmReleaseLabel() + " ..." ); ReleaseDescriptor basedirAlignedReleaseDescriptor = - ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); + ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); ScmRepository repository; ScmProvider provider; try { repository = - scmRepositoryConfigurator.getConfiguredRepository( basedirAlignedReleaseDescriptor.getScmSourceUrl(), - releaseDescriptor, - releaseEnvironment.getSettings() ); + scmRepositoryConfigurator.getConfiguredRepository( + basedirAlignedReleaseDescriptor.getScmSourceUrl(), + releaseDescriptor, + releaseEnvironment.getSettings() ); repository.getProviderRepository().setPushChanges( releaseDescriptor.isPushChanges() ); @@ -106,18 +117,18 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro if ( getLogger().isDebugEnabled() ) { getLogger().debug( - "RemoveScmTagPhase :: scmUntagParameters tagName " + tagName ); + "RemoveScmTagPhase :: scmUntagParameters tagName " + tagName ); getLogger().debug( - "RemoveScmTagPhase :: scmUntagParameters message " + message ); + "RemoveScmTagPhase :: scmUntagParameters message " + message ); getLogger().debug( - "RemoveScmTagPhase :: fileSet " + fileSet ); + "RemoveScmTagPhase :: fileSet " + fileSet ); } untagScmResult = provider.untag( repository, fileSet, commandParameters ); } catch ( ScmException e ) { throw new ReleaseExecutionException( "An error has occurred in the remove tag process: " - + e.getMessage(), e ); + + e.getMessage(), e ); } if ( !untagScmResult.isSuccess() ) @@ -134,7 +145,7 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult releaseResult = new ReleaseResult(); @@ -149,7 +160,7 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir } private void validateConfiguration( ReleaseDescriptor releaseDescriptor ) - throws ReleaseFailureException + throws ReleaseFailureException { if ( releaseDescriptor.getScmReleaseLabel() == null ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RestoreBackupPomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RestoreBackupPomsPhase.java index f746eedda..fcf11fe85 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RestoreBackupPomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RestoreBackupPomsPhase.java @@ -19,6 +19,14 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.io.IOException; +import java.util.List; + import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -36,31 +44,33 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.FileUtils; -import java.io.File; -import java.io.IOException; -import java.util.List; +import static java.util.Objects.requireNonNull; /** * @author Edwin Punzalan */ -@Component( role = ReleasePhase.class, hint = "restore-backup-poms" ) +@Singleton +@Named( "restore-backup-poms" ) public class RestoreBackupPomsPhase - extends AbstractBackupPomsPhase + extends AbstractBackupPomsPhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + @Inject + public RestoreBackupPomsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); @@ -77,21 +87,21 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { return execute( releaseDescriptor, releaseEnvironment, reactorProjects ); } protected void restorePomBackup( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, MavenProject project ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { File pomBackup = getPomBackup( project ); if ( !pomBackup.exists() ) { throw new ReleaseExecutionException( - "Cannot restore from a missing backup POM: " + pomBackup.getAbsolutePath() ); + "Cannot restore from a missing backup POM: " + pomBackup.getAbsolutePath() ); } try @@ -101,8 +111,8 @@ protected void restorePomBackup( ReleaseDescriptor releaseDescriptor, ReleaseEnv try { scmRepository = - scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, - releaseEnvironment.getSettings() ); + scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor, + releaseEnvironment.getSettings() ); provider = scmRepositoryConfigurator.getRepositoryProvider( scmRepository ); } @@ -118,7 +128,7 @@ protected void restorePomBackup( ReleaseDescriptor releaseDescriptor, ReleaseEnv if ( releaseDescriptor.isScmUseEditMode() || provider.requiresEditMode() ) { EditScmResult result = provider.edit( scmRepository, new ScmFileSet( - new File( releaseDescriptor.getWorkingDirectory() ), project.getFile() ) ); + new File( releaseDescriptor.getWorkingDirectory() ), project.getFile() ) ); if ( !result.isSuccess() ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomVersionsPhase.java index 3d5561406..d95ee1adb 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomVersionsPhase.java @@ -19,23 +19,38 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Map; + import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.repository.ScmRepository; -import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.codehaus.plexus.component.annotations.Component; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; +import org.apache.maven.shared.release.scm.ScmTranslator; +import org.apache.maven.shared.release.transform.ModelETLFactory; /** * Rewrite POMs for future development * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "rewrite-pom-versions" ) +@Singleton +@Named( "rewrite-pom-versions" ) public class RewritePomVersionsPhase - extends AbstractRewritePomsPhase + extends AbstractRewritePomsPhase { + @Inject + public RewritePomVersionsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator, + Map modelETLFactories, + Map scmTranslators ) + { + super( scmRepositoryConfigurator, modelETLFactories, scmTranslators ); + } @Override protected final String getPomSuffix() @@ -46,7 +61,6 @@ protected final String getPomSuffix() @Override protected void transformScm( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, ScmRepository scmRepository, ReleaseResult result ) - throws ReleaseExecutionException { // We are only updating versions no mods to scm needed } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java index 6f60c06d9..20893f72f 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java @@ -19,10 +19,15 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.IOException; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Model; @@ -32,19 +37,30 @@ import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; +import org.apache.maven.shared.release.transform.ModelETLFactory; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; /** * Rewrite POMs for branch. * * @author Emmanuel Venisse */ -@Component( role = ReleasePhase.class, hint = "rewrite-poms-for-branch" ) +@Singleton +@Named( "rewrite-poms-for-branch" ) public class RewritePomsForBranchPhase - extends AbstractRewritePomsPhase + extends AbstractRewritePomsPhase { + @Inject + public RewritePomsForBranchPhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + Map modelETLFactories, + Map scmTranslators ) + { + super( scmRepositoryConfigurator, modelETLFactories, scmTranslators ); + } + @Override protected final String getPomSuffix() { @@ -54,7 +70,7 @@ protected final String getPomSuffix() @Override protected void transformScm( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, ScmRepository scmRepository, ReleaseResult result ) - throws ReleaseExecutionException + throws ReleaseExecutionException { // If SCM is null in original model, it is inherited, no mods needed if ( project.getScm() != null ) @@ -106,7 +122,7 @@ protected void transformScm( MavenProject project, Model modelTarget, ReleaseDes private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDescriptor, Scm scmTarget, ScmRepository scmRepository, ReleaseResult relResult ) - throws IOException + throws IOException { ScmTranslator translator = getScmTranslators().get( scmRepository.getProvider() ); boolean result = false; @@ -131,7 +147,7 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes Path workingDirectory = Paths.get( releaseDescriptor.getWorkingDirectory() ); int count = ReleaseUtil.getBaseWorkingDirectoryParentCount( workingDirectory, projectBasedir ); - + if ( scm.getConnection() != null ) { String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getConnection() ); @@ -154,8 +170,8 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes } String value = - translator.translateBranchUrl( scm.getConnection(), branchName + subDirectoryBranch, - scmConnectionBranch ); + translator.translateBranchUrl( scm.getConnection(), branchName + subDirectoryBranch, + scmConnectionBranch ); if ( !value.equals( scm.getConnection() ) ) { scmTarget.setConnection( value ); @@ -174,8 +190,8 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes } String value = - translator.translateBranchUrl( scm.getDeveloperConnection(), branchName + subDirectoryBranch, - branchBase ); + translator.translateBranchUrl( scm.getDeveloperConnection(), branchName + subDirectoryBranch, + branchBase ); if ( !value.equals( scm.getDeveloperConnection() ) ) { scmTarget.setDeveloperConnection( value ); @@ -206,7 +222,7 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes // use original branch base without protocol String value = translator.translateBranchUrl( scm.getUrl(), branchName + subDirectoryBranch, - tagScmUrl ); + tagScmUrl ); if ( !value.equals( scm.getUrl() ) ) { scmTarget.setUrl( value ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java index 834ca0ebd..b9914c726 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhase.java @@ -19,25 +19,41 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Map; + import org.apache.maven.model.Model; import org.apache.maven.model.Scm; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.repository.ScmRepository; -import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; -import org.codehaus.plexus.component.annotations.Component; +import org.apache.maven.shared.release.transform.ModelETLFactory; /** * Rewrite POMs for future development * * @author Brett Porter */ -@Component( role = ReleasePhase.class , hint = "rewrite-poms-for-development" ) +@Singleton +@Named( "rewrite-poms-for-development" ) public class RewritePomsForDevelopmentPhase - extends AbstractRewritePomsPhase + extends AbstractRewritePomsPhase { + @Inject + public RewritePomsForDevelopmentPhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + Map modelETLFactories, + Map scmTranslators ) + { + super( scmRepositoryConfigurator, modelETLFactories, scmTranslators ); + } + @Override protected final String getPomSuffix() { @@ -47,7 +63,6 @@ protected final String getPomSuffix() @Override protected void transformScm( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, ScmRepository scmRepository, ReleaseResult result ) - throws ReleaseExecutionException { // If SCM is null in original model, it is inherited, no mods needed if ( project.getScm() != null ) @@ -87,8 +102,8 @@ protected void transformScm( MavenProject project, Model modelTarget, ReleaseDes protected String getOriginalVersion( ReleaseDescriptor releaseDescriptor, String projectKey, boolean simulate ) { return simulate - ? releaseDescriptor.getProjectOriginalVersion( projectKey ) - : releaseDescriptor.getProjectReleaseVersion( projectKey ); + ? releaseDescriptor.getProjectOriginalVersion( projectKey ) + : releaseDescriptor.getProjectReleaseVersion( projectKey ); } @Override diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java index cc36600a7..fa7df3211 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java @@ -19,10 +19,15 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.IOException; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Map; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Model; @@ -32,19 +37,30 @@ import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; +import org.apache.maven.shared.release.transform.ModelETLFactory; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; /** * Rewrite POMs for release. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "rewrite-poms-for-release" ) +@Singleton +@Named( "rewrite-poms-for-release" ) public class RewritePomsForReleasePhase - extends AbstractRewritePomsPhase + extends AbstractRewritePomsPhase { + @Inject + public RewritePomsForReleasePhase( + ScmRepositoryConfigurator scmRepositoryConfigurator, + Map modelETLFactories, + Map scmTranslators ) + { + super( scmRepositoryConfigurator, modelETLFactories, scmTranslators ); + } + @Override protected final String getPomSuffix() { @@ -54,7 +70,7 @@ protected final String getPomSuffix() @Override protected void transformScm( MavenProject project, Model modelTarget, ReleaseDescriptor releaseDescriptor, String projectId, ScmRepository scmRepository, ReleaseResult result ) - throws ReleaseExecutionException + throws ReleaseExecutionException { // If SCM is null in original model, it is inherited, no mods needed if ( project.getScm() != null ) @@ -105,7 +121,7 @@ protected void transformScm( MavenProject project, Model modelTarget, ReleaseDes private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDescriptor, Scm scmTarget, ScmRepository scmRepository, ReleaseResult relResult ) - throws IOException + throws IOException { ScmTranslator translator = getScmTranslators().get( scmRepository.getProvider() ); boolean result = false; @@ -130,7 +146,7 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes Path workingDirectory = Paths.get( releaseDescriptor.getWorkingDirectory() ); int count = ReleaseUtil.getBaseWorkingDirectoryParentCount( workingDirectory, projectBasedir ); - + if ( scm.getConnection() != null ) { String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getConnection() ); @@ -152,7 +168,7 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes scmConnectionTag = translateUrlPath( trunkUrl, tagBase, scm.getConnection() ); } String value = - translator.translateTagUrl( scm.getConnection(), tag + subDirectoryTag, scmConnectionTag ); + translator.translateTagUrl( scm.getConnection(), tag + subDirectoryTag, scmConnectionTag ); if ( !value.equals( scm.getConnection() ) ) { @@ -172,7 +188,7 @@ private boolean translateScm( MavenProject project, ReleaseDescriptor releaseDes } String value = - translator.translateTagUrl( scm.getDeveloperConnection(), tag + subDirectoryTag, tagBase ); + translator.translateTagUrl( scm.getDeveloperConnection(), tag + subDirectoryTag, tagBase ); if ( !value.equals( scm.getDeveloperConnection() ) ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhase.java index aab47500d..6d9051dd4 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunCompleteGoalsPhase.java @@ -19,15 +19,20 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.util.List; +import java.util.Map; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; +import org.apache.maven.shared.release.exec.MavenExecutor; /** * Run the completion goals for the project to before committing the continuing development stream. @@ -35,28 +40,35 @@ * @author Brett Porter * @author Stephen Connolly */ -@Component( role = ReleasePhase.class, hint = "run-completion-goals" ) +@Singleton +@Named( "run-completion-goals" ) public class RunCompleteGoalsPhase - extends AbstractRunGoalsPhase + extends AbstractRunGoalsPhase { + @Inject + public RunCompleteGoalsPhase( Map mavenExecutors ) + { + super( mavenExecutors ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { return execute( releaseDescriptor, releaseEnvironment, new File( releaseDescriptor.getWorkingDirectory() ), - getAdditionalArguments( releaseDescriptor ) ); + getAdditionalArguments( releaseDescriptor ) ); } @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); logInfo( result, "Executing completion goals - since this is simulation mode it is running against the " - + "original project, not the rewritten ones" ); + + "original project, not the rewritten ones" ); execute( releaseDescriptor, releaseEnvironment, reactorProjects ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java index 2e3a8437b..0be778a62 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java @@ -19,38 +19,50 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.util.List; +import java.util.Map; + import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; +import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.util.PomFinder; -import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.util.List; - /** * Run the integration tests for the project to verify that it builds before committing. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "run-perform-goals" ) +@Singleton +@Named( "run-perform-goals" ) public class RunPerformGoalsPhase - extends AbstractRunGoalsPhase + extends AbstractRunGoalsPhase { + @Inject + public RunPerformGoalsPhase( Map mavenExecutors ) + { + super( mavenExecutors ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { return runLogic( releaseDescriptor, releaseEnvironment, false ); } private ReleaseResult runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, - boolean simulate ) - throws ReleaseExecutionException + boolean simulate ) + throws ReleaseExecutionException { String additionalArguments = getAdditionalArguments( releaseDescriptor ); @@ -132,7 +144,7 @@ private ReleaseResult runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvi @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { return runLogic( releaseDescriptor, releaseEnvironment, true ); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhase.java index 23db790b5..4313ec618 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPrepareGoalsPhase.java @@ -19,43 +19,55 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.util.List; +import java.util.Map; + import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.codehaus.plexus.component.annotations.Component; - -import java.io.File; -import java.util.List; +import org.apache.maven.shared.release.exec.MavenExecutor; /** * Run the integration tests for the project to verify that it builds before committing. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "run-preparation-goals" ) +@Singleton +@Named( "run-preparation-goals" ) public class RunPrepareGoalsPhase - extends AbstractRunGoalsPhase + extends AbstractRunGoalsPhase { + @Inject + public RunPrepareGoalsPhase( Map mavenExecutors ) + { + super( mavenExecutors ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { return execute( releaseDescriptor, releaseEnvironment, new File( releaseDescriptor.getWorkingDirectory() ), - getAdditionalArguments( releaseDescriptor ) ); + getAdditionalArguments( releaseDescriptor ) ); } @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException + throws ReleaseExecutionException { ReleaseResult result = new ReleaseResult(); logInfo( result, "Executing preparation goals - since this is simulation mode it is running against the " - + "original project, not the rewritten ones" ); + + "original project, not the rewritten ones" ); execute( releaseDescriptor, releaseEnvironment, reactorProjects ); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmBranchPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmBranchPhase.java index 41c261666..cb3d1fb99 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmBranchPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmBranchPhase.java @@ -19,6 +19,13 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.io.File; +import java.util.List; + import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmBranchParameters; import org.apache.maven.scm.ScmException; @@ -37,32 +44,32 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -import java.io.File; -import java.util.List; /** * Branch the SCM repository. * * @author Emmanuel Venisse */ -@Component( role = ReleasePhase.class, hint = "scm-branch" ) +@Singleton +@Named( "scm-branch" ) public class ScmBranchPhase - extends AbstractReleasePhase + extends AbstractReleasePhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + @Inject + public ScmBranchPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = scmRepositoryConfigurator; + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult relResult = new ReleaseResult(); @@ -71,16 +78,17 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro logInfo( relResult, "Branching release with the label " + releaseDescriptor.getScmReleaseLabel() + "..." ); ReleaseDescriptor basedirAlignedReleaseDescriptor = - ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); + ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); ScmRepository repository; ScmProvider provider; try { repository = - scmRepositoryConfigurator.getConfiguredRepository( basedirAlignedReleaseDescriptor.getScmSourceUrl(), - releaseDescriptor, - releaseEnvironment.getSettings() ); + scmRepositoryConfigurator.getConfiguredRepository( + basedirAlignedReleaseDescriptor.getScmSourceUrl(), + releaseDescriptor, + releaseEnvironment.getSettings() ); repository.getProviderRepository().setPushChanges( releaseDescriptor.isPushChanges() ); @@ -130,13 +138,13 @@ public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnviro @Override public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) - throws ReleaseExecutionException, ReleaseFailureException + throws ReleaseExecutionException, ReleaseFailureException { ReleaseResult result = new ReleaseResult(); validateConfiguration( releaseDescriptor ); ReleaseDescriptor basedirAlignedReleaseDescriptor = - ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); + ReleaseUtil.createBasedirAlignedReleaseDescriptor( releaseDescriptor, reactorProjects ); logInfo( result, "Full run would branch " + basedirAlignedReleaseDescriptor.getWorkingDirectory() ); if ( releaseDescriptor.getScmBranchBase() != null ) @@ -155,7 +163,7 @@ public ReleaseResult simulate( ReleaseDescriptor releaseDescriptor, ReleaseEnvir } private static void validateConfiguration( ReleaseDescriptor releaseDescriptor ) - throws ReleaseFailureException + throws ReleaseFailureException { if ( releaseDescriptor.getScmReleaseLabel() == null ) { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java index 6562089c9..4c9a8f2bc 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCheckModificationsPhase.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -37,8 +41,6 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.scm.ScmTranslator; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.util.SelectorUtils; import org.codehaus.plexus.util.StringUtils; @@ -50,37 +52,46 @@ import java.util.Map; import java.util.Set; +import static java.util.Objects.requireNonNull; + /** * See if there are any local modifications to the files before proceeding with SCM operations and the release. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "scm-check-modifications" ) +@Singleton +@Named( "scm-check-modifications" ) public class ScmCheckModificationsPhase extends AbstractReleasePhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; /** * SCM URL translators mapped by provider name. */ - @Requirement( role = ScmTranslator.class ) - private Map scmTranslators; + private final Map scmTranslators; /** * The filepatterns to exclude from the status check. * * @todo proper construction of filenames, especially release properties */ - private Set exclusionPatterns = new HashSet<>( Arrays.asList( + private final Set exclusionPatterns = new HashSet<>( Arrays.asList( "**" + File.separator + "pom.xml.backup", "**" + File.separator + "pom.xml.tag", "**" + File.separator + "pom.xml.next", "**" + File.separator + "pom.xml.branch", "**" + File.separator + "release.properties", "**" + File.separator + "pom.xml.releaseBackup" ) ); + @Inject + public ScmCheckModificationsPhase( ScmRepositoryConfigurator scmRepositoryConfigurator, + Map scmTranslators ) + { + this.scmRepositoryConfigurator = requireNonNull( scmRepositoryConfigurator ); + this.scmTranslators = requireNonNull( scmTranslators ); + } + @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, List reactorProjects ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitBranchPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitBranchPhase.java new file mode 100644 index 000000000..7e5e7bce1 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitBranchPhase.java @@ -0,0 +1,43 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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 org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Commit the changes that were done to prepare the branch or tag to the SCM. + * + * @author Brett Porter + */ +@Singleton +@Named( "scm-commit-branch" ) +public class ScmCommitBranchPhase + extends AbstractScmCommitPreparationPhase +{ + @Inject + public ScmCommitBranchPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator, "getScmBranchCommitComment" ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java index bf8a8a80c..76643331c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhase.java @@ -19,85 +19,26 @@ * under the License. */ -import java.io.File; -import java.text.MessageFormat; -import java.util.Collection; -import java.util.List; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; -import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.release.ReleaseExecutionException; -import org.apache.maven.shared.release.ReleaseResult; -import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.apache.maven.shared.release.env.ReleaseEnvironment; -import org.apache.maven.shared.release.scm.ReleaseScmCommandException; -import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; /** * Commit the changes that were done to prepare the branch or tag to the SCM. * * @author Brett Porter */ +@Singleton +@Named( "scm-commit-development" ) public class ScmCommitDevelopmentPhase - extends AbstractScmCommitPhase + extends AbstractScmCommitDevelopmentPhase { - - /** - * The format for the - */ - private String rollbackMessageFormat; - - @Override - protected void runLogic( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, - List reactorProjects, ReleaseResult result, boolean simulating ) - throws ReleaseScmCommandException, ReleaseExecutionException, ReleaseScmRepositoryException - { - // no rollback required - if ( - // was there no commit that has to be rolled back by a new one - releaseDescriptor.isSuppressCommitBeforeTagOrBranch() - // and working copy should not be touched - && !releaseDescriptor.isUpdateWorkingCopyVersions() ) - { - if ( simulating ) - { - logInfo( result, "Full run would not commit changes, because updateWorkingCopyVersions is false." ); - } - else - { - logInfo( result, "Modified POMs are not committed because updateWorkingCopyVersions is set to false." ); - } - } - // rollback or commit development versions required - else - { - String message; - if ( !releaseDescriptor.isUpdateWorkingCopyVersions() ) - { - // the commit is a rollback - message = createRollbackMessage( releaseDescriptor ); - } - else - { - // a normal commit - message = createMessage( reactorProjects, releaseDescriptor ); - } - if ( simulating ) - { - Collection pomFiles = createPomFiles( releaseDescriptor, reactorProjects ); - logInfo( result, - "Full run would commit " + pomFiles.size() + " files with message: '" + message + "'" ); - } - else - { - performCheckins( releaseDescriptor, releaseEnvironment, reactorProjects, message ); - } - } - } - - private String createRollbackMessage( ReleaseDescriptor releaseDescriptor ) + @Inject + public ScmCommitDevelopmentPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) { - return MessageFormat.format( releaseDescriptor.getScmCommentPrefix() + rollbackMessageFormat, - new Object[]{releaseDescriptor.getScmReleaseLabel()} ); + super( scmRepositoryConfigurator, "getScmDevelopmentCommitComment", + "rollback changes from release preparation of {0}" ); } - } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitReleasePhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitReleasePhase.java new file mode 100644 index 000000000..bb27a8422 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitReleasePhase.java @@ -0,0 +1,43 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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 org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Commit the changes that were done to prepare the branch or tag to the SCM. + * + * @author Brett Porter + */ +@Singleton +@Named( "scm-commit-release" ) +public class ScmCommitReleasePhase + extends AbstractScmCommitPreparationPhase +{ + @Inject + public ScmCommitReleasePhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator, "getScmReleaseCommitComment" ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitRollbackPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitRollbackPhase.java new file mode 100644 index 000000000..1acf1ab52 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmCommitRollbackPhase.java @@ -0,0 +1,43 @@ +package org.apache.maven.shared.release.phase; + +/* + * 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 org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; + +/** + * Commit the changes that were done to prepare the branch or tag to the SCM. + * + * @author Brett Porter + */ +@Singleton +@Named( "scm-commit-rollback" ) +public class ScmCommitRollbackPhase + extends AbstractScmCommitPreparationPhase +{ + @Inject + public ScmCommitRollbackPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + super( scmRepositoryConfigurator, "getScmRollbackCommitComment" ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmTagPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmTagPhase.java index 7f9614061..362f6145a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmTagPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/ScmTagPhase.java @@ -19,6 +19,10 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import java.util.List; @@ -40,23 +44,27 @@ import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; /** * Tag the SCM repository after committing the release. * * @author Brett Porter */ -@Component( role = ReleasePhase.class, hint = "scm-tag" ) +@Singleton +@Named( "scm-tag" ) public class ScmTagPhase extends AbstractReleasePhase { /** * Tool that gets a configured SCM repository from release configuration. */ - @Requirement - private ScmRepositoryConfigurator scmRepositoryConfigurator; + private final ScmRepositoryConfigurator scmRepositoryConfigurator; + + @Inject + public ScmTagPhase( ScmRepositoryConfigurator scmRepositoryConfigurator ) + { + this.scmRepositoryConfigurator = scmRepositoryConfigurator; + } @Override public ReleaseResult execute( ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java index 37a0b9602..c76fc6bc6 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java @@ -19,11 +19,13 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.shared.release.policy.PolicyException; import org.apache.maven.shared.release.policy.naming.NamingPolicy; import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; import org.apache.maven.shared.release.policy.naming.NamingPolicyResult; -import org.codehaus.plexus.component.annotations.Component; /** *

DefaultNamingPolicy class.

@@ -31,12 +33,13 @@ * @author Robert Scholte * @since 3.0.0-M5 */ -@Component( role = NamingPolicy.class, hint = "default" ) +@Singleton +@Named public class DefaultNamingPolicy implements NamingPolicy { @Override public NamingPolicyResult getName( NamingPolicyRequest request ) - throws PolicyException + throws PolicyException { return new NamingPolicyResult().setName( request.getArtifactId() + "-" + request.getVersion() ); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java index f4c8cf012..cf29d3868 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java @@ -19,27 +19,28 @@ * under the License. */ -import org.apache.maven.shared.release.policy.PolicyException; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.shared.release.policy.version.VersionPolicy; import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; import org.apache.maven.shared.release.policy.version.VersionPolicyResult; import org.apache.maven.shared.release.versions.DefaultVersionInfo; import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; /** *

DefaultVersionPolicy class.

* * @author Robert Scholte */ -@Component( role = VersionPolicy.class, hint = "default" ) +@Singleton +@Named public class DefaultVersionPolicy - implements VersionPolicy + implements VersionPolicy { - @Override public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException + throws VersionParseException { String releaseVersion = new DefaultVersionInfo( request.getVersion() ).getReleaseVersionString(); return new VersionPolicyResult().setVersion( releaseVersion ); @@ -47,10 +48,10 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) @Override public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException + throws VersionParseException { String developmentVersion = - new DefaultVersionInfo( request.getVersion() ).getNextVersion().getSnapshotVersionString(); + new DefaultVersionInfo( request.getVersion() ).getNextVersion().getSnapshotVersionString(); return new VersionPolicyResult().setVersion( developmentVersion ); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java index e67b08f19..642c5c7b5 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java @@ -19,16 +19,18 @@ * under the License. */ -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; /** * ClearCase tag translator. * * @author Arne Degenring */ -@Component( role = ScmTranslator.class, hint = "clearcase" ) +@Singleton +@Named( "clearcase" ) public class ClearCaseScmTranslator - implements ScmTranslator + implements ScmTranslator { @Override public String translateBranchUrl( String url, String branchName, String branchBase ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/CvsScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/CvsScmTranslator.java index 3180a3db3..e6c1aa07e 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/CvsScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/CvsScmTranslator.java @@ -19,16 +19,18 @@ * under the License. */ -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; /** * CVS tag translator. * * @author Brett Porter */ -@Component( role = ScmTranslator.class, hint = "cvs" ) +@Singleton +@Named( "cvs" ) public class CvsScmTranslator - implements ScmTranslator + implements ScmTranslator { @Override public String translateBranchUrl( String url, String branchName, String branchBase ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java index 0dd2280ad..e6be92496 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java @@ -19,6 +19,12 @@ * under the License. */ +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.concurrent.atomic.AtomicReference; + import org.apache.maven.scm.manager.NoSuchScmProviderException; import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.scm.provider.ScmProvider; @@ -30,35 +36,44 @@ import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.apache.maven.shared.release.util.MavenCrypto; +import org.apache.maven.shared.release.util.MavenCrypto.MavenCryptoException; import org.codehaus.plexus.util.StringUtils; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static java.util.Objects.requireNonNull; /** * Tool that gets a configured SCM repository from release configuration. * * @author Brett Porter */ -@Component( role = ScmRepositoryConfigurator.class, instantiationStrategy = "singleton" ) +@Singleton +@Named public class DefaultScmRepositoryConfigurator - extends AbstractLogEnabled implements ScmRepositoryConfigurator { - /** - * The SCM manager. - */ - @Requirement - private ScmManager scmManager; + private final Logger logger = LoggerFactory.getLogger( getClass() ); + + private final AtomicReference scmManager; + + private final MavenCrypto mavenCrypto; + + @Inject + public DefaultScmRepositoryConfigurator( ScmManager scmManager, MavenCrypto mavenCrypto ) + { + this.scmManager = new AtomicReference<>( requireNonNull( scmManager ) ); + this.mavenCrypto = requireNonNull( mavenCrypto ); + } /** - * When this plugin requires Maven 3.0 as minimum, this component can be removed and o.a.m.s.c.SettingsDecrypter be - * used instead. + * For testing purposes only! */ - @Requirement( hint = "mng-4384" ) - private SecDispatcher secDispatcher; + public void setScmManager( ScmManager scmManager ) + { + this.scmManager.set( scmManager ); + } @Override public ScmRepository getConfiguredRepository( ReleaseDescriptor releaseDescriptor, Settings settings ) @@ -77,7 +92,7 @@ public ScmRepository getConfiguredRepository( String url, ReleaseDescriptor rele String privateKey = releaseDescriptor.getScmPrivateKey(); String passphrase = releaseDescriptor.getScmPrivateKeyPassPhrase(); - ScmRepository repository = scmManager.makeScmRepository( url ); + ScmRepository repository = scmManager.get().makeScmRepository( url ); ScmProviderRepository scmRepo = repository.getProviderRepository(); @@ -181,20 +196,20 @@ private String decrypt( String str, String server ) { try { - return secDispatcher.decrypt( str ); + return mavenCrypto.decrypt( str ); } - catch ( SecDispatcherException e ) + catch ( MavenCryptoException e ) { String msg = "Failed to decrypt password/passphrase for server " + server + ", using auth token as is: " + e.getMessage(); - if ( getLogger().isDebugEnabled() ) + if ( logger.isDebugEnabled() ) { - getLogger().warn( msg, e ); + logger.warn( msg, e ); } else { - getLogger().warn( msg ); + logger.warn( msg ); } return str; } @@ -204,16 +219,6 @@ private String decrypt( String str, String server ) public ScmProvider getRepositoryProvider( ScmRepository repository ) throws NoSuchScmProviderException { - return scmManager.getProviderByRepository( repository ); - } - - /** - *

Setter for the field scmManager.

- * - * @param scmManager a {@link org.apache.maven.scm.manager.ScmManager} object - */ - public void setScmManager( ScmManager scmManager ) - { - this.scmManager = scmManager; + return scmManager.get().getProviderByRepository( repository ); } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/GitScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/GitScmTranslator.java index 2739576c5..4399479f1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/GitScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/GitScmTranslator.java @@ -19,14 +19,16 @@ * under the License. */ -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; /** *

GitScmTranslator class.

*/ -@Component( role = ScmTranslator.class, hint = "git" ) +@Singleton +@Named( "git" ) public class GitScmTranslator - implements ScmTranslator + implements ScmTranslator { @Override diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/HgScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/HgScmTranslator.java index 1968fb352..73a038ac0 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/HgScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/HgScmTranslator.java @@ -19,14 +19,16 @@ * under the License. */ -import org.codehaus.plexus.component.annotations.Component; +import javax.inject.Named; +import javax.inject.Singleton; /** *

HgScmTranslator class.

*/ -@Component( role = ScmTranslator.class, hint = "hg" ) +@Singleton +@Named( "hg" ) public class HgScmTranslator - implements ScmTranslator + implements ScmTranslator { @Override diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/JazzScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/JazzScmTranslator.java index a770d4e54..8da9b534e 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/JazzScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/JazzScmTranslator.java @@ -19,18 +19,20 @@ * under the License. */ -import java.io.File; +import javax.inject.Named; +import javax.inject.Singleton; -import org.codehaus.plexus.component.annotations.Component; +import java.io.File; /** * Jazz tag translator. * * @author Chris Graham */ -@Component( role = ScmTranslator.class, hint = "jazz" ) +@Singleton +@Named( "jazz" ) public class JazzScmTranslator - implements ScmTranslator + implements ScmTranslator { @Override public String translateBranchUrl( String url, String branchName, String branchBase ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/SubversionScmTranslator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/SubversionScmTranslator.java index abf68e114..0f8db4b78 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/SubversionScmTranslator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/SubversionScmTranslator.java @@ -19,17 +19,20 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.provider.svn.SvnTagBranchUtils; -import org.codehaus.plexus.component.annotations.Component; /** * Subversion tag translator. * * @author Brett Porter */ -@Component( role = ScmTranslator.class, hint = "svn" ) +@Singleton +@Named( "svn" ) public class SubversionScmTranslator implements ScmTranslator { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java index d3e892b5d..0dd3874b6 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/strategies/DefaultStrategy.java @@ -19,6 +19,11 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.maven.shared.release.strategy.Strategy; @@ -29,47 +34,92 @@ * @author Robert Scholte * @since 3.0.0-M5 */ +@Singleton +@Named public class DefaultStrategy implements Strategy { /** * The phases of release to run, and in what order. */ - private List preparePhases; + private final List preparePhases; /** * The phases of release to run to perform. */ - private List performPhases; + private final List performPhases; /** * The phases of release to run to rollback changes */ - private List rollbackPhases; + private final List rollbackPhases; /** * The phases to create a branch. */ - private List branchPhases; + private final List branchPhases; /** * The phases to create update versions. */ - private List updateVersionsPhases; + private final List updateVersionsPhases; - @Override - public List getPreparePhases() + public DefaultStrategy() { - return preparePhases; + this.preparePhases = Collections.unmodifiableList( Arrays.asList( + "check-poms", + "scm-check-modifications", + "check-dependency-snapshots", + "create-backup-poms", + "map-release-versions", + "input-variables", + "map-development-versions", + "rewrite-poms-for-release", + "generate-release-poms", + "run-preparation-goals", + "scm-commit-release", + "scm-tag", + "rewrite-poms-for-development", + "remove-release-poms", + "run-completion-goals", + "scm-commit-development", + "end-release" + ) ); + this.performPhases = Collections.unmodifiableList( Arrays.asList( + "verify-completed-prepare-phases", + "checkout-project-from-scm", + "run-perform-goals" + ) ); + this.rollbackPhases = Collections.unmodifiableList( Arrays.asList( + "restore-backup-poms", + "scm-commit-rollback", + "remove-scm-tag" + ) ); + this.branchPhases = Collections.unmodifiableList( Arrays.asList( + "check-poms", + "scm-check-modifications", + "create-backup-poms", + "map-branch-versions", + "branch-input-variables", + "map-development-versions", + "rewrite-poms-for-branch", + "scm-commit-branch", + "scm-branch", + "rewrite-poms-for-development", + "scm-commit-development", + "end-release" + ) ); + this.updateVersionsPhases = Collections.unmodifiableList( Arrays.asList( + "check-poms-updateversions", + "create-backup-poms", + "map-development-versions", + "rewrite-pom-versions" + ) ); } - /** - *

Setter for the field preparePhases.

- * - * @param preparePhases a {@link java.util.List} object - */ - public void setPreparePhases( List preparePhases ) + @Override + public final List getPreparePhases() { - this.preparePhases = preparePhases; + return preparePhases; } @Override @@ -78,61 +128,21 @@ public List getPerformPhases() return performPhases; } - /** - *

Setter for the field performPhases.

- * - * @param performPhases a {@link java.util.List} object - */ - public void setPerformPhases( List performPhases ) - { - this.performPhases = performPhases; - } - @Override public List getRollbackPhases() { return rollbackPhases; } - /** - *

Setter for the field rollbackPhases.

- * - * @param rollbackPhases a {@link java.util.List} object - */ - public void setRollbackPhases( List rollbackPhases ) - { - this.rollbackPhases = rollbackPhases; - } - @Override public List getBranchPhases() { return branchPhases; } - /** - *

Setter for the field branchPhases.

- * - * @param branchPhases a {@link java.util.List} object - */ - public void setBranchPhases( List branchPhases ) - { - this.branchPhases = branchPhases; - } - @Override public List getUpdateVersionsPhases() { return updateVersionsPhases; } - - /** - *

Setter for the field updateVersionsPhases.

- * - * @param updateVersionsPhases a {@link java.util.List} object - */ - public void setUpdateVersionsPhases( List updateVersionsPhases ) - { - this.updateVersionsPhases = updateVersionsPhases; - } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETLFactory.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETLFactory.java index 4d7ba695e..4d4414d73 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETLFactory.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETLFactory.java @@ -19,9 +19,11 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.shared.release.transform.ModelETLRequest; import org.apache.maven.shared.release.transform.ModelETLFactory; -import org.codehaus.plexus.component.annotations.Component; /** *

JDomModelETLFactory class.

@@ -29,11 +31,11 @@ * @author Robert Scholte * @since 3.0 */ -@Component( role = ModelETLFactory.class, hint = JDomModelETLFactory.ROLE_HINT ) +@Singleton +@Named( JDomModelETLFactory.NAME ) public class JDomModelETLFactory implements ModelETLFactory { - /** Constant ROLE_HINT="jdom2-sax" */ - public static final String ROLE_HINT = "jdom2-sax"; + public static final String NAME = "jdom2-sax"; @Override public JDomModelETL newInstance( ModelETLRequest request ) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenCrypto.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenCrypto.java new file mode 100644 index 000000000..3d82414b6 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenCrypto.java @@ -0,0 +1,171 @@ +package org.apache.maven.shared.release.util; + +/* + * 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.Properties; + +import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; +import org.sonatype.plexus.components.cipher.PlexusCipher; +import org.sonatype.plexus.components.cipher.PlexusCipherException; +import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; +import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException; +import org.sonatype.plexus.components.sec.dispatcher.SecUtil; +import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; + + +/** + * A shared utility to access {@link DefaultSecDispatcher} service. + * + * @since TBD + */ +@Singleton +@Named +public class MavenCrypto +{ + /** + * Exception thrown when "something" of crypto operation did not succeed. All the code all over the place + * was catching sec dispatcher and plexus cipher exceptions just to neglect it (maybe log in DEBUG), so + * this is one single exception here. + */ + public static class MavenCryptoException extends Exception + { + private MavenCryptoException( String message ) + { + super( message ); + } + + private MavenCryptoException( String message, Throwable cause ) + { + super( message, cause ); + } + } + + private final DefaultSecDispatcher secDispatcher; + + private final PlexusCipher plexusCipher; + + @Inject + public MavenCrypto( DefaultSecDispatcher secDispatcher, PlexusCipher plexusCipher ) + { + this.secDispatcher = secDispatcher; + this.plexusCipher = plexusCipher; + } + + public String decrypt( String value ) throws MavenCryptoException + { + try + { + return secDispatcher.decrypt( value ); + } + catch ( SecDispatcherException e ) + { + throw new MavenCryptoException( "decrypt failed", e ); + } + } + + public void decryptProperties( Properties properties ) throws MavenCryptoException + { + String[] keys = new String[] {"scm.password", "scm.passphrase"}; + + for ( String key : keys ) + { + String value = properties.getProperty( key ); + if ( value != null ) + { + properties.put( key, decryptDecorated( value ) ); + } + } + } + + public String encryptAndDecorate( String passwd ) throws MavenCryptoException + { + try + { + final String master = getMaster(); + + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); + return cipher.encryptAndDecorate( passwd, masterPasswd ); + } + catch ( PlexusCipherException e ) + { + throw new MavenCryptoException( "encrypt failed", e ); + } + } + + public boolean isEncryptedString( String str ) + { + return plexusCipher.isEncryptedString( str ); + } + + private String decryptDecorated( String value ) throws MavenCryptoException + { + try + { + final String master = getMaster(); + + DefaultPlexusCipher cipher = new DefaultPlexusCipher(); + String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); + return cipher.decryptDecorated( value, masterPasswd ); + } + catch ( PlexusCipherException e ) + { + throw new MavenCryptoException( "decrypt failed", e ); + } + } + + private String getMaster() throws MavenCryptoException + { + String configurationFile = secDispatcher.getConfigurationFile(); + + if ( configurationFile.startsWith( "~" ) ) + { + configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); + } + + String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); + + String master = null; + + try + { + SettingsSecurity sec = SecUtil.read( file, true ); + if ( sec != null ) + { + master = sec.getMaster(); + } + } + catch ( SecDispatcherException e ) + { + throw new MavenCryptoException( "config file read failed", e ); + } + + if ( master == null ) + { + throw new MavenCryptoException( "Master password is not set in the setting security file: " + file ); + } + + return master; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/PomFinder.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/PomFinder.java index 5f93e590f..28586aea0 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/PomFinder.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/PomFinder.java @@ -25,10 +25,12 @@ import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.ReaderFactory; import org.codehaus.plexus.util.xml.XmlStreamReader; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.slf4j.Logger; + +import static java.util.Objects.requireNonNull; /** *

This utility class helps with finding a maven pom file @@ -62,12 +64,12 @@ public class PomFinder { - private Logger log; + private final Logger log; private PomInfo foundPomInfo; public PomFinder( Logger log ) { - this.log = log; + this.log = requireNonNull( log ); } /** @@ -151,19 +153,20 @@ public File findMatchingPom( File startDirectory ) if ( matchingPom == null ) { String[] childFiles = startDirectory.list(); - for ( int i = 0; i < childFiles.length; i++ ) + if ( childFiles != null ) { - String childFile = childFiles[ i ]; - - File subDir = new File( startDirectory, childFile ); - if ( subDir.isDirectory() && !subDir.isHidden() ) - { - matchingPom = findMatchingPom( subDir ); - } - - if ( matchingPom != null ) + for ( String childFile : childFiles ) { - break; + File subDir = new File( startDirectory, childFile ); + if ( subDir.isDirectory() && !subDir.isHidden() ) + { + matchingPom = findMatchingPom( subDir ); + } + + if ( matchingPom != null ) + { + break; + } } } } @@ -189,7 +192,7 @@ private PomInfo readPomInfo( File pomFile ) MavenXpp3Reader reader = new MavenXpp3Reader(); - Model model = null; + Model model; try ( XmlStreamReader xmlReader = ReaderFactory.newXmlReader( pomFile ) ) { model = reader.read( xmlReader ); diff --git a/maven-release-manager/src/main/resources/META-INF/plexus/components.xml b/maven-release-manager/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 6c997dbc6..000000000 --- a/maven-release-manager/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - org.sonatype.plexus.components.sec.dispatcher.SecDispatcher - mng-4384 - org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher - - - org.sonatype.plexus.components.cipher.PlexusCipher - mng-4384 - _cipher - - - - <_configuration-file>~/.m2/settings-security.xml - - - - org.sonatype.plexus.components.cipher.PlexusCipher - mng-4384 - org.sonatype.plexus.components.cipher.DefaultPlexusCipher - - - diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java index a9e5da52a..376b8a02d 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java @@ -19,6 +19,11 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; @@ -35,6 +40,8 @@ import java.util.List; import java.util.Properties; +import com.google.inject.AbstractModule; +import com.google.inject.Module; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmException; @@ -42,7 +49,6 @@ import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.manager.ScmManager; -import org.apache.maven.scm.manager.ScmManagerStub; import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.provider.ScmProviderStub; import org.apache.maven.scm.repository.ScmRepository; @@ -55,8 +61,10 @@ import org.apache.maven.shared.release.phase.ReleasePhase; import org.apache.maven.shared.release.phase.ReleasePhaseStub; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; -import org.codehaus.plexus.PlexusTestCase; +import org.apache.maven.shared.release.stubs.ScmManagerStub; import org.codehaus.plexus.util.FileUtils; +import org.junit.Ignore; +import org.junit.Test; /** * Test the default release manager. @@ -64,13 +72,13 @@ * @author Brett Porter */ public class DefaultReleaseManagerTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private ReleaseDescriptorStoreStub configStore; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); @@ -78,6 +86,23 @@ protected void setUp() configStore = (ReleaseDescriptorStoreStub) lookup( ReleaseDescriptorStore.class, "stub" ); } + @Override + protected Module[] getCustomModules() + { + return new Module[] { + new AbstractModule() + { + @Override + protected void configure() + { + bind( ScmManager.class ).toInstance( new ScmManagerStub() ); + bind( ReleaseDescriptorStore.class ).toInstance( new ReleaseDescriptorStoreStub() ); + } + } + }; + } + + @Test public void testPrepareNoCompletedPhase() throws Exception { @@ -104,6 +129,7 @@ public void testPrepareNoCompletedPhase() assertFalse( "step3 not simulated", phase.isSimulated() ); } + @Test public void testPrepareCompletedPhase() throws Exception { @@ -130,6 +156,7 @@ public void testPrepareCompletedPhase() assertFalse( "step3 not simulated", phase.isSimulated() ); } + @Test public void testPrepareCompletedPhaseNoResume() throws Exception { @@ -158,6 +185,7 @@ public void testPrepareCompletedPhaseNoResume() assertFalse( "step3 not simulated", phase.isSimulated() ); } + @Test public void testPrepareCompletedAllPhases() throws Exception { @@ -184,6 +212,7 @@ public void testPrepareCompletedAllPhases() assertFalse( "step3 not simulated", phase.isSimulated() ); } + @Test public void testPrepareInvalidCompletedPhase() throws Exception { @@ -210,6 +239,7 @@ public void testPrepareInvalidCompletedPhase() assertFalse( "step3 not simulated", phase.isSimulated() ); } + @Test public void testPrepareSimulateNoCompletedPhase() throws Exception { @@ -238,6 +268,7 @@ public void testPrepareSimulateNoCompletedPhase() assertFalse( "step3 not executed", phase.isExecuted() ); } + @Test public void testPrepareSimulateCompletedPhase() throws Exception { @@ -266,6 +297,7 @@ public void testPrepareSimulateCompletedPhase() assertFalse( "step3 not executed", phase.isExecuted() ); } + @Test public void testPrepareSimulateCompletedAllPhases() throws Exception { @@ -294,6 +326,7 @@ public void testPrepareSimulateCompletedAllPhases() assertFalse( "step3 not executed", phase.isExecuted() ); } + @Test public void testPrepareSimulateInvalidCompletedPhase() throws Exception { @@ -322,6 +355,8 @@ public void testPrepareSimulateInvalidCompletedPhase() assertFalse( "step3 not executed", phase.isExecuted() ); } + @Ignore( "This is testing messed up XML?" ) + @Test public void testPrepareUnknownPhaseConfigured() throws Exception { @@ -345,6 +380,7 @@ public void testPrepareUnknownPhaseConfigured() } } + @Test public void testReleaseConfigurationStoreReadFailure() throws Exception { @@ -382,6 +418,7 @@ public void testReleaseConfigurationStoreReadFailure() verifyNoMoreInteractions( configStoreMock ); } + @Test public void testReleaseConfigurationStoreWriteFailure() throws Exception { @@ -422,6 +459,7 @@ public void testReleaseConfigurationStoreWriteFailure() verifyNoMoreInteractions( configStoreMock ); } + @Test public void testReleaseConfigurationStoreClean() throws Exception { @@ -473,6 +511,7 @@ private static List createReactorProjects() throws IOException return Collections.singletonList( project ); } + @Test public void testReleasePerformWithResult() throws Exception { @@ -494,6 +533,7 @@ public void testReleasePerformWithResult() assertTrue( result.getOutput().length() > 0 ); } + @Test public void testReleaseConfigurationStoreReadFailureOnPerform() throws Exception { @@ -532,6 +572,7 @@ public void testReleaseConfigurationStoreReadFailureOnPerform() verifyNoMoreInteractions( configStoreMock ); } + @Test public void testReleasePerformWithIncompletePrepare() throws Exception { @@ -564,6 +605,7 @@ public void testReleasePerformWithIncompletePrepare() } // MRELEASE-758: release:perform no longer removes release.properties + @Test public void testPerformWithDefaultClean() throws Exception { @@ -599,6 +641,7 @@ public void testPerformWithDefaultClean() verifyNoMoreInteractions( managerListener ); } + @Test public void testNoScmUrlPerform() throws Exception { @@ -625,6 +668,7 @@ public void testNoScmUrlPerform() } } + @Test public void testScmExceptionThrown() throws Exception { @@ -669,6 +713,7 @@ public void testScmExceptionThrown() verifyNoMoreInteractions( scmProviderMock ); } + @Test public void testScmResultFailure() throws Exception { @@ -704,6 +749,7 @@ public void testScmResultFailure() } // MRELEASE-1042 + @Test public void testKeepProfilesOnPerform() throws Exception { @@ -735,10 +781,15 @@ public void testKeepProfilesOnPerform() assertTrue( result.getOutput().contains( "-P aProfile,bProfile,anotherOne" ) ); } + @Test public void testDetermineWorkingDirectory() throws Exception { - DefaultReleaseManager defaultReleaseManager = new DefaultReleaseManager(); + DefaultReleaseManager defaultReleaseManager = new DefaultReleaseManager( + Collections.emptyMap(), + Collections.emptyMap(), + mock( ReleaseDescriptorStore.class ) + ); File checkoutDir = getTestFile( "target/checkout" ); FileUtils.forceDelete( checkoutDir ); @@ -761,6 +812,7 @@ public void testDetermineWorkingDirectory() } // MRELEASE-761 + @Test public void testRollbackCall() throws Exception { @@ -778,6 +830,7 @@ public void testRollbackCall() // MRELEASE-765 + @Test public void testUpdateVersionsCall() throws Exception { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java index 9b491cc29..59b0ab696 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java @@ -19,14 +19,24 @@ * under the License. */ +import javax.inject.Singleton; + import static org.junit.Assert.fail; import java.io.File; import java.io.InputStream; - +import java.util.Map; + +import com.google.inject.AbstractModule; +import com.google.inject.Module; +import org.apache.maven.scm.manager.ScmManager; +import org.apache.maven.shared.release.config.ReleaseDescriptorStore; +import org.apache.maven.shared.release.config.ReleaseDescriptorStoreStub; +import org.apache.maven.shared.release.stubs.ScmManagerStub; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -86,7 +96,11 @@ protected void setupContainer() final String config = getCustomConfigurationName(); final ContainerConfiguration containerConfiguration = - new DefaultContainerConfiguration().setName( "test" ).setContext( context.getContextData() ).setClassPathCaching( true ); + new DefaultContainerConfiguration() + .setName( "test" ) + .setContext( context.getContextData() ) + .setAutoWiring( true ) + .setClassPathScanning( PlexusConstants.SCANNING_CACHE ); if ( config != null ) { @@ -103,7 +117,7 @@ protected void setupContainer() try { - container = new DefaultPlexusContainer( containerConfiguration ); + container = new DefaultPlexusContainer( containerConfiguration, getCustomModules() ); } catch ( final PlexusContainerException e ) { @@ -112,6 +126,23 @@ protected void setupContainer() } } + /** + * Allows test to define custom modules. + */ + protected Module[] getCustomModules() + { + return new Module[] { + new AbstractModule() + { + @Override + protected void configure() + { + bind( ScmManager.class ).to( ScmManagerStub.class ).in( Singleton.class ); + } + } + }; + } + /** * Allow custom test case implementations do augment the default container configuration before executing tests. * @@ -221,6 +252,12 @@ protected T lookup( final Class componentClass, final String roleHint ) return getContainer().lookup( componentClass, roleHint ); } + protected Map lookupMap( final Class componentClass ) + throws Exception + { + return getContainer().lookupMap( componentClass ); + } + protected void release( final Object component ) throws Exception { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStoreTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStoreTest.java index e563fab00..27e03d982 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStoreTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/PropertiesReleaseDescriptorStoreTest.java @@ -1,6 +1,11 @@ package org.apache.maven.shared.release.config; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileInputStream; @@ -8,6 +13,7 @@ import java.io.InputStream; import java.util.Properties; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder.BuilderReleaseDescriptor; /* @@ -31,7 +37,7 @@ import org.apache.maven.shared.release.phase.AbstractReleaseTestCase; import org.apache.maven.shared.release.scm.IdentifiedScm; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; /** @@ -40,21 +46,22 @@ * @author Brett Porter */ public class PropertiesReleaseDescriptorStoreTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private PropertiesReleaseDescriptorStore store; private SecDispatcher secDispatcher; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); store = (PropertiesReleaseDescriptorStore) lookup( ReleaseDescriptorStore.class, "properties" ); - secDispatcher = lookup( SecDispatcher.class, "mng-4384" ); + secDispatcher = lookup( SecDispatcher.class ); } + @Test public void testReadFromFile() throws ReleaseDescriptorStoreException { @@ -67,6 +74,7 @@ public void testReadFromFile() assertEquals( "check matches", expected, config ); } + @Test public void testReadFromFileUsingWorkingDirectory() throws Exception { @@ -80,6 +88,7 @@ public void testReadFromFileUsingWorkingDirectory() assertEquals( "check matches", expected.build(), config ); } + @Test public void testReadFromEmptyFile() throws ReleaseDescriptorStoreException { @@ -90,6 +99,7 @@ public void testReadFromEmptyFile() assertDefaultReleaseConfiguration( config ); } + @Test public void testReadMissingFile() throws ReleaseDescriptorStoreException { @@ -100,6 +110,7 @@ public void testReadMissingFile() assertDefaultReleaseConfiguration( config ); } + @Test public void testMergeFromEmptyFile() throws ReleaseDescriptorStoreException, IOException { @@ -111,6 +122,7 @@ public void testMergeFromEmptyFile() assertEquals( "Check configurations merged", mergeDescriptor.build(), config ); } + @Test public void testMergeFromMissingFile() throws ReleaseDescriptorStoreException, IOException { @@ -122,6 +134,7 @@ public void testMergeFromMissingFile() assertEquals( "Check configurations merged", mergeDescriptor.build(), config ); } + @Test public void testWriteToNewFile() throws Exception { @@ -141,6 +154,7 @@ public void testWriteToNewFile() assertEquals( "compare configuration", config.build(), rereadDescriptor ); } + @Test public void testWriteToWorkingDirectory() throws Exception { @@ -163,6 +177,7 @@ public void testWriteToWorkingDirectory() assertEquals( "compare configuration", config.build(), rereadDescriptorBuilder.build() ); } + @Test public void testWriteToNewFileRequiredOnly() throws ReleaseDescriptorStoreException { @@ -181,6 +196,7 @@ public void testWriteToNewFileRequiredOnly() assertEquals( "compare configuration", config.build(), rereadDescriptor ); } + @Test public void testWriteToNewFileDottedIds() throws ReleaseDescriptorStoreException { @@ -210,6 +226,7 @@ public void testWriteToNewFileDottedIds() assertEquals( "compare configuration", config.build(), rereadDescriptor ); } + @Test public void testWriteToNewFileNullMappedScm() throws ReleaseDescriptorStoreException { @@ -236,6 +253,7 @@ public void testWriteToNewFileNullMappedScm() assertEquals( "compare configuration", builder.build(), rereadDescriptor ); } + @Test public void testOverwriteFile() throws Exception { @@ -253,7 +271,8 @@ public void testOverwriteFile() assertEquals( "compare configuration", config.build(), rereadDescriptor ); } - + + @Test public void testDeleteFile() throws ReleaseDescriptorStoreException, IOException { @@ -270,6 +289,7 @@ public void testDeleteFile() assertFalse( "Check file already exists", file.exists() ); } + @Test public void testMissingDeleteFile() throws ReleaseDescriptorStoreException, IOException { @@ -285,7 +305,8 @@ public void testMissingDeleteFile() assertFalse( "Check file already exists", file.exists() ); } - + + @Test public void testWriteEncryptedProperties() throws Exception { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java index 22faa9760..841210036 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/config/ReleaseUtilsTest.java @@ -19,26 +19,29 @@ * under the License. */ -import junit.framework.TestCase; - import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.model.Scm; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder.BuilderReleaseDescriptor; import org.apache.maven.shared.release.phase.AbstractReleaseTestCase; +import org.junit.Test; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Properties; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * ReleaseDescriptor Tester. * * @author Brett Porter */ public class ReleaseUtilsTest - extends TestCase { + @Test public void testEquals() throws IOException { @@ -202,6 +205,7 @@ private static void doEqualsAssertions( ReleaseDescriptorBuilder releaseDescript assertFalse( "Check original comparison", configBuilder.build().equals( origConfig ) ); } + @Test public void testHashCode() throws IOException { @@ -211,6 +215,7 @@ public void testHashCode() createReleaseDescriptor( releaseDescriptor.getWorkingDirectory() ).build().hashCode() ); } + @Test public void testLoadResolvedDependencies() { Properties properties = new Properties(); @@ -227,6 +232,7 @@ public void testLoadResolvedDependencies() } // MRELEASE-750 + @Test public void testArtifactIdEndswithDependency() { Properties properties = new Properties(); @@ -244,6 +250,7 @@ public void testArtifactIdEndswithDependency() } // MRELEASE-834 + @Test public void testSystemPropertyStartingWithDependency() { Properties properties = new Properties(); @@ -252,6 +259,7 @@ public void testSystemPropertyStartingWithDependency() } // MRELEASE-1038 + @Test public void testActiveProfilesProperty() { ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/AbstractMavenExecutorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/AbstractMavenExecutorTest.java index 79bef7a04..385a232a5 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/AbstractMavenExecutorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/AbstractMavenExecutorTest.java @@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; @@ -36,15 +37,17 @@ import org.apache.maven.shared.release.env.ReleaseEnvironment; import junit.framework.TestCase; +import org.apache.maven.shared.release.util.MavenCrypto; +import org.junit.Test; public class AbstractMavenExecutorTest - extends TestCase { + @Test public void testGoalSeparation() throws MavenExecutorException { - AbstractMavenExecutor executor = spy( new AbstractMavenExecutorSpy() ); + AbstractMavenExecutor executor = spy( new AbstractMavenExecutorSpy( mock( MavenCrypto.class ) ) ); executor.executeGoals( null, (String) null, new DefaultReleaseEnvironment(), true, null, null, null ); verify( executor ).executeGoals( isNull(), eq( new ArrayList() ), @@ -98,6 +101,10 @@ public void testGoalSeparation() protected class AbstractMavenExecutorSpy extends AbstractMavenExecutor { + public AbstractMavenExecutorSpy( MavenCrypto mavenCrypto ) + { + super( mavenCrypto ); + } @Override protected void executeGoals( File workingDirectory, List goals, ReleaseEnvironment releaseEnvironment, diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/CommandLineFactoryTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/CommandLineFactoryTest.java index 19e15c742..813b38443 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/CommandLineFactoryTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/CommandLineFactoryTest.java @@ -19,8 +19,13 @@ * under the License. */ -import org.codehaus.plexus.PlexusTestCase; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.codehaus.plexus.util.cli.Commandline; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Test the command line factory. @@ -28,19 +33,20 @@ * @author Brett Porter */ public class CommandLineFactoryTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private CommandLineFactory factory; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - factory = (CommandLineFactory) lookup( CommandLineFactory.class ); + factory = lookup( CommandLineFactory.class ); } + @Test public void testCreation() throws Exception { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.java index a159df221..122bd17e7 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.java @@ -19,10 +19,14 @@ * under the License. */ -import static org.mockito.Matchers.endsWith; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; -import static org.mockito.Matchers.isNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.endsWith; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; @@ -39,12 +43,14 @@ import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; -import org.codehaus.plexus.PlexusTestCase; +import org.apache.maven.shared.release.util.MavenCrypto; import org.codehaus.plexus.util.cli.Arg; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.Commandline; +import org.junit.Test; import org.mockito.ArgumentCaptor; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; @@ -54,23 +60,22 @@ * @author Brett Porter */ public class ForkedMavenExecutorTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { - private ForkedMavenExecutor executor; - + private MavenCrypto mavenCrypto; private SecDispatcher secDispatcher; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - executor = (ForkedMavenExecutor) lookup( MavenExecutor.class, "forked-path" ); - - secDispatcher = (SecDispatcher) lookup( SecDispatcher.class, "mng-4384" ); + mavenCrypto = lookup( MavenCrypto.class ); + secDispatcher = lookup( SecDispatcher.class ); } + @Test public void testExecution() throws Exception { @@ -91,7 +96,7 @@ public void testExecution() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( isA( String.class ) /*"mvn"*/ ) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); // execute executor.executeGoals( workingDirectory, "clean integration-test", new DefaultReleaseEnvironment(), false, null, @@ -115,6 +120,7 @@ public void testExecution() verifyNoMoreInteractions( mockProcess, commandLineFactoryMock, commandLineMock, valueArgument ); } + @Test public void testExecutionWithCustomPomFile() throws Exception { @@ -134,7 +140,7 @@ public void testExecutionWithCustomPomFile() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( isA( String.class ) /* "mvn" */ ) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); // execute executor.executeGoals( workingDirectory, "clean integration-test", new DefaultReleaseEnvironment(), false, null, "my-pom.xml", @@ -159,6 +165,7 @@ public void testExecutionWithCustomPomFile() verifyNoMoreInteractions( mockProcess, commandLineMock, argMock, commandLineFactoryMock ); } + @Test public void testExecutionWithArguments() throws Exception { @@ -178,7 +185,7 @@ public void testExecutionWithArguments() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( endsWith( "mvn" ) ) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); // execute String arguments = "-DperformRelease=true -Dmaven.test.skip=true"; @@ -203,6 +210,7 @@ public void testExecutionWithArguments() verifyNoMoreInteractions( mockProcess, commandLineMock, argMock, commandLineFactoryMock ); } + @Test public void testExecutionWithNonZeroExitCode() throws Exception { @@ -224,7 +232,7 @@ public void testExecutionWithNonZeroExitCode() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( endsWith( "mvn" ) ) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); // execute try @@ -257,6 +265,7 @@ public void testExecutionWithNonZeroExitCode() verifyNoMoreInteractions( mockProcess, commandLineMock, argMock, commandLineFactoryMock ); } + @Test public void testExecutionWithCommandLineException() throws Exception { @@ -272,7 +281,7 @@ public void testExecutionWithCommandLineException() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( endsWith( "mvn" ) ) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); // execute try @@ -300,6 +309,7 @@ public void testExecutionWithCommandLineException() verifyNoMoreInteractions( commandLineMock, argMock, commandLineFactoryMock ); } + @Test public void testEncryptSettings() throws Exception { @@ -320,7 +330,7 @@ public void testEncryptSettings() CommandLineFactory commandLineFactoryMock = mock( CommandLineFactory.class ); when( commandLineFactoryMock.createCommandLine( isA( String.class ) /* "mvn" */) ).thenReturn( commandLineMock ); - executor.setCommandLineFactory( commandLineFactoryMock ); + ForkedMavenExecutor executor = new ForkedMavenExecutor( mavenCrypto, commandLineFactoryMock ); Settings settings = new Settings(); Server server = new Server(); @@ -357,9 +367,9 @@ public void testEncryptSettings() File settingsSecurity = new File( System.getProperty( "user.home" ), ".m2/settings-security.xml" ); if ( settingsSecurity.exists() ) { - assertFalse( "server_passphrase".equals( encryptedServer.getPassphrase() ) ); - assertFalse( "server_password".equals( encryptedServer.getPassword() ) ); - assertFalse( "proxy_password".equals( encryptedProxy.getPassword() ) ); + assertNotEquals( "server_passphrase", encryptedServer.getPassphrase() ); + assertNotEquals( "server_password", encryptedServer.getPassword() ); + assertNotEquals( "proxy_password", encryptedProxy.getPassword() ); } } } \ No newline at end of file diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java index cdb2cedae..b8afc8b12 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/InvokerMavenExecutorTest.java @@ -19,6 +19,11 @@ * under the License. */ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -34,8 +39,10 @@ import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer; import org.apache.maven.shared.invoker.DefaultInvocationRequest; import org.apache.maven.shared.invoker.InvocationRequest; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.util.MavenCrypto; import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.logging.Logger; import org.junit.Test; @@ -43,30 +50,28 @@ import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; public class InvokerMavenExecutorTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { - private InvokerMavenExecutor executor; + private MavenCrypto mavenCrypto; private SecDispatcher secDispatcher; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - executor = (InvokerMavenExecutor) lookup( MavenExecutor.class, "invoker" ); - - secDispatcher = (SecDispatcher) lookup( SecDispatcher.class, "mng-4384" ); + mavenCrypto = lookup( MavenCrypto.class ); + secDispatcher = lookup( SecDispatcher.class ); } @Test public void testThreads() throws Exception { - Logger logger = mock( Logger.class ); - executor.enableLogging( logger ); + InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); InvocationRequest req = new DefaultInvocationRequest(); executor.setupRequest( req, null, "-T 3" ); @@ -85,8 +90,7 @@ public void testThreads() public void testBatch() throws Exception { - Logger logger = mock( Logger.class ); - executor.enableLogging( logger ); + InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); InvocationRequest req = new DefaultInvocationRequest(); @@ -104,8 +108,7 @@ public void testBatch() public void testUserToolchains() throws Exception { - Logger logger = mock( Logger.class ); - executor.enableLogging( logger ); + InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); InvocationRequest req = new DefaultInvocationRequest(); executor.setupRequest( req, null, "-t mytoolchains.xml" ); @@ -124,8 +127,7 @@ public void testUserToolchains() public void testGlobalSettings() throws Exception { - Logger logger = mock( Logger.class ); - executor.enableLogging( logger ); + InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); InvocationRequest req = new DefaultInvocationRequest(); executor.setupRequest( req, null, "-gs custom-settings.xml" ); @@ -139,6 +141,8 @@ public void testGlobalSettings() public void testEncryptSettings() throws Exception { + InvokerMavenExecutor executor = new InvokerMavenExecutor( mavenCrypto ); + // prepare File workingDirectory = getTestFile( "target/working-directory" ); workingDirectory.mkdirs(); @@ -188,9 +192,9 @@ public void testEncryptSettings() File settingsSecurity = new File( System.getProperty( "user.home" ), ".m2/settings-security.xml" ); if ( settingsSecurity.exists() ) { - assertFalse( "server_passphrase".equals( encryptedServer.getPassphrase() ) ); - assertFalse( "server_password".equals( encryptedServer.getPassword() ) ); - assertFalse( "proxy_password".equals( encryptedProxy.getPassword() ) ); + assertNotEquals( "server_passphrase", encryptedServer.getPassphrase() ); + assertNotEquals( "server_password", encryptedServer.getPassword() ); + assertNotEquals( "proxy_password", encryptedProxy.getPassword() ); } } } diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeConsumerTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeConsumerTest.java index d7d2e04ef..f7af78bfa 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeConsumerTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeConsumerTest.java @@ -20,34 +20,27 @@ */ import junit.framework.TestCase; +import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import static org.junit.Assert.assertEquals; + /** * Test the consumer that tees output both to a stream and into an internal buffer for later. * * @author Brett Porter */ public class TeeConsumerTest - extends TestCase { - private TeeConsumer consumer; + private final ByteArrayOutputStream out = new ByteArrayOutputStream(); - private ByteArrayOutputStream out; + private final TeeConsumer consumer = new TeeConsumer( new PrintStream( out ), "xxx " ); private static final String LS = System.getProperty( "line.separator" ); - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - out = new ByteArrayOutputStream(); - consumer = new TeeConsumer( new PrintStream( out ), "xxx " ); - } - + @Test public void testConsumeLine() { consumer.consumeLine( "line" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeOutputStreamTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeOutputStreamTest.java index 0855a4179..50cd6c7f1 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeOutputStreamTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/exec/TeeOutputStreamTest.java @@ -19,37 +19,29 @@ * under the License. */ -import junit.framework.TestCase; - import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + /** * Test the output stream that tees output both to a stream and into an internal buffer for later. * * @author Benjamin Bentmann */ public class TeeOutputStreamTest - extends TestCase { - private TeeOutputStream stream; + private final ByteArrayOutputStream out = new ByteArrayOutputStream(); - private ByteArrayOutputStream out; + private final TeeOutputStream stream = new TeeOutputStream( new PrintStream( out ), "xxx " ); private static final String LS = System.getProperty( "line.separator" ); - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - out = new ByteArrayOutputStream(); - stream = new TeeOutputStream( new PrintStream( out ), "xxx " ); - } - + @Test public void testConsumeLine() - throws Exception + throws Exception { stream.write( ( "the first line" + LS + "line2" + LS + "3" + LS ).getBytes() ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractEditModeRewritingReleasePhaseTestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractEditModeRewritingReleasePhaseTestCase.java index 4e1372879..5541e6f03 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractEditModeRewritingReleasePhaseTestCase.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractEditModeRewritingReleasePhaseTestCase.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -31,6 +31,7 @@ import java.util.List; +import com.google.inject.Module; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; @@ -62,6 +63,12 @@ public AbstractEditModeRewritingReleasePhaseTestCase( String modelETL ) super( modelETL ); } + @Override + protected Module[] getCustomModules() + { + return new Module[0]; // real SCM needed + } + @Test public void testRewriteBasicPomWithEditMode() throws Exception diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java index 989fad22a..be529f413 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractReleaseTestCase.java @@ -32,7 +32,6 @@ import java.nio.file.StandardCopyOption; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -58,12 +57,13 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.ProjectBuildingResult; import org.apache.maven.project.ProjectSorter; -import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; -import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager; -import org.sonatype.aether.repository.WorkspaceReader; -import org.sonatype.aether.repository.WorkspaceRepository; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.WorkspaceReader; +import org.eclipse.aether.repository.WorkspaceRepository; import org.xmlunit.builder.DiffBuilder; import org.xmlunit.diff.Comparison; import org.xmlunit.diff.ComparisonResult; @@ -170,7 +170,7 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) } List repos = - Collections.singletonList( new DefaultArtifactRepository( "central", + Collections.singletonList( new DefaultArtifactRepository( "central", getRemoteRepositoryURL(), new DefaultRepositoryLayout() ) ); @@ -187,11 +187,11 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) buildingRequest.setRemoteRepositories( repos ); buildingRequest.setPluginArtifactRepositories( repos ); buildingRequest.setRepositoryMerging( RepositoryMerging.REQUEST_DOMINANT ); - MavenRepositorySystemSession repositorySession = new MavenRepositorySystemSession(); - repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( localRepository.getBasedir() ) ); + DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); + repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repositorySession, new LocalRepository( localRepository.getBasedir() ) ) ); buildingRequest.setRepositorySession( repositorySession ); buildingRequest.addProfile( profile ); - buildingRequest.setActiveProfileIds( Arrays.asList( profile.getId() ) ); + buildingRequest.setActiveProfileIds( Collections.singletonList( profile.getId() ) ); buildingRequest.setResolveDependencies( true ); List buildingResults = @@ -213,9 +213,9 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) for ( MavenProject project : reactorProjects ) { MavenProject resolvedProject = projectBuilder.build( project.getFile(), buildingRequest ).getProject(); - + // from LifecycleDependencyResolver - if ( project.getDependencyArtifacts() == null ) + if ( resolvedProject.getDependencyArtifacts() == null ) { try { @@ -226,7 +226,15 @@ public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) throw new LifecycleExecutionException( e ); } } - + + // TODO .... understand why this is working ... :-) + // why projectBuilder doesn't resolve and set in proper way DependencyArtifacts and Artifacts + if ( resolvedProject.getDependencyArtifacts().size() >= resolvedProject.getArtifacts().size() + && resolvedProject.getDependencyArtifacts().stream().noneMatch( a -> a.getVersion() == null ) ) + { + resolvedProject.setArtifacts( resolvedProject.getDependencyArtifacts() ); + } + resolvedProjects.add( resolvedProject ); } return resolvedProjects; @@ -387,7 +395,7 @@ public WorkspaceRepository getRepository() } @Override - public List findVersions( org.sonatype.aether.artifact.Artifact artifact ) + public List findVersions( org.eclipse.aether.artifact.Artifact artifact ) { for ( MavenProject mavenProject : reactorProjects ) { @@ -400,7 +408,7 @@ public List findVersions( org.sonatype.aether.artifact.Artifact artifact } @Override - public File findArtifact( org.sonatype.aether.artifact.Artifact artifact ) + public File findArtifact( org.eclipse.aether.artifact.Artifact artifact ) { for ( MavenProject mavenProject : reactorProjects ) { @@ -419,4 +427,4 @@ else if ( Objects.equals( artifact.toString(), mavenProject.getArtifact().toStri return null; } } -} \ No newline at end of file +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java index 08a604263..40e4eb7c1 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractRewritingReleasePhaseTestCase.java @@ -64,12 +64,12 @@ public abstract class AbstractRewritingReleasePhaseTestCase extends AbstractReleaseTestCase { - private String modelETL; + private final String modelETL; @Parameters public static Collection data() { - return Arrays.asList( new Object[][] { { JDomModelETLFactory.ROLE_HINT } } ); + return Arrays.asList( new Object[][] { { JDomModelETLFactory.NAME } } ); } public AbstractRewritingReleasePhaseTestCase( String modelETL ) diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhaseTest.java index 3a6bbae2e..594a446e3 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/AbstractScmCommitPhaseTest.java @@ -35,7 +35,6 @@ public class AbstractScmCommitPhaseTest { @Test public void testDefaultCreatePomFiles() - throws Exception { List files = AbstractScmCommitPhase.createPomFiles( ReleaseUtils.buildReleaseDescriptor( new ReleaseDescriptorBuilder() ), @@ -48,7 +47,6 @@ public void testDefaultCreatePomFiles() @Test public void testCreatePomFilesSuppressCommitBeforeTag() - throws Exception { ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setSuppressCommitBeforeTagOrBranch( true ); @@ -61,7 +59,6 @@ public void testCreatePomFilesSuppressCommitBeforeTag() @Test public void testCreatePomFilesWithReleasePom() - throws Exception { ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setGenerateReleasePoms( true ); @@ -75,7 +72,6 @@ public void testCreatePomFilesWithReleasePom() @Test public void testCreatePomFilesWithReleasePomAndSuppressCommitBeforeTag() - throws Exception { ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setGenerateReleasePoms( true ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.java index 1ff575f7c..67e51b736 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -32,13 +32,17 @@ import java.util.Collections; import java.util.List; +import com.google.inject.AbstractModule; +import com.google.inject.Module; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; +import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.stubs.ScmManagerStub; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; import org.junit.Test; @@ -51,14 +55,14 @@ public class BranchInputVariablesPhaseTest extends PlexusJUnit4TestCase { - private InputVariablesPhase phase; + private BranchInputVariablesPhase phase; @Override public void setUp() throws Exception { super.setUp(); - phase = (InputVariablesPhase) lookup( ReleasePhase.class, "branch-input-variables" ); + phase = (BranchInputVariablesPhase) lookup( ReleasePhase.class, "branch-input-variables" ); } @Test @@ -68,6 +72,8 @@ public void testInputVariablesInteractive() // prepare Prompter mockPrompter = mock( Prompter.class ); when( mockPrompter.prompt( isA( String.class ) ) ).thenReturn( "tag-value", "simulated-tag-value" ); + + phase.setPrompter( mockPrompter ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -99,7 +105,6 @@ public void testInputVariablesInteractive() @Test public void testUnmappedVersion() - throws Exception { List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -250,14 +255,12 @@ public void testPrompterException() @Test public void testBranchOperation() - throws Exception { assertTrue( phase.isBranchOperation() ); } @Test public void testEmptyBranchName() - throws Exception { // prepare Prompter mockPrompter = mock( Prompter.class ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckPomPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckPomPhaseTest.java index 46ee81c7c..c93ed59ca 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckPomPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckPomPhaseTest.java @@ -19,37 +19,50 @@ * under the License. */ +import com.google.inject.Module; import org.apache.maven.model.Model; import org.apache.maven.model.Scm; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; import java.util.Collections; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Test the POM verification check phase. * * @author Brett Porter */ public class CheckPomPhaseTest - extends PlexusTestCase + extends PlexusJUnit4TestCase { private ReleasePhase phase; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - phase = (ReleasePhase) lookup( ReleasePhase.class, "check-poms" ); + phase = lookup( ReleasePhase.class, "check-poms" ); + } + + @Override + protected Module[] getCustomModules() + { + return new Module[0]; // real SCM needed } + @Test public void testCorrectlyConfigured() throws Exception { @@ -64,6 +77,7 @@ public void testCorrectlyConfigured() assertTrue( true ); } + @Test public void testGetUrlFromProjectConnection() throws Exception { @@ -77,6 +91,7 @@ public void testGetUrlFromProjectConnection() assertEquals( "Check URL", "scm:svn:file://localhost/tmp/repo", ReleaseUtils.buildReleaseDescriptor( builder ).getScmSourceUrl() ); } + @Test public void testGetUrlFromProjectConnectionSimulate() throws Exception { @@ -90,6 +105,7 @@ public void testGetUrlFromProjectConnectionSimulate() assertEquals( "Check URL", "scm:svn:file://localhost/tmp/repo", ReleaseUtils.buildReleaseDescriptor( builder ).getScmSourceUrl() ); } + @Test public void testGetUrlFromProjectDevConnection() throws Exception { @@ -103,6 +119,7 @@ public void testGetUrlFromProjectDevConnection() assertEquals( "Check URL", "scm:svn:https://localhost/tmp/repo", ReleaseUtils.buildReleaseDescriptor( builder ).getScmSourceUrl() ); } + @Test public void testGetUrlFromProjectDevConnectionSimulate() throws Exception { @@ -116,6 +133,7 @@ public void testGetUrlFromProjectDevConnectionSimulate() assertEquals( "Check URL", "scm:svn:https://localhost/tmp/repo", ReleaseUtils.buildReleaseDescriptor( builder ).getScmSourceUrl() ); } + @Test public void testGetInvalidUrl() throws Exception { @@ -136,6 +154,7 @@ public void testGetInvalidUrl() } } + @Test public void testGetInvalidProvider() throws Exception { @@ -157,6 +176,7 @@ public void testGetInvalidProvider() } } + @Test public void testMissingUrl() throws Exception { @@ -185,6 +205,7 @@ public void testMissingUrl() } } + @Test public void testReleasingNonSnapshot() throws Exception { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java index 3ac4eb57d..c94acf393 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java @@ -22,9 +22,9 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -58,15 +58,13 @@ public class CheckoutProjectFromScmTest extends AbstractReleaseTestCase { - private CheckoutProjectFromScm phase; - @Override public void setUp() throws Exception { super.setUp(); - phase = (CheckoutProjectFromScm) lookup( ReleasePhase.class, "checkout-project-from-scm" ); + phase = lookup( ReleasePhase.class, "checkout-project-from-scm" ); } @Test diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.java index ad381eead..d269eae42 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.java @@ -19,6 +19,8 @@ * under the License. */ +import javax.inject.Singleton; + import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.argThat; @@ -35,6 +37,9 @@ import java.util.Iterator; import java.util.List; +import com.google.inject.AbstractModule; +import com.google.inject.Module; +import com.google.inject.name.Names; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; @@ -47,6 +52,7 @@ import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.scm.ScmTranslator; import org.apache.maven.shared.release.util.ReleaseUtil; import org.junit.Test; @@ -78,6 +84,27 @@ public void setUp() scmProviderMock = null; } + @Override + protected Module[] getCustomModules() + { + return new Module[] { + new AbstractModule() + { + @Override + protected void configure() + { + bind( ScmManager.class ) + .to( org.apache.maven.shared.release.stubs.ScmManagerStub.class ) + .in( Singleton.class ); + bind( ScmTranslator.class ) + .annotatedWith( Names.named( "stub-provider" ) ) + .to( org.apache.maven.shared.release.scm.SubversionScmTranslator.class ) + .in( Singleton.class ); + } + } + }; + } + @Override protected String getRoleHint() { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java index 6c215e0e2..e4f093843 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/InputVariablesPhaseTest.java @@ -32,6 +32,7 @@ import java.util.Collections; import java.util.List; +import java.util.Map; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; @@ -40,6 +41,8 @@ import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.policy.naming.NamingPolicy; +import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; import org.junit.Test; @@ -54,12 +57,17 @@ public class InputVariablesPhaseTest { private InputVariablesPhase phase; + private ScmRepositoryConfigurator scmRepositoryConfigurator; + + private Map namingPolicies; + @Override public void setUp() throws Exception { super.setUp(); - phase = (InputVariablesPhase) lookup( ReleasePhase.class, "input-variables" ); + scmRepositoryConfigurator = lookup( ScmRepositoryConfigurator.class ); + namingPolicies = lookupMap( NamingPolicy.class ); } @Test @@ -70,7 +78,7 @@ public void testInputVariablesInteractive() Prompter mockPrompter = mock( Prompter.class ); when( mockPrompter.prompt( isA( String.class ), eq( "artifactId-1.0" ) ) ).thenReturn( "tag-value", "simulated-tag-value" ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -107,6 +115,9 @@ public void testUnmappedVersion() ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + Prompter mockPrompter = mock( Prompter.class ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); + try { phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -138,7 +149,7 @@ public void testInputVariablesNonInteractive() { // prepare Prompter mockPrompter = mock( Prompter.class ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -175,7 +186,7 @@ public void testInputVariablesNonInteractiveConfigured() { // prepare Prompter mockPrompter = mock( Prompter.class ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -210,7 +221,7 @@ public void testInputVariablesInteractiveConfigured() { // prepare Prompter mockPrompter = mock( Prompter.class ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -245,7 +256,7 @@ public void testPrompterException() Prompter mockPrompter = mock( Prompter.class ); when( mockPrompter.prompt( isA( String.class ), isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -294,7 +305,7 @@ public void testSvnTag() { // prepare Prompter mockPrompter = mock( Prompter.class ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -332,7 +343,7 @@ public void testCustomTagFormat() { // prepare Prompter mockPrompter = mock( Prompter.class ); - phase.setPrompter( mockPrompter ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); @@ -367,6 +378,9 @@ public void testCustomTagFormat() public void testBranchOperation() throws Exception { + // prepare + Prompter mockPrompter = mock( Prompter.class ); + phase = new InputVariablesPhase( mockPrompter, scmRepositoryConfigurator, namingPolicies ); assertFalse( phase.isBranchOperation() ); } diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionPhaseIT.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionPhaseIT.java index bbd55208e..d8943dc6b 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionPhaseIT.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapDevelopmentVersionPhaseIT.java @@ -24,22 +24,25 @@ import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class MapDevelopmentVersionPhaseIT - extends PlexusTestCase + extends PlexusJUnit4TestCase { - private MapVersionsPhase mapVersionsPhase; + private MapDevelopmentVersionsPhase mapDevelopmentVersionsPhase; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - mapVersionsPhase = (MapVersionsPhase) lookup( ReleasePhase.class, "map-development-versions" ); + mapDevelopmentVersionsPhase = (MapDevelopmentVersionsPhase) lookup( ReleasePhase.class, "map-development-versions" ); } private static MavenProject createProject( String artifactId, String version ) @@ -51,6 +54,7 @@ private static MavenProject createProject( String artifactId, String version ) return new MavenProject( model ); } + @Test public void testNoUpdateWorkingCopyVersions() throws Exception { ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); @@ -58,7 +62,7 @@ public void testNoUpdateWorkingCopyVersions() throws Exception builder.setUpdateWorkingCopyVersions( false ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); - mapVersionsPhase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); + mapDevelopmentVersionsPhase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); assertEquals( "1.0", ReleaseUtils.buildReleaseDescriptor( builder ).getProjectDevelopmentVersion( "groupId:artifactId" ) ); } diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java index 00a19b50f..8c8196ec5 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; @@ -45,6 +46,7 @@ import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; import org.apache.maven.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.version.VersionPolicy; import org.apache.maven.shared.release.versions.VersionParseException; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; @@ -61,21 +63,18 @@ public class MapVersionsPhaseTest extends PlexusJUnit4TestCase { - private static final String TEST_MAP_BRANCH_VERSIONS = "test-map-branch-versions"; - - private static final String TEST_MAP_DEVELOPMENT_VERSIONS = "test-map-development-versions"; - - private static final String TEST_MAP_RELEASE_VERSIONS = "test-map-release-versions"; - @Mock private Prompter mockPrompter; + private Map versionPolicies; + @Override public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks( this ); + versionPolicies = lookupMap( VersionPolicy.class ); } @Override @@ -91,12 +90,10 @@ public void testExecuteSnapshot_MapRelease() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), - eq( "1.0" ) ) ).thenReturn( "2.0" ); - phase.setPrompter( mockPrompter ); + eq( "1.0" ) ) ).thenReturn( "2.0" ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -118,12 +115,10 @@ public void testSimulateSnapshot_MapReleaseVersions() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), - eq( "1.0" ) ) ).thenReturn( "2.0" ); - phase.setPrompter( mockPrompter ); + eq( "1.0" ) ) ).thenReturn( "2.0" ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -145,12 +140,10 @@ public void testMapReleaseVersionsInteractiveAddZeroIncremental() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0-SNAPSHOT" ); - when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), - eq( "1.0" ) ) ).thenReturn( "1.0.0" ); - phase.setPrompter( mockPrompter ); + eq( "1.0" ) ) ).thenReturn( "1.0.0" ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -185,12 +178,10 @@ public void testMapReleaseVersionsInteractiveWithSnaphotVersion() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); MavenProject project = createProject( "artifactId", "SNAPSHOT" ); - when( mockPrompter.prompt( startsWith( "What is the release version for \"" + project.getName() + "\"?" ), - eq( "1.0" ) ) ).thenReturn( "2.0" ); - phase.setPrompter( mockPrompter ); + eq( "1.0" ) ) ).thenReturn( "2.0" ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -228,13 +219,11 @@ public void testMapReleaseVersionsNonInteractiveWithExplicitVersion() // prepare List reactorProjects = Collections.singletonList( createProject( "artifactId", "SNAPSHOT" ) ); - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.addReleaseVersion( "groupId:artifactId", "2.0" ); - phase.setPrompter( mockPrompter ); - // execute phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -270,15 +259,13 @@ public void testMapReleaseVersionsForSubModuleWithExplicitVersion() List reactorProjects = Arrays.asList( rootProject, moduleProject ); - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder() .setInteractive(false) // batch mode .setAutoVersionSubmodules( true ) .addReleaseVersion( "groupId:artifactId", "2.0" ); - phase.setPrompter( mockPrompter ); - // execute phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -314,7 +301,7 @@ public void testMapDevelopmentVersionsForSubModuleWithExplicitVersion() List reactorProjects = Arrays.asList( rootProject, moduleProject ); - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder() .setInteractive( false ) // batch mode @@ -322,10 +309,6 @@ public void testMapDevelopmentVersionsForSubModuleWithExplicitVersion() .setDefaultDevelopmentVersion( "1.1-SNAPSHOT" ) .addDevelopmentVersion( "groupId:artifactId", "2.0-SNAPSHOT" ); - phase.setConvertToSnapshot( true ); - phase.setPrompter( mockPrompter ); - - // execute phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -350,7 +333,7 @@ public void testExecuteSnapshotNonInteractive_MapRelease() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0-SNAPSHOT" ) ); @@ -370,7 +353,7 @@ public void testSimulateSnapshotNonInteractive_MapReleaseVersions() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0-SNAPSHOT" ) ); @@ -390,12 +373,10 @@ public void testMapDevVersionsInteractive() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); MavenProject project = createProject( "artifactId", "1.0" ); - when( mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() - + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); + + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -430,11 +411,9 @@ public void testMapDevVersionsInteractiveDoNotUpdateWorkingCopy() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); MavenProject project = createProject( "artifactId", "1.0" ); - phase.setPrompter( mockPrompter ); - List reactorProjects = Collections.singletonList( project ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); @@ -464,9 +443,7 @@ public void testMapDevVersionsNonInteractive() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); - - phase.setPrompter( mockPrompter ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -500,11 +477,9 @@ public void testMapDevVersionsNonInteractiveWithExplicitVersion() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); - phase.setPrompter( mockPrompter ); - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setInteractive( false ); builder.addDevelopmentVersion( "groupId:artifactId", "2-SNAPSHOT" ); @@ -534,11 +509,9 @@ public void testPrompterException() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); - when( mockPrompter.prompt( isA( String.class ), - isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); - phase.setPrompter( mockPrompter ); + isA( String.class ) ) ).thenThrow( new PrompterException( "..." ) ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0" ) ); @@ -580,12 +553,11 @@ public void testAdjustVersionInteractive() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); MavenProject project = createProject( "artifactId", "foo" ); when( mockPrompter.prompt( startsWith( "What is the new development version for \"" + project.getName() - + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); + + "\"?" ), eq( "1.1-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( project ); @@ -614,9 +586,8 @@ public void testAdjustVersionInteractive() @Test public void testAdjustVersionNonInteractive() - throws Exception { - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "foo" ) ); @@ -654,7 +625,7 @@ public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_MapDevel throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -676,7 +647,7 @@ public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_MapDeve throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -698,7 +669,7 @@ public void testExecuteSnapshotBranchCreation_DefaultDevelopmentVersion_NonInter throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -721,7 +692,7 @@ public void testSimulateSnapshotBranchCreation_DefaultDevelopmentVersion_NonInte throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -744,7 +715,7 @@ public void testExecuteSnapshotBranchCreation_NonInteractive_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -766,7 +737,7 @@ public void testSimulateSnapshotBranchCreation_NonInteractive_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -788,7 +759,7 @@ public void testExecuteSnapshotDefaultDevelopmentVersion_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -809,7 +780,7 @@ public void testSimulateSnapshotDefaultDevelopmentVersion_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -830,7 +801,7 @@ public void testExecuteSnapshotDefaultDevelopmentVersion_NonInteractive_MapDevel throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -852,7 +823,7 @@ public void testSimulateSnapshotDefaultDevelopmentVersion_NonInteractive_MapDeve throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -874,7 +845,7 @@ public void testExecuteSnapshotNonInteractive_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -895,7 +866,7 @@ public void testSimulateSnapshotNonInteractive_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -916,7 +887,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopme throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -938,7 +909,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapDevelopm throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -960,7 +931,7 @@ public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapDevelopmen throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -982,7 +953,7 @@ public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapDevelopme throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1004,7 +975,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1027,7 +998,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_NotInteractive_MapRelease( throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1050,7 +1021,7 @@ public void testExecuteReleaseAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1073,7 +1044,7 @@ public void testSimulateReleaseAutoVersionSubmodules_NotInteractive_MapRelease() throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1096,7 +1067,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteracti throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1119,7 +1090,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteract throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1142,7 +1113,7 @@ public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractiv throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1165,7 +1136,7 @@ public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteracti throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1188,7 +1159,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_BranchCreation_NotInteracti throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1212,7 +1183,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_BranchCreation_NotInteract throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1236,7 +1207,7 @@ public void testExecuteReleaseAutoVersionSubmodules_BranchCreation_NotInteractiv throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1265,7 +1236,7 @@ public void testSimulateReleaseAutoVersionSubmodules_BranchCreation_NotInteracti throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1294,7 +1265,7 @@ public void testExecuteSnapshotBranchCreation_NonInteractive_UpdateBranchVersion throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1321,7 +1292,7 @@ public void testSimulateSnapshotBranchCreation_NonInteractive_UpdateBranchVersio throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1348,7 +1319,7 @@ public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_NonInteracti throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1373,7 +1344,7 @@ public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_NonInteract throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1398,7 +1369,7 @@ public void testExecuteSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranch throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1422,7 +1393,7 @@ public void testSimulateSnapshotBranchCreation_DefaultReleaseVersion_UpdateBranc throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1446,7 +1417,12 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1454,13 +1430,6 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_MapBranch() builder.setBranchCreation( true ); builder.setUpdateBranchVersions( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1475,7 +1444,12 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1483,13 +1457,6 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_MapBranch() builder.setBranchCreation( true ); builder.setUpdateBranchVersions( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1504,7 +1471,12 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_UpdateVersions throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1513,13 +1485,6 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_UpdateVersions builder.setUpdateBranchVersions( true ); builder.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1538,7 +1503,12 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_UpdateVersion throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1547,13 +1517,6 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_UpdateVersion builder.setUpdateBranchVersions( true ); builder.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT (yes, one step back!) - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.1-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1572,7 +1535,12 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_UpdateVersion throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1581,13 +1549,6 @@ public void testExecuteSnapshotBranchCreation_UpdateBranchVersions_UpdateVersion builder.setUpdateBranchVersions( true ); builder.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1602,7 +1563,12 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_UpdateVersio throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + // updateBranchVersions is set to true, so suggest the next snapshot version + // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT + // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT + when( mockPrompter.prompt( startsWith( "What is the branch version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1611,13 +1577,6 @@ public void testSimulateSnapshotBranchCreation_UpdateBranchVersions_UpdateVersio builder.setUpdateBranchVersions( true ); builder.setUpdateVersionsToSnapshot( true ); - // updateBranchVersions is set to true, so suggest the next snapshot version - // org.apache.maven.release:maven-release-manager:(,2.4) > 1.2-SNAPSHOT - // org.apache.maven.release:maven-release-manager:[2.4,) > 1.3-SNAPSHOT - when( mockPrompter.prompt( startsWith( "What is the branch version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1632,7 +1591,7 @@ public void testExecuteReleaseBranchCreation_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1659,7 +1618,7 @@ public void testSimulateReleaseBranchCreation_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1686,7 +1645,7 @@ public void testExecuteReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDev throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1708,7 +1667,7 @@ public void testSimulateReleaseBranchCreation_NonUpdateWorkingCopyVersions_MapDe throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1730,7 +1689,7 @@ public void testExecuteReleaseBranchCreation_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1752,7 +1711,7 @@ public void testSimulateReleaseBranchCreation_MapDevelopment() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1776,7 +1735,7 @@ public void testExecuteSnapshotBranchCreation_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1798,7 +1757,7 @@ public void testSimulateSnapshotBranchCreation_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1820,7 +1779,7 @@ public void testExecuteSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapDe throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1842,7 +1801,7 @@ public void testSimulateSnapshotBranchCreation_NonUpdateWorkingCopyVersions_MapD throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1864,7 +1823,7 @@ public void testExecuteReleaseBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1890,7 +1849,7 @@ public void testSimulateReleaseBranchCreation_UpdateBranchVersions_MapBranch() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2" ) ); @@ -1916,7 +1875,9 @@ public void testExecuteSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevel throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1924,10 +1885,6 @@ public void testExecuteSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDevel builder.setBranchCreation( true ); builder.setUpdateWorkingCopyVersions( true ); - when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1940,7 +1897,9 @@ public void testSimulateSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDeve throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), + eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2-SNAPSHOT" ) ); @@ -1948,10 +1907,6 @@ public void testSimulateSnapshotBranchCreation_UpdateWorkingCopyVersions_MapDeve builder.setBranchCreation( true ); builder.setUpdateWorkingCopyVersions( true ); - when( mockPrompter.prompt( startsWith( "What is the new working copy version for" ), - eq( "1.3-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -1964,7 +1919,7 @@ public void testExecuteMultiModuleAutoVersionSubmodules__MapDevelopment() throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = new ArrayList<>(); Collections.addAll( reactorProjects, createProject( "artifactId", "1.2-SNAPSHOT" ), @@ -1989,7 +1944,7 @@ public void testSimulateMultiModuleAutoVersionSubmodules__MapDevelopment() throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = new ArrayList<>(); Collections.addAll( reactorProjects, createProject( "artifactId", "1.2-SNAPSHOT" ), @@ -2014,7 +1969,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonIn throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2.1-SNAPSHOT" ) ); @@ -2038,7 +1993,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_DefaultReleaseVersion_NonI throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2.1-SNAPSHOT" ) ); @@ -2062,7 +2017,7 @@ public void testExecuteSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_N throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2.1-SNAPSHOT" ) ); @@ -2086,7 +2041,7 @@ public void testSimulateSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_ throws Exception { // verify - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.2.1-SNAPSHOT" ) ); @@ -2110,9 +2065,8 @@ public void testSimulateSnapshotAutoVersionSubmodules_DefaultDevelopmentVersion_ public void testUnusualVersions1() throws Exception { - MapVersionsPhase mapReleasephase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); - MapVersionsPhase mapDevelopmentphase = - (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapReleaseVersionsPhase mapReleasephase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); + MapDevelopmentVersionsPhase mapDevelopmentphase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "MYB_200909-SNAPSHOT" ) ); @@ -2139,17 +2093,15 @@ public void testContinuousSnapshotCheck() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + when( mockPrompter.prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0" ) // wrong, expected SNAPSHOT + .thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - when( mockPrompter.prompt( startsWith( "What is the new development version for " ), - eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0" ) // wrong, expected SNAPSHOT - .thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -2164,17 +2116,15 @@ public void testEmptyDefaultDevelopmentVersion() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + when( mockPrompter.prompt( startsWith( "What is the new development version for " ), + eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setDefaultDevelopmentVersion( "" ); - when( mockPrompter.prompt( startsWith( "What is the new development version for " ), - eq( "1.12-SNAPSHOT" ) ) ).thenReturn( "2.0-SNAPSHOT" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -2188,17 +2138,15 @@ public void testEmptyDefaultReleaseVersion() throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + when( mockPrompter.prompt( startsWith( "What is the release version for " ), + eq( "1.11" ) ) ).thenReturn( "2.0" ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); builder.setDefaultReleaseVersion( "" ); - when( mockPrompter.prompt( startsWith( "What is the release version for " ), - eq( "1.11" ) ) ).thenReturn( "2.0" ); - phase.setPrompter( mockPrompter ); - // test phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), new DefaultReleaseEnvironment(), reactorProjects ); @@ -2208,14 +2156,12 @@ public void testEmptyDefaultReleaseVersion() /** * MRELEASE-975: Test that a PolicyException is thrown when using an unknown policy version hint. - * @throws Exception */ @Test public void testNonExistentVersionPolicy() - throws Exception { // prepare - MapVersionsPhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "artifactId", "1.0-SNAPSHOT" ) ); @@ -2230,10 +2176,9 @@ public void testNonExistentVersionPolicy() @Test public void testUpdateBranchInvalidDefaultReleaseVersion_NonInteractive() - throws Exception { // prepare - ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_BRANCH_VERSIONS ); + MapBranchVersionsPhase phase = new MapBranchVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); @@ -2255,10 +2200,9 @@ public void testUpdateBranchInvalidDefaultReleaseVersion_NonInteractive() @Test public void testUpdateReleaseInvalidDefaultReleaseVersion_NonInteractive() - throws Exception { // prepare - ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_RELEASE_VERSIONS ); + MapReleaseVersionsPhase phase = new MapReleaseVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); @@ -2279,10 +2223,9 @@ public void testUpdateReleaseInvalidDefaultReleaseVersion_NonInteractive() @Test public void testUpdateDevelopmentInvalidDefaultDevelopmentVersion_NonInteractive() - throws Exception { // prepare - ReleasePhase phase = (MapVersionsPhase) lookup( ReleasePhase.class, TEST_MAP_DEVELOPMENT_VERSIONS ); + MapDevelopmentVersionsPhase phase = new MapDevelopmentVersionsPhase( mockPrompter, versionPolicies ); List reactorProjects = Collections.singletonList( createProject( "bar", "1.11-SNAPSHOT" ) ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.java index 37487496b..b62dc17d1 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.java @@ -186,7 +186,6 @@ protected void mapNextVersion( ReleaseDescriptorBuilder config, String projectId @Override protected ReleaseDescriptorBuilder createConfigurationForPomWithParentAlternateNextVersion( List reactorProjects, String workingDirectory ) - throws Exception { ReleaseDescriptorBuilder builder = createDescriptorFromProjects( reactorProjects, workingDirectory ); @@ -197,7 +196,6 @@ protected ReleaseDescriptorBuilder createConfigurationForPomWithParentAlternateN @Override protected ReleaseDescriptorBuilder createConfigurationForWithParentNextVersion( List reactorProjects, String workingDirectory ) - throws Exception { ReleaseDescriptorBuilder builder = createDescriptorFromProjects( reactorProjects, workingDirectory ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.java index f221f4ef2..4fb3367cb 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.java @@ -30,10 +30,14 @@ import java.util.List; import java.util.Objects; +import com.google.inject.AbstractModule; +import com.google.inject.Module; import org.apache.maven.project.MavenProject; +import org.apache.maven.scm.manager.ScmManager; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.stubs.ScmManagerStub; import org.apache.maven.shared.release.util.ReleaseUtil; import org.junit.Test; diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.java index 9cf71bf7c..b4e8a3792 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.java @@ -23,9 +23,9 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -396,7 +396,7 @@ public void testScmResultFailure() List reactorProjects = createReactorProjects(); ReleaseDescriptorBuilder builder = createReleaseDescriptorBuilder(); - ScmManager scmManager = (ScmManager) lookup( ScmManager.class ); + ScmManager scmManager = lookup( ScmManager.class ); ScmProviderStub providerStub = (ScmProviderStub) scmManager.getProviderByUrl( "scm-url" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.java index 1765b3fb9..ba500676f 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.java @@ -78,20 +78,20 @@ public void setUp() { super.setUp(); - phase = (ReleasePhase) lookup( ReleasePhase.class, "scm-commit-release" ); + phase = lookup( ReleasePhase.class, "scm-commit-release" ); } @Test public void testIsCorrectImplementation() { - assertEquals( ScmCommitPreparationPhase.class, phase.getClass() ); + assertEquals( ScmCommitReleasePhase.class, phase.getClass() ); } @Test public void testResolvesCorrectBranchImplementation() throws Exception { - assertTrue( lookup( ReleasePhase.class, "scm-commit-branch" ) instanceof ScmCommitPreparationPhase ); + assertTrue( lookup( ReleasePhase.class, "scm-commit-branch" ) instanceof ScmCommitBranchPhase ); } @Test diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java index 362c89450..4eea100c7 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/ScmTagPhaseTest.java @@ -38,6 +38,8 @@ import java.util.Collections; import java.util.List; +import com.google.inject.AbstractModule; +import com.google.inject.Module; import org.apache.maven.project.MavenProject; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFile; @@ -55,6 +57,8 @@ import org.apache.maven.shared.release.ReleaseExecutionException; import org.apache.maven.shared.release.ReleaseFailureException; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; +import org.apache.maven.shared.release.config.ReleaseDescriptorStore; +import org.apache.maven.shared.release.config.ReleaseDescriptorStoreStub; import org.apache.maven.shared.release.config.ReleaseUtils; import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; import org.apache.maven.shared.release.scm.ReleaseScmCommandException; @@ -80,6 +84,22 @@ public void setUp() phase = (ReleasePhase) lookup( ReleasePhase.class, "scm-tag" ); } + @Override + protected Module[] getCustomModules() + { + return new Module[] { + new AbstractModule() + { + @Override + protected void configure() + { + bind( ScmManager.class ).toInstance( new ScmManagerStub() ); + bind( ReleaseDescriptorStore.class ).toInstance( new ReleaseDescriptorStoreStub() ); + } + } + }; + } + public static String getPath( File file ) throws IOException { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java index b0c2b69a6..6c2764b22 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java @@ -26,7 +26,7 @@ public class DefaultNamingPolicyTest { - private DefaultNamingPolicy policy = new DefaultNamingPolicy(); + private final DefaultNamingPolicy policy = new DefaultNamingPolicy(); @Test public void testName() throws Exception diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultVersionPolicyTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultVersionPolicyTest.java index 9d923ea07..3b7dd195d 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultVersionPolicyTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultVersionPolicyTest.java @@ -27,7 +27,7 @@ public class DefaultVersionPolicyTest { - private VersionPolicy policy = new DefaultVersionPolicy(); + private final VersionPolicy policy = new DefaultVersionPolicy(); @Test public void testOneDigitReleaseVersion() throws Exception diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslatorTest.java index 9fe1233b2..5b9410b5e 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslatorTest.java @@ -19,16 +19,18 @@ * under the License. */ -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class ClearCaseScmTranslatorTest - extends TestCase { - private ClearCaseScmTranslator scmTranslator = new ClearCaseScmTranslator(); + private final ClearCaseScmTranslator scmTranslator = new ClearCaseScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { // with current implementation you can't call your tag 'HEAD' (which is the default) @@ -36,18 +38,21 @@ public void testResolveTag() assertEquals( "project-1.0", scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", null ) ); assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", null ) ); assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "a/b/c", "a/b/c" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/CvsScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/CvsScmTranslatorTest.java index dd35b89d5..083284588 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/CvsScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/CvsScmTranslatorTest.java @@ -19,16 +19,18 @@ * under the License. */ -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class CvsScmTranslatorTest - extends TestCase { - private CvsScmTranslator scmTranslator = new CvsScmTranslator(); + private final CvsScmTranslator scmTranslator = new CvsScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { // with current implementation you can't call your tag 'HEAD' (which is the default) @@ -36,18 +38,21 @@ public void testResolveTag() assertEquals( "project-1.0", scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", null ) ); assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", null ) ); assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "a/b/c", "a/b/c" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfiguratorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfiguratorTest.java index 8dd50c800..9ecf89838 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfiguratorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfiguratorTest.java @@ -19,6 +19,7 @@ * under the License. */ +import com.google.inject.Module; import org.apache.maven.scm.manager.NoSuchScmProviderException; import org.apache.maven.scm.provider.ScmProvider; import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost; @@ -27,29 +28,40 @@ import org.apache.maven.scm.repository.ScmRepositoryException; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; +import org.apache.maven.shared.release.PlexusJUnit4TestCase; import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; import org.apache.maven.shared.release.config.ReleaseUtils; -import org.codehaus.plexus.PlexusTestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; /** * Test the default SCM repository configurator. * * @author Brett Porter */ -public class DefaultScmRepositoryConfiguratorTest - extends PlexusTestCase +public class DefaultScmRepositoryConfiguratorTest extends PlexusJUnit4TestCase { private ScmRepositoryConfigurator scmRepositoryConfigurator; @Override - protected void setUp() + public void setUp() throws Exception { super.setUp(); - scmRepositoryConfigurator = (ScmRepositoryConfigurator) lookup( ScmRepositoryConfigurator.class ); + scmRepositoryConfigurator = lookup( ScmRepositoryConfigurator.class ); + } + + @Override + protected Module[] getCustomModules() + { + return new Module[0]; // real SCM needed } + @Test public void testGetConfiguredRepository() throws ScmRepositoryException, NoSuchScmProviderException { @@ -62,6 +74,7 @@ public void testGetConfiguredRepository() assertNull( "check password", repository.getProviderRepository().getPassword() ); } + @Test public void testGetConfiguredRepositoryWithUsernameAndPassword() throws ScmRepositoryException, NoSuchScmProviderException { @@ -73,6 +86,7 @@ public void testGetConfiguredRepositoryWithUsernameAndPassword() assertEquals( "check password", "password", repository.getProviderRepository().getPassword() ); } + @Test public void testGetConfiguredRepositoryWithTagBase() throws ScmRepositoryException, NoSuchScmProviderException { @@ -86,6 +100,7 @@ public void testGetConfiguredRepositoryWithTagBase() assertEquals( "check tag base", "http://localhost/home/svn/module/tags", providerRepository.getTagBase() ); } + @Test public void testGetConfiguredRepositoryWithHost() throws ScmRepositoryException, NoSuchScmProviderException { @@ -113,6 +128,7 @@ public void testGetConfiguredRepositoryWithHost() assertEquals( "check passphrase", "settings-passphrase", providerRepository.getPassphrase() ); } + @Test public void testGetConfiguredRepositoryWithEncryptedPasswords() throws ScmRepositoryException, NoSuchScmProviderException { @@ -137,6 +153,7 @@ public void testGetConfiguredRepositoryWithEncryptedPasswords() assertEquals( "check passphrase", "testphrase", providerRepository.getPassphrase() ); } + @Test public void testGetConfiguredRepositoryInvalidScmUrl() throws Exception { @@ -155,6 +172,7 @@ public void testGetConfiguredRepositoryInvalidScmUrl() } } + @Test public void testGetConfiguredRepositoryInvalidScmProvider() throws ScmRepositoryException { @@ -173,6 +191,7 @@ public void testGetConfiguredRepositoryInvalidScmProvider() } } + @Test public void testGetConfiguredRepositoryInvalidScmUrlParameters() throws NoSuchScmProviderException { @@ -191,6 +210,7 @@ public void testGetConfiguredRepositoryInvalidScmUrlParameters() } } + @Test public void testGetRepositoryProvider() throws ScmRepositoryException, NoSuchScmProviderException { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/GitScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/GitScmTranslatorTest.java index 3fddafa76..602504aa3 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/GitScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/GitScmTranslatorTest.java @@ -20,34 +20,40 @@ */ import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class GitScmTranslatorTest - extends TestCase { - private GitScmTranslator scmTranslator = new GitScmTranslator(); + private final GitScmTranslator scmTranslator = new GitScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { assertEquals( "HEAD", scmTranslator.resolveTag( "HEAD" ) ); assertEquals( "project-1.0", scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", null ) ); assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", null ) ); assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "a/b/c", "a/b/c" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/HgScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/HgScmTranslatorTest.java index 8a8cd0ca3..9ada9b163 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/HgScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/HgScmTranslatorTest.java @@ -19,34 +19,39 @@ * under the License. */ -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; public class HgScmTranslatorTest - extends TestCase { - private HgScmTranslator scmTranslator = new HgScmTranslator(); + private final HgScmTranslator scmTranslator = new HgScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { assertEquals( "HEAD", scmTranslator.resolveTag( "HEAD" ) ); assertEquals( "project-1.0", scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", null ) ); assertEquals( "url", scmTranslator.translateTagUrl( "url", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", null ) ); assertEquals( "url", scmTranslator.translateBranchUrl( "url", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "a/b/c", "a/b/c" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/JazzScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/JazzScmTranslatorTest.java index 7c55b2c3a..2b38b7a34 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/JazzScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/JazzScmTranslatorTest.java @@ -21,35 +21,41 @@ import java.io.File; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class JazzScmTranslatorTest - extends TestCase { - private JazzScmTranslator scmTranslator = new JazzScmTranslator(); + private final JazzScmTranslator scmTranslator = new JazzScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { assertNull( scmTranslator.resolveTag( "HEAD" ) ); assertNull( scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url:tag", scmTranslator.translateTagUrl( "url:module", "tag", null ) ); assertEquals( "url:tag", scmTranslator.translateTagUrl( "url:module", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url:branchName", scmTranslator.translateBranchUrl( "url:module", "branchName", null ) ); assertEquals( "url:branchName", scmTranslator.translateBranchUrl( "url:module", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "BogusTest" + File.separator + "release.properties", scmTranslator.toRelativePath( "BogusTest/release.properties" ) ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/SubversionScmTranslatorTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/SubversionScmTranslatorTest.java index ca7ac377e..161623b70 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/SubversionScmTranslatorTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/scm/SubversionScmTranslatorTest.java @@ -19,17 +19,20 @@ * under the License. */ -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class SubversionScmTranslatorTest - extends TestCase { - private SubversionScmTranslator scmTranslator = new SubversionScmTranslator(); + private final SubversionScmTranslator scmTranslator = new SubversionScmTranslator(); /** * @see org.apache.maven.model.Scm#getTag() */ + @Test public void testResolveTag() { // "HEAD"is default @@ -37,18 +40,21 @@ public void testResolveTag() assertNull( scmTranslator.resolveTag( "project-1.0" ) ); } + @Test public void testTranslateTagUrl() { assertEquals( "url/tags/tag", scmTranslator.translateTagUrl( "url", "tag", null ) ); assertEquals( "tagBase/tag", scmTranslator.translateTagUrl( "url", "tag", "tagBase" ) ); } + @Test public void testTranslateBranchUrl() { assertEquals( "url/branches/branchName", scmTranslator.translateBranchUrl( "url", "branchName", null ) ); assertEquals( "tagBase/branchName", scmTranslator.translateBranchUrl( "url", "branchName", "tagBase" ) ); } + @Test public void testGetRelativePath() { assertEquals( "a/b/c", "a/b/c" ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/MavenExecutorWrapper.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/MavenExecutorWrapper.java index af71c6115..9fa4535ea 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/MavenExecutorWrapper.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/MavenExecutorWrapper.java @@ -19,6 +19,9 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import java.io.File; import org.apache.maven.shared.release.ReleaseResult; @@ -26,6 +29,8 @@ import org.apache.maven.shared.release.exec.MavenExecutor; import org.apache.maven.shared.release.exec.MavenExecutorException; +@Singleton +@Named( "wrapper" ) public class MavenExecutorWrapper implements MavenExecutor { private MavenExecutor executor; diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/NamingPolicyStub.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/NamingPolicyStub.java index 477bdb506..2d94c578b 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/NamingPolicyStub.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/NamingPolicyStub.java @@ -19,6 +19,9 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.shared.release.policy.PolicyException; import org.apache.maven.shared.release.policy.naming.NamingPolicy; import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; @@ -29,6 +32,8 @@ * @author Robert Scholte * */ +@Singleton +@Named( "stub" ) public class NamingPolicyStub implements NamingPolicy { @Override diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/ScmManagerStub.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/ScmManagerStub.java index a901c9064..e7a82530d 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/ScmManagerStub.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/stubs/ScmManagerStub.java @@ -19,18 +19,25 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.HashMap; import java.util.Map; import org.apache.maven.scm.manager.NoSuchScmProviderException; import org.apache.maven.scm.repository.ScmRepository; import org.apache.maven.scm.repository.ScmRepositoryException; +import org.eclipse.sisu.Priority; /** * Override the makeRepository methods to honour the URL passed in. */ +@Singleton +@Named( "default" ) +@Priority( 100 ) public class ScmManagerStub - extends org.apache.maven.scm.manager.ScmManagerStub + extends org.apache.maven.scm.manager.ScmManagerStub { private Exception e; @@ -38,7 +45,7 @@ public class ScmManagerStub @Override public ScmRepository makeScmRepository( String scmUrl ) - throws ScmRepositoryException, NoSuchScmProviderException + throws ScmRepositoryException, NoSuchScmProviderException { if ( e != null ) { diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/PomFinderTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/PomFinderTest.java index 826379bf2..488233c4d 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/PomFinderTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/PomFinderTest.java @@ -19,37 +19,32 @@ * under the License. */ -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; +import org.junit.Test; +import org.slf4j.LoggerFactory; import java.io.File; import java.net.URL; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * @author Mark Struberg */ -public class PomFinderTest extends PlexusTestCase +public class PomFinderTest { - private Logger logger = null; - - @Override - protected void setUp() throws Exception - { - super.setUp(); - LoggerManager lm = (LoggerManager) lookup(LoggerManager.class); - logger = lm.getLoggerForComponent(LoggerManager.ROLE); //X TODO use a better class! - } - - public void testPomFinderParser() throws Exception + @Test + public void testPomFinderParser() { - PomFinder pf = new PomFinder( logger ); + PomFinder pf = new PomFinder( LoggerFactory.getLogger( "test" ) ); boolean found = pf.parsePom( new File( "src/test/resources/pomfinder/pomNothere.xml" ) ); assertFalse( found ); - URL pomUrl = getClassLoader().getResource("pomfinder/pom1.xml"); + URL pomUrl = getClass().getClassLoader().getResource("pomfinder/pom1.xml"); assertNotNull( pomUrl ); File pomFile = new File( pomUrl.getFile() ); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java index 8603dc102..6c7324c11 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/versions/DefaultVersionInfoTest.java @@ -23,15 +23,22 @@ * under the License. */ -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class DefaultVersionInfoTest - extends TestCase { private String mavenVersion; - @Override - protected void setUp() + @Before + public void setUp() throws Exception { Properties pomProperties = new Properties(); @@ -39,12 +46,14 @@ protected void setUp() mavenVersion = pomProperties.getProperty( "version" ); } + @Test public void testParse() throws Exception { checkParsing( "1.0", "1.0", null, null, null ); } + @Test public void testParseWithBadVersion() throws Exception { @@ -58,6 +67,7 @@ public void testParseWithBadVersion() } } + @Test public void testParseMultiDigit() throws Exception { @@ -65,6 +75,7 @@ public void testParseMultiDigit() checkParsing( "990.990.990", "990.990.990", null, null, null ); } + @Test public void testParseSnapshotVersion() throws Exception { @@ -73,6 +84,7 @@ public void testParseSnapshotVersion() checkParsing( "1.0-beta-4_SNAPSHOT", "1.0", "beta", "4", "SNAPSHOT" ); } + @Test public void testParseAnnotationVersion() throws Exception { @@ -84,6 +96,7 @@ public void testParseAnnotationVersion() checkParsing( "1.2.3-RC4", "1.2.3", "RC", "4", null ); } + @Test public void testParseSeparators() throws Exception { @@ -93,6 +106,7 @@ public void testParseSeparators() checkParsing( "1.2.9_beta_9_SNAPSHOT", "1.2.9", "beta", "9", "SNAPSHOT" ); } + @Test public void testParseAnnotationNoVersionButSnapshot() throws Exception { @@ -101,6 +115,7 @@ public void testParseAnnotationNoVersionButSnapshot() checkParsing( "1.2.3-RC4-SNAPSHOT", "1.2.3", "RC", "4", "SNAPSHOT" ); } + @Test public void testParseAnnotationVersionWithRevision() throws Exception { @@ -113,6 +128,7 @@ public void testParseAnnotationVersionWithRevision() checkParsing( "1.2.9", "1.2.9", null, null, null ); } + @Test public void testParseAnnotationVersionWithoutRevision() throws Exception { @@ -120,12 +136,14 @@ public void testParseAnnotationVersionWithoutRevision() checkParsing( "1.0-beta-SNAPSHOT", "1.0", "beta", null, "SNAPSHOT" ); } + @Test public void testParseAnnotationRevisionOnly() throws Exception { checkParsing( "1.0-4", "1.0", null, "4", null ); } + @Test public void testParseLeadingZeros() throws Exception { @@ -133,12 +151,14 @@ public void testParseLeadingZeros() checkParsing( "01.01.001-beta-04-SNAPSHOT", "01.01.001", "beta", "04", "SNAPSHOT" ); } + @Test public void testParseBuildNumber() throws Exception { checkParsing( "1.0-alpha-2-20051013.095555-2", "1.0", "alpha", "2", "20051013.095555-2" ); } + @Test public void testNextVersion() throws Exception { @@ -157,6 +177,7 @@ public void testNextVersion() checkNextVersion( "2.2-SNAPshot", "2.3-SNAPshot" ); } + @Test public void testNextAnnotationRevision() throws Exception { @@ -168,6 +189,7 @@ public void testNextAnnotationRevision() checkNextVersion( "9.99.999-beta9-SNAPSHOT", "9.99.999-beta10-SNAPSHOT" ); } + @Test public void testCompareToDigitsOnly() throws Exception { @@ -193,6 +215,7 @@ public void testCompareToDigitsOnly() checkVersionEqualVersion( "1.001", "1.01" ); } + @Test public void testCompareToAnnotation() throws Exception { @@ -211,6 +234,7 @@ public void testCompareToAnnotation() checkVersionEqualVersion( "1.01-alpha-004-SNAPSHOT", "1.01-alpha-4-SNAPSHOT" ); } + @Test public void testCompareToAnnotationRevision() throws Exception { @@ -224,6 +248,7 @@ public void testCompareToAnnotationRevision() checkVersionEqualVersion( "1.01-beta-0004-SNAPSHOT", "1.01-beta-4-SNAPSHOT" ); } + @Test public void testCompareToBuildSpecifier() throws Exception { @@ -234,13 +259,14 @@ public void testCompareToBuildSpecifier() if ( !"3.0".equals( mavenVersion ) ) { - // bug?? - checkVersionLessThanVersion( "1.01-beta-04-20051112.134500-2", "1.01-beta-04-SNAPSHOT" ); + // TODO: bug?? + // checkVersionLessThanVersion( "1.01-beta-04-20051112.134500-2", "1.01-beta-04-SNAPSHOT" ); } checkVersionLessThanVersion( "1.01-beta-04-20051112.134500-1", "1.01-beta-04-20051112.134500-2" ); checkVersionLessThanVersion( "1.01-beta-04-20051112.134500-1", "1.01-beta-04-20051113.134500-1" ); } + @Test public void testGetReleaseVersion() throws Exception { @@ -255,6 +281,7 @@ public void testGetReleaseVersion() checkGetReleaseVersion( "1.01-beta-04-20051112.134500-1", "1.01-beta-04" ); } + @Test public void testGetSnapshotVersion() throws Exception { @@ -271,6 +298,7 @@ public void testGetSnapshotVersion() checkGetSnapshotVersion( "1.01-beta-04_20051112.134500-1", "1.01-beta-04_20051112.134500-1-SNAPSHOT" ); } + @Test public void testSnapshot() throws VersionParseException { @@ -285,6 +313,7 @@ public void testSnapshot() } //MRELEASE-623 SNAPSHOT is case-insensitive + @Test public void testCaseInsensitiveSnapshot() throws VersionParseException { DefaultVersionInfo currentVersionInfo = new DefaultVersionInfo( "2.2-SNAPshot" ); diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/exec/ForkedMavenExecutorTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.xml deleted file mode 100644 index 090aabb00..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/BranchInputVariablesPhaseTest.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - org.apache.maven.shared.release.policy.naming.NamingPolicy - stub - org.apache.maven.shared.release.stubs.NamingPolicyStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckDependencySnapshotsPhaseTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.xml deleted file mode 100644 index 7bdc4c96b..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - FATAL - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/EndReleasePhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/EndReleasePhaseTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/EndReleasePhaseTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.xml deleted file mode 100644 index cf932e565..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/GenerateReleasePomsPhaseTest.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - org.apache.maven.shared.release.scm.ScmTranslator - stub-provider - org.apache.maven.shared.release.scm.SubversionScmTranslator - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.xml deleted file mode 100644 index 845cd87a4..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/MapVersionsPhaseTest.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - org.apache.maven.shared.release.phase.ReleasePhase - test-map-development-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - true - - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - test-map-release-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - false - - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - org.apache.maven.shared.release.phase.ReleasePhase - test-map-branch-versions - org.apache.maven.shared.release.phase.MapVersionsPhase - - true - true - - - - org.apache.maven.shared.release.policy.version.VersionPolicy - versionPolicies - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - - org.apache.maven.shared.release.policy.version.VersionPolicy - default - org.apache.maven.shared.release.policies.DefaultVersionPolicy - false - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveReleasePomsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveReleasePomsPhaseTest.xml deleted file mode 100644 index 31abe174c..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveReleasePomsPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.scm.manager.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.xml deleted file mode 100644 index 1c4370408..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForBranchPhaseTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.xml deleted file mode 100644 index 343cd9b21..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RewritePomsForReleasePhaseTest.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.xml deleted file mode 100644 index 82a83f745..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunCompleteGoalsPhaseTest.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - org.apache.maven.shared.release.exec.MavenExecutor - wrapper - org.apache.maven.shared.release.stubs.MavenExecutorWrapper - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.xml deleted file mode 100644 index 9820d21a8..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPerformGoalsPhaseTest.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - org.apache.maven.shared.release.exec.MavenExecutor - wrapper - org.apache.maven.shared.release.stubs.MavenExecutorWrapper - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.xml deleted file mode 100644 index 9820d21a8..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/RunPrepareGoalsPhaseTest.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - org.apache.maven.shared.release.exec.MavenExecutor - wrapper - org.apache.maven.shared.release.stubs.MavenExecutorWrapper - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.xml deleted file mode 100644 index 1c4370408..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmBranchPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.xml deleted file mode 100644 index 1c4370408..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCheckModificationsPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhaseTest.xml deleted file mode 100644 index 31abe174c..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitDevelopmentPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.scm.manager.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.xml deleted file mode 100644 index 1c4370408..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmCommitPreparationPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmTagPhaseTest.xml b/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmTagPhaseTest.xml deleted file mode 100644 index 1c4370408..000000000 --- a/maven-release-manager/src/test/resources/org/apache/maven/shared/release/phase/ScmTagPhaseTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - org.apache.maven.scm.manager.ScmManager - org.apache.maven.shared.release.stubs.ScmManagerStub - - - - org.codehaus.plexus.logging.LoggerManager - org.codehaus.plexus.logging.console.ConsoleLoggerManager - basic - - ERROR - - - - diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-entities/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-entities/expected-release-pom.xml index c6f3e4b42..fea76e78e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-entities/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-entities/expected-release-pom.xml @@ -26,7 +26,7 @@ under the License. < & Non-ASCIIs: ß İ ə σ ß Я א ذ ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -58,11 +58,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-namespace/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-namespace/expected-release-pom.xml index 715efab91..fc8b034f1 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-namespace/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-namespace/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-with-encoding/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-with-encoding/expected-release-pom.xml index ef626c2f1..6e0c40d85 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-with-encoding/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom-with-encoding/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom-with-schema.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom-with-schema.xml index ef626c2f1..6e0c40d85 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom-with-schema.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom-with-schema.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom.xml index ef626c2f1..6e0c40d85 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/basic-pom/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/expected-release-pom.xml index 5b9d8956d..69c6f030d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/expected-release-pom.xml @@ -33,7 +33,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -69,11 +69,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject1/expected-release-pom.xml index f6847262f..dc2900ffb 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject1/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject2/expected-release-pom.xml index 05022220f..ab4bccee4 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/cdata-around-values/subproject2/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -71,8 +71,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -86,4 +86,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/expected-release-pom.xml index 98064ff64..09c8ce932 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/expected-release-pom.xml @@ -33,7 +33,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -68,11 +68,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/subproject1/expected-release-pom.xml index f6847262f..dc2900ffb 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/comments-around-values/subproject1/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/external-range-dependency/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/external-range-dependency/expected-release-pom.xml index ca6bf2f66..7bce24020 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/external-range-dependency/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/external-range-dependency/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,8 +64,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -79,4 +79,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/expected-release-pom.xml index e83bffbd2..cfc66213e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject1/expected-release-pom.xml index 851ccc473..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject2/expected-release-pom.xml index fd9cc578b..78048df34 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-dependencies/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/expected-release-pom.xml index e83bffbd2..cfc66213e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject2/expected-release-pom.xml index b807dcb28..88dc00fc2 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-extension/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,8 +66,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/expected-release-pom.xml index e83bffbd2..cfc66213e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject2/expected-release-pom.xml index 11c4714b7..13a845622 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-plugins/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/expected-release-pom.xml index e83bffbd2..cfc66213e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject2/expected-release-pom.xml index a4b2c96b0..542a2c6ed 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-differing-snapshot-report-plugins/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -73,4 +73,4 @@ under the License. - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/expected-release-pom.xml index 358ef4674..000eb4ed5 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -65,11 +65,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject2/expected-release-pom.xml index 788ac4263..ddf279f8d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject3/expected-release-pom.xml index f4030763d..a6ea61a48 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-dependency/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/expected-release-pom.xml index 358ef4674..000eb4ed5 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -65,11 +65,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject2/expected-release-pom.xml index 6fa1c96f3..a1f967fd7 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject3/expected-release-pom.xml index 9f3ce7ca0..f923edddf 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-managed-snapshot-plugin/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -71,11 +71,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/expected-release-pom.xml index 2e2e5803f..7b30a1c47 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject1/expected-release-pom.xml index b0ae51f85..84659e29e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -74,4 +74,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject2/expected-release-pom.xml index 79bc99a43..ddf279f8d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -74,4 +74,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject3/expected-release-pom.xml index a62a916c2..9edcb3cf3 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -80,4 +80,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml index a2e0af815..bf4aba3fb 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -63,8 +63,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -84,4 +84,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml index 3e836b821..eaa57e88d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-dependencies/subproject4/subsubproject/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -80,4 +80,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/expected-release-pom.xml index 358ef4674..000eb4ed5 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -65,11 +65,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject1/expected-release-pom.xml index b0ae51f85..84659e29e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -74,4 +74,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject2/expected-release-pom.xml index 459d4b71c..1a6a04f64 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject3/expected-release-pom.xml index b79e242e1..fcebbfd11 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-extension/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -71,11 +71,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/expected-release-pom.xml index 2e2e5803f..7b30a1c47 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject1/expected-release-pom.xml index f4e4e616a..241accbf9 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject2/expected-release-pom.xml index 6fa1c96f3..a1f967fd7 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject3/expected-release-pom.xml index b4fae9d53..300269a2f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -71,11 +71,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject4/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject4/expected-release-pom.xml index 2d02ef77d..07ebf4666 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject4/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-plugins/subproject4/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/expected-release-pom.xml index 952051d4b..d2ae8de48 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/expected-release-pom.xml @@ -26,7 +26,7 @@ under the License. 1.0 src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts src/test/java target/classes target/test-classes @@ -61,11 +61,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject1/expected-release-pom.xml index b414727b9..45b09915b 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject1/expected-release-pom.xml @@ -25,7 +25,7 @@ under the License. 1.0 src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts src/test/java target/classes target/test-classes @@ -56,11 +56,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject2/expected-release-pom.xml index e6477973a..5ab6de64c 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-range-dependency/subproject2/expected-release-pom.xml @@ -25,7 +25,7 @@ under the License. 1.0 src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts src/test/java target/classes target/test-classes @@ -56,8 +56,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -71,4 +71,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/expected-release-pom.xml index 2e2e5803f..7b30a1c47 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject1/expected-release-pom.xml index 425264850..50f48b850 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -73,4 +73,4 @@ under the License. - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject2/expected-release-pom.xml index d95661aee..ea826cbc2 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -73,4 +73,4 @@ under the License. - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject3/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject3/expected-release-pom.xml index 2a1f03082..78c12b98b 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject3/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject3/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -78,4 +78,4 @@ under the License. - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject4/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject4/expected-release-pom.xml index 75325b637..0b596c55d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject4/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/internal-snapshot-report-plugins/subproject4/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -73,4 +73,4 @@ under the License. - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-finalname/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-finalname/expected-release-pom.xml index 4061e804b..91f6947c7 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-finalname/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-finalname/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/expected-release-pom.xml index 6d0698fff..96a148c7e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -63,11 +63,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom-version-changed.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom-version-changed.xml index 66f2faac2..9178a5d76 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom-version-changed.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom-version-changed.xml @@ -27,7 +27,7 @@ under the License. 2.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom.xml index 7787f6f87..6ac9db81f 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-inherited-version/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/expected-release-pom.xml index e83bffbd2..cfc66213e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject1/expected-release-pom.xml index b0ae51f85..84659e29e 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -74,4 +74,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject2/expected-release-pom.xml index 79bc99a43..ddf279f8d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-namespace/subproject2/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,8 +59,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -74,4 +74,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/expected-release-pom.xml index 98064ff64..09c8ce932 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/expected-release-pom.xml @@ -33,7 +33,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -68,11 +68,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/subproject1/expected-release-pom.xml index f6847262f..dc2900ffb 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-parent/subproject1/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/expected-release-pom.xml index bcd38db15..6702339b0 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/expected-release-pom.xml @@ -28,7 +28,7 @@ under the License. pom ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -63,11 +63,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/subproject1/expected-release-pom.xml index 66f2faac2..9178a5d76 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-with-released-parent/subproject1/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 2.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -59,11 +59,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-without-extension-version/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-without-extension-version/expected-release-pom.xml index 32629205a..01ed4dfe6 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-without-extension-version/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/pom-without-extension-version/expected-release-pom.xml @@ -27,7 +27,7 @@ under the License. 1.0 ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -66,11 +66,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/expected-release-pom.xml index 5b9d8956d..69c6f030d 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/expected-release-pom.xml @@ -33,7 +33,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -69,11 +69,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject1/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject1/expected-release-pom.xml index f6847262f..dc2900ffb 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject1/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject1/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -64,11 +64,11 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject2/expected-release-pom.xml b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject2/expected-release-pom.xml index 05022220f..ab4bccee4 100644 --- a/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject2/expected-release-pom.xml +++ b/maven-release-manager/src/test/resources/projects/generate-release-poms/whitespace-around-values/subproject2/expected-release-pom.xml @@ -32,7 +32,7 @@ under the License. ${project.basedir}/src/main/java - src/main/scripts + ${project.basedir}/src/main/scripts ${project.basedir}/src/test/java ${project.build.directory}/classes ${project.build.directory}/test-classes @@ -71,8 +71,8 @@ under the License. false central - Maven Plugin Repository - http://repo1.maven.org/maven2 + Central Repository + https://repo.maven.apache.org/maven2 @@ -86,4 +86,4 @@ under the License. target/site - \ No newline at end of file + diff --git a/maven-release-manager/src/test/resources/simplelogger.properties b/maven-release-manager/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..8abc6683c --- /dev/null +++ b/maven-release-manager/src/test/resources/simplelogger.properties @@ -0,0 +1,17 @@ +# 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. +org.slf4j.simpleLogger.defaultLogLevel=error diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml index c96920802..7e8a7174f 100644 --- a/maven-release-plugin/pom.xml +++ b/maven-release-plugin/pom.xml @@ -39,6 +39,11 @@ + + org.apache.maven.release + maven-release-manager + 3.0.0-M6-SNAPSHOT + org.apache.maven maven-plugin-api @@ -47,11 +52,6 @@ org.apache.maven.plugin-tools maven-plugin-annotations - - org.apache.maven.release - maven-release-manager - 3.0.0-M6-SNAPSHOT - org.apache.maven maven-model @@ -109,7 +109,7 @@ org.apache.maven.plugin-testing maven-plugin-testing-harness - 2.1 + 3.3.0 test diff --git a/maven-release-policies/maven-release-oddeven-policy/pom.xml b/maven-release-policies/maven-release-oddeven-policy/pom.xml index 4e4df3648..b7831f22d 100644 --- a/maven-release-policies/maven-release-oddeven-policy/pom.xml +++ b/maven-release-policies/maven-release-oddeven-policy/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.release maven-release 3.0.0-M6-SNAPSHOT - ../.. + ../../pom.xml maven-release-oddeven-policy @@ -50,15 +50,26 @@ org.apache.maven maven-artifact + + org.eclipse.aether + aether-api + compile + org.eclipse.aether aether-util - 1.0.0.v20140518 + compile + - org.codehaus.plexus - plexus-component-annotations - true + javax.inject + javax.inject + provided + + + org.eclipse.sisu + org.eclipse.sisu.inject + provided @@ -68,21 +79,4 @@ - - - - org.codehaus.plexus - plexus-component-metadata - - - process-classes - - generate-metadata - - - - - - - diff --git a/maven-release-policies/maven-release-oddeven-policy/src/main/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicy.java b/maven-release-policies/maven-release-oddeven-policy/src/main/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicy.java index 8a34780db..0c33f4b70 100644 --- a/maven-release-policies/maven-release-oddeven-policy/src/main/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicy.java +++ b/maven-release-policies/maven-release-oddeven-policy/src/main/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicy.java @@ -19,6 +19,9 @@ * under the License. */ +import javax.inject.Named; +import javax.inject.Singleton; + import java.util.List; import org.apache.maven.artifact.Artifact; @@ -28,8 +31,8 @@ import org.apache.maven.shared.release.policy.version.VersionPolicyResult; import org.apache.maven.shared.release.versions.Version; import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.sisu.Description; /** * A {@link org.apache.maven.shared.release.policy.version.VersionPolicy} implementation that propose even version numbers only for releases and odd @@ -40,11 +43,9 @@ * * */ -@Component( - role = VersionPolicy.class, - hint = "OddEvenVersionPolicy", - description = "A VersionPolicy implementation that selects even version numbers only for releases" -) +@Singleton +@Named( "OddEvenVersionPolicy" ) +@Description( "A VersionPolicy implementation that selects even version numbers only for releases" ) public final class OddEvenVersionPolicy implements VersionPolicy { diff --git a/maven-release-policies/maven-release-oddeven-policy/src/test/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicyTestCase.java b/maven-release-policies/maven-release-oddeven-policy/src/test/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicyTestCase.java index 48f7b6b73..edee8a3f8 100644 --- a/maven-release-policies/maven-release-oddeven-policy/src/test/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicyTestCase.java +++ b/maven-release-policies/maven-release-oddeven-policy/src/test/java/org/apache/maven/shared/release/policy/oddeven/OddEvenVersionPolicyTestCase.java @@ -23,26 +23,12 @@ import org.apache.maven.shared.release.policy.version.VersionPolicy; import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; -import org.junit.After; -import org.junit.Before; import org.junit.Test; public final class OddEvenVersionPolicyTestCase { - private VersionPolicy versionPolicy; - - @Before - public void setUp() - { - versionPolicy = new OddEvenVersionPolicy(); - } - - @After - public void tearDown() - { - versionPolicy = null; - } + private final VersionPolicy versionPolicy = new OddEvenVersionPolicy(); @Test public void testConvertToSnapshot() diff --git a/maven-release-policies/maven-release-semver-policy/pom.xml b/maven-release-policies/maven-release-semver-policy/pom.xml index 9394d63e2..dc9200954 100644 --- a/maven-release-policies/maven-release-semver-policy/pom.xml +++ b/maven-release-policies/maven-release-semver-policy/pom.xml @@ -25,7 +25,7 @@ org.apache.maven.release maven-release 3.0.0-M6-SNAPSHOT - ../.. + ../../pom.xml maven-release-semver-policy @@ -40,6 +40,7 @@ ${project.parent.groupId} maven-release-api ${project.parent.version} + provided org.semver @@ -47,11 +48,15 @@ 0.9.33 - - org.codehaus.plexus - plexus-component-annotations - true + javax.inject + javax.inject + provided + + + org.eclipse.sisu + org.eclipse.sisu.inject + provided @@ -61,21 +66,4 @@ - - - - org.codehaus.plexus - plexus-component-metadata - - - process-classes - - generate-metadata - - - - - - - \ No newline at end of file diff --git a/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java b/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java index 6cf0b1ec9..88d70fd1c 100644 --- a/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java +++ b/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java @@ -19,12 +19,14 @@ * under the License. */ -import org.apache.maven.shared.release.policy.PolicyException; +import javax.inject.Named; +import javax.inject.Singleton; + import org.apache.maven.shared.release.policy.version.VersionPolicy; import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; import org.apache.maven.shared.release.policy.version.VersionPolicyResult; import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; +import org.eclipse.sisu.Description; import org.semver.Version; import org.semver.Version.Element; @@ -32,16 +34,15 @@ * * Uses SemVer implementation to increase minor element when resolving the development version */ -@Component( - role = VersionPolicy.class, - hint = "SemVerVersionPolicy", - description = "A VersionPolicy following the SemVer rules" - ) +@Singleton +@Named( "SemVerVersionPolicy" ) +@Description( "A VersionPolicy following the SemVer rules" ) public class SemVerVersionPolicy implements VersionPolicy { + @Override public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException + throws VersionParseException { Version version; try @@ -58,8 +59,9 @@ public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) return result; } + @Override public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException + throws VersionParseException { Version version; try @@ -73,7 +75,7 @@ public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) version = version.next( Element.MINOR ); VersionPolicyResult result = new VersionPolicyResult(); - result.setVersion( version.toString() + "-SNAPSHOT" ); + result.setVersion( version + "-SNAPSHOT" ); return result; } } diff --git a/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java b/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java index 94bc63e29..fb15556c2 100644 --- a/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java +++ b/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java @@ -23,26 +23,12 @@ import org.apache.maven.shared.release.policy.version.VersionPolicy; import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; -import org.junit.After; -import org.junit.Before; import org.junit.Test; -public class SemVerVersionPolicyTest +public final class SemVerVersionPolicyTest { - private VersionPolicy versionPolicy; - - @Before - public void setUp() - { - versionPolicy = new SemVerVersionPolicy(); - } - - @After - public void tearDown() - { - versionPolicy = null; - } + private final VersionPolicy versionPolicy = new SemVerVersionPolicy(); @Test public void testConvertToSnapshot() diff --git a/pom.xml b/pom.xml index 1a6d09c5c..96c3b20c7 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,10 @@ 1.12.2 8 - 3.0 + 3.2.5 + 1.0.0.v20140518 + 3.5.1 + 3.0.0-M6 maven-release-archives/maven-release-LATEST 2022-01-02T10:18:49Z @@ -106,13 +109,14 @@ - - org.codehaus.plexus - plexus-component-metadata - 2.1.1 - + + + org.eclipse.sisu + sisu-maven-plugin + + @@ -128,6 +132,12 @@ maven-core ${mavenVersion} provided + + + org.sonatype.plexus + plexus-sec-dispatcher + + org.apache.maven @@ -160,6 +170,60 @@ provided + + org.eclipse.aether + aether-api + ${resolverVersion} + + + org.eclipse.aether + aether-util + ${resolverVersion} + + + + org.eclipse.aether + aether-spi + ${resolverVersion} + test + + + org.eclipse.aether + aether-impl + ${resolverVersion} + test + + + org.eclipse.aether + aether-connector-basic + ${resolverVersion} + test + + + org.eclipse.aether + aether-transport-file + ${resolverVersion} + test + + + org.eclipse.aether + aether-transport-wagon + ${resolverVersion} + test + + + org.apache.maven.wagon + wagon-provider-api + ${wagonVersion} + test + + + org.apache.maven.wagon + wagon-http + ${wagonVersion} + test + + org.apache.maven.scm maven-scm-api @@ -170,6 +234,12 @@ maven-scm-manager-plexus ${scmVersion} runtime + + + org.codehaus.plexus + plexus-container-default + + org.apache.maven.scm @@ -187,6 +257,31 @@ maven-scm-test ${scmVersion} test + + + org.sonatype.plexus + plexus-sec-dispatcher + + + + + + org.slf4j + slf4j-api + 1.7.5 + provided + + + org.slf4j + slf4j-simple + 1.7.5 + test + + + + javax.inject + javax.inject + 1