You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/05/23 12:07:44 UTC
[maven-wrapper-plugin] 01/01: Initial setup of wrapper mojo
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git
commit 69f0ef23177994f00c6c870c257d128ea5d3cf76
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Feb 9 16:21:44 2020 +0100
Initial setup of wrapper mojo
---
.gitignore | 4 +
Jenkinsfile | 20 ++
pom.xml | 125 +++++++++++
src/it/projects/default/invoker.properties | 18 ++
src/it/projects/default/pom.xml | 29 +++
src/it/projects/default/verify.groovy | 26 +++
src/it/projects/excludeDebug/invoker.properties | 18 ++
src/it/projects/excludeDebug/pom.xml | 29 +++
src/it/projects/excludeDebug/test.properties | 18 ++
src/it/projects/excludeDebug/verify.groovy | 24 +++
src/it/projects/extension/invoker.properties | 18 ++
src/it/projects/extension/pom.xml | 40 ++++
src/it/projects/extension/verify.groovy | 25 +++
src/it/projects/mavenversion/invoker.properties | 18 ++
src/it/projects/mavenversion/pom.xml | 29 +++
src/it/projects/mavenversion/test.properties | 18 ++
src/it/projects/mavenversion/verify.groovy | 34 +++
src/it/projects/type_bin/invoker.properties | 18 ++
src/it/projects/type_bin/pom.xml | 29 +++
src/it/projects/type_bin/test.properties | 18 ++
src/it/projects/type_bin/verify.groovy | 26 +++
src/it/projects/type_source/invoker.properties | 18 ++
src/it/projects/type_source/pom.xml | 29 +++
src/it/projects/type_source/test.properties | 18 ++
src/it/projects/type_source/verify.groovy | 27 +++
src/it/projects/wrapperversion/invoker.properties | 17 ++
src/it/projects/wrapperversion/pom.xml | 29 +++
src/it/projects/wrapperversion/test.properties | 18 ++
src/it/projects/wrapperversion/verify.groovy | 34 +++
src/it/settings.xml | 54 +++++
.../apache/maven/plugins/wrapper/WrapperMojo.java | 239 +++++++++++++++++++++
src/main/resources/META-INF/plexus/components.xml | 42 ++++
32 files changed, 1109 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..06a84e9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/.classpath
+/.project
+/.settings
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..9481f86
--- /dev/null
+++ b/Jenkinsfile
@@ -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.
+ */
+
+asfMavenTlpPlgnBuild(jdk:['8','11','14','15'])
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..ddf70f9
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,125 @@
+<?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>
+
+ <parent>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugins</artifactId>
+ <version>33</version>
+ <relativePath/>
+ </parent>
+
+ <artifactId>maven-wrapper-plugin</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+
+ <name>Apache Maven Wrapper Plugin</name>
+ <description>
+ The Maven Wrapper Plugin is a plugin that provides support for the Maven Wrapper.
+ </description>
+ <inceptionYear>2020</inceptionYear>
+
+ <prerequisites>
+ <maven>3.6.9999</maven>
+ </prerequisites>
+
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/maven-wrapper-plugin.git</developerConnection>
+ <url>https://github.com/apache/maven-wrapper-plugin/tree/${project.scm.tag}</url>
+ <tag>HEAD</tag>
+ </scm>
+ <issueManagement>
+ <system>JIRA</system>
+ <url>https://issues.apache.org/jira/browse/MWRAPPER</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Jenkins</system>
+ <url>https://builds.apache.org/job/maven-box/job/maven-wrapper-plugin/</url>
+ </ciManagement>
+ <distributionManagement>
+ <site>
+ <id>apache.website</id>
+ <url>scm:svn:https://svn.apache.org/repos/asf/maven/website/components/${maven.site.path}</url>
+ </site>
+ </distributionManagement>
+
+ <properties>
+ <mavenVersion>3.1.1</mavenVersion>
+ <javaVersion>8</javaVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-artifact-transfer</artifactId>
+ <version>0.12.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-archiver</artifactId>
+ <version>4.2.1</version>
+ </dependency>
+
+ <!-- dependencies to annotations -->
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <goals>
+ <goal>wrapper</goal>
+ </goals>
+ <projectsDirectory>src/it/projects</projectsDirectory>
+ <pomExcludes>
+ <!-- remove once Maven 3.7.0 is released -->
+ <pomExclude>wrapperversion/pom.xml</pomExclude>
+ </pomExcludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/src/it/projects/default/invoker.properties b/src/it/projects/default/invoker.properties
new file mode 100644
index 0000000..d880d6e
--- /dev/null
+++ b/src/it/projects/default/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.maven.version = 3.7.0+
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/default/pom.xml b/src/it/projects/default/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/default/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/default/verify.groovy b/src/it/projects/default/verify.groovy
new file mode 100644
index 0000000..04369ef
--- /dev/null
+++ b/src/it/projects/default/verify.groovy
@@ -0,0 +1,26 @@
+
+/*
+ * 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()
+assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()
+assert !(new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists())
\ No newline at end of file
diff --git a/src/it/projects/excludeDebug/invoker.properties b/src/it/projects/excludeDebug/invoker.properties
new file mode 100644
index 0000000..d880d6e
--- /dev/null
+++ b/src/it/projects/excludeDebug/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.maven.version = 3.7.0+
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/excludeDebug/pom.xml b/src/it/projects/excludeDebug/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/excludeDebug/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/excludeDebug/test.properties b/src/it/projects/excludeDebug/test.properties
new file mode 100644
index 0000000..6600e23
--- /dev/null
+++ b/src/it/projects/excludeDebug/test.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.
+
+includeDebug=false
\ No newline at end of file
diff --git a/src/it/projects/excludeDebug/verify.groovy b/src/it/projects/excludeDebug/verify.groovy
new file mode 100644
index 0000000..5d269c2
--- /dev/null
+++ b/src/it/projects/excludeDebug/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.
+ */
+
+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())
diff --git a/src/it/projects/extension/invoker.properties b/src/it/projects/extension/invoker.properties
new file mode 100644
index 0000000..7b22bf3
--- /dev/null
+++ b/src/it/projects/extension/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.maven.version = 3.7.0+
diff --git a/src/it/projects/extension/pom.xml b/src/it/projects/extension/pom.xml
new file mode 100644
index 0000000..0cbaa78
--- /dev/null
+++ b/src/it/projects/extension/pom.xml
@@ -0,0 +1,40 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-wrapper-plugin</artifactId>
+ <version>@project.version@</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/extension/verify.groovy b/src/it/projects/extension/verify.groovy
new file mode 100644
index 0000000..627b37e
--- /dev/null
+++ b/src/it/projects/extension/verify.groovy
@@ -0,0 +1,25 @@
+
+/*
+ * 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()
+assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()
diff --git a/src/it/projects/mavenversion/invoker.properties b/src/it/projects/mavenversion/invoker.properties
new file mode 100644
index 0000000..d880d6e
--- /dev/null
+++ b/src/it/projects/mavenversion/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.maven.version = 3.7.0+
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/mavenversion/pom.xml b/src/it/projects/mavenversion/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/mavenversion/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/mavenversion/test.properties b/src/it/projects/mavenversion/test.properties
new file mode 100644
index 0000000..46c2d1b
--- /dev/null
+++ b/src/it/projects/mavenversion/test.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.
+
+mavenVersion=3.6.3
\ No newline at end of file
diff --git a/src/it/projects/mavenversion/verify.groovy b/src/it/projects/mavenversion/verify.groovy
new file mode 100644
index 0000000..f972b23
--- /dev/null
+++ b/src/it/projects/mavenversion/verify.groovy
@@ -0,0 +1,34 @@
+
+/*
+ * 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)
+}
+
+assert props.distributionUrl == 'https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip'
diff --git a/src/it/projects/type_bin/invoker.properties b/src/it/projects/type_bin/invoker.properties
new file mode 100644
index 0000000..d880d6e
--- /dev/null
+++ b/src/it/projects/type_bin/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.maven.version = 3.7.0+
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/type_bin/pom.xml b/src/it/projects/type_bin/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/type_bin/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/type_bin/test.properties b/src/it/projects/type_bin/test.properties
new file mode 100644
index 0000000..b77cbfd
--- /dev/null
+++ b/src/it/projects/type_bin/test.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.
+
+type=bin
\ No newline at end of file
diff --git a/src/it/projects/type_bin/verify.groovy b/src/it/projects/type_bin/verify.groovy
new file mode 100644
index 0000000..e079d58
--- /dev/null
+++ b/src/it/projects/type_bin/verify.groovy
@@ -0,0 +1,26 @@
+
+/*
+ * 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()
+assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()
+assert new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists()
\ No newline at end of file
diff --git a/src/it/projects/type_source/invoker.properties b/src/it/projects/type_source/invoker.properties
new file mode 100644
index 0000000..d880d6e
--- /dev/null
+++ b/src/it/projects/type_source/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.maven.version = 3.7.0+
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/type_source/pom.xml b/src/it/projects/type_source/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/type_source/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/type_source/test.properties b/src/it/projects/type_source/test.properties
new file mode 100644
index 0000000..1c83fbb
--- /dev/null
+++ b/src/it/projects/type_source/test.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.
+
+type=source
\ No newline at end of file
diff --git a/src/it/projects/type_source/verify.groovy b/src/it/projects/type_source/verify.groovy
new file mode 100644
index 0000000..a4a2ed6
--- /dev/null
+++ b/src/it/projects/type_source/verify.groovy
@@ -0,0 +1,27 @@
+
+/*
+ * 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()
+assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists()
+assert new File(basedir,'.mvn/wrapper/MavenWrapperDownloader.java').exists()
+assert !(new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists())
diff --git a/src/it/projects/wrapperversion/invoker.properties b/src/it/projects/wrapperversion/invoker.properties
new file mode 100644
index 0000000..308bfd8
--- /dev/null
+++ b/src/it/projects/wrapperversion/invoker.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.
+invoker.goals = org.apache.maven.plugins:maven-wrapper-plugin:${project.version}:wrapper
\ No newline at end of file
diff --git a/src/it/projects/wrapperversion/pom.xml b/src/it/projects/wrapperversion/pom.xml
new file mode 100644
index 0000000..ed54d55
--- /dev/null
+++ b/src/it/projects/wrapperversion/pom.xml
@@ -0,0 +1,29 @@
+<?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>extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+</project>
\ No newline at end of file
diff --git a/src/it/projects/wrapperversion/test.properties b/src/it/projects/wrapperversion/test.properties
new file mode 100644
index 0000000..e84426f
--- /dev/null
+++ b/src/it/projects/wrapperversion/test.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.
+
+wrapperVersion=3.7.0
\ No newline at end of file
diff --git a/src/it/projects/wrapperversion/verify.groovy b/src/it/projects/wrapperversion/verify.groovy
new file mode 100644
index 0000000..f972b23
--- /dev/null
+++ b/src/it/projects/wrapperversion/verify.groovy
@@ -0,0 +1,34 @@
+
+/*
+ * 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)
+}
+
+assert props.distributionUrl == 'https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip'
diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..fef4268
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,54 @@
+<?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.
+-->
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+ <activeProfiles>
+ <activeProfile>it-repo</activeProfile>
+ </activeProfiles>
+</settings>
diff --git a/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
new file mode 100644
index 0000000..afd548b
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java
@@ -0,0 +1,239 @@
+package org.apache.maven.plugins.wrapper;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedWriter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.inject.Inject;
+
+import org.apache.maven.Maven;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.components.io.fileselectors.FileSelector;
+
+/**
+ * Adds the maven-wrapper files to this project
+ *
+ * @author Robert Scholte
+ * @since 3.0.0
+ */
+@Mojo( name = "wrapper", aggregator = true, requiresDirectInvocation = true )
+public class WrapperMojo extends AbstractMojo
+{
+ // CONFIGURATION PARAMETERS
+
+ /**
+ * The version of Maven to require, default value is the Runtime version of Maven.
+ * Can be any valid release above 2.0.9
+ */
+ @Parameter( property = "mavenVersion" )
+ private String mavenVersion;
+
+ /**
+ * The version of the wrapper, default value is the Runtime version of Maven, should be at least 3.7.0
+ */
+ @Parameter( property = "wrapperVersion" )
+ private String wrapperVersion;
+
+ /**
+ * Options are:
+ * <dl>
+ * <dt>script (default)</dt>
+ * <dd>only mvnw scripts</dd>
+ * <dt>bin</dt>
+ * <dd>precompiled and packaged code</dd>
+ * <dt>source</dt>
+ * <dd>sourcecode, will be compiled on the fly</dd>
+ * </dl>
+ *
+ * Value will be used as classifier of the downloaded file
+ */
+ @Parameter( defaultValue = "script", property = "type" )
+ private String distributionType;
+
+ @Parameter( defaultValue = "true", property = "includeDebug" )
+ private boolean includeDebugScript;
+
+ // READONLY PARAMETERS
+
+ @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ private MavenSession session;
+
+ // Waiting for org.codehaus.plexus.component.configurator.converters.basic.PathConverter
+ @Parameter( defaultValue = "${project.basedir}" )
+ private File basedir;
+
+ // CONSTANTS
+
+ private String groupId = "org.apache.maven";
+
+ private String artifactId = "apache-maven-wrapper";
+
+ private String extension = "zip";
+
+ // COMPONENTS
+
+ @Inject
+ private ArtifactResolver artifactResolver;
+
+ @Inject
+ private Map<String, UnArchiver> unarchivers;
+
+ @Override
+ public void execute() throws MojoExecutionException
+ {
+ Artifact artifact;
+ try
+ {
+ artifact = download();
+ }
+ catch ( ArtifactResolverException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+
+ try
+ {
+ unpack( artifact, basedir.toPath() );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+
+ if ( mavenVersion != null )
+ {
+ try
+ {
+ replaceProperties( Files.createDirectories( basedir.toPath().resolve( ".mvn/wrapper" ) ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "can't create wrapper.proeprties", e );
+ }
+ }
+ }
+
+ private Artifact download()
+ throws ArtifactResolverException
+ {
+ ProjectBuildingRequest buildingRequest =
+ new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+
+ DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+ coordinate.setGroupId( groupId );
+ coordinate.setArtifactId( artifactId );
+ coordinate.setVersion( getVersion( this.wrapperVersion ) );
+ coordinate.setClassifier( distributionType );
+ coordinate.setExtension( extension );
+
+ return artifactResolver.resolveArtifact( buildingRequest, coordinate ).getArtifact();
+ }
+
+ private void unpack( Artifact artifact, Path targetFolder ) throws IOException
+ {
+ targetFolder = Files.createDirectories( targetFolder );
+ UnArchiver unarchiver = unarchivers.get( extension );
+ unarchiver.setDestDirectory( targetFolder.toFile() );
+ unarchiver.setSourceFile( artifact.getFile() );
+ if ( !includeDebugScript )
+ {
+ unarchiver.setFileSelectors( new FileSelector[]
+ {
+ f -> !f.getName().contains( "Debug" )
+ } );
+ }
+ unarchiver.extract();
+ }
+
+ /**
+ * As long as the content only contains the license and the distributionUrl, we can simply replace it.
+ * No need to look for other properties, restore them, respecting comments, etc.
+ *
+ * @param targetFolder the folder containing the wrapper.properties
+ * @throws IOException if writing fails
+ */
+ private void replaceProperties( Path targetFolder ) throws IOException
+ {
+ Path wrapperPropertiesFile = targetFolder.resolve( "maven-wrapper.properties" );
+
+ final String license = "# Licensed to the Apache Software Foundation (ASF) under one\n"
+ + "# or more contributor license agreements. See the NOTICE file\n"
+ + "# distributed with this work for additional information\n"
+ + "# regarding copyright ownership. The ASF licenses this file\n"
+ + "# to you under the Apache License, Version 2.0 (the\n"
+ + "# \"License\"); you may not use this file except in compliance\n"
+ + "# with the License. You may obtain a copy of the License at\n" + "# \n"
+ + "# http://www.apache.org/licenses/LICENSE-2.0\n" + "# \n"
+ + "# Unless required by applicable law or agreed to in writing,\n"
+ + "# software distributed under the License is distributed on an\n"
+ + "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+ + "# KIND, either express or implied. See the License for the\n"
+ + "# specific language governing permissions and limitations\n" + "# under the License.\n";
+
+ try ( BufferedWriter out = Files.newBufferedWriter( wrapperPropertiesFile ) )
+ {
+ out.append( license );
+ out.append( "distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/"
+ + mavenVersion
+ + "/apache-maven-"
+ + mavenVersion
+ + "-bin.zip" );
+ }
+ }
+
+ private String getVersion( String defaultVersion )
+ {
+ String version = defaultVersion;
+ if ( version == null )
+ {
+ Properties props = new Properties();
+ try ( InputStream is =
+ Maven.class.getResourceAsStream( "/META-INF/maven/org.apache.maven/maven-core/pom.properties" ) )
+ {
+ props.load( is );
+ version = props.getProperty( "version" );
+ }
+ catch ( IOException e )
+ {
+ // noop
+ }
+ }
+ return version;
+ }
+}
diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..05b1156
--- /dev/null
+++ b/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,42 @@
+<?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.
+-->
+
+<component-set>
+ <components>
+
+ <!-- Delete once available in maven-core -->
+ <component>
+ <role>org.apache.maven.lifecycle.Lifecycle</role>
+ <implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
+ <role-hint>wrapper</role-hint>
+ <configuration>
+ <id>wrapper</id>
+ <phases>
+ <phase>wrapper</phase>
+ </phases>
+ <default-phases>
+ <wrapper>org.apache.maven.plugins:maven-wrapper-plugin:wrapper</wrapper>
+ </default-phases>
+ </configuration>
+ </component>
+
+ </components>
+</component-set>