This is an automated email from the ASF dual-hosted git repository. kwin pushed a commit to branch feature/ci-friendly-complex-expressions in repository https://gitbox.apache.org/repos/asf/maven-release.git
commit 6eecad367076474dc298eb600c0e48f09cc7b1fa Author: Mikhail Kolesnikov <m.kolesni...@id-mt.ru> AuthorDate: Wed Nov 29 19:47:06 2023 +0300 MRELEASE-1109 full support of CI Friendly expression --- .../release/phase/AbstractCheckPomPhase.java | 4 +- .../release/phase/AbstractRewritePomsPhase.java | 113 ++++++++++++++++++++- .../shared/release/transform/jdom2/JDomModel.java | 2 +- .../maven/shared/release/util/MavenExpression.java | 44 ++++++++ .../phase/RewritePomsForDevelopmentPhaseTest.java | 15 +++ .../release/transform/jdom2/JDomModelTest.java | 2 +- .../shared/release/util/MavenExpressionTest.java | 61 +++++++++++ .../expected-pom.xml} | 5 +- .../pom.xml} | 5 +- .../subproject1/expected-pom.xml | 2 +- .../subproject1/pom.xml | 2 +- .../expected-pom.xml | 5 +- .../pom.xml | 5 +- .../subproject1/expected-pom.xml | 2 +- .../subproject1/pom.xml | 2 +- maven-release-plugin/pom.xml | 8 +- .../ci-friendly-multi-module/module-a/pom.xml | 39 +++++++ .../apache/maven/plugin/release/module/a/App.java | 32 ++++++ .../maven/plugin/release/module/a/AppTest.java | 57 +++++++++++ .../ci-friendly-multi-module/module-b/pom.xml | 39 +++++++ .../apache/maven/plugin/release/module/b/App.java | 32 ++++++ .../maven/plugin/release/module/b/AppTest.java | 57 +++++++++++ .../prepare/ci-friendly-multi-module/pom.xml | 72 +++++++++++++ .../prepare/ci-friendly-multi-module/verify.groovy | 45 ++++++++ .../src/it/projects/prepare/invoker.properties | 4 +- 25 files changed, 629 insertions(+), 25 deletions(-) diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java index fed38504..7b24d39a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractCheckPomPhase.java @@ -31,6 +31,7 @@ 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.MavenExpression; import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; @@ -89,7 +90,8 @@ public abstract class AbstractCheckPomPhase extends AbstractReleasePhase { boolean containsSnapshotProjects = false; for (MavenProject project : reactorProjects) { - if (ArtifactUtils.isSnapshot(project.getVersion())) { + String projectVersion = MavenExpression.evaluate(project.getVersion(), project.getProperties()); + if (ArtifactUtils.isSnapshot(projectVersion)) { containsSnapshotProjects = true; break; 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 7e799f30..d6aa3c0c 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 @@ -99,7 +99,7 @@ public abstract class AbstractRewritePomsPhase extends AbstractReleasePhase impl * Regular expression pattern matching Maven expressions (i.e. references to Maven properties). * The first group selects the property name the expression refers to. */ - private static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+)\\}"); + private static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+?)\\}"); /** * All Maven properties allowed to be referenced in parent versions via expressions @@ -475,7 +475,7 @@ public abstract class AbstractRewritePomsPhase extends AbstractReleasePhase impl */ public static String extractPropertyFromExpression(String expression) { Matcher matcher = EXPRESSION_PATTERN.matcher(expression); - if (!matcher.matches()) { + if (!matcher.find()) { return null; } return matcher.group(1); @@ -548,10 +548,119 @@ public abstract class AbstractRewritePomsPhase extends AbstractReleasePhase impl return; } +<<<<<<< Upstream, based on master String rawGroupId = artifact.getGroupId(); if (rawGroupId == null) { if ("plugin".equals(artifact.getName())) { rawGroupId = "org.apache.maven.plugins"; +======= + String rawArtifactId = coordinate.getArtifactId(); + if (rawArtifactId == null) { + // incomplete element + continue; + } + String artifactId = ReleaseUtil.interpolate(rawArtifactId, projectModel); + + String key = ArtifactUtils.versionlessKey(groupId, artifactId); + String resolvedSnapshotVersion = getResolvedSnapshotVersion(key, releaseDescriptor); + String mappedVersion = getNextVersion(releaseDescriptor, key); + String originalVersion = getOriginalVersion(releaseDescriptor, key, simulate); + if (originalVersion == null) { + originalVersion = getOriginalResolvedSnapshotVersion(key, releaseDescriptor); + } + + // MRELEASE-220 + if (mappedVersion != null + && mappedVersion.endsWith(Artifact.SNAPSHOT_VERSION) + && !rawVersion.endsWith(Artifact.SNAPSHOT_VERSION) + && !releaseDescriptor.isUpdateDependencies()) { + continue; + } + + if (mappedVersion != null) { + if (rawVersion.equals(originalVersion)) { + logInfo(result, " Updating " + artifactId + " to " + mappedVersion); + coordinate.setVersion(mappedVersion); + } else { + String property = extractPropertyFromExpression(rawVersion); + logInfo(result, "CI Friendly property " + property + " and rawVersion is " + rawVersion); + if (property != null) { + if (property.startsWith("project.") + || property.startsWith("pom.") + || "version".equals(property)) { + if (!mappedVersion.equals(getNextVersion(releaseDescriptor, projectId))) { + logInfo(result, " Updating " + artifactId + " to " + mappedVersion); + coordinate.setVersion(mappedVersion); + } else { + logInfo(result, " Ignoring artifact version update for expression " + rawVersion); + } + } else if (properties != null) { + // version is an expression, check for properties to update instead + String propertyValue = properties.getProperty(property); + if (propertyValue != null) { + if (propertyValue.equals(originalVersion)) { + logInfo(result, " Updating " + rawVersion + " to " + mappedVersion); + // change the property only if the property is the same as what's in the reactor + properties.setProperty(property, mappedVersion); + } 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"); + } 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)) { + logInfo( + result, + " Ignoring artifact version update for expression " + 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 (" + rawVersion + ") in the " + + "project (" + projectId + ")."); + } + } + } else { + if (CI_FRIENDLY_PROPERTIES.contains(property)) { + // the parent's pom revision is set inside + // org.apache.maven.shared.release.transform.jdom2.JDomModel.setVersion + logInfo( + result, + " Ignoring artifact version update for CI friendly expression " + + rawVersion); + } else { + // the expression used to define the version of this artifact may be inherited + // TODO needs a better error message, what pom? what dependency? + throw new ReleaseFailureException( + "Could not find property resolving version expression: " + rawVersion); + } + } + } else { + // the expression used to define the version of this artifact may be inherited + // TODO needs a better error message, what pom? what dependency? + throw new ReleaseFailureException( + "Could not find properties resolving version expression : " + rawVersion); + } + } else { + // different/previous version not related to current release + // this is the only place where the returned null from `extractPropertyFromExpression` is + // supposed to be handled. + // And the unit test RewritePomsForBranchPhaseTest depends on null result from + // `extractPropertyFromExpression`. + } + } + } else if (resolvedSnapshotVersion != null) { + logInfo(result, " Updating " + artifactId + " to " + resolvedSnapshotVersion); + + coordinate.setVersion(resolvedSnapshotVersion); +>>>>>>> 21df8de MRELEASE-1109 full support of CI Friendly expression } else { // incomplete dependency return; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java index 6198ee73..20d972bd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModel.java @@ -198,7 +198,7 @@ public class JDomModel extends Model { AbstractRewritePomsPhase.extractPropertyFromExpression(versionElement.getTextNormalize()); Properties properties = getProperties(); if (properties != null) { - properties.computeIfPresent(ciFriendlyPropertyName, (k, v) -> version); + properties.setProperty(ciFriendlyPropertyName, version); } } else { JDomUtils.rewriteValue(versionElement, version); diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenExpression.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenExpression.java new file mode 100644 index 00000000..6986cdb8 --- /dev/null +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/MavenExpression.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.shared.release.util; + +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author <a href="mailto:mikhail_kolesni...@outlook.com">Mikhail Kolesnikov</a> + */ +public class MavenExpression { + public static final Pattern EXPRESSION_PATTERN = Pattern.compile("\\$\\{(.+?)\\}"); + + private MavenExpression() {} + + public static String evaluate(String expression, Properties properties) { + StringBuilder result = new StringBuilder(expression); + Matcher matcher = EXPRESSION_PATTERN.matcher(result); + while (matcher.find()) { + String propertyName = matcher.group(1); + String propertyValue = properties.getProperty(propertyName); + result.replace(matcher.start(), matcher.end(), String.valueOf(propertyValue)); + matcher.reset(); + } + return result.toString(); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java index b303a514..b1bebb81 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RewritePomsForDevelopmentPhaseTest.java @@ -398,4 +398,19 @@ public class RewritePomsForDevelopmentPhaseTest extends AbstractEditModeRewritin assertTrue(comparePomFiles(reactorProjects)); } + + @Test + public void testRewritePomWithCiFriendlyReactor() throws Exception { + List<MavenProject> reactorProjects = createReactorProjects("pom-with-parent-and-cifriendly-expressions"); + + ReleaseDescriptorBuilder builder = + createDescriptorFromProjects(reactorProjects, "pom-with-parent-and-cifriendly-expressions"); + builder.addReleaseVersion("groupId:artifactId", RELEASE_VERSION); + builder.addDevelopmentVersion("groupId:artifactId", NEXT_VERSION); + builder.addReleaseVersion("groupId:subproject1", RELEASE_VERSION); + builder.addDevelopmentVersion("groupId:subproject1", NEXT_VERSION); + phase.execute(ReleaseUtils.buildReleaseDescriptor(builder), new DefaultReleaseEnvironment(), reactorProjects); + + assertTrue(comparePomFiles(reactorProjects)); + } } diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom2/JDomModelTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom2/JDomModelTest.java index ebd0ec28..abe03d6c 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom2/JDomModelTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom2/JDomModelTest.java @@ -69,7 +69,7 @@ public class JDomModelTest { assertNull(model.getVersion()); // inherit from parent via CI friendly - content = "<project><parent><version>${revision}</version></parent></project>"; + content = "<project><parent><version>${revision}${changelist}</version></parent></project>"; projectElm = builder.build(new StringReader(content)).getRootElement(); model = new JDomModel(projectElm); assertNull(model.getVersion()); diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/MavenExpressionTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/MavenExpressionTest.java new file mode 100644 index 00000000..12c1b2d4 --- /dev/null +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/MavenExpressionTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.shared.release.util; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Properties; + +import junit.framework.TestCase; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * @author <a href="mailto:mikhail_kolesni...@outlook.com">Mikhail Kolesnikov</a> + */ +@RunWith(Parameterized.class) +public class MavenExpressionTest extends TestCase { + + private final String expected; + private final String expression; + private final Properties properties = new Properties(); + + public MavenExpressionTest(String expected, String expression) { + this.expected = expected; + this.expression = expression; + properties.setProperty("revision", "12"); + properties.setProperty("sha1", "34"); + properties.setProperty("changelist", "56"); + } + + @Parameters(name = "expected result {0} for expression {1}") + public static Collection<Object[]> parameters() { + return Arrays.asList( + new Object[] {"123456", "${revision}${sha1}${changelist}"}, + new Object[] {"12-34-56", "${revision}-${sha1}-${changelist}"}, + new Object[] {"12-null-56", "${revision}-${unknown}-${changelist}"}); + } + + @Test + public void testEvaluate() { + assertEquals(expected, MavenExpression.evaluate(expression, properties)); + } +} diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/expected-pom.xml similarity index 91% copy from maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml copy to maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/expected-pom.xml index 0c9bd8b2..b30f8a7e 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/expected-pom.xml @@ -20,7 +20,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> <packaging>pom</packaging> <scm> @@ -30,7 +30,8 @@ </scm> <properties> - <revision>1.0-SNAPSHOT</revision> + <revision>1.1</revision> + <changelist>-SNAPSHOT</changelist> </properties> <modules> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/pom.xml similarity index 91% copy from maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml copy to maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/pom.xml index c7504063..cf04d4b7 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/pom.xml @@ -20,7 +20,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> <packaging>pom</packaging> <scm> @@ -30,7 +30,8 @@ </scm> <properties> - <revision>1.0-SNAPSHOT</revision> + <revision>1.0</revision> + <changelist>-SNAPSHOT</changelist> </properties> <modules> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml similarity index 94% copy from maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml copy to maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml index 7b2fa88c..db70f739 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> </parent> <artifactId>subproject1</artifactId> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml similarity index 94% copy from maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml copy to maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml index 7b2fa88c..db70f739 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-development/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> </parent> <artifactId>subproject1</artifactId> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml index c7504063..2f68ea26 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/expected-pom.xml @@ -20,7 +20,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> <packaging>pom</packaging> <scm> @@ -30,7 +30,8 @@ </scm> <properties> - <revision>1.0-SNAPSHOT</revision> + <revision>1.0</revision> + <changelist></changelist> </properties> <modules> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml index 0c9bd8b2..5910661e 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/pom.xml @@ -20,7 +20,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> <packaging>pom</packaging> <scm> @@ -30,7 +30,8 @@ </scm> <properties> - <revision>1.0-SNAPSHOT</revision> + <revision>1.0</revision> + <changelist>-SNAPSHOT</changelist> </properties> <modules> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml index 7b2fa88c..db70f739 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/expected-pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> </parent> <artifactId>subproject1</artifactId> diff --git a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml index 7b2fa88c..db70f739 100644 --- a/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml +++ b/maven-release-manager/src/test/resources/projects/rewrite-for-release/pom-with-parent-and-cifriendly-expressions/subproject1/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>groupId</groupId> <artifactId>artifactId</artifactId> - <version>${revision}</version> + <version>${revision}${changelist}</version> </parent> <artifactId>subproject1</artifactId> diff --git a/maven-release-plugin/pom.xml b/maven-release-plugin/pom.xml index 3aa59772..2af4a213 100644 --- a/maven-release-plugin/pom.xml +++ b/maven-release-plugin/pom.xml @@ -224,13 +224,7 @@ <setupInclude>setup/*/pom.xml</setupInclude> </setupIncludes> <pomIncludes> - <pomInclude>projects/prepare/*/*pom.xml</pomInclude> - <pomInclude>projects/prepare/flat-multi-module/parent-project/pom.xml</pomInclude> - <pomInclude>projects/prepare-with-pom/*/*pom.xml</pomInclude> - <pomInclude>projects/branch/*/pom.xml</pomInclude> - <pomInclude>projects/perform/*/pom.xml</pomInclude> - <pomInclude>projects/update-versions/*/pom.xml</pomInclude> - <pomInclude>projects/stage/*/pom.xml</pomInclude> + <pomInclude>projects/prepare/ci-friendly-multi-module/*pom.xml</pomInclude> </pomIncludes> <pomExcludes> <pomExclude>projects/prepare/MRELEASE-966/pom.xml</pomExclude> diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml new file mode 100644 index 00000000..1a042b0c --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<project> + <parent> + <artifactId>ci-friendly-multi-module-project</artifactId> + <groupId>org.apache.maven.plugin.release</groupId> + <version>${revision}${changelist}</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugin.release</groupId> + <artifactId>module-a</artifactId> + <name>module-a</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>@junitVersion@</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/main/java/org/apache/maven/plugin/release/module/a/App.java b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/main/java/org/apache/maven/plugin/release/module/a/App.java new file mode 100644 index 00000000..05ca6eca --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/main/java/org/apache/maven/plugin/release/module/a/App.java @@ -0,0 +1,32 @@ +package org.apache.maven.plugin.release.module.a; + +/* + * 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. + */ + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java new file mode 100644 index 00000000..ca41b5f5 --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-a/src/test/java/org/apache/maven/plugin/release/module/a/AppTest.java @@ -0,0 +1,57 @@ +package org.apache.maven.plugin.release.module.a; + +/* + * 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 junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml new file mode 100644 index 00000000..f7fec33f --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/pom.xml @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<project> + <parent> + <artifactId>ci-friendly-multi-module-project</artifactId> + <groupId>org.apache.maven.plugin.release</groupId> + <version>${revision}${changelist}</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugin.release</groupId> + <artifactId>module-b</artifactId> + <name>module-b</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>@junitVersion@</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/main/java/org/apache/maven/plugin/release/module/b/App.java b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/main/java/org/apache/maven/plugin/release/module/b/App.java new file mode 100644 index 00000000..8d4d841d --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/main/java/org/apache/maven/plugin/release/module/b/App.java @@ -0,0 +1,32 @@ +package org.apache.maven.plugin.release.module.b; + +/* + * 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. + */ + +/** + * Hello world! + * + */ +public class App +{ + public static void main( String[] args ) + { + System.out.println( "Hello World!" ); + } +} diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java new file mode 100644 index 00000000..c1a903ec --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/module-b/src/test/java/org/apache/maven/plugin/release/module/b/AppTest.java @@ -0,0 +1,57 @@ +package org.apache.maven.plugin.release.module.b; + +/* + * 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 junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml new file mode 100644 index 00000000..ff2ffc91 --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/pom.xml @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugin.release</groupId> + <artifactId>ci-friendly-multi-module-project</artifactId> + <packaging>pom</packaging> + <version>${revision}${changelist}</version> + <name>parent-project</name> + <url>http://maven.apache.org</url> + <scm> + <connection>scm:stub|</connection> + <developerConnection>scm:stub|</developerConnection> + <tag>HEAD</tag> + </scm> + + <properties> + <revision>1.0</revision> + <changelist>-SNAPSHOT</changelist> + <maven.compiler.source>@maven.compiler.source@</maven.compiler.source> + <maven.compiler.target>@maven.compiler.target@</maven.compiler.target> + </properties> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>@project.version@</version> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.release</groupId> + <artifactId>maven-scm-provider-stub</artifactId> + <version>1.0</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>@junitVersion@</version> + <scope>test</scope> + </dependency> + </dependencies> + <modules> + <module>module-a</module> + <module>module-b</module> + </modules> +</project> diff --git a/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/verify.groovy b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/verify.groovy new file mode 100644 index 00000000..5104bc5e --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/ci-friendly-multi-module/verify.groovy @@ -0,0 +1,45 @@ +/* + * 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 groovy.xml.XmlSlurper + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +// next development versions +def projectRootTag = new XmlSlurper().parse( new File( basedir, 'pom.xml.tag' ) ) +assert projectRootTag.version.text() == '${revision}${changelist}' +// updating of the revision property is not implemented +assert projectRootTag.properties.revision.text() == "1.0" +assert projectRootTag.properties.changelist.text() == "" + +// next development versions +def projectRoot = new XmlSlurper().parse( new File( basedir, 'pom.xml.next' ) ) +assert projectRoot.version.text() == '${revision}${changelist}' +// updating of the revision property is not implemented +assert projectRoot.properties.revision.text() == "1.1" +assert projectRoot.properties.changelist.text() == "-SNAPSHOT" + +def projectA = new XmlSlurper().parse( new File( basedir, 'module-a/pom.xml.next' ) ) +assert projectA.parent.version.text() == '${revision}${changelist}' + +def projectB = new XmlSlurper().parse( new File( basedir, 'module-b/pom.xml.next' ) ) +assert projectB.parent.version.text() == '${revision}${changelist}' + +return true \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/invoker.properties b/maven-release-plugin/src/it/projects/prepare/invoker.properties index 43b6c5fc..2ac39567 100644 --- a/maven-release-plugin/src/it/projects/prepare/invoker.properties +++ b/maven-release-plugin/src/it/projects/prepare/invoker.properties @@ -15,4 +15,6 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = release:clean release:prepare \ No newline at end of file +invoker.goals = release:clean release:prepare + +invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 \ No newline at end of file