From 3064cffdffceaedf2d926d06b1a483edcd5e4043 Mon Sep 17 00:00:00 2001 From: Niels Basjes Date: Sun, 6 Feb 2022 15:26:49 +0100 Subject: [PATCH] [MRELEASE-1077] Add support for prepare-specific profiles This closes #101 --- .../prepare/MRELEASE-1077/invoker.properties | 18 +++++ .../it/projects/prepare/MRELEASE-1077/pom.xml | 78 +++++++++++++++++++ .../prepare/MRELEASE-1077/verify.groovy | 24 ++++++ .../plugins/release/PrepareReleaseMojo.java | 14 ++++ 4 files changed, 134 insertions(+) create mode 100644 maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/invoker.properties create mode 100644 maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/pom.xml create mode 100644 maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/verify.groovy diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/invoker.properties b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/invoker.properties new file mode 100644 index 000000000..43b6c5fcb --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.goals = release:clean release:prepare \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/pom.xml new file mode 100644 index 000000000..807c401d6 --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.maven.plugin.release.its + mrelease-1077 + 1.0-SNAPSHOT + + scm:dummy|nul + + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + scm:dummy|nul + perform_username + perform_password + PrepProfA,PrepProfB + + + + org.apache.maven.its.release + maven-scm-provider-dummy + 1.0 + + + + + + org.apache.maven.plugins + maven-help-plugin + 3.3.0 + + + Show profiles + validate + + active-profiles + + + + + + + + + + PrepProfA + + + + PrepProfB + + + + diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/verify.groovy b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/verify.groovy new file mode 100644 index 000000000..a0e52dc92 --- /dev/null +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-1077/verify.groovy @@ -0,0 +1,24 @@ +/* + * 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. + */ + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +assert buildLog.text.contains( "[INFO] - PrepProfA (source: org.apache.maven.plugin.release.its:mrelease-1077:1.0-SNAPSHOT)") +assert buildLog.text.contains( "[INFO] - PrepProfB (source: org.apache.maven.plugin.release.its:mrelease-1077:1.0-SNAPSHOT)") diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java index e7403b998..0d24ab4a5 100644 --- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java +++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/PrepareReleaseMojo.java @@ -102,6 +102,12 @@ public class PrepareReleaseMojo extends AbstractScmReleaseMojo { @Parameter(defaultValue = "true", property = "addSchema") private boolean addSchema; + /** + * Comma separated profiles to enable on release prepare, in addition to active profiles for project execution. + */ + @Parameter(property = "preparationProfiles") + private String preparationProfiles; + /** * Goals to run as part of the preparation step, after transformation but before committing. Space delimited. */ @@ -323,6 +329,14 @@ public class PrepareReleaseMojo extends AbstractScmReleaseMojo { @Parameter(defaultValue = "false", property = "pinExternals") private boolean pinExternals; + /** + * {@inheritDoc} + */ + @Override + protected String getAdditionalProfiles() { + return preparationProfiles; + } + /** * Specifies the line separator to format pom.xml. The following properties are * available: