This is an automated email from the ASF dual-hosted git repository. hboutemy pushed a commit to branch MWRAPPER-14 in repository https://gitbox.apache.org/repos/asf/maven.git
commit f793d862e3158f8dde98f00905f907b6bd5e0aaf Author: Hervé Boutemy <[email protected]> AuthorDate: Sun Dec 26 17:42:35 2021 +0100 [MWRAPPER-14] remove Maven Wrapper from core --- .github/workflows/maven.yml | 28 +-- Jenkinsfile | 14 +- Jenkinsfile.its | 4 +- apache-maven-wrapper/pom.xml | 128 ------------ apache-maven-wrapper/src/assembly/bin.xml | 85 -------- apache-maven-wrapper/src/assembly/script.xml | 77 ------- apache-maven-wrapper/src/assembly/script/download | 51 ----- .../src/assembly/script/download.cmd | 32 --- .../shared/mvn/wrapper/maven-wrapper.properties | 17 -- apache-maven-wrapper/src/assembly/shared/mvnwDebug | 35 ---- .../src/assembly/shared/mvnwDebug.cmd | 44 ---- .../src/assembly/shared/mvnwlauncher | 3 - .../src/assembly/shared/mvnwlauncher.cmd | 3 - apache-maven-wrapper/src/assembly/source.xml | 82 -------- apache-maven-wrapper/src/assembly/source/download | 34 --- .../src/assembly/source/download.cmd | 21 -- .../source/mvn/wrapper/MavenWrapperDownloader.java | 131 ------------ apache-maven-wrapper/src/site/apt/index.apt.vm | 58 ------ apache-maven-wrapper/src/site/site.xml | 31 --- maven-wrapper/pom.xml | 65 ------ .../apache/maven/wrapper/BootstrapMainStarter.java | 64 ------ .../apache/maven/wrapper/DefaultDownloader.java | 190 ----------------- .../java/org/apache/maven/wrapper/Downloader.java | 54 ----- .../java/org/apache/maven/wrapper/Installer.java | 231 --------------------- .../main/java/org/apache/maven/wrapper/Logger.java | 41 ---- .../org/apache/maven/wrapper/MavenWrapperMain.java | 107 ---------- .../org/apache/maven/wrapper/PathAssembler.java | 131 ------------ .../apache/maven/wrapper/WrapperConfiguration.java | 116 ----------- .../org/apache/maven/wrapper/WrapperExecutor.java | 178 ---------------- maven-wrapper/src/site/apt/index.apt | 30 --- maven-wrapper/src/site/site.xml | 38 ---- .../org/apache/maven/wrapper/DownloaderTest.java | 71 ------- .../org/apache/maven/wrapper/InstallerTest.java | 214 ------------------- .../apache/maven/wrapper/PathAssemblerTest.java | 115 ---------- .../apache/maven/wrapper/WrapperExecutorTest.java | 202 ------------------ .../org/apache/maven/wrapper/wrapper.properties | 21 -- pom.xml | 2 - src/site/resources/images/maven-deps.png | Bin 160957 -> 168500 bytes src/site/xdoc/index.xml | 75 ++++--- src/site/xdoc/maven-deps.odg | Bin 22633 -> 21196 bytes 40 files changed, 41 insertions(+), 2782 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index addba89..3b82ac1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,20 +46,6 @@ jobs: name: built-maven path: apache-maven/target/ - - name: Upload built Apache Maven Wrapper - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - name: built-apache-maven-wrapper - path: apache-maven-wrapper/target/ - - - name: Upload built Maven Wrapper - uses: actions/upload-artifact@v2 - if: ${{ matrix.os == 'ubuntu-latest' }} - with: - name: built-maven-wrapper - path: maven-wrapper/target/maven-wrapper.jar - integration-test: needs: build strategy: @@ -123,18 +109,6 @@ jobs: name: built-maven path: built-maven/ - - name: Download built Apache Maven Wrapper - uses: actions/download-artifact@v2 - with: - name: built-apache-maven-wrapper - path: built-apache-maven-wrapper/ - - - name: Download built Maven Wrapper - uses: actions/download-artifact@v2 - with: - name: built-maven-wrapper - path: built-maven-wrapper/ - - name: Set up JDK uses: actions/setup-java@v2 with: @@ -144,4 +118,4 @@ jobs: - name: Running integration tests shell: bash - run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -DwrapperDistroDir="$GITHUB_WORKSPACE/built-apache-maven-wrapper/" -DmavenWrapper="$GITHUB_WORKSPACE/built-maven-wrapper/maven-wrapper.jar" -f maven-integration-testing/pom.xml + run: mvn install -e -B -V -Prun-its,embedded -Dmaven.repo.local="$HOME/.m2/repository" -DmavenDistro="$GITHUB_WORKSPACE/built-maven/apache-maven-bin.zip" -f maven-integration-testing/pom.xml diff --git a/Jenkinsfile b/Jenkinsfile index 15947ed..60d4e8e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,19 +58,11 @@ node(jenkinsEnv.nodeSelection(osNode)) { invokerPublisher(disabled: true), pipelineGraphPublisher(disabled: false) ], publisherStrategy: 'EXPLICIT') { - // For now: maven-wrapper contains 2 poms sharing the same outputDirectory, so separate clean - sh "mvn clean" - sh "mvn ${MAVEN_GOAL} -B -U -e -fae -V -Dmaven.test.failure.ignore=true -P versionlessMavenDist" + sh "mvn clean ${MAVEN_GOAL} -B -U -e -fae -V -Dmaven.test.failure.ignore -PversionlessMavenDist" } dir ('apache-maven/target') { stash includes: 'apache-maven-bin.zip', name: 'maven-dist' } - dir ('apache-maven-wrapper/target') { - stash includes: 'apache-maven-wrapper-*.zip', name: 'maven-wrapper-dist' - } - dir ('maven-wrapper/target') { - stash includes: 'maven-wrapper.jar', name: 'wrapper-dist' - } } tests = resolveScm source: [$class: 'GitSCMSource', credentialsId: '', id: '_', remote: 'https://gitbox.apache.org/repos/asf/maven-integration-testing.git', traits: [[$class: 'jenkins.plugins.git.traits.BranchDiscoveryTrait'], [$class: 'GitToolSCMSourceTrait', gitTool: 'Default']]], targets: [BRANCH_NAME, 'master'] @@ -105,14 +97,12 @@ for (String os in runITsOses) { } dir('dists') { unstash 'maven-dist' - unstash 'maven-wrapper-dist' - unstash 'wrapper-dist' } try { withMaven(jdk: jdkName, maven: mvnName, mavenLocalRepo:"${WORK_DIR}/it-local-repo", options:[ junitPublisher(ignoreAttachments: false) ]) { - String cmd = "${runITscommand} -DmavenDistro=$WORK_DIR/dists/apache-maven-bin.zip -Dmaven.test.failure.ignore=true -DmavenWrapper=$WORK_DIR/dists/maven-wrapper.jar -DwrapperDistroDir=${WORK_DIR}/dists" + String cmd = "${runITscommand} -DmavenDistro=$WORK_DIR/dists/apache-maven-bin.zip -Dmaven.test.failure.ignore" if (isUnix()) { sh 'df -hT' diff --git a/Jenkinsfile.its b/Jenkinsfile.its index 8258613..d52c179 100644 --- a/Jenkinsfile.its +++ b/Jenkinsfile.its @@ -32,7 +32,7 @@ pipeline { stage("Build Maven Core") { steps { withEnv(["JAVA_HOME=${ tool "JDK 1.8 (latest)" }", "PATH+MAVEN=${tool 'Maven 3.6.3'}/bin:${env.JAVA_HOME}/bin"]) { - sh "mvn -Drat.skip=true -T2 -B -V install -P versionlessMavenDist -Dmaven.repo.local=${env.WORKSPACE}/repo" + sh "mvn -Drat.skip=true -T2 -B -V install -PversionlessMavenDist -Dmaven.repo.local=${env.WORKSPACE}/repo" } } } @@ -41,7 +41,7 @@ pipeline { git url: "https://github.com/apache/maven-integration-testing.git", branch: "${ITS_BRANCH}" sh "ls -lrt ${env.WORKSPACE}/apache-maven/target/" withEnv(["JAVA_HOME=${ tool "JDK 1.8 (latest)" }", "PATH+MAVEN=${tool 'Maven 3.6.3'}/bin:${env.JAVA_HOME}/bin"]) { - sh "mvn clean install -V -B -Prun-its,embedded -Dmaven.test.failure.ignore=true -Dmaven.repo.local=${env.WORKSPACE}/repo -DmavenDistro=${env.WORKSPACE}/apache-maven/target/apache-maven-bin.zip -DwrapperDistroDir=${env.WORKSPACE}/apache-maven-wrapper/target -DmavenWrapper=${env.WORKSPACE}/maven-wrapper/target/maven-wrapper.jar" + sh "mvn clean install -V -B -Prun-its,embedded -Dmaven.test.failure.ignore -Dmaven.repo.local=${env.WORKSPACE}/repo -DmavenDistro=${env.WORKSPACE}/apache-maven/target/apache-maven-bin.zip" } } } diff --git a/apache-maven-wrapper/pom.xml b/apache-maven-wrapper/pom.xml deleted file mode 100644 index eec5c7c..0000000 --- a/apache-maven-wrapper/pom.xml +++ /dev/null @@ -1,128 +0,0 @@ -<?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</groupId> - <artifactId>maven</artifactId> - <version>4.0.0-alpha-1-SNAPSHOT</version> - </parent> - - <artifactId>apache-maven-wrapper</artifactId> - <packaging>pom</packaging> - - <name>Apache Maven Wrapper Distribution</name> - <description>The Apache Maven Wrapper distribution zips in 3 types: script, bin and source.</description> - - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - <configuration> - <excludes combine.children="append"> - <exclude>src/assembly/maven/bin/m2.conf</exclude> - <!-- these are partial scripts, resulting in mwnw scripts --> - <exclude>src/assembly/shared/mvnwlauncher</exclude> - <exclude>src/assembly/shared/mvnwlauncher.cmd</exclude> - <exclude>src/assembly/*/download</exclude> - <exclude>src/assembly/*/download.cmd</exclude> - </excludes> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-clean-plugin</artifactId> - <configuration> - <skip>true</skip> <!-- sharing outputDirectory with maven-dist --> - </configuration> - </plugin> - </plugins> - </pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - <configuration> - <descriptors> - <descriptor>src/assembly/script.xml</descriptor> - <descriptor>src/assembly/bin.xml</descriptor> - <descriptor>src/assembly/source.xml</descriptor> - </descriptors> - </configuration> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-wrapper</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>apache-release</id> - <build> - <plugins> - <!-- calculate sha512 checksums --> - <plugin> - <groupId>net.nicoulaj.maven.plugins</groupId> - <artifactId>checksum-maven-plugin</artifactId> - <executions> - <execution> - <id>source-release-checksum</id> - <goals> - <goal>files</goal> - </goals> - </execution> - </executions> - <configuration> - <fileSets> - <fileSet> - <directory>${project.build.directory}</directory> - <includes> - <include>${project.artifactId}-${project.version}-bin.zip</include> - <include>${project.artifactId}-${project.version}-script.zip</include> - <include>${project.artifactId}-${project.version}-source.zip</include> - </includes> - </fileSet> - </fileSets> - <failIfNoFiles>true</failIfNoFiles> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> diff --git a/apache-maven-wrapper/src/assembly/bin.xml b/apache-maven-wrapper/src/assembly/bin.xml deleted file mode 100644 index 76cdc18..0000000 --- a/apache-maven-wrapper/src/assembly/bin.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?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. ---> - -<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> - <id>bin</id> - <formats> - <format>zip</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <dependencySets> - <dependencySet> - <useProjectArtifact>false</useProjectArtifact> - <includes> - <include>org.apache.maven:maven-wrapper:jar:*</include> - </includes> - <outputDirectory>.mvn/wrapper</outputDirectory> - <outputFileNameMapping>maven-wrapper.jar</outputFileNameMapping> - </dependencySet> - </dependencySets> - <files> - <file> - <source>src/assembly/shared/mvnwDebug.cmd</source> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - </file> - <file> - <source>src/assembly/shared/mvnwDebug</source> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate.cmd</source> - <source>../apache-maven/src/assembly/shared/init.cmd</source> - <source>src/assembly/shared/mvnwlauncher.cmd</source> - <source>../apache-maven/src/assembly/shared/run.cmd</source> - </sources> - <destName>mvnw.cmd</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - <filtered>true</filtered> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate</source> - <source>../apache-maven/src/assembly/shared/init</source> - <source>src/assembly/shared/mvnwlauncher</source> - <source>../apache-maven/src/assembly/shared/run</source> - </sources> - <destName>mvnw</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - <filtered>true</filtered> - </file> - </files> - <fileSets> - <fileSet> - <directory>src/assembly/shared/mvn</directory> - <outputDirectory>.mvn</outputDirectory> - <filtered>true</filtered> - </fileSet> - </fileSets> -</assembly> diff --git a/apache-maven-wrapper/src/assembly/script.xml b/apache-maven-wrapper/src/assembly/script.xml deleted file mode 100644 index 8f5406e..0000000 --- a/apache-maven-wrapper/src/assembly/script.xml +++ /dev/null @@ -1,77 +0,0 @@ -<?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. ---> - -<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> - <id>script</id> - <formats> - <format>zip</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <files> - <file> - <source>src/assembly/shared/mvnwDebug.cmd</source> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - </file> - <file> - <source>src/assembly/shared/mvnwDebug</source> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate.cmd</source> - <source>../apache-maven/src/assembly/shared/init.cmd</source> - <source>src/assembly/shared/mvnwlauncher.cmd</source> - <source>src/assembly/script/download.cmd</source> - <source>../apache-maven/src/assembly/shared/run.cmd</source> - </sources> - <destName>mvnw.cmd</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - <filtered>true</filtered> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate</source> - <source>../apache-maven/src/assembly/shared/init</source> - <source>src/assembly/shared/mvnwlauncher</source> - <source>src/assembly/script/download</source> - <source>../apache-maven/src/assembly/shared/run</source> - </sources> - <destName>mvnw</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - <filtered>true</filtered> - </file> - </files> - <fileSets> - <fileSet> - <directory>src/assembly/shared/mvn</directory> - <outputDirectory>.mvn</outputDirectory> - <filtered>true</filtered> - </fileSet> - </fileSets> -</assembly> diff --git a/apache-maven-wrapper/src/assembly/script/download b/apache-maven-wrapper/src/assembly/script/download deleted file mode 100755 index ed8243e..0000000 --- a/apache-maven-wrapper/src/assembly/script/download +++ /dev/null @@ -1,51 +0,0 @@ -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - - jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" - - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" - fi - - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if [ `echo "${jarUrl}" | cut -c 1-4` != 'file' ] && command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl --location -o "$wrapperJarPath" "$jarUrl" -f - else - curl --location --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - diff --git a/apache-maven-wrapper/src/assembly/script/download.cmd b/apache-maven-wrapper/src/assembly/script/download.cmd deleted file mode 100755 index 9166b9a..0000000 --- a/apache-maven-wrapper/src/assembly/script/download.cmd +++ /dev/null @@ -1,32 +0,0 @@ -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -IF NOT EXIST %LAUNCHER_JAR% goto downloadWrapper - -if "%MVNW_VERBOSE%" == "true" ECHO Found %LAUNCHER_JAR% -goto endWrapper - -:downloadWrapper -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" - -if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/maven-wrapper/${project.version}/maven-wrapper-${project.version}.jar" -) -if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %LAUNCHER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% -) - -powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%LAUNCHER_JAR%')"^ - "}" -if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %LAUNCHER_JAR% -) - -:endWrapper -@REM End of extension - diff --git a/apache-maven-wrapper/src/assembly/shared/mvn/wrapper/maven-wrapper.properties b/apache-maven-wrapper/src/assembly/shared/mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 6fda8be..0000000 --- a/apache-maven-wrapper/src/assembly/shared/mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,17 +0,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. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/${project.version}/apache-maven-${project.version}-bin.zip diff --git a/apache-maven-wrapper/src/assembly/shared/mvnwDebug b/apache-maven-wrapper/src/assembly/shared/mvnwDebug deleted file mode 100644 index 3e66a1a..0000000 --- a/apache-maven-wrapper/src/assembly/shared/mvnwDebug +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# 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. - -# ----------------------------------------------------------------------------- -# Apache Maven Debug Script -# -# Environment Variable Prerequisites -# -# JAVA_HOME (Optional) Points to a Java installation. -# MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. -# MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. -# MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000 -# ----------------------------------------------------------------------------- - -MAVEN_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${MAVEN_DEBUG_ADDRESS:-localhost:8000}" - -echo Preparing to execute Maven Wrapper in debug mode - -env MAVEN_OPTS="$MAVEN_OPTS" MAVEN_DEBUG_OPTS="$MAVEN_DEBUG_OPTS" "`dirname "$0"`/mvnw" "$@" diff --git a/apache-maven-wrapper/src/assembly/shared/mvnwDebug.cmd b/apache-maven-wrapper/src/assembly/shared/mvnwDebug.cmd deleted file mode 100644 index 52368be..0000000 --- a/apache-maven-wrapper/src/assembly/shared/mvnwDebug.cmd +++ /dev/null @@ -1,44 +0,0 @@ -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. - -@REM ----------------------------------------------------------------------------- -@REM Apache Maven Debug Script -@REM -@REM Environment Variable Prerequisites -@REM -@REM JAVA_HOME (Optional) Points to a Java installation. -@REM MAVEN_BATCH_ECHO (Optional) Set to 'on' to enable the echoing of the batch commands. -@REM MAVEN_BATCH_PAUSE (Optional) set to 'on' to wait for a key stroke before ending. -@REM MAVEN_OPTS (Optional) Java runtime options used when Maven is executed. -@REM MAVEN_SKIP_RC (Optional) Flag to disable loading of mavenrc files. -@REM MAVEN_DEBUG_ADDRESS (Optional) Set the debug address. Default value is localhost:8000 -@REM ----------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%"=="on" echo %MAVEN_BATCH_ECHO% - -@setlocal - -IF "%MAVEN_DEBUG_ADDRESS%"=="" @set MAVEN_DEBUG_ADDRESS=localhost:8000 - -@set MAVEN_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%MAVEN_DEBUG_ADDRESS% - -@call "%~dp0"mvnw.cmd %* diff --git a/apache-maven-wrapper/src/assembly/shared/mvnwlauncher b/apache-maven-wrapper/src/assembly/shared/mvnwlauncher deleted file mode 100755 index 3fbd254..0000000 --- a/apache-maven-wrapper/src/assembly/shared/mvnwlauncher +++ /dev/null @@ -1,3 +0,0 @@ -LAUNCHER_JAR="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -LAUNCHER_CLASS=org.apache.maven.wrapper.MavenWrapperMain - diff --git a/apache-maven-wrapper/src/assembly/shared/mvnwlauncher.cmd b/apache-maven-wrapper/src/assembly/shared/mvnwlauncher.cmd deleted file mode 100755 index 193db12..0000000 --- a/apache-maven-wrapper/src/assembly/shared/mvnwlauncher.cmd +++ /dev/null @@ -1,3 +0,0 @@ -set LAUNCHER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set LAUNCHER_CLASS=org.apache.maven.wrapper.MavenWrapperMain - diff --git a/apache-maven-wrapper/src/assembly/source.xml b/apache-maven-wrapper/src/assembly/source.xml deleted file mode 100644 index 1e7e667..0000000 --- a/apache-maven-wrapper/src/assembly/source.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?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. ---> - -<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> - <id>source</id> - <formats> - <format>zip</format> - </formats> - <includeBaseDirectory>false</includeBaseDirectory> - <files> - <file> - <source>src/assembly/shared/mvnwDebug.cmd</source> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - </file> - <file> - <source>src/assembly/shared/mvnwDebug</source> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate.cmd</source> - <source>../apache-maven/src/assembly/shared/init.cmd</source> - <source>src/assembly/shared/mvnwlauncher.cmd</source> - <source>src/assembly/source/download.cmd</source> - <source>../apache-maven/src/assembly/shared/run.cmd</source> - </sources> - <destName>mvnw.cmd</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>dos</lineEnding> - <filtered>true</filtered> - </file> - <file> - <sources> - <source>../apache-maven/src/assembly/shared/validate</source> - <source>../apache-maven/src/assembly/shared/init</source> - <source>src/assembly/shared/mvnwlauncher</source> - <source>src/assembly/source/download</source> - <source>../apache-maven/src/assembly/shared/run</source> - </sources> - <destName>mvnw</destName> - <outputDirectory>.</outputDirectory> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - <filtered>true</filtered> - </file> - </files> - <fileSets> - <fileSet> - <directory>src/assembly/shared/mvn</directory> - <outputDirectory>.mvn</outputDirectory> - <filtered>true</filtered> - </fileSet> - <fileSet> - <directory>src/assembly/source/mvn</directory> - <outputDirectory>.mvn</outputDirectory> - <filtered>true</filtered> - </fileSet> - </fileSets> -</assembly> diff --git a/apache-maven-wrapper/src/assembly/source/download b/apache-maven-wrapper/src/assembly/source/download deleted file mode 100644 index 30cf5e4..0000000 --- a/apache-maven-wrapper/src/assembly/source/download +++ /dev/null @@ -1,34 +0,0 @@ -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## diff --git a/apache-maven-wrapper/src/assembly/source/download.cmd b/apache-maven-wrapper/src/assembly/source/download.cmd deleted file mode 100644 index 40d8451..0000000 --- a/apache-maven-wrapper/src/assembly/source/download.cmd +++ /dev/null @@ -1,21 +0,0 @@ -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. - -SET javaClass="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\MavenWrapperDownloader.java" -IF EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\MavenDownloader.class" goto :runDownloader - -if "%MVNW_VERBOSE%" == "true" echo - Compiling MavenWrapperDownloader.java ... - -@REM Compiling the Java class -"%JAVA_HOME%\bin\javac" %javaClass% - -:runDownloader -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\MavenWrapperDownloader.class" goto endWrapper - -if "%MVNW_VERBOSE%" == "true" echo - Running MavenWrapperDownloader.class ... -@REM Running the downloader -"%JAVA_HOME%\bin\java" -cp "%MAVEN_PROJECTBASEDIR%\.mvn\wrapper" MavenWrapperDownloader "%MAVEN_PROJECTBASEDIR%" - -:endWrapper -@REM End of extension - diff --git a/apache-maven-wrapper/src/assembly/source/mvn/wrapper/MavenWrapperDownloader.java b/apache-maven-wrapper/src/assembly/source/mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index 29c5656..0000000 --- a/apache-maven-wrapper/src/assembly/source/mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.Authenticator; -import java.net.PasswordAuthentication; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; -import java.util.Objects; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "${project.version}"; - - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_PATH = "/org/apache/maven/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main( String args[] ) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - - String url = null; - - String repoUrl = System.getenv( "MVNW_REPOURL" ); - if ( repoUrl != null ) - { - url = repoUrl + DEFAULT_DOWNLOAD_PATH; - } - else if ( mavenWrapperPropertyFile.exists() ) - { - Properties mavenWrapperProperties = new Properties(); - try ( InputStream mavenWrapperPropertyFileInputStream = new FileInputStream( mavenWrapperPropertyFile ) ) - { - mavenWrapperProperties.load( mavenWrapperPropertyFileInputStream ); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } - catch ( IOException e ) - { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } - } - - if ( url == null ) - { - url = "https://repo.maven.apache.org/maven2" + DEFAULT_DOWNLOAD_PATH; - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - try ( ReadableByteChannel rbc = Channels.newChannel( website.openStream() ); - FileOutputStream fos = new FileOutputStream(destination) ) - { - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - } - } - -} diff --git a/apache-maven-wrapper/src/site/apt/index.apt.vm b/apache-maven-wrapper/src/site/apt/index.apt.vm deleted file mode 100644 index a8ecdc9..0000000 --- a/apache-maven-wrapper/src/site/apt/index.apt.vm +++ /dev/null @@ -1,58 +0,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.name} - ----- - Hervé Boutemy - ----- - 2021-10-10 - ----- - -${project.name} - - ${project.description} - - Distributions types share the same base structure: - ----- -mvnw -mvnw.cmd -mvnwDebug -mvnwDebug.cmd -.mvn/wrapper/maven-wrapper.properties ----- - - but every distribution has specific <<<mvnw>>>/<<<mvnw.cmd>>> scripts to manage different strategies to get {{{../maven-wrapper/}<<<maven-wrapper.jar>>>}}: - - - <<<script>>> (default): <<<mvnw>>>/<<<mvnw.cmd>>> scripts will download {{{../maven-wrapper/}<<<maven-wrapper.jar>>>}} with <<<wget>>> or <<<curl>>> on Unix or PowerShell on Windows - - - <<<bin>>>: no need to download <<<maven-wrapper.jar>>> binary, it is directly provided and used from project source tree: - ----- -.mvn/wrapper/maven-wrapper.jar ----- - - - <<<source>>>: <<<mvnw>>>/<<<mvnw.cmd>>> scripts will compile <<<MavenWrapperDownloader.java>>> source then run the class to download {{{../maven-wrapper/}<<<maven-wrapper.jar>>>}}: - ----- -.mvn/wrapper/MavenWrapperDownloader.java ----- - - [] - - Distribution can be installed in a project either by unpacking zip archive by hand, or by using {{{/plugins/maven-wrapper-plugin/}<<<wrapper:wrapper>>>}}. diff --git a/apache-maven-wrapper/src/site/site.xml b/apache-maven-wrapper/src/site/site.xml deleted file mode 100644 index cd7807c..0000000 --- a/apache-maven-wrapper/src/site/site.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?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/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd"> - - <edit>${project.scm.url}</edit> - - <body> - <menu ref="parent"/> - <menu ref="reports"/> - </body> -</project> \ No newline at end of file diff --git a/maven-wrapper/pom.xml b/maven-wrapper/pom.xml deleted file mode 100644 index 984ea2a..0000000 --- a/maven-wrapper/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?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</groupId> - <artifactId>maven</artifactId> - <version>4.0.0-alpha-1-SNAPSHOT</version> - </parent> - - <artifactId>maven-wrapper</artifactId> - <name>Maven Wrapper</name> - <description>Maven Wrapper ...</description> - - <build> - <finalName>${project.artifactId}</finalName> <!-- to simplify installation for maven-integration-testing --> - </build> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.13.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest</artifactId> - <version>2.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <version>2.23.0</version> - <scope>test</scope> - </dependency> - <!-- Using zip util class, should be replaced with a zip lib --> - <dependency> - <groupId>org.apache.ant</groupId> - <artifactId>ant</artifactId> - <version>1.10.9</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java deleted file mode 100644 index 720b450..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/BootstrapMainStarter.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.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.IOException; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.stream.Stream; - -/** - * Maven starter, from a provided Maven home directory. - * - * @author Hans Dockter - */ -public class BootstrapMainStarter -{ - public void start( String[] args, Path mavenHome ) - throws Exception - { - Path mavenJar = findLauncherJar( mavenHome ); - URLClassLoader contextClassLoader = new URLClassLoader( new URL[] { mavenJar.toUri().toURL() }, - ClassLoader.getSystemClassLoader().getParent() ); - Thread.currentThread().setContextClassLoader( contextClassLoader ); - Class<?> mainClass = contextClassLoader.loadClass( "org.codehaus.plexus.classworlds.launcher.Launcher" ); - - System.setProperty( "maven.home", mavenHome.toAbsolutePath().toString() ); - System.setProperty( "classworlds.conf", mavenHome.resolve( "bin/m2.conf" ).toAbsolutePath().toString() ); - - Method mainMethod = mainClass.getMethod( "main", String[].class ); - mainMethod.invoke( null, new Object[] { args } ); - } - - private Path findLauncherJar( Path mavenHome ) throws RuntimeException, IOException - { - try ( Stream<Path> list = Files.list( mavenHome.resolve( "boot" ) ) ) - { - return list.filter( p -> p.getFileName().toString().matches( "plexus-classworlds-.*\\.jar" ) ) - .findFirst() - .orElseThrow( () -> new RuntimeException( - String.format( "Couldn't locate the Maven launcher JAR in Maven distribution '%s'.", - mavenHome ) ) ); - } - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java deleted file mode 100644 index f5dd89c..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.apache.maven.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 static org.apache.maven.wrapper.MavenWrapperMain.MVNW_PASSWORD; -import static org.apache.maven.wrapper.MavenWrapperMain.MVNW_USERNAME; - -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Authenticator; -import java.net.PasswordAuthentication; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Base64; - -/** - * @author Hans Dockter - */ -public class DefaultDownloader - implements Downloader -{ - private static final int PROGRESS_CHUNK = 500000; - - private static final int BUFFER_SIZE = 10000; - - private final String applicationName; - - private final String applicationVersion; - - public DefaultDownloader( String applicationName, String applicationVersion ) - { - this.applicationName = applicationName; - this.applicationVersion = applicationVersion; - configureProxyAuthentication(); - configureAuthentication(); - } - - private void configureProxyAuthentication() - { - if ( System.getProperty( "http.proxyUser" ) != null ) - { - Authenticator.setDefault( new SystemPropertiesProxyAuthenticator() ); - } - } - - private void configureAuthentication() - { - if ( System.getenv( MVNW_USERNAME ) != null && System.getenv( MVNW_PASSWORD ) != null - && System.getProperty( "http.proxyUser" ) == null ) - { - Authenticator.setDefault( new Authenticator() - { - @Override - protected PasswordAuthentication getPasswordAuthentication() - { - return new PasswordAuthentication( System.getenv( MVNW_USERNAME ), - System.getenv( MVNW_PASSWORD ).toCharArray() ); - } - } ); - } - } - - @Override - public void download( URI address, Path destination ) throws IOException - { - if ( Files.exists( destination ) ) - { - return; - } - Files.createDirectories( destination.getParent() ); - - downloadInternal( address, destination ); - } - - private void downloadInternal( URI address, Path destination ) throws IOException - { - URL url = address.toURL(); - URLConnection conn = url.openConnection(); - addBasicAuthentication( address, conn ); - final String userAgentValue = calculateUserAgent(); - conn.setRequestProperty( "User-Agent", userAgentValue ); - - try ( OutputStream out = new BufferedOutputStream( Files.newOutputStream( destination ) ); - InputStream in = conn.getInputStream() ) - { - byte[] buffer = new byte[BUFFER_SIZE]; - int numRead; - long progressCounter = 0; - while ( ( numRead = in.read( buffer ) ) != -1 ) - { - progressCounter += numRead; - if ( progressCounter / PROGRESS_CHUNK > 0 ) - { - Logger.info( "." ); - progressCounter = progressCounter - PROGRESS_CHUNK; - } - out.write( buffer, 0, numRead ); - } - } - finally - { - Logger.info( "" ); - } - } - - private void addBasicAuthentication( URI address, URLConnection connection ) - throws IOException - { - String userInfo = calculateUserInfo( address ); - if ( userInfo == null ) - { - return; - } - if ( !"https".equals( address.getScheme() ) ) - { - Logger.warn( "WARNING Using HTTP Basic Authentication over an insecure connection" - + " to download the Maven distribution. Please consider using HTTPS." ); - } - connection.setRequestProperty( "Authorization", "Basic " + base64Encode( userInfo ) ); - } - - /** - * Base64 encode user info for HTTP Basic Authentication. - * - * @param userInfo user info - * @return Base64 encoded user info - * @throws RuntimeException if no public Base64 encoder is available on this JVM - */ - private String base64Encode( String userInfo ) - { - return Base64.getEncoder().encodeToString( userInfo.getBytes( StandardCharsets.UTF_8 ) ); - } - - private String calculateUserInfo( URI uri ) - { - String username = System.getenv( MVNW_USERNAME ); - String password = System.getenv( MVNW_PASSWORD ); - if ( username != null && password != null ) - { - return username + ':' + password; - } - return uri.getUserInfo(); - } - - private String calculateUserAgent() - { - String javaVendor = System.getProperty( "java.vendor" ); - String javaVersion = System.getProperty( "java.version" ); - String javaVendorVersion = System.getProperty( "java.vm.version" ); - String osName = System.getProperty( "os.name" ); - String osVersion = System.getProperty( "os.version" ); - String osArch = System.getProperty( "os.arch" ); - return String.format( "%s/%s (%s;%s;%s) (%s;%s;%s)", applicationName, applicationVersion, osName, osVersion, - osArch, javaVendor, javaVersion, javaVendorVersion ); - } - - private static class SystemPropertiesProxyAuthenticator - extends Authenticator - { - @Override - protected PasswordAuthentication getPasswordAuthentication() - { - return new PasswordAuthentication( System.getProperty( "http.proxyUser" ), - System.getProperty( "http.proxyPassword", "" ).toCharArray() ); - } - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Downloader.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Downloader.java deleted file mode 100644 index 90dc089..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Downloader.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.maven.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.IOException; - -/* - * 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.net.URI; -import java.nio.file.Path; - -/** - * Maven distribution downloader. - * - * @author Hans Dockter - */ -public interface Downloader -{ - void download( URI address, Path destination ) throws IOException; -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java deleted file mode 100644 index b5c287f..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Installer.java +++ /dev/null @@ -1,231 +0,0 @@ -package org.apache.maven.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.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Enumeration; -import java.util.Formatter; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - - -/** - * Maven distribution installer, eventually using a {@link Downloader} first. - * - * @author Hans Dockter - */ -public class Installer -{ - public static final String DEFAULT_DISTRIBUTION_PATH = "wrapper/dists"; - - private final Downloader download; - - private final PathAssembler pathAssembler; - - public Installer( Downloader download, PathAssembler pathAssembler ) - { - this.download = download; - this.pathAssembler = pathAssembler; - } - - public Path createDist( WrapperConfiguration configuration ) - throws IOException, URISyntaxException - { - URI distributionUrl; - String mvnwRepoUrl = System.getenv( MavenWrapperMain.MVNW_REPOURL ); - if ( mvnwRepoUrl != null && !mvnwRepoUrl.isEmpty() ) - { - distributionUrl = new URI( mvnwRepoUrl + "/" + MavenWrapperMain.MVN_PATH ); - Logger.info( "Detected MVNW_REPOURL environment variable " + mvnwRepoUrl ); - } - else - { - distributionUrl = configuration.getDistribution(); - } - Logger.info( "Downloading Maven binary from " + distributionUrl ); - boolean alwaysDownload = configuration.isAlwaysDownload(); - boolean alwaysUnpack = configuration.isAlwaysUnpack(); - - PathAssembler.LocalDistribution localDistribution = pathAssembler.getDistribution( configuration ); - - Path localZipFile = localDistribution.getZipFile(); - boolean downloaded = false; - if ( alwaysDownload || !Files.exists( localZipFile ) ) - { - Path tmpZipFile = localZipFile.resolveSibling( localZipFile.getFileName() + ".part" ); - Files.deleteIfExists( tmpZipFile ); - Logger.info( "Downloading " + distributionUrl ); - download.download( distributionUrl, tmpZipFile ); - Files.move( tmpZipFile, localZipFile ); - downloaded = true; - } - - Path distDir = localDistribution.getDistributionDir(); - List<Path> dirs = listDirs( distDir ); - - if ( downloaded || alwaysUnpack || dirs.isEmpty() ) - { - Files.walkFileTree( distDir.toAbsolutePath(), new SimpleFileVisitor<Path>() - { - @Override - public FileVisitResult postVisitDirectory( Path dir, IOException exc ) - throws IOException - { - if ( dir.getParent().equals( distDir ) ) - { - Logger.info( "Deleting directory " + distDir.toAbsolutePath() ); - Files.delete( dir ); - } - return FileVisitResult.CONTINUE; - } - - public FileVisitResult visitFile( Path file, BasicFileAttributes attrs ) - throws IOException - { - if ( !file.getParent().equals( distDir ) ) - { - Files.delete( file ); - } - return FileVisitResult.CONTINUE; - }; - } ); - - Logger.info( "Unzipping " + localZipFile.toAbsolutePath() + " to " + distDir.toAbsolutePath() ); - unzip( localZipFile, distDir ); - - dirs = listDirs( distDir ); - if ( dirs.isEmpty() ) - { - throw new RuntimeException( String.format( - "Maven distribution '%s' does not contain any directories. Expected to find exactly 1 directory.", - distributionUrl ) ); - } - setExecutablePermissions( dirs.get( 0 ) ); - } - if ( dirs.size() != 1 ) - { - throw new IllegalStateException( String.format( - "Maven distribution '%s' contains too many directories. Expected to find exactly 1 directory.", - distributionUrl ) ); - } - return dirs.get( 0 ); - } - - private List<Path> listDirs( Path distDir ) throws IOException - { - try ( Stream<Path> stream = Files.walk( distDir, 1 ) ) - { - return stream.filter( p -> !distDir.equals( p ) ) - .filter( Files::isDirectory ) - .collect( Collectors.toList() ); - } - } - - private void setExecutablePermissions( Path mavenHome ) - { - if ( isWindows() ) - { - return; - } - Path mavenCommand = mavenHome.resolve( "bin/mvn" ); - String errorMessage = null; - try - { - ProcessBuilder pb = new ProcessBuilder( "chmod", "755", mavenCommand.toString() ); - Process p = pb.start(); - if ( p.waitFor() == 0 ) - { - Logger.info( "Set executable permissions for: " + mavenCommand.toString() ); - } - else - { - - try ( BufferedReader is = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); - Formatter stdout = new Formatter() ) - { - String line; - while ( ( line = is.readLine() ) != null ) - { - stdout.format( "%s%n", line ); - } - errorMessage = stdout.toString(); - } - } - } - catch ( IOException | InterruptedException e ) - { - errorMessage = e.getMessage(); - } - if ( errorMessage != null ) - { - Logger.warn( "Could not set executable permissions for: " + mavenCommand ); - Logger.warn( "Please do this manually if you want to use maven." ); - } - } - - private boolean isWindows() - { - String osName = System.getProperty( "os.name" ).toLowerCase( Locale.US ); - - return ( osName.indexOf( "windows" ) > -1 ); - } - - private void unzip( Path zip, Path dest ) - throws IOException - { - try ( ZipFile zipFile = new ZipFile( zip.toFile() ) ) - { - Enumeration<? extends ZipEntry> entries = zipFile.entries(); - - while ( entries.hasMoreElements() ) - { - ZipEntry entry = entries.nextElement(); - - if ( entry.isDirectory() ) - { - continue; - } - - Path targetFile = dest.resolve( entry.getName() ).normalize(); - - // prevent Zip Slip - if ( targetFile.startsWith( dest ) ) - { - Files.createDirectories( targetFile.getParent() ); - - Files.copy( zipFile.getInputStream( entry ), targetFile ); - } - } - } - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Logger.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/Logger.java deleted file mode 100644 index 4998520..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/Logger.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.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. - */ - -/** - * @author <a href="mailto:[email protected]">Konstantin Sobolev</a> - */ -public class Logger -{ - private static final boolean VERBOSE = "true".equalsIgnoreCase( System.getenv( MavenWrapperMain.MVNW_VERBOSE ) ); - - public static void info( String msg ) - { - if ( VERBOSE ) - { - System.out.println( msg ); - } - } - - public static void warn( String msg ) - { - System.out.println( msg ); - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java deleted file mode 100644 index 16cf2f8..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/MavenWrapperMain.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.apache.maven.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.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Properties; - -/** - * Main entry point for the Maven Wrapper, delegating wrapper execution to {@link WrapperExecutor}. - * - * @author Hans Dockter - */ -public class MavenWrapperMain -{ - private static final String POM_PROPERTIES = "/META-INF/maven/org.apache.maven/maven-wrapper/pom.properties"; - - public static final String DEFAULT_MAVEN_USER_HOME = System.getProperty( "user.home" ) + "/.m2"; - - public static final String MVNW_VERBOSE = "MVNW_VERBOSE"; - - public static final String MVNW_USERNAME = "MVNW_USERNAME"; - - public static final String MVNW_PASSWORD = "MVNW_PASSWORD"; - - public static final String MVNW_REPOURL = "MVNW_REPOURL"; - - public static final String MVN_PATH = - "org/apache/maven/apache-maven/" + wrapperVersion() + "/apache-maven-" + wrapperVersion() + "-bin.zip"; - - public static void main( String[] args ) - throws Exception - { - Path wrapperJar = wrapperJar(); - Path propertiesFile = wrapperProperties( wrapperJar ); - - String wrapperVersion = wrapperVersion(); - Logger.info( "Apache Maven Wrapper " + wrapperVersion ); - - WrapperExecutor wrapperExecutor = WrapperExecutor.forWrapperPropertiesFile( propertiesFile ); - wrapperExecutor.execute( args, new Installer( new DefaultDownloader( "mvnw", wrapperVersion ), - new PathAssembler( mavenUserHome() ) ), - new BootstrapMainStarter() ); - } - - private static Path wrapperProperties( Path wrapperJar ) throws URISyntaxException - { - return wrapperJar().resolveSibling( wrapperJar.getFileName().toString().replaceFirst( "\\.jar$", - ".properties" ) ); - } - - private static Path wrapperJar() throws URISyntaxException - { - URI location = MavenWrapperMain.class.getProtectionDomain().getCodeSource().getLocation().toURI(); - - return Paths.get( location ); - } - - static String wrapperVersion() - { - try ( InputStream resourceAsStream = MavenWrapperMain.class.getResourceAsStream( POM_PROPERTIES ) ) - { - if ( resourceAsStream == null ) - { - throw new IllegalStateException( POM_PROPERTIES + " not found." ); - } - Properties mavenProperties = new Properties(); - mavenProperties.load( resourceAsStream ); - String version = mavenProperties.getProperty( "version" ); - if ( version == null ) - { - throw new NullPointerException( "No version specified in " + POM_PROPERTIES ); - } - return version; - } - catch ( IOException e ) - { - throw new RuntimeException( "Could not determine wrapper version.", e ); - } - } - - private static Path mavenUserHome() - { - return Paths.get( DEFAULT_MAVEN_USER_HOME ); - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/PathAssembler.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/PathAssembler.java deleted file mode 100644 index fd99986..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/PathAssembler.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.maven.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.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; - -/** - * @author Hans Dockter - */ -public class PathAssembler -{ - public static final String MAVEN_USER_HOME_STRING = "MAVEN_USER_HOME"; - - public static final String PROJECT_STRING = "PROJECT"; - - private Path mavenUserHome; - - public PathAssembler() - { - } - - public PathAssembler( Path mavenUserHome ) - { - this.mavenUserHome = mavenUserHome; - } - - /** - * Determines the local locations for the distribution to use given the supplied configuration. - */ - public LocalDistribution getDistribution( WrapperConfiguration configuration ) - { - String baseName = getDistName( configuration.getDistribution() ); - String rootDirName = removeExtension( baseName ); - Path distDir = getBaseDir( configuration.getDistributionBase() ) - .resolve( configuration.getDistributionPath() ) - .resolve( rootDirName ); - Path distZip = getBaseDir( configuration.getZipBase() ) - .resolve( configuration.getZipPath() ) - .resolve( rootDirName ) - .resolve( baseName ); - return new LocalDistribution( distDir, distZip ); - } - - private String removeExtension( String name ) - { - int p = name.lastIndexOf( "." ); - if ( p < 0 ) - { - return name; - } - return name.substring( 0, p ); - } - - private String getDistName( URI distUrl ) - { - String path = distUrl.getPath(); - int p = path.lastIndexOf( "/" ); - if ( p < 0 ) - { - return path; - } - return path.substring( p + 1 ); - } - - private Path getBaseDir( String base ) - { - if ( MAVEN_USER_HOME_STRING.equals( base ) ) - { - return mavenUserHome; - } - else if ( PROJECT_STRING.equals( base ) ) - { - return Paths.get( System.getProperty( "user.dir" ) ); - } - else - { - throw new IllegalArgumentException( "Base: " + base + " is unknown" ); - } - } - - /** - * The Local Distribution - */ - public class LocalDistribution - { - private final Path distZip; - - private final Path distDir; - - public LocalDistribution( Path distDir, Path distZip ) - { - this.distDir = distDir; - this.distZip = distZip; - } - - /** - * Returns the location to install the distribution into. - */ - public Path getDistributionDir() - { - return distDir; - } - - /** - * Returns the location to install the distribution ZIP file to. - */ - public Path getZipFile() - { - return distZip; - } - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperConfiguration.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperConfiguration.java deleted file mode 100644 index d7be04e..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperConfiguration.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.apache.maven.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.net.URI; - -/** - * The Wrapper Configuration - */ -public class WrapperConfiguration -{ - public static final String ALWAYS_UNPACK_ENV = "MAVEN_WRAPPER_ALWAYS_UNPACK"; - - public static final String ALWAYS_DOWNLOAD_ENV = "MAVEN_WRAPPER_ALWAYS_DOWNLOAD"; - - private boolean alwaysUnpack = Boolean.parseBoolean( System.getenv( ALWAYS_UNPACK_ENV ) ); - - private boolean alwaysDownload = Boolean.parseBoolean( System.getenv( ALWAYS_DOWNLOAD_ENV ) ); - - private URI distribution; - - private String distributionBase = PathAssembler.MAVEN_USER_HOME_STRING; - - private String distributionPath = Installer.DEFAULT_DISTRIBUTION_PATH; - - private String zipBase = PathAssembler.MAVEN_USER_HOME_STRING; - - private String zipPath = Installer.DEFAULT_DISTRIBUTION_PATH; - - public boolean isAlwaysDownload() - { - return alwaysDownload; - } - - public void setAlwaysDownload( boolean alwaysDownload ) - { - this.alwaysDownload = alwaysDownload; - } - - public boolean isAlwaysUnpack() - { - return alwaysUnpack; - } - - public void setAlwaysUnpack( boolean alwaysUnpack ) - { - this.alwaysUnpack = alwaysUnpack; - } - - public URI getDistribution() - { - return distribution; - } - - public void setDistribution( URI distribution ) - { - this.distribution = distribution; - } - - public String getDistributionBase() - { - return distributionBase; - } - - public void setDistributionBase( String distributionBase ) - { - this.distributionBase = distributionBase; - } - - public String getDistributionPath() - { - return distributionPath; - } - - public void setDistributionPath( String distributionPath ) - { - this.distributionPath = distributionPath; - } - - public String getZipBase() - { - return zipBase; - } - - public void setZipBase( String zipBase ) - { - this.zipBase = zipBase; - } - - public String getZipPath() - { - return zipPath; - } - - public void setZipPath( String zipPath ) - { - this.zipPath = zipPath; - } -} diff --git a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java b/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java deleted file mode 100644 index 42d5677..0000000 --- a/maven-wrapper/src/main/java/org/apache/maven/wrapper/WrapperExecutor.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.apache.maven.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.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Properties; - -/** - * Wrapper executor, running {@link Installer} to get a Maven distribution ready, followed by {@BootstrapMainStarter} - * to launch the Maven bootstrap. - * - * @author Hans Dockter - */ -public class WrapperExecutor -{ - public static final String DISTRIBUTION_URL_PROPERTY = "distributionUrl"; - - public static final String DISTRIBUTION_BASE_PROPERTY = "distributionBase"; - - public static final String ZIP_STORE_BASE_PROPERTY = "zipStoreBase"; - - public static final String DISTRIBUTION_PATH_PROPERTY = "distributionPath"; - - public static final String ZIP_STORE_PATH_PROPERTY = "zipStorePath"; - - private final Properties properties; - - private final Path propertiesFile; - - private final WrapperConfiguration config = new WrapperConfiguration(); - - public static WrapperExecutor forProjectDirectory( Path projectDir ) - { - return new WrapperExecutor( projectDir.resolve( "maven/wrapper/maven-wrapper.properties" ), - new Properties() ); - } - - public static WrapperExecutor forWrapperPropertiesFile( Path propertiesFile ) - { - if ( !Files.exists( propertiesFile ) ) - { - throw new RuntimeException( String.format( "Wrapper properties file '%s' does not exist.", - propertiesFile ) ); - } - return new WrapperExecutor( propertiesFile, new Properties() ); - } - - WrapperExecutor( Path propertiesFile, Properties properties ) - { - this.properties = properties; - this.propertiesFile = propertiesFile; - if ( Files.exists( propertiesFile ) ) - { - try - { - loadProperties( propertiesFile, properties ); - config.setDistribution( prepareDistributionUri() ); - config.setDistributionBase( getProperty( DISTRIBUTION_BASE_PROPERTY, config.getDistributionBase() ) ); - config.setDistributionPath( getProperty( DISTRIBUTION_PATH_PROPERTY, config.getDistributionPath() ) ); - config.setZipBase( getProperty( ZIP_STORE_BASE_PROPERTY, config.getZipBase() ) ); - config.setZipPath( getProperty( ZIP_STORE_PATH_PROPERTY, config.getZipPath() ) ); - } - catch ( IOException | URISyntaxException e ) - { - throw new RuntimeException( String.format( "Could not load wrapper properties from '%s'.", - propertiesFile ), - e ); - } - } - } - - private URI prepareDistributionUri() - throws URISyntaxException - { - URI source = readDistroUrl(); - if ( source.getScheme() == null ) - { - // no scheme means someone passed a relative url. In our context only file relative urls make sense. - return propertiesFile.getParent().resolve( source.getSchemeSpecificPart() ).toUri(); - } - else - { - return source; - } - } - - private URI readDistroUrl() - throws URISyntaxException - { - if ( properties.getProperty( DISTRIBUTION_URL_PROPERTY ) != null ) - { - return new URI( getProperty( DISTRIBUTION_URL_PROPERTY ) ); - } - - reportMissingProperty( DISTRIBUTION_URL_PROPERTY ); - return null; // previous line will fail - } - - private static void loadProperties( Path propertiesFile, Properties properties ) - throws IOException - { - try ( InputStream inStream = Files.newInputStream( propertiesFile ) ) - { - properties.load( inStream ); - } - } - - /** - * Returns the distribution which this wrapper will use. Returns null if no wrapper meta-data was found in the - * specified project directory. - */ - public URI getDistribution() - { - return config.getDistribution(); - } - - /** - * Returns the configuration for this wrapper. - */ - public WrapperConfiguration getConfiguration() - { - return config; - } - - public void execute( String[] args, Installer install, BootstrapMainStarter bootstrapMainStarter ) - throws Exception - { - Path mavenHome = install.createDist( config ); - bootstrapMainStarter.start( args, mavenHome ); - } - - private String getProperty( String propertyName ) - { - return getProperty( propertyName, null ); - } - - private String getProperty( String propertyName, String defaultValue ) - { - String value = properties.getProperty( propertyName ); - if ( value != null ) - { - return value; - } - if ( defaultValue != null ) - { - return defaultValue; - } - return reportMissingProperty( propertyName ); - } - - private String reportMissingProperty( String propertyName ) - { - throw new RuntimeException( String.format( "No value with key '%s' specified in wrapper properties file '%s'.", - propertyName, propertiesFile ) ); - } -} diff --git a/maven-wrapper/src/site/apt/index.apt b/maven-wrapper/src/site/apt/index.apt deleted file mode 100644 index c579786..0000000 --- a/maven-wrapper/src/site/apt/index.apt +++ /dev/null @@ -1,30 +0,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. - - ----- - Introduction - ----- - Hervé Boutemy - ----- - 2021-04-05 - ----- - -Maven Wrapper - - Maven Wrapper dowloads Maven distribution if not already in cache, installs it, then launches Maven: Maven distributions installed by Maven Wrapper are stored under <<<~/.m2/wrapper/dists>>> by default. - - Maven Wrapper is called by {{{../apache-maven-wrapper/}<<<mvnw>>>/<<<mvnw.cmd>>> scripts}} that need to be installed in the project source tree and called instead of <<<mvn>>>/<<<mvn.cmd>>>. diff --git a/maven-wrapper/src/site/site.xml b/maven-wrapper/src/site/site.xml deleted file mode 100644 index e475330..0000000 --- a/maven-wrapper/src/site/site.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?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/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd"> - - <edit>${project.scm.url}</edit> - - <body> - <menu name="Overview"> - <item name="Introduction" href="index.html"/> - <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> - <!--item name="FAQ" href="faq.html"/--> - </menu> - - <menu ref="parent"/> - <menu ref="reports"/> - </body> -</project> \ No newline at end of file diff --git a/maven-wrapper/src/test/java/org/apache/maven/wrapper/DownloaderTest.java b/maven-wrapper/src/test/java/org/apache/maven/wrapper/DownloaderTest.java deleted file mode 100644 index c0e84c7..0000000 --- a/maven-wrapper/src/test/java/org/apache/maven/wrapper/DownloaderTest.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.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 static org.junit.jupiter.api.Assertions.assertEquals; - -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -public class DownloaderTest -{ - @TempDir - public Path testDir; - - private DefaultDownloader download; - - private Path downloadFile; - - private Path rootDir; - - private URI sourceRoot; - - private Path remoteFile; - - @BeforeEach - public void setUp() - throws Exception - { - download = new DefaultDownloader( "mvnw", "aVersion" ); - rootDir = testDir.resolve( "root" ); - downloadFile = rootDir.resolve( "file" ); - remoteFile = testDir.resolve( "remoteFile" ); - Files.write( remoteFile, Arrays.asList( "sometext" ) ); - sourceRoot = remoteFile.toUri(); - } - - @Test - public void testDownload() - throws Exception - { - assert !Files.exists( downloadFile ); - download.download( sourceRoot, downloadFile ); - assert Files.exists( downloadFile ); - assertEquals( "sometext", - Files.readAllLines( downloadFile ).stream().collect( Collectors.joining() ) ); - } -} diff --git a/maven-wrapper/src/test/java/org/apache/maven/wrapper/InstallerTest.java b/maven-wrapper/src/test/java/org/apache/maven/wrapper/InstallerTest.java deleted file mode 100644 index bef2057..0000000 --- a/maven-wrapper/src/test/java/org/apache/maven/wrapper/InstallerTest.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.apache.maven.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 static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Zip; -import org.junit.Assert; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -/** - * @author Hans Dockter - */ -public class InstallerTest -{ - @TempDir - public Path temporaryFolder; - - private Installer install; - - private Path distributionDir; - - private Path zipStore; - - private Path mavenHomeDir; - - private Path zipDestination; - - private WrapperConfiguration configuration = new WrapperConfiguration(); - - private Downloader download; - - private PathAssembler pathAssembler; - - private PathAssembler.LocalDistribution localDistribution; - - @BeforeEach - public void setup() - throws Exception - { - configuration.setZipBase( PathAssembler.PROJECT_STRING ); - configuration.setZipPath( "someZipPath" ); - configuration.setDistributionBase( PathAssembler.MAVEN_USER_HOME_STRING ); - configuration.setDistributionPath( "someDistPath" ); - configuration.setDistribution( new URI( "http://server/maven-0.9.zip" ) ); - configuration.setAlwaysDownload( false ); - configuration.setAlwaysUnpack( false ); - distributionDir = temporaryFolder.resolve( "someDistPath" ); - Files.createDirectories( distributionDir ); - mavenHomeDir = distributionDir.resolve( "maven-0.9" ); - zipStore = temporaryFolder.resolve( "zips" ); - Files.createDirectories( zipStore ); - zipDestination = zipStore.resolve( "maven-0.9.zip" ); - - download = mock( Downloader.class ); - pathAssembler = mock( PathAssembler.class ); - localDistribution = mock( PathAssembler.LocalDistribution.class ); - - when( localDistribution.getZipFile() ).thenReturn( zipDestination ); - when( localDistribution.getDistributionDir() ).thenReturn( distributionDir ); - when( pathAssembler.getDistribution( configuration ) ).thenReturn( localDistribution ); - - install = new Installer( download, pathAssembler ); - } - - private void createTestZip( Path zipDestination ) - throws Exception - { - Files.createDirectories( zipDestination.getParent() ); - - Path explodedZipDir = temporaryFolder.resolve( "explodedZip" ); - - Path mavenScript = explodedZipDir.resolve( "maven-0.9/bin/mvn" ); - Files.createDirectories( mavenScript.getParent() ); - Files.write( mavenScript, Arrays.asList( "something" ) ); - - zipTo( explodedZipDir, zipDestination ); - } - - @Test - @Disabled("not working") - public void testCreateDist() - throws Exception - { - Path homeDir = install.createDist( configuration ); - - Assert.assertEquals( mavenHomeDir, homeDir ); - Assert.assertTrue( Files.isDirectory( homeDir ) ); - Assert.assertTrue( Files.exists( homeDir.resolve( "bin/mvn" ) ) ); - Assert.assertTrue( Files.exists( zipDestination ) ); - - Assert.assertEquals( localDistribution, pathAssembler.getDistribution( configuration ) ); - Assert.assertEquals( distributionDir, localDistribution.getDistributionDir() ); - Assert.assertEquals( zipDestination, localDistribution.getZipFile() ); - - // download.download(new URI("http://some/test"), distributionDir); - // verify(download).download(new URI("http://some/test"), distributionDir); - } - - @Test - public void testCreateDistWithExistingDistribution() - throws Exception - { - Files.createFile( zipDestination ); - - Files.createDirectories( mavenHomeDir ); - Path someFile = mavenHomeDir.resolve( "some-file" ); - Files.createFile( someFile ); - - Path homeDir = install.createDist( configuration ); - - Assert.assertEquals( mavenHomeDir, homeDir ); - Assert.assertTrue( Files.isDirectory( mavenHomeDir ) ); - Assert.assertTrue( Files.exists( homeDir.resolve( "some-file" ) ) ); - Assert.assertTrue( Files.exists( zipDestination ) ); - - Assert.assertEquals( localDistribution, pathAssembler.getDistribution( configuration ) ); - Assert.assertEquals( distributionDir, localDistribution.getDistributionDir() ); - Assert.assertEquals( zipDestination, localDistribution.getZipFile() ); - } - - @Test - public void testCreateDistWithExistingDistAndZipAndAlwaysUnpackTrue() - throws Exception - { - - createTestZip( zipDestination ); - Files.createDirectories( mavenHomeDir ); - File garbage = mavenHomeDir.resolve( "garbage" ).toFile(); - Files.createFile( garbage.toPath() ); - - configuration.setAlwaysUnpack( true ); - - Path homeDir = install.createDist( configuration ); - - Assert.assertEquals( mavenHomeDir, homeDir ); - Assert.assertTrue( Files.isDirectory( mavenHomeDir ) ); - Assert.assertFalse( Files.exists( homeDir.resolve( "garbage" ) ) ); - Assert.assertTrue( Files.exists( zipDestination ) ); - - Assert.assertEquals( localDistribution, pathAssembler.getDistribution( configuration ) ); - Assert.assertEquals( distributionDir, localDistribution.getDistributionDir() ); - Assert.assertEquals( zipDestination, localDistribution.getZipFile() ); - } - - @Test - public void testCreateDistWithExistingZipAndDistAndAlwaysDownloadTrue() - throws Exception - { - - createTestZip( zipDestination ); - Files.createDirectories( mavenHomeDir ); - File garbage = mavenHomeDir.resolve( "garbage" ).toFile(); - Files.createFile( garbage.toPath() ); - - configuration.setAlwaysUnpack( true ); - - Path homeDir = install.createDist( configuration ); - - Assert.assertEquals( mavenHomeDir, homeDir ); - Assert.assertTrue( Files.isDirectory( mavenHomeDir ) ); - Assert.assertTrue( Files.exists( homeDir.resolve( "bin/mvn" ) ) ); - Assert.assertFalse( Files.exists( homeDir.resolve( "garbage" ) ) ); - Assert.assertTrue( Files.exists( zipDestination ) ); - - Assert.assertEquals( localDistribution, pathAssembler.getDistribution( configuration ) ); - Assert.assertEquals( distributionDir, localDistribution.getDistributionDir() ); - Assert.assertEquals( zipDestination, localDistribution.getZipFile() ); - - // download.download(new URI("http://some/test"), distributionDir); - // verify(download).download(new URI("http://some/test"), distributionDir); - } - - public void zipTo( Path directoryToZip, Path zipFile ) - { - Zip zip = new Zip(); - zip.setBasedir( directoryToZip.toFile() ); - zip.setDestFile( zipFile.toFile() ); - zip.setProject( new Project() ); - - Zip.WhenEmpty whenEmpty = new Zip.WhenEmpty(); - whenEmpty.setValue( "create" ); - zip.setWhenempty( whenEmpty ); - zip.execute(); - } -} diff --git a/maven-wrapper/src/test/java/org/apache/maven/wrapper/PathAssemblerTest.java b/maven-wrapper/src/test/java/org/apache/maven/wrapper/PathAssemblerTest.java deleted file mode 100644 index a2334c1..0000000 --- a/maven-wrapper/src/test/java/org/apache/maven/wrapper/PathAssemblerTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.apache.maven.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 static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.net.URI; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -/** - * @author Hans Dockter - */ -public class PathAssemblerTest -{ - public static final String TEST_MAVEN_USER_HOME = "someUserHome"; - - private PathAssembler pathAssembler = new PathAssembler( Paths.get( TEST_MAVEN_USER_HOME ) ); - - final WrapperConfiguration configuration = new WrapperConfiguration(); - - @BeforeEach - public void setup() - { - configuration.setDistributionBase( PathAssembler.MAVEN_USER_HOME_STRING ); - configuration.setDistributionPath( "somePath" ); - configuration.setZipBase( PathAssembler.MAVEN_USER_HOME_STRING ); - configuration.setZipPath( "somePath" ); - } - - @Test - public void distributionDirWithMavenUserHomeBase() - throws Exception - { - configuration.setDistribution( new URI( "http://server/dist/maven-0.9-bin.zip" ) ); - - Path distributionDir = pathAssembler.getDistribution( configuration ).getDistributionDir(); - assertThat( distributionDir, is( Paths.get( TEST_MAVEN_USER_HOME, "/somePath/maven-0.9-bin" ) ) ); - } - - @Test - public void distributionDirWithProjectBase() - throws Exception - { - configuration.setDistributionBase( PathAssembler.PROJECT_STRING ); - configuration.setDistribution( new URI( "http://server/dist/maven-0.9-bin.zip" ) ); - - Path distributionDir = pathAssembler.getDistribution( configuration ).getDistributionDir(); - assertThat( distributionDir, equalTo( Paths.get( currentDirPath(), "/somePath/maven-0.9-bin" ) ) ); - } - - @Test - public void distributionDirWithUnknownBase() - throws Exception - { - configuration.setDistribution( new URI( "http://server/dist/maven-1.0.zip" ) ); - configuration.setDistributionBase( "unknownBase" ); - - RuntimeException e = - assertThrows( RuntimeException.class, () -> pathAssembler.getDistribution( configuration ) ); - assertEquals( "Base: unknownBase is unknown", e.getMessage() ); - } - - @Test - public void distZipWithMavenUserHomeBase() - throws Exception - { - configuration.setDistribution( new URI( "http://server/dist/maven-1.0.zip" ) ); - - Path dist = pathAssembler.getDistribution( configuration ).getZipFile(); - assertThat( dist.getFileName().toString(), equalTo( "maven-1.0.zip" ) ); - assertThat( dist.getParent(), equalTo( Paths.get( TEST_MAVEN_USER_HOME, "/somePath/maven-1.0" ) ) ); - } - - @Test - public void distZipWithProjectBase() - throws Exception - { - configuration.setZipBase( PathAssembler.PROJECT_STRING ); - configuration.setDistribution( new URI( "http://server/dist/maven-1.0.zip" ) ); - - Path dist = pathAssembler.getDistribution( configuration ).getZipFile(); - assertThat( dist.getFileName().toString(), equalTo( "maven-1.0.zip" ) ); - assertThat( dist.getParent(), equalTo( Paths.get( currentDirPath(), "/somePath/maven-1.0" ) ) ); - } - - private String currentDirPath() - { - return System.getProperty( "user.dir" ); - } -} diff --git a/maven-wrapper/src/test/java/org/apache/maven/wrapper/WrapperExecutorTest.java b/maven-wrapper/src/test/java/org/apache/maven/wrapper/WrapperExecutorTest.java deleted file mode 100644 index 23bcf21..0000000 --- a/maven-wrapper/src/test/java/org/apache/maven/wrapper/WrapperExecutorTest.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.apache.maven.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 static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Properties; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.mockito.Mockito; - -public class WrapperExecutorTest -{ - @TempDir - public Path testDir; - - private Installer install; - - private BootstrapMainStarter start; - - private Path propertiesFile; - - private Properties properties = new Properties(); - - private Path mockInstallDir; - - @BeforeEach - public void setUp() - throws Exception - { - mockInstallDir = testDir.resolve( "mock-dir" ); - - install = mock( Installer.class ); - when( install.createDist( Mockito.any( WrapperConfiguration.class ) ) ).thenReturn( mockInstallDir ); - start = mock( BootstrapMainStarter.class ); - - propertiesFile = testDir.resolve( "maven" ).resolve( "wrapper" ).resolve( "maven-wrapper.properties" ); - - properties.put( "distributionUrl", "http://server/test/maven.zip" ); - properties.put( "distributionBase", "testDistBase" ); - properties.put( "distributionPath", "testDistPath" ); - properties.put( "zipStoreBase", "testZipBase" ); - properties.put( "zipStorePath", "testZipPath" ); - - writePropertiesFile( properties, propertiesFile, "header" ); - } - - @Test - public void loadWrapperMetadataFromFile() - throws Exception - { - WrapperExecutor wrapper = WrapperExecutor.forWrapperPropertiesFile( propertiesFile ); - - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getDistribution() ); - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getConfiguration().getDistribution() ); - assertEquals( "testDistBase", wrapper.getConfiguration().getDistributionBase() ); - assertEquals( "testDistPath", wrapper.getConfiguration().getDistributionPath() ); - assertEquals( "testZipBase", wrapper.getConfiguration().getZipBase() ); - assertEquals( "testZipPath", wrapper.getConfiguration().getZipPath() ); - } - - @Test - public void loadWrapperMetadataFromDirectory() - throws Exception - { - WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory( testDir ); - - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getDistribution() ); - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getConfiguration().getDistribution() ); - assertEquals( "testDistBase", wrapper.getConfiguration().getDistributionBase() ); - assertEquals( "testDistPath", wrapper.getConfiguration().getDistributionPath() ); - assertEquals( "testZipBase", wrapper.getConfiguration().getZipBase() ); - assertEquals( "testZipPath", wrapper.getConfiguration().getZipPath() ); - } - - @Test - public void useDefaultMetadataNoProeprtiesFile() - throws Exception - { - WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory( testDir.resolve( "unknown" ) ); - - assertNull( wrapper.getDistribution() ); - assertNull( wrapper.getConfiguration().getDistribution() ); - assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getDistributionBase() ); - assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getDistributionPath() ); - assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getZipBase() ); - assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getZipPath() ); - } - - @Test - public void propertiesFileOnlyContainsDistURL() - throws Exception - { - - properties = new Properties(); - properties.put( "distributionUrl", "http://server/test/maven.zip" ); - writePropertiesFile( properties, propertiesFile, "header" ); - - WrapperExecutor wrapper = WrapperExecutor.forWrapperPropertiesFile( propertiesFile ); - - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getDistribution() ); - assertEquals( new URI( "http://server/test/maven.zip" ), wrapper.getConfiguration().getDistribution() ); - assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getDistributionBase() ); - assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getDistributionPath() ); - assertEquals( PathAssembler.MAVEN_USER_HOME_STRING, wrapper.getConfiguration().getZipBase() ); - assertEquals( Installer.DEFAULT_DISTRIBUTION_PATH, wrapper.getConfiguration().getZipPath() ); - } - - @Test - public void executeInstallAndLaunch() - throws Exception - { - WrapperExecutor wrapper = WrapperExecutor.forProjectDirectory( propertiesFile ); - - wrapper.execute( new String[] { "arg" }, install, start ); - verify( install ).createDist( Mockito.any( WrapperConfiguration.class ) ); - verify( start ).start( new String[] { "arg" }, mockInstallDir ); - } - - @Test( ) - public void failWhenDistNotSetInProperties() - throws Exception - { - properties = new Properties(); - writePropertiesFile( properties, propertiesFile, "header" ); - - RuntimeException e = assertThrows( - RuntimeException.class, - () -> WrapperExecutor.forWrapperPropertiesFile( propertiesFile ), - "Expected RuntimeException" ); - assertEquals( "No value with key 'distributionUrl' specified in wrapper properties file '" - + propertiesFile + "'.", e.getMessage() ); - } - - @Test - public void failWhenPropertiesFileDoesNotExist() - { - propertiesFile = testDir.resolve( "unknown.properties" ); - - RuntimeException e = assertThrows( - RuntimeException.class, - () -> WrapperExecutor.forWrapperPropertiesFile( propertiesFile ), - "Expected RuntimeException" ); - assertEquals( "Wrapper properties file '" + propertiesFile + "' does not exist.", e.getMessage() ); - } - - @Test - public void testRelativeDistUrl() - throws Exception - { - - properties = new Properties(); - properties.put( "distributionUrl", "some/relative/url/to/bin.zip" ); - writePropertiesFile( properties, propertiesFile, "header" ); - - WrapperExecutor wrapper = WrapperExecutor.forWrapperPropertiesFile( propertiesFile ); - assertNotEquals( "some/relative/url/to/bin.zip", wrapper.getDistribution().getSchemeSpecificPart() ); - assertTrue( wrapper.getDistribution().getSchemeSpecificPart().endsWith( "some/relative/url/to/bin.zip" ) ); - } - - private void writePropertiesFile( Properties properties, Path propertiesFile, String message ) - throws IOException - { - Files.createDirectories( propertiesFile.getParent() ); - - try ( OutputStream outStream = Files.newOutputStream( propertiesFile ) ) - { - properties.store( outStream, message ); - } - } -} diff --git a/maven-wrapper/src/test/resources/org/apache/maven/wrapper/wrapper.properties b/maven-wrapper/src/test/resources/org/apache/maven/wrapper/wrapper.properties deleted file mode 100644 index a471a8c..0000000 --- a/maven-wrapper/src/test/resources/org/apache/maven/wrapper/wrapper.properties +++ /dev/null @@ -1,21 +0,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. -distributionUrl=http://server/test/maven.zip -distributionBase=testDistBase -zipStoreBase=testZipBase -distributionPath=testDistPath -zipStorePath=testZipPath diff --git a/pom.xml b/pom.xml index 2cdc213..ed238b1 100644 --- a/pom.xml +++ b/pom.xml @@ -96,8 +96,6 @@ under the License. <module>maven-embedder</module> <module>maven-compat</module> <module>apache-maven</module> <!-- rename to apache-maven/maven.pom after RAT-268 --> - <module>maven-wrapper</module> - <module>apache-maven-wrapper</module> <module>maven-toolchain-model</module> <module>maven-toolchain-builder</module> </modules> diff --git a/src/site/resources/images/maven-deps.png b/src/site/resources/images/maven-deps.png index 88265b4..5e11095 100644 Binary files a/src/site/resources/images/maven-deps.png and b/src/site/resources/images/maven-deps.png differ diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index a00e276..8d89afb 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -40,46 +40,43 @@ under the License. process.</p> <p> - <img src="images/maven-deps.png" width="1046" height="784" border="0" usemap="#Maven_dependencies" /> + <img src="images/maven-deps.png" width="1242" height="789" border="0" usemap="#Maven_dependencies" /> <map name="Maven_dependencies"> - <area shape="rect" coords="433,1,658,41" alt="apache-maven-wrapper" href="apache-maven-wrapper/" /> - <area shape="rect" coords="711,0,959,40" alt="maven-wrapper-plugin" href="/plugins/maven-wrapper-plugin/" /> - <area shape="rect" coords="488,67,604,107" alt="maven-wrapper" href="maven-wrapper/" /> - <area shape="rect" coords="378,132,467,172" alt="maven-bom" href="maven-bom/" /> - <area shape="rect" coords="257,67,407,107" alt="apache-maven" href="apache-maven/" /> - <area shape="rect" coords="257,198,407,237" alt="maven-embedder" href="maven-embedder/" /> - <area shape="rect" coords="259,264,406,304" alt="maven-compat" href="maven-compat/" /> - <area shape="rect" coords="258,329,406,369" alt="maven-core" href="maven-core/" /> - <area shape="rect" coords="152,540,328,581" alt="maven-resolver-provider" href="maven-resolver-provider/" /> - <area shape="rect" coords="205,742,423,783" alt="maven-repository-metadata" href="maven-repository-metadata/" /> - <area shape="rect" coords="488,329,597,369" alt="maven-plugin-api" href="maven-plugin-api/" /> - <area shape="rect" coords="556,743,650,782" alt="maven-artifact" href="maven-artifact/" /> - <area shape="rect" coords="342,559,507,600" alt="maven-builder-support" href="maven-builder-support/" /> - <area shape="rect" coords="342,395,507,435" alt="maven-settings-builder" href="maven-settings-builder/" /> - <area shape="rect" coords="318,460,412,501" alt="maven-settings" href="maven-settings/" /> - <area shape="rect" coords="341,626,490,665" alt="maven-model-builder" href="maven-model-builder/" /> - <area shape="rect" coords="317,690,491,730" alt="maven-model-transform" href="maven-model-transform/" /> - <area shape="rect" coords="447,743,550,782" alt="maven-model" href="maven-model/" /> - <area shape="rect" coords="675,742,822,783" alt="maven-test-support" href="maven-test-support/" /> - <area shape="rect" coords="64,67,211,107" alt="maven-slf4j-provider" href="maven-slf4j-provider/" /> - <area shape="rect" coords="64,132,211,172" alt="maven-slf4j-wrapper" href="maven-slf4j-wrapper/" /> - <area shape="rect" coords="1,621,193,782" alt="maven-resolver" href="https://maven.apache.org/resolver/" /> - <area shape="rect" coords="79,198,196,238" alt="slf4j-api" href="http://www.slf4j.org/manual.html" /> - <area shape="rect" coords="620,198,796,239" alt="commons-cli" href="http://commons.apache.org/cli/" /> - <area shape="rect" coords="100,328,230,368" alt="maven-shared-utils" href="https://maven.apache.org/shared/maven-shared-utils/" /> - <area shape="rect" coords="1,329,79,369" alt="jansi" href="http://fusesource.github.io/jansi/" /> - <area shape="rect" coords="0,395,79,435" alt="jansi-native" href="https://github.com/fusesource/jansi-native" /> - <area shape="rect" coords="620,263,832,304" alt="wagon-provider-api" href="https://maven.apache.org/wagon/wagon-provider-api/" /> - <area shape="rect" coords="629,513,787,554" alt="plexus-sec-dispatcher" href="https://github.com/codehaus-plexus/plexus-sec-dispatcher" /> - <area shape="rect" coords="814,513,903,554" alt="plexus-cipher" href="https://github.com/codehaus-plexus/plexus-cipher" /> - <area shape="rect" coords="634,588,777,629" alt="plexus-interpolation" href="https://codehaus-plexus.github.io/plexus-interpolation" /> - <area shape="rect" coords="629,455,883,496" alt="plexus-component-annotations" href="https://codehaus-plexus.github.io/plexus-containers" /> - <area shape="rect" coords="898,456,1033,497" alt="plexus-classworlds" href="https://codehaus-plexus.github.io/plexus-classworlds" /> - <area shape="rect" coords="921,588,1024,628" alt="plexus-utils" href="https://codehaus-plexus.github.io/plexus-utils" /> - <area shape="rect" coords="620,442,1045,671" alt="plexus" href="https://codehaus-plexus.github.io/" /> - <area shape="rect" coords="620,315,873,413" alt="sisu" href="http://www.eclipse.org/projects/project_summary.php?projectid=technology.sisu" /> - <area shape="rect" coords="935,328,1020,370" alt="guice" href="http://code.google.com/p/google-guice/" /> - <area shape="rect" coords="907,390,1045,431" alt="javax.inject" href="http://docs.oracle.com/javaee/6/api/javax/inject/package-summary.html" /> + <area shape="rect" coords="542,1,631,40" alt="maven-bom" href="maven-bom/" /> + <area shape="rect" coords="256,0,408,42" alt="apache-maven" href="apache-maven/" /> + <area shape="rect" coords="255,130,406,171" alt="maven-embedder" href="maven-embedder/" /> + <area shape="rect" coords="255,195,407,239" alt="maven-compat" href="maven-compat/" /> + <area shape="rect" coords="375,262,525,305" alt="maven-core" href="maven-core/" /> + <area shape="rect" coords="150,545,329,587" alt="maven-resolver-provider" href="maven-resolver-provider/" /> + <area shape="rect" coords="206,748,421,787" alt="maven-repository-metadata" href="maven-repository-metadata/" /> + <area shape="rect" coords="683,260,794,303" alt="maven-plugin-api" href="maven-plugin-api/" /> + <area shape="rect" coords="477,328,657,368" alt="maven-toolchain-builder" href="maven-toolchain-builder/" /> + <area shape="rect" coords="480,387,654,430" alt="maven-toolchain-model" href="maven-toolchain-model/" /> + <area shape="rect" coords="752,746,845,787" alt="maven-artifact" href="maven-artifact/" /> + <area shape="rect" coords="485,544,649,584" alt="maven-builder-support" href="maven-builder-support/" /> + <area shape="rect" coords="306,437,471,479" alt="maven-settings-builder" href="maven-settings-builder/" /> + <area shape="rect" coords="340,520,435,562" alt="maven-settings" href="maven-settings/" /> + <area shape="rect" coords="488,628,643,671" alt="maven-model-builder" href="maven-model-builder/" /> + <area shape="rect" coords="319,695,490,737" alt="maven-model-transform" href="maven-model-transform/" /> + <area shape="rect" coords="643,747,744,789" alt="maven-model" href="maven-model/" /> + <area shape="rect" coords="62,0,211,41" alt="maven-slf4j-provider" href="maven-slf4j-provider/" /> + <area shape="rect" coords="63,65,210,108" alt="maven-slf4j-wrapper" href="maven-slf4j-wrapper/" /> + <area shape="rect" coords="1,625,195,787" alt="maven-resolver" href="https://maven.apache.org/resolver/" /> + <area shape="rect" coords="78,132,194,171" alt="slf4j-api" href="http://www.slf4j.org/manual.html" /> + <area shape="rect" coords="816,131,993,174" alt="commons-cli" href="http://commons.apache.org/cli/" /> + <area shape="rect" coords="98,261,232,304" alt="maven-shared-utils" href="https://maven.apache.org/shared/maven-shared-utils/" /> + <area shape="rect" coords="0,265,80,305" alt="jansi" href="http://fusesource.github.io/jansi/" /> + <area shape="rect" coords="818,197,1027,238" alt="wagon-provider-api" href="https://maven.apache.org/wagon/wagon-provider-api/" /> + <area shape="rect" coords="824,446,981,488" alt="plexus-sec-dispatcher" href="https://github.com/codehaus-plexus/plexus-sec-dispatcher" /> + <area shape="rect" coords="1010,446,1098,487" alt="plexus-cipher" href="https://github.com/codehaus-plexus/plexus-cipher" /> + <area shape="rect" coords="828,520,973,563" alt="plexus-interpolation" href="https://codehaus-plexus.github.io/plexus-interpolation" /> + <area shape="rect" coords="823,389,1080,430" alt="plexus-component-annotations" href="https://codehaus-plexus.github.io/plexus-containers" /> + <area shape="rect" coords="1095,389,1229,434" alt="plexus-classworlds" href="https://codehaus-plexus.github.io/plexus-classworlds" /> + <area shape="rect" coords="1117,520,1221,561" alt="plexus-utils" href="https://codehaus-plexus.github.io/plexus-utils" /> + <area shape="rect" coords="816,376,1238,602" alt="plexus" href="https://codehaus-plexus.github.io/" /> + <area shape="rect" coords="815,248,1069,347" alt="sisu" href="http://www.eclipse.org/projects/project_summary.php?projectid=technology.sisu" /> + <area shape="rect" coords="1130,261,1215,305" alt="guice" href="http://code.google.com/p/google-guice/" /> + <area shape="rect" coords="1103,323,1241,364" alt="javax.inject" href="http://docs.oracle.com/javaee/6/api/javax/inject/package-summary.html" /> </map> </p> </section> diff --git a/src/site/xdoc/maven-deps.odg b/src/site/xdoc/maven-deps.odg index 8f7f977..d8485b7 100644 Binary files a/src/site/xdoc/maven-deps.odg and b/src/site/xdoc/maven-deps.odg differ
