You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2022/07/06 05:49:54 UTC
[maven-wrapper] 01/01: [MWRAPPER-73] Allow empty maven version property
This is an automated email from the ASF dual-hosted git repository.
sjaranowski pushed a commit to branch MWRAPPER-73
in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git
commit 4f83256b57f9f7cc24f9e231beca8b5b7a20ee22
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Wed Jul 6 07:49:27 2022 +0200
[MWRAPPER-73] Allow empty maven version property
---
.../mavenversion-empty1/invoker.properties | 20 +++++++
.../src/it/projects/mavenversion-empty1/pom.xml | 66 ++++++++++++++++++++++
.../it/projects/mavenversion-empty1/verify.groovy | 41 ++++++++++++++
.../mavenversion-empty2/invoker.properties | 20 +++++++
.../src/it/projects/mavenversion-empty2/pom.xml | 66 ++++++++++++++++++++++
.../it/projects/mavenversion-empty2/verify.groovy | 41 ++++++++++++++
.../apache/maven/plugins/wrapper/WrapperMojo.java | 2 +-
7 files changed, 255 insertions(+), 1 deletion(-)
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/invoker.properties b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/invoker.properties
new file mode 100644
index 0000000..a2f2dc3
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/invoker.properties
@@ -0,0 +1,20 @@
+# 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.1 = ${project.groupId}:${project.artifactId}:${project.version}:wrapper -Dmaven
+invoker.goals.2 = exec:exec
+
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/pom.xml b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/pom.xml
new file mode 100644
index 0000000..a35f8ab
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/pom.xml
@@ -0,0 +1,66 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.it.wrapper</groupId>
+ <artifactId>mavenversion-empty1</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <cmd></cmd>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <executable>mvnw${cmd}</executable>
+ <arguments>
+ <argument>-v</argument>
+ </arguments>
+ <environmentVariables>
+ <MVNW_VERBOSE>true</MVNW_VERBOSE>
+ </environmentVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>windows</id>
+ <activation>
+ <os><family>windows</family></os>
+ </activation>
+ <properties>
+ <cmd>.cmd</cmd>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy
new file mode 100644
index 0000000..0ee5d42
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+assert new File( basedir, 'mvnw' ).exists()
+assert new File( basedir, 'mvnw.cmd' ).exists()
+assert !(new File( basedir, 'mvnwDebug' ).exists())
+assert !(new File( basedir, 'mvnwDebug.cmd' ).exists())
+
+def propertiesFile = new File( basedir, '.mvn/wrapper/maven-wrapper.properties' )
+assert propertiesFile.exists()
+
+def props = new Properties()
+propertiesFile.withInputStream {
+ props.load( it )
+}
+
+def (_, mavenVersion1, mavenVersion2) = (props.distributionUrl =~ /\/org\/apache\/maven\/apache-maven\/(.+)\/apache-maven-(.+)-bin.zip/)[0]
+
+assert mavenVersion1 == mavenVersion2
+
+log = new File( basedir, 'build.log' ).text
+// check "mvn wrapper:wrapper" output
+assert log.contains( '[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:' )
+// check "mvnw -v" output
+assert log.contains( 'Apache Maven ' + mavenVersion1 )
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/invoker.properties b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/invoker.properties
new file mode 100644
index 0000000..0844b36
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/invoker.properties
@@ -0,0 +1,20 @@
+# 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.1 = ${project.groupId}:${project.artifactId}:${project.version}:wrapper -Dmaven=
+invoker.goals.2 = exec:exec
+
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/pom.xml b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/pom.xml
new file mode 100644
index 0000000..8356276
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/pom.xml
@@ -0,0 +1,66 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.it.wrapper</groupId>
+ <artifactId>mavenversion-empty2</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <cmd></cmd>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>3.0.0</version>
+ <configuration>
+ <executable>mvnw${cmd}</executable>
+ <arguments>
+ <argument>-v</argument>
+ </arguments>
+ <environmentVariables>
+ <MVNW_VERBOSE>true</MVNW_VERBOSE>
+ </environmentVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>windows</id>
+ <activation>
+ <os><family>windows</family></os>
+ </activation>
+ <properties>
+ <cmd>.cmd</cmd>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy
new file mode 100644
index 0000000..0ee5d42
--- /dev/null
+++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+assert new File( basedir, 'mvnw' ).exists()
+assert new File( basedir, 'mvnw.cmd' ).exists()
+assert !(new File( basedir, 'mvnwDebug' ).exists())
+assert !(new File( basedir, 'mvnwDebug.cmd' ).exists())
+
+def propertiesFile = new File( basedir, '.mvn/wrapper/maven-wrapper.properties' )
+assert propertiesFile.exists()
+
+def props = new Properties()
+propertiesFile.withInputStream {
+ props.load( it )
+}
+
+def (_, mavenVersion1, mavenVersion2) = (props.distributionUrl =~ /\/org\/apache\/maven\/apache-maven\/(.+)\/apache-maven-(.+)-bin.zip/)[0]
+
+assert mavenVersion1 == mavenVersion2
+
+log = new File( basedir, 'build.log' ).text
+// check "mvn wrapper:wrapper" output
+assert log.contains( '[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:' )
+// check "mvnw -v" output
+assert log.contains( 'Apache Maven ' + mavenVersion1 )
diff --git a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
index 826c0cb..fde6cd6 100644
--- a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
+++ b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
@@ -282,7 +282,7 @@ public class WrapperMojo
private String getVersion( String defaultVersion, Class<?> clazz, String path )
{
String version = defaultVersion;
- if ( version == null )
+ if ( version == null || version.trim().length() == 0 || "true".equals( version ) )
{
Properties props = new Properties();
try ( InputStream is = clazz.getResourceAsStream( "/META-INF/maven/" + path + "/pom.properties" ) )